r.Post("/:org/teams/new", bindIgnErr(auth.CreateTeamForm{}), org.NewTeamPost) | r.Post("/:org/teams/new", bindIgnErr(auth.CreateTeamForm{}), org.NewTeamPost) | ||||
r.Get("/:org/teams/:team/edit", org.EditTeam) | r.Get("/:org/teams/:team/edit", org.EditTeam) | ||||
r.Get("/:org/team/:team", org.SingleTeam) | |||||
r.Get("/:org/teams/:team", org.SingleTeam) | |||||
r.Get("/:org/settings", org.Settings) | r.Get("/:org/settings", org.Settings) | ||||
r.Post("/:org/settings", bindIgnErr(auth.OrgSettingForm{}), org.SettingsPost) | r.Post("/:org/settings", bindIgnErr(auth.OrgSettingForm{}), org.SettingsPost) | ||||
}, reqSignIn, middleware.RepoAssignment(true), reqTrueOwner) | }, reqSignIn, middleware.RepoAssignment(true), reqTrueOwner) | ||||
m.Group("/:username/:reponame", func(r *macaron.Router) { | m.Group("/:username/:reponame", func(r *macaron.Router) { | ||||
// r.Get("/action/:action", repo.Action) | |||||
r.Get("/action/:action", repo.Action) | |||||
m.Group("/issues", func(r *macaron.Router) { | m.Group("/issues", func(r *macaron.Router) { | ||||
r.Get("/new", repo.CreateIssue) | r.Get("/new", repo.CreateIssue) |
migrate_type_helper = This repository will be a <span class="label label-blue label-radius">Mirror</span> | migrate_type_helper = This repository will be a <span class="label label-blue label-radius">Mirror</span> | ||||
migrate_repo = Migrate Repository | migrate_repo = Migrate Repository | ||||
clone_helper = Need help cloning? Visit <a target="_blank" href="http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository">Help</a>! | |||||
unwatch = Unwatch | |||||
watch = Watch | |||||
unstar = Unstar | |||||
star = Star | |||||
fork = Fork | |||||
settings = Settings | settings = Settings | ||||
settings.options = Options | settings.options = Options | ||||
settings.collaboration = Collaboration | settings.collaboration = Collaboration | ||||
org_name_helper = Great organization names are short and memorable. | org_name_helper = Great organization names are short and memorable. | ||||
org_email_helper = Organization's Email receives all notifications and confirmations. | org_email_helper = Organization's Email receives all notifications and confirmations. | ||||
create_org = Create Organization | create_org = Create Organization | ||||
repo_updated = Updated | |||||
people = People | |||||
invite_someone = Invite Someone | |||||
teams = Teams | |||||
lower_members = members | |||||
lower_repositories = repositories | |||||
create_new_team = Create New Team | |||||
[action] | [action] | ||||
create_repo = created repository <a href="/%s">%s</a> | create_repo = created repository <a href="/%s">%s</a> |
migrate_type_helper = 本仓库将是 <span class="label label-blue label-radius">镜像</span> | migrate_type_helper = 本仓库将是 <span class="label label-blue label-radius">镜像</span> | ||||
migrate_repo = 迁移仓库 | migrate_repo = 迁移仓库 | ||||
clone_helper = 不知道如何操作?访问 <a target="_blank" href="http://git-scm.com/book/zh/Git-基础-取得项目的-Git-仓库">此处</a> 查看帮助! | |||||
unwatch = 取消关注 | |||||
watch = 关注 | |||||
unstar = 取消点赞 | |||||
star = 点赞 | |||||
fork = 派生 | |||||
settings = 仓库设置 | settings = 仓库设置 | ||||
settings.options = 基本设置 | settings.options = 基本设置 | ||||
settings.collaboration = 管理协作者 | settings.collaboration = 管理协作者 | ||||
org_name_helper = 伟大的组织都有一个简短而寓意深刻的名字。 | org_name_helper = 伟大的组织都有一个简短而寓意深刻的名字。 | ||||
org_email_helper = 组织的邮箱用于接收所有通知和确认邮件。 | org_email_helper = 组织的邮箱用于接收所有通知和确认邮件。 | ||||
create_org = 创建组织 | create_org = 创建组织 | ||||
repo_updated = 最后更新于 | |||||
people = 组织成员 | |||||
invite_someone = 邀请他人加入 | |||||
teams = 组织团队 | |||||
lower_members = 名成员 | |||||
lower_repositories = 个仓库 | |||||
create_new_team = 创建新的团队 | |||||
[action] | [action] | ||||
create_repo = 创建了仓库 <a href="/%s">%s</a> | create_repo = 创建了仓库 <a href="/%s">%s</a> |
"github.com/gogits/gogs/modules/setting" | "github.com/gogits/gogs/modules/setting" | ||||
) | ) | ||||
const APP_VER = "0.4.7.0809 Alpha" | |||||
const APP_VER = "0.4.7.0810 Alpha" | |||||
func init() { | func init() { | ||||
runtime.GOMAXPROCS(runtime.NumCPU()) | runtime.GOMAXPROCS(runtime.NumCPU()) |
) | ) | ||||
func init() { | func init() { | ||||
tables = append(tables, new(User), new(PublicKey), new(Repository), new(Watch), | |||||
new(Action), new(Access), new(Issue), new(Comment), new(Oauth2), new(Follow), | |||||
tables = append(tables, new(User), new(PublicKey), | |||||
new(Repository), new(Watch), new(Star), new(Action), new(Access), | |||||
new(Issue), new(Comment), new(Oauth2), new(Follow), | |||||
new(Mirror), new(Release), new(LoginSource), new(Webhook), new(IssueUser), | new(Mirror), new(Release), new(LoginSource), new(Webhook), new(IssueUser), | ||||
new(Milestone), new(Label), new(HookTask), new(Team), new(OrgUser), new(TeamUser), | new(Milestone), new(Label), new(HookTask), new(Team), new(OrgUser), new(TeamUser), | ||||
new(UpdateTask), new(Attachment)) | new(UpdateTask), new(Attachment)) |
// Create default owner team. | // Create default owner team. | ||||
t := &Team{ | t := &Team{ | ||||
OrgId: org.Id, | OrgId: org.Id, | ||||
LowerName: strings.ToLower(OWNER_TEAM), | |||||
Name: OWNER_TEAM, | Name: OWNER_TEAM, | ||||
Authorize: ORG_ADMIN, | Authorize: ORG_ADMIN, | ||||
NumMembers: 1, | NumMembers: 1, |
NumTags int `xorm:"-"` | NumTags int `xorm:"-"` | ||||
IsPrivate bool | IsPrivate bool | ||||
IsMirror bool | IsMirror bool | ||||
*Mirror `xorm:"-"` | |||||
IsFork bool `xorm:"NOT NULL DEFAULT false"` | IsFork bool `xorm:"NOT NULL DEFAULT false"` | ||||
IsBare bool | IsBare bool | ||||
IsGoget bool | IsGoget bool | ||||
return err | return err | ||||
} | } | ||||
func (repo *Repository) GetMirror() (err error) { | |||||
repo.Mirror, err = GetMirror(repo.Id) | |||||
return err | |||||
} | |||||
// DescriptionHtml does special handles to description and return HTML string. | // DescriptionHtml does special handles to description and return HTML string. | ||||
func (repo *Repository) DescriptionHtml() template.HTML { | func (repo *Repository) DescriptionHtml() template.HTML { | ||||
sanitize := func(s string) string { | sanitize := func(s string) string { | ||||
} | } | ||||
// Watch or unwatch repository. | // Watch or unwatch repository. | ||||
func WatchRepo(uid, rid int64, watch bool) (err error) { | |||||
func WatchRepo(uid, repoId int64, watch bool) (err error) { | |||||
if watch { | if watch { | ||||
if _, err = x.Insert(&Watch{RepoId: rid, UserId: uid}); err != nil { | |||||
if IsWatching(uid, repoId) { | |||||
return nil | |||||
} | |||||
if _, err = x.Insert(&Watch{RepoId: repoId, UserId: uid}); err != nil { | |||||
return err | return err | ||||
} | } | ||||
_, err = x.Exec("UPDATE `repository` SET num_watches = num_watches + 1 WHERE id = ?", rid) | |||||
_, err = x.Exec("UPDATE `repository` SET num_watches = num_watches + 1 WHERE id = ?", repoId) | |||||
} else { | } else { | ||||
if _, err = x.Delete(&Watch{0, uid, rid}); err != nil { | |||||
if !IsWatching(uid, repoId) { | |||||
return nil | |||||
} | |||||
if _, err = x.Delete(&Watch{0, uid, repoId}); err != nil { | |||||
return err | return err | ||||
} | } | ||||
_, err = x.Exec("UPDATE `repository` SET num_watches = num_watches - 1 WHERE id = ?", rid) | |||||
_, err = x.Exec("UPDATE `repository` SET num_watches = num_watches - 1 WHERE id = ?", repoId) | |||||
} | } | ||||
return err | return err | ||||
} | } | ||||
// IsWatching checks if user has watched given repository. | |||||
func IsWatching(uid, rid int64) bool { | |||||
has, _ := x.Get(&Watch{0, uid, rid}) | |||||
return has | |||||
} | |||||
// GetWatchers returns all watchers of given repository. | // GetWatchers returns all watchers of given repository. | ||||
func GetWatchers(rid int64) ([]*Watch, error) { | func GetWatchers(rid int64) ([]*Watch, error) { | ||||
watches := make([]*Watch, 0, 10) | watches := make([]*Watch, 0, 10) | ||||
return nil | return nil | ||||
} | } | ||||
// IsWatching checks if user has watched given repository. | |||||
func IsWatching(uid, rid int64) bool { | |||||
has, _ := x.Get(&Watch{0, uid, rid}) | |||||
type Star struct { | |||||
Id int64 | |||||
Uid int64 `xorm:"UNIQUE(s)"` | |||||
RepoId int64 `xorm:"UNIQUE(s)"` | |||||
} | |||||
// Star or unstar repository. | |||||
func StarRepo(uid, repoId int64, star bool) (err error) { | |||||
if star { | |||||
if IsStaring(uid, repoId) { | |||||
return nil | |||||
} | |||||
if _, err = x.Insert(&Star{Uid: uid, RepoId: repoId}); err != nil { | |||||
return err | |||||
} | |||||
_, err = x.Exec("UPDATE `repository` SET num_stars = num_stars + 1 WHERE id = ?", repoId) | |||||
} else { | |||||
if !IsStaring(uid, repoId) { | |||||
return nil | |||||
} | |||||
if _, err = x.Delete(&Star{0, uid, repoId}); err != nil { | |||||
return err | |||||
} | |||||
_, err = x.Exec("UPDATE `repository` SET num_stars = num_stars - 1 WHERE id = ?", repoId) | |||||
} | |||||
return err | |||||
} | |||||
// IsStaring checks if user has starred given repository. | |||||
func IsStaring(uid, repoId int64) bool { | |||||
has, _ := x.Get(&Star{0, uid, repoId}) | |||||
return has | return has | ||||
} | } | ||||
package middleware | package middleware | ||||
import ( | import ( | ||||
"fmt" | |||||
"net/url" | "net/url" | ||||
"strings" | "strings" | ||||
} | } | ||||
if options.SignInRequire { | if options.SignInRequire { | ||||
fmt.Println(ctx.User.IsActive, setting.Service.RegisterEmailConfirm) | |||||
if !ctx.IsSigned { | if !ctx.IsSigned { | ||||
// Ignore watch repository operation. | // Ignore watch repository operation. | ||||
if strings.HasSuffix(ctx.Req.RequestURI, "watch") { | if strings.HasSuffix(ctx.Req.RequestURI, "watch") { |
} | } | ||||
// repo is bare and display enable | // repo is bare and display enable | ||||
if displayBare && ctx.Repo.Repository.IsBare { | |||||
if ctx.Repo.Repository.IsBare { | |||||
log.Debug("Bare repository: %s", ctx.Repo.RepoLink) | log.Debug("Bare repository: %s", ctx.Repo.RepoLink) | ||||
ctx.HTML(200, "repo/bare") | |||||
if displayBare { | |||||
ctx.HTML(200, "repo/bare") | |||||
} | |||||
return | return | ||||
} | } | ||||
if ctx.IsSigned { | if ctx.IsSigned { | ||||
ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.Id, repo.Id) | ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.Id, repo.Id) | ||||
} | |||||
if ctx.Repo.Repository.IsBare { | |||||
return | |||||
ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.Id, repo.Id) | |||||
} | } | ||||
ctx.Data["TagName"] = ctx.Repo.TagName | ctx.Data["TagName"] = ctx.Repo.TagName |
height: 48px; | height: 48px; | ||||
vertical-align: middle; | vertical-align: middle; | ||||
} | } | ||||
img.avatar-100 { | |||||
width: 100px; | |||||
height: 100px; | |||||
vertical-align: middle; | |||||
} | |||||
#wrapper { | #wrapper { | ||||
padding: 0; | padding: 0; | ||||
margin: 0 0 -55px 0; | margin: 0 0 -55px 0; | ||||
.text-grey { | .text-grey { | ||||
color: #999999; | color: #999999; | ||||
} | } | ||||
.text-black { | |||||
color: #444444; | |||||
} | |||||
.markdown { | .markdown { | ||||
background-color: white; | background-color: white; | ||||
font-size: 16px; | font-size: 16px; | ||||
border-left: none; | border-left: none; | ||||
} | } | ||||
#repo-clone-help { | #repo-clone-help { | ||||
clear: both; | |||||
line-height: 48px; | line-height: 48px; | ||||
} | } | ||||
#repo-clone-zip { | #repo-clone-zip { | ||||
box-sizing: border-box; | box-sizing: border-box; | ||||
height: 120px; | height: 120px; | ||||
} | } | ||||
.org-header { | |||||
padding: 16px 0; | |||||
background-color: #FFF; | |||||
border-bottom: 1px solid #DDD; | |||||
} | |||||
.org-header img { | |||||
padding-right: 10px; | |||||
} | |||||
#org-home-header { | |||||
min-height: 100px; | |||||
} | |||||
#org-home-header-info { | |||||
padding-top: 10px; | |||||
} | |||||
#org-home-header-info h2 { | |||||
font-size: 30px; | |||||
} | |||||
#org-home-header-info ul { | |||||
list-style: none; | |||||
} | |||||
#org-home-header-info ul li { | |||||
float: left; | |||||
padding-right: 5px; | |||||
} | |||||
#org-home-repo-list { | |||||
padding: 10px 0; | |||||
} | |||||
#org-repo-list { | |||||
padding: 10px 0; | |||||
} | |||||
#org-repo-list .org-repo-item { | |||||
border-top: 1px solid #eee; | |||||
padding: 30px 20px; | |||||
} | |||||
#org-repo-list .org-repo-item .org-repo-status { | |||||
list-style: none; | |||||
color: #888; | |||||
} | |||||
#org-repo-list .org-repo-item .org-repo-status li { | |||||
float: left; | |||||
margin-right: 6px; | |||||
} | |||||
#org-repo-list .org-repo-item h2 { | |||||
margin-bottom: 5px; | |||||
} | |||||
#org-repo-list .org-repo-item .org-repo-description { | |||||
margin: 0; | |||||
font-size: 14px; | |||||
color: #666; | |||||
} | |||||
#org-repo-list .org-repo-item .org-repo-updated { | |||||
font-size: 12px; | |||||
display: block; | |||||
margin: 5px 0 0; | |||||
color: #808080; | |||||
} | |||||
.org-sidebar { | |||||
margin: -80px 0 0 20px; | |||||
} | |||||
.org-sidebar .panel-footer { | |||||
padding: .8em 1.2em; | |||||
} | |||||
#org-member-avatar-group { | |||||
padding: 15px; | |||||
} | |||||
#org-member-avatar-group img { | |||||
width: 59px; | |||||
height: 59px; | |||||
border-radius: 3px; | |||||
} | |||||
#org-home-team-list { | |||||
padding: 0 15px; | |||||
} | |||||
#org-home-team-list ul { | |||||
list-style: none; | |||||
padding-top: 10px; | |||||
} | |||||
#org-home-team-list ul li { | |||||
padding: 10px 0; | |||||
border-bottom: 1px solid #eee; | |||||
} | |||||
#org-home-team-list ul li:last-child { | |||||
border-bottom: 0; | |||||
} | |||||
.team-name { | |||||
display: block; | |||||
font-size: 14px; | |||||
overflow: hidden; | |||||
text-overflow: ellipsis; | |||||
white-space: nowrap; | |||||
} | |||||
.team-meta { | |||||
margin-top: 0; | |||||
margin-bottom: 0; | |||||
color: #777; | |||||
} |
font-size: 10.8px; | font-size: 10.8px; | ||||
padding: .4em .9em; | padding: .4em .9em; | ||||
} | } | ||||
.btn-medium { | |||||
font-size: 12px; | |||||
padding: .4em .9em; | |||||
} | |||||
.btn-large { | .btn-large { | ||||
font-size: 14.4px; | font-size: 14.4px; | ||||
} | } |
@import "gogs/sign"; | @import "gogs/sign"; | ||||
@import "gogs/repository"; | @import "gogs/repository"; | ||||
@import "gogs/settings"; | @import "gogs/settings"; | ||||
@import "gogs/issue"; | |||||
@import "gogs/issue"; | |||||
@import "gogs/organization"; |
height: 48px; | height: 48px; | ||||
vertical-align: middle; | vertical-align: middle; | ||||
} | } | ||||
img.avatar-100{ | |||||
width: 100px; | |||||
height: 100px; | |||||
vertical-align: middle; | |||||
} | |||||
#wrapper { | #wrapper { | ||||
padding: 0; | padding: 0; | ||||
margin: 0 0 -55px 0; | margin: 0 0 -55px 0; | ||||
} | } | ||||
.text-grey { | .text-grey { | ||||
color: #999999; | color: #999999; | ||||
} | |||||
.text-black { | |||||
color: #444444; | |||||
} | } |
.org-header { | |||||
padding: 16px 0; | |||||
background-color: #FFF; | |||||
border-bottom: 1px solid #DDD; | |||||
img { | |||||
padding-right: 10px; | |||||
} | |||||
} | |||||
#org-home-header { | |||||
min-height: 100px; | |||||
} | |||||
#org-home-header-info { | |||||
padding-top: 10px; | |||||
h2 { | |||||
font-size: 30px; | |||||
} | |||||
ul { | |||||
list-style: none; | |||||
li { | |||||
float: left; | |||||
padding-right: 5px; | |||||
} | |||||
} | |||||
} | |||||
#org-home-repo-list { | |||||
padding: 10px 0; | |||||
} | |||||
#org-repo-list { | |||||
padding: 10px 0; | |||||
.org-repo-item { | |||||
border-top: 1px solid #eee; | |||||
padding: 30px 20px; | |||||
.org-repo-status { | |||||
list-style: none; | |||||
color: #888; | |||||
li { | |||||
float: left; | |||||
margin-right: 6px; | |||||
} | |||||
} | |||||
h2 { | |||||
margin-bottom: 5px; | |||||
} | |||||
.org-repo-description { | |||||
margin: 0; | |||||
font-size: 14px; | |||||
color: #666; | |||||
} | |||||
.org-repo-updated { | |||||
font-size: 12px; | |||||
display: block; | |||||
margin: 5px 0 0; | |||||
color: #808080; | |||||
} | |||||
} | |||||
} | |||||
.org-sidebar { | |||||
margin: -80px 0 0 20px; | |||||
.panel-footer { | |||||
padding: .8em 1.2em; | |||||
} | |||||
} | |||||
#org-member-avatar-group { | |||||
padding: 15px; | |||||
img { | |||||
width: 59px; | |||||
height: 59px; | |||||
border-radius: 3px; | |||||
} | |||||
} | |||||
#org-home-team-list { | |||||
padding: 0 15px; | |||||
ul { | |||||
list-style: none; | |||||
padding-top: 10px; | |||||
li { | |||||
padding: 10px 0; | |||||
border-bottom: 1px solid #eee; | |||||
&:last-child { | |||||
border-bottom: 0; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
.team-name { | |||||
display: block; | |||||
font-size: 14px; | |||||
overflow: hidden; | |||||
text-overflow: ellipsis; | |||||
white-space: nowrap; | |||||
} | |||||
.team-meta { | |||||
margin-top: 0; | |||||
margin-bottom: 0; | |||||
color: #777; | |||||
} |
border-left: none; | border-left: none; | ||||
} | } | ||||
#repo-clone-help { | #repo-clone-help { | ||||
clear: both; | |||||
line-height: 48px; | line-height: 48px; | ||||
} | } | ||||
#repo-clone-zip { | #repo-clone-zip { |
&:hover { | &:hover { | ||||
} | } | ||||
} | } | ||||
.btn-small { | .btn-small { | ||||
font-size: 0.9*@baseFontSize; | font-size: 0.9*@baseFontSize; | ||||
padding: .4em .9em; | padding: .4em .9em; | ||||
} | } | ||||
.btn-medium { | |||||
font-size: @baseFontSize; | |||||
padding: .4em .9em; | |||||
} | |||||
.btn-large { | .btn-large { | ||||
font-size: 1.2*@baseFontSize; | |||||
font-size: 1.2*@baseFontSize; | |||||
} | } | ||||
.btn-green { | .btn-green { | ||||
color: #FFF; | color: #FFF; | ||||
} | } | ||||
} | } | ||||
.btn-blue { | .btn-blue { | ||||
background-color: @btnBlueColor; | background-color: @btnBlueColor; | ||||
border: 1px solid @btnBlueColor; | border: 1px solid @btnBlueColor; |
) | ) | ||||
func Home(ctx *middleware.Context) { | func Home(ctx *middleware.Context) { | ||||
ctx.Data["Title"] = "Organization " + ctx.Params(":org") | |||||
ctx.Data["Title"] = ctx.Params(":org") | |||||
org, err := models.GetUserByName(ctx.Params(":org")) | org, err := models.GetUserByName(ctx.Params(":org")) | ||||
if err != nil { | if err != nil { | ||||
if err == models.ErrUserNotExist { | if err == models.ErrUserNotExist { | ||||
ctx.Handle(404, "org.Home(GetUserByName)", err) | |||||
ctx.Handle(404, "GetUserByName", err) | |||||
} else { | } else { | ||||
ctx.Handle(500, "org.Home(GetUserByName)", err) | |||||
ctx.Handle(500, "GetUserByName", err) | |||||
} | } | ||||
return | return | ||||
} | } | ||||
ctx.Data["Org"] = org | ctx.Data["Org"] = org | ||||
ctx.Data["Repos"], err = models.GetRepositories(org.Id, | |||||
ctx.IsSigned && org.IsOrgMember(ctx.User.Id)) | |||||
ctx.Data["Repos"], err = models.GetRepositories(org.Id, ctx.IsSigned && org.IsOrgMember(ctx.User.Id)) | |||||
if err != nil { | if err != nil { | ||||
ctx.Handle(500, "org.Home(GetRepositories)", err) | |||||
ctx.Handle(500, "GetRepositories", err) | |||||
return | return | ||||
} | } | ||||
if err = org.GetMembers(); err != nil { | if err = org.GetMembers(); err != nil { | ||||
ctx.Handle(500, "org.Home(GetMembers)", err) | |||||
ctx.Handle(500, "GetMembers", err) | |||||
return | return | ||||
} | } | ||||
ctx.Data["Members"] = org.Members | ctx.Data["Members"] = org.Members | ||||
if err = org.GetTeams(); err != nil { | if err = org.GetTeams(); err != nil { | ||||
ctx.Handle(500, "org.Home(GetTeams)", err) | |||||
ctx.Handle(500, "GetTeams", err) | |||||
return | return | ||||
} | } | ||||
ctx.Data["Teams"] = org.Teams | ctx.Data["Teams"] = org.Teams |
ctx.Handle(500, "MigratePost", err) | ctx.Handle(500, "MigratePost", err) | ||||
} | } | ||||
// func Action(ctx *middleware.Context, params martini.Params) { | |||||
// var err error | |||||
// switch params["action"] { | |||||
// case "watch": | |||||
// err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, true) | |||||
// case "unwatch": | |||||
// err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, false) | |||||
// case "desc": | |||||
// if !ctx.Repo.IsOwner { | |||||
// ctx.Error(404) | |||||
// return | |||||
// } | |||||
// ctx.Repo.Repository.Description = ctx.Query("desc") | |||||
// ctx.Repo.Repository.Website = ctx.Query("site") | |||||
// err = models.UpdateRepository(ctx.Repo.Repository) | |||||
// } | |||||
// if err != nil { | |||||
// log.Error("repo.Action(%s): %v", params["action"], err) | |||||
// ctx.JSON(200, map[string]interface{}{ | |||||
// "ok": false, | |||||
// "err": err.Error(), | |||||
// }) | |||||
// return | |||||
// } | |||||
// ctx.JSON(200, map[string]interface{}{ | |||||
// "ok": true, | |||||
// }) | |||||
// } | |||||
func Action(ctx *middleware.Context) { | |||||
var err error | |||||
switch ctx.Params(":action") { | |||||
case "watch": | |||||
err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, true) | |||||
case "unwatch": | |||||
err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, false) | |||||
case "star": | |||||
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, true) | |||||
case "unstar": | |||||
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, false) | |||||
case "desc": | |||||
if !ctx.Repo.IsOwner { | |||||
ctx.Error(404) | |||||
return | |||||
} | |||||
ctx.Repo.Repository.Description = ctx.Query("desc") | |||||
ctx.Repo.Repository.Website = ctx.Query("site") | |||||
err = models.UpdateRepository(ctx.Repo.Repository) | |||||
} | |||||
if err != nil { | |||||
log.Error(4, "repo.Action(%s): %v", ctx.Params(":action"), err) | |||||
ctx.JSON(200, map[string]interface{}{ | |||||
"ok": false, | |||||
"err": err.Error(), | |||||
}) | |||||
return | |||||
} | |||||
ctx.Redirect(ctx.Repo.RepoLink) | |||||
return | |||||
ctx.JSON(200, map[string]interface{}{ | |||||
"ok": true, | |||||
}) | |||||
} | |||||
func Download(ctx *middleware.Context) { | func Download(ctx *middleware.Context) { | ||||
ext := "." + ctx.Params(":ext") | ext := "." + ctx.Params(":ext") |
mirrors := make([]*models.Repository, 0, len(repos)/2) | mirrors := make([]*models.Repository, 0, len(repos)/2) | ||||
for _, repo := range repos { | for _, repo := range repos { | ||||
if repo.IsMirror { | if repo.IsMirror { | ||||
if err = repo.GetMirror(); err != nil { | |||||
ctx.Handle(500, "GetMirror: "+repo.Name, err) | |||||
return | |||||
} | |||||
mirrors = append(mirrors, repo) | mirrors = append(mirrors, repo) | ||||
} | } | ||||
} | } |
HOME=$(grep "^$USER:" /etc/passwd | cut -d: -f6) | HOME=$(grep "^$USER:" /etc/passwd | cut -d: -f6) | ||||
export USER HOME PATH | export USER HOME PATH | ||||
cd "$(dirname $0)" && exec ./gogs web | |||||
cd "$(pwd)" && exec ./gogs web |
0.4.7.0809 Alpha | |||||
0.4.7.0810 Alpha |
{{template "base/head" .}} | |||||
{{template "base/navbar" .}} | |||||
<div id="body-nav" class="org-nav"> | |||||
<div class="container clearfix"> | |||||
<div class="col-md-8" id="org-nav-wrapper"> | |||||
<img class="pull-left org-logo" src="{{.Org.AvatarLink}}?s=140" alt="" width="100"/> | |||||
<div id="org-nav-info"> | |||||
<h2 class="org-name">{{.Org.FullName}}</h2> | |||||
{{if .Org.Description}}<p class="org-description">{{.Org.Description}}</p>{{end}} | |||||
<ul class="org-meta list-inline"> | |||||
{{if .Org.Website}}<li><i class="fa fa-link"></i><a target="_blank" href="{{.Org.Website}}">{{.Org.Website}}</a></li>{{end}} | |||||
<li><i class="fa fa-envelope"></i><a href="mailto:{{.Org.Email}}">{{.Org.Email}}</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{{template "ng/base/head" .}} | |||||
{{template "ng/base/header" .}} | |||||
<div class="org-header" id="org-home-header"> | |||||
<div class="container clear"> | |||||
<img class="avatar-100 left" src="{{.Org.AvatarLink}}?s=140"/> | |||||
<div id="org-home-header-info"> | |||||
<h2>{{.Org.FullName}} <a class="text-grey" href="/org/{{.Org.LowerName}}/settings"><span class="octicon octicon-gear"></span></a></h2> | |||||
{{if .Org.Description}}<p>{{.Org.Description}}</p>{{end}} | |||||
<ul class="text-grey"> | |||||
{{if .Org.Location}}<li><span class="octicon octicon-location"></span> <span>{{.Org.Location}}</span></li>{{end}} | |||||
{{if .Org.Website}}<li><span class="octicon octicon-link"></span> <a target="_blank" href="{{.Org.Website}}">{{.Org.Website}}</a></li>{{end}} | |||||
{{if .Org.Email}}<li><span class="octicon octicon-mail"></span> <a href="mailto:{{.Org.Email}}">{{.Org.Email}}</a></li>{{end}} | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
</div> | </div> | ||||
<div id="body" class="container"> | |||||
<div id="org"> | |||||
<div class="org-main col-md-8"> | |||||
<div class="org-toolbar clearfix"> | |||||
<a class="btn pull-right btn-success" href="/repo/create?org={{.Org.Id}}"><i class="fa fa-plus"></i> New Repository</a> | |||||
</div> | |||||
<hr style="width: 100%;border-color: #DDD"/> | |||||
<div class="org-repo-list" id="org-repo-list"> | |||||
{{range .Repos}} | |||||
<div class="org-repo-item"> | |||||
<div class="org-repo-status pull-right"> | |||||
<!-- <ul class="list-inline"> | |||||
<li><strong>Go</strong></li> | |||||
<li><i class="i fa fa-star"></i><strong>6</strong></li> | |||||
<li><i class="fa fa-code-fork"></i><strong>2</strong></li> | |||||
</ul> --> | |||||
</div> | |||||
<h3 class="org-repo-name"><a href="/{{$.Org.Name}}/{{.Name}}">{{.Name}}</a></h3> | |||||
<p class="org-repo-description">{{.Description}}</p> | |||||
<p class="org-repo-update">Updated {{TimeSince .Updated $.Lang}}</p> | |||||
</div> | |||||
{{end}} | |||||
</div> | |||||
<div class="container"> | |||||
<div id="org-home-repo-list" class="left grid-2-3"> | |||||
<div class="clear"> | |||||
<a class="btn btn-green btn-large btn-link btn-radius right" href="/repo/create?org={{.Org.Id}}"><i class="octicon octicon-repo-create"></i> {{.i18n.Tr "new_repo"}}</a> | |||||
</div> | </div> | ||||
<div class="org-sidebar col-md-4"> | |||||
<div class="org-panel panel panel-default" id="org-sidebar-members"> | |||||
<div class="panel-heading"><strong><a href="/org/{{$.Org.Name}}/members">Members</a></strong></div> | |||||
<div class="panel-body"> | |||||
{{range .Members}} | |||||
<a class="org-member" href="/user/{{.Name}}" data-toggle="tooltip" title="{{.Name}}" data-placement="bottom"><img src="{{.AvatarLink}}?s=140" alt=""/></a> | |||||
{{end}} | |||||
</div> | |||||
</div> | |||||
<div class="org-panel panel panel-default" id="org-sidebar-teams"> | |||||
<div class="panel-heading"><strong><a href="/org/{{$.Org.Name}}/teams">Teams</a></strong></div> | |||||
<div class="panel-body"> | |||||
{{range .Teams}} | |||||
<div class="org-team"> | |||||
<a href="/org/{{$.Org.Name}}/teams/{{.LowerName}}"> | |||||
<p class="org-team-name"><strong>{{.Name}}</strong></p> | |||||
<p class="org-team-meta"> | |||||
{{.NumMembers}} members · {{.NumRepos}} repositories | |||||
</p> | |||||
</a> | |||||
</div> | |||||
{{end}} | |||||
</div> | |||||
</div> | |||||
<div id="org-repo-list"> | |||||
{{range .Repos}} | |||||
<div class="org-repo-item"> | |||||
<ul class="org-repo-status right"> | |||||
<li><i class="octicon octicon-star"></i> {{.NumStars}}</li> | |||||
<li><i class="octicon octicon-git-branch"></i> {{.NumForks}}</li> | |||||
</ul> | |||||
<h2><a href="/{{$.Org.Name}}/{{.Name}}">{{.Name}}</a></h2> | |||||
<p class="org-repo-description">{{.Description}}</p> | |||||
<p class="org-repo-updated">{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}</p> | |||||
</div> | |||||
{{end}} | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="grid-1-3 right"> | |||||
<div class="org-sidebar"> | |||||
<div class="panel panel-radius"> | |||||
<div class="panel-header"> | |||||
<a class="text-grey right" href="/org/{{.Org.LowerName}}/members"><strong>{{.Org.NumMembers}}</strong><span class="octicon octicon-chevron-right"></span></a> | |||||
<strong>{{.i18n.Tr "org.people"}}</strong> | |||||
</div> | |||||
<div class="panel-body" id="org-member-avatar-group"> | |||||
{{range .Members}} | |||||
<a href="/{{.Name}}"><img src="{{.AvatarLink}}"></a> | |||||
{{end}} | |||||
</div> | |||||
<div class="panel-footer"> | |||||
<a class="btn btn-medium btn-blue btn-link btn-radius" href="">{{.i18n.Tr "org.invite_someone"}}</a> | |||||
</div> | |||||
</div> | |||||
<br> | |||||
<div class="panel panel-radius"> | |||||
<div class="panel-header"> | |||||
<a class="text-grey right" href="/org/{{.Org.LowerName}}/teams"><strong>{{.Org.NumTeams}}</strong><span class="octicon octicon-chevron-right"></span></a> | |||||
<strong>{{.i18n.Tr "org.teams"}}</strong> | |||||
</div> | |||||
<div class="panel-body" id="org-home-team-list"> | |||||
<ul> | |||||
{{range .Teams}} | |||||
<li> | |||||
<a class="text-black" href="/org/{{$.Org.LowerName}}/teams/{{.LowerName}}"><strong class="team-name">{{.Name}}</strong></a> | |||||
<p class="team-meta">{{.NumMembers}} {{$.i18n.Tr "org.lower_members"}} · {{.NumRepos}} {{$.i18n.Tr "org.lower_repositories"}}</p> | |||||
</li> | |||||
{{end}} | |||||
</ul> | |||||
</div> | |||||
<div class="panel-footer"> | |||||
<a class="btn btn-medium btn-blue btn-link btn-radius" href="/org/{{$.Org.LowerName}}/teams/new">{{.i18n.Tr "org.create_new_team"}}</a> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | </div> | ||||
{{template "base/footer" .}} | |||||
{{template "ng/base/footer" .}} |
</p> | </p> | ||||
</div> | </div> | ||||
<div class="panel-footer"> | <div class="panel-footer"> | ||||
{{if .IsMember $.SignedUserId}} | |||||
{{if .IsMember $.SignedUser.Id}} | |||||
<a class="pull-right btn btn-danger" href="/org/{{$.Org.Name}}/teams/{{.LowerName}}?action=leave">Leave</a> | <a class="pull-right btn btn-danger" href="/org/{{$.Org.Name}}/teams/{{.LowerName}}?action=leave">Leave</a> | ||||
{{else}} | {{else}} | ||||
<a class="pull-right btn btn-default" href="/org/{{$.Org.Name}}/teams/{{.LowerName}}?action=join">Join</a> | <a class="pull-right btn btn-default" href="/org/{{$.Org.Name}}/teams/{{.LowerName}}?action=join">Join</a> |
<label for="owner" class="req">{{.i18n.Tr "repo.owner"}}</label> | <label for="owner" class="req">{{.i18n.Tr "repo.owner"}}</label> | ||||
<input id="repo-owner-id" type="hidden" name="uid" value="{{.ContextUser.Id}}" /> | <input id="repo-owner-id" type="hidden" name="uid" value="{{.ContextUser.Id}}" /> | ||||
<div class="inline-block drop"> | <div class="inline-block drop"> | ||||
<a href="#" class="drop-bottom"> | |||||
<a class="drop-bottom"> | |||||
<img class="avatar" src="{{.ContextUser.AvatarLink}}" id="repo-owner-avatar" alt="user-avatar"> | <img class="avatar" src="{{.ContextUser.AvatarLink}}" id="repo-owner-avatar" alt="user-avatar"> | ||||
<strong id="repo-owner-name">{{.ContextUser.Name}}</strong> | <strong id="repo-owner-name">{{.ContextUser.Name}}</strong> | ||||
</a> | </a> |
<button id="repo-clone-https" class="btn btn-gray left">HTTPS</button> | <button id="repo-clone-https" class="btn btn-gray left">HTTPS</button> | ||||
<input id="repo-clone-url" type="text" class="ipt ipt-disabled left" value="{{.CloneLink.SSH}}" /> | <input id="repo-clone-url" type="text" class="ipt ipt-disabled left" value="{{.CloneLink.SSH}}" /> | ||||
<button id="repo-clone-copy" class="btn btn-black left btn-right-radius">Copy</button> | <button id="repo-clone-copy" class="btn btn-black left btn-right-radius">Copy</button> | ||||
<p class="text-center" id="repo-clone-help">Need help cloning? Visit <a target="_blank" href="http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository">Help</a>!</p> | |||||
<p class="text-center" id="repo-clone-help">{{.i18n.Tr "repo.clone_helper" | Str2html}}</p> | |||||
<hr/> | <hr/> | ||||
<div class="text-center" id="repo-clone-zip"> | <div class="text-center" id="repo-clone-zip"> | ||||
<a class="btn btn-green btn-radius" href="{{.RepoLink}}/archive/{{.BranchName}}.zip"><i class="octicon octicon-file-zip"></i>ZIP</a> | <a class="btn btn-green btn-radius" href="{{.RepoLink}}/archive/{{.BranchName}}.zip"><i class="octicon octicon-file-zip"></i>ZIP</a> | ||||
</div> | </div> | ||||
</li> | </li> | ||||
<li id="repo-header-watch"> | <li id="repo-header-watch"> | ||||
<a id="repo-header-watch-btn" href="#"> | |||||
<a id="repo-header-watch-btn" href="{{.RepoLink}}/action/{{if .IsWatchingRepo}}un{{end}}watch"> | |||||
<button class="btn btn-gray text-bold btn-radius"> | <button class="btn btn-gray text-bold btn-radius"> | ||||
<i class="octicon octicon-eye-watch"></i>{{if .IsWatchingRepo}}Unwatch{{else}}Watch{{end}} | |||||
<span class="num">{{.Repository.NumWatches}}</span> | |||||
<i class="octicon octicon-eye-watch"></i>{{if .IsWatchingRepo}}{{.i18n.Tr "repo.unwatch"}}{{else}}{{.i18n.Tr "repo.watch"}}{{end}}<span class="num">{{.Repository.NumWatches}}</span> | |||||
</button> | </button> | ||||
</a> | </a> | ||||
</li> | </li> | ||||
<li id="repo-header-star"> | <li id="repo-header-star"> | ||||
<a id="repo-header-star-btn" href="#"> | |||||
<a id="repo-header-star-btn" href="{{.RepoLink}}/action/{{if .IsStaringRepo}}un{{end}}star"> | |||||
<button class="btn btn-gray text-bold btn-radius"> | <button class="btn btn-gray text-bold btn-radius"> | ||||
<i class="octicon octicon-star"></i>Star | |||||
<i class="octicon octicon-star"></i>{{if .IsStaringRepo}}{{.i18n.Tr "repo.unstar"}}{{else}}{{.i18n.Tr "repo.star"}}{{end}} | |||||
<span class="num">{{.Repository.NumStars}}</span> | <span class="num">{{.Repository.NumStars}}</span> | ||||
</button> | </button> | ||||
</a> | </a> | ||||
</li> | </li> | ||||
<li id="repo-header-fork"> | <li id="repo-header-fork"> | ||||
<a id="repo-header-fork-btn" href="#"> | |||||
<a id="repo-header-fork-btn" href="{{.RepoLink}}/action/fork"> | |||||
<button class="btn btn-gray text-bold btn-radius"> | <button class="btn btn-gray text-bold btn-radius"> | ||||
<i class="octicon octicon-repo-forked"></i>Fork | |||||
<i class="octicon octicon-repo-forked"></i>{{.i18n.Tr "repo.fork"}} | |||||
<span class="num">{{.Repository.NumForks}}</span> | <span class="num">{{.Repository.NumForks}}</span> | ||||
</button> | </button> | ||||
</a> | </a> |
</li> | </li> | ||||
<li id="repo-commits-jump" class="repo-jump right"> | <li id="repo-commits-jump" class="repo-jump right"> | ||||
<a href="#"> | <a href="#"> | ||||
<button class="btn btn-small btn-gray btn-radius"><i class="octicon octicon-git-commit"></i></button> | |||||
<button class="btn btn-small btn-gray btn-right-radius"><i class="octicon octicon-git-commit"></i></button> | |||||
</a> | </a> | ||||
</li> | </li> | ||||
<li id="repo-find-jump" class="repo-jump right"> | <li id="repo-find-jump" class="repo-jump right"> | ||||
<a href="#"> | <a href="#"> | ||||
<button class="btn btn-small btn-gray btn-radius"><i class="octicon octicon-list-unordered"></i></button> | |||||
<button class="btn btn-small btn-gray btn-left-radius"><i class="octicon octicon-list-unordered"></i></button> | |||||
</a> | </a> | ||||
</li> | </li> | ||||
</ul> | </ul> |
<strong class="repo">{{.Name}}</strong> | <strong class="repo">{{.Name}}</strong> | ||||
</span> | </span> | ||||
<span class="right repo-star"> | <span class="right repo-star"> | ||||
<i class="octicon octicon-star"></i>{{.NumStars}} | |||||
<i class="octicon octicon-sync"></i>{{.Interval}}H | |||||
</span> | </span> | ||||
</a> | </a> | ||||
</li> | </li> |