Huge updates!!!!! Be careful to merge!!!!
This commit is contained in:
parent
3f38ff6c09
commit
5c4bc3c848
150
cmd/web.go
150
cmd/web.go
|
@ -30,7 +30,7 @@ import (
|
|||
"github.com/gogits/gogs/routers/admin"
|
||||
"github.com/gogits/gogs/routers/api/v1"
|
||||
"github.com/gogits/gogs/routers/dev"
|
||||
// "github.com/gogits/gogs/routers/org"
|
||||
"github.com/gogits/gogs/routers/org"
|
||||
"github.com/gogits/gogs/routers/repo"
|
||||
"github.com/gogits/gogs/routers/user"
|
||||
)
|
||||
|
@ -101,8 +101,8 @@ func runWeb(*cli.Context) {
|
|||
|
||||
// Routers.
|
||||
m.Get("/", ignSignIn, routers.Home)
|
||||
// m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install)
|
||||
// m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost)
|
||||
m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install)
|
||||
m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost)
|
||||
m.Group("", func(r *macaron.Router) {
|
||||
r.Get("/issues", user.Issues)
|
||||
r.Get("/pulls", user.Pulls)
|
||||
|
@ -151,6 +151,7 @@ func runWeb(*cli.Context) {
|
|||
r.Get("/ssh", user.SettingsSSHKeys)
|
||||
r.Post("/ssh", bindIgnErr(auth.AddSSHKeyForm{}), user.SettingsSSHKeysPost)
|
||||
r.Get("/social", user.SettingsSocial)
|
||||
r.Get("/orgs", user.SettingsOrgs)
|
||||
r.Route("/delete", "GET,POST", user.SettingsDelete)
|
||||
})
|
||||
}, reqSignIn)
|
||||
|
@ -173,8 +174,8 @@ func runWeb(*cli.Context) {
|
|||
m.Group("/repo", func(r *macaron.Router) {
|
||||
r.Get("/create", repo.Create)
|
||||
r.Post("/create", bindIgnErr(auth.CreateRepoForm{}), repo.CreatePost)
|
||||
// r.Get("/migrate", repo.Migrate)
|
||||
// r.Post("/migrate", bindIgnErr(auth.MigrateRepoForm{}), repo.MigratePost)
|
||||
r.Get("/migrate", repo.Migrate)
|
||||
r.Post("/migrate", bindIgnErr(auth.MigrateRepoForm{}), repo.MigratePost)
|
||||
}, reqSignIn)
|
||||
|
||||
adminReq := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: true, AdminRequire: true})
|
||||
|
@ -210,91 +211,92 @@ func runWeb(*cli.Context) {
|
|||
dev.RegisterDebugRoutes(m)
|
||||
}
|
||||
|
||||
// reqTrueOwner := middleware.RequireTrueOwner()
|
||||
reqTrueOwner := middleware.RequireTrueOwner()
|
||||
|
||||
// m.Group("/org", func(r *macaron.Router) {
|
||||
// r.Get("/create", org.New)
|
||||
// r.Post("/create", bindIgnErr(auth.CreateOrgForm{}), org.NewPost)
|
||||
// r.Get("/:org", org.Home)
|
||||
// r.Get("/:org/dashboard", org.Dashboard)
|
||||
// r.Get("/:org/members", org.Members)
|
||||
// Organization routers.
|
||||
m.Group("/org", func(r *macaron.Router) {
|
||||
r.Get("/create", org.New)
|
||||
r.Post("/create", bindIgnErr(auth.CreateOrgForm{}), org.NewPost)
|
||||
r.Get("/:org", org.Home)
|
||||
r.Get("/:org/dashboard", org.Dashboard)
|
||||
r.Get("/:org/members", org.Members)
|
||||
|
||||
// r.Get("/:org/teams", org.Teams)
|
||||
// r.Get("/:org/teams/new", org.NewTeam)
|
||||
// r.Post("/:org/teams/new", bindIgnErr(auth.CreateTeamForm{}), org.NewTeamPost)
|
||||
// r.Get("/:org/teams/:team/edit", org.EditTeam)
|
||||
r.Get("/:org/teams", org.Teams)
|
||||
r.Get("/:org/teams/new", org.NewTeam)
|
||||
r.Post("/:org/teams/new", bindIgnErr(auth.CreateTeamForm{}), org.NewTeamPost)
|
||||
r.Get("/:org/teams/:team/edit", org.EditTeam)
|
||||
|
||||
// r.Get("/:org/team/:team", org.SingleTeam)
|
||||
r.Get("/:org/team/:team", org.SingleTeam)
|
||||
|
||||
// r.Get("/:org/settings", org.Settings)
|
||||
// r.Post("/:org/settings", bindIgnErr(auth.OrgSettingForm{}), org.SettingsPost)
|
||||
// r.Post("/:org/settings/delete", org.DeletePost)
|
||||
// }, reqSignIn)
|
||||
r.Get("/:org/settings", org.Settings)
|
||||
r.Post("/:org/settings", bindIgnErr(auth.OrgSettingForm{}), org.SettingsPost)
|
||||
r.Post("/:org/settings/delete", org.DeletePost)
|
||||
}, reqSignIn)
|
||||
|
||||
// m.Group("/:username/:reponame", func(r *macaron.Router) {
|
||||
// r.Get("/settings", repo.Setting)
|
||||
// r.Post("/settings", bindIgnErr(auth.RepoSettingForm{}), repo.SettingPost)
|
||||
m.Group("/:username/:reponame", func(r *macaron.Router) {
|
||||
r.Get("/settings", repo.Setting)
|
||||
r.Post("/settings", bindIgnErr(auth.RepoSettingForm{}), repo.SettingPost)
|
||||
|
||||
// m.Group("/settings", func(r *macaron.Router) {
|
||||
// r.Get("/collaboration", repo.Collaboration)
|
||||
// r.Post("/collaboration", repo.CollaborationPost)
|
||||
// r.Get("/hooks", repo.WebHooks)
|
||||
// r.Get("/hooks/add", repo.WebHooksAdd)
|
||||
// r.Post("/hooks/add", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksAddPost)
|
||||
// r.Get("/hooks/:id", repo.WebHooksEdit)
|
||||
// r.Post("/hooks/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
|
||||
// })
|
||||
// }, reqSignIn, middleware.RepoAssignment(true), reqTrueOwner)
|
||||
m.Group("/settings", func(r *macaron.Router) {
|
||||
r.Get("/collaboration", repo.Collaboration)
|
||||
r.Post("/collaboration", repo.CollaborationPost)
|
||||
r.Get("/hooks", repo.WebHooks)
|
||||
r.Get("/hooks/add", repo.WebHooksAdd)
|
||||
r.Post("/hooks/add", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksAddPost)
|
||||
r.Get("/hooks/:id", repo.WebHooksEdit)
|
||||
r.Post("/hooks/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
|
||||
})
|
||||
}, 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)
|
||||
|
||||
// m.Group("/issues", func(r *macaron.Router) {
|
||||
// r.Get("/new", repo.CreateIssue)
|
||||
// r.Post("/new", bindIgnErr(auth.CreateIssueForm{}), repo.CreateIssuePost)
|
||||
// r.Post("/:index", bindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue)
|
||||
// r.Post("/:index/label", repo.UpdateIssueLabel)
|
||||
// r.Post("/:index/milestone", repo.UpdateIssueMilestone)
|
||||
// r.Post("/:index/assignee", repo.UpdateAssignee)
|
||||
// r.Get("/:index/attachment/:id", repo.IssueGetAttachment)
|
||||
// r.Post("/labels/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel)
|
||||
// r.Post("/labels/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel)
|
||||
// r.Post("/labels/delete", repo.DeleteLabel)
|
||||
// r.Get("/milestones", repo.Milestones)
|
||||
// r.Get("/milestones/new", repo.NewMilestone)
|
||||
// r.Post("/milestones/new", bindIgnErr(auth.CreateMilestoneForm{}), repo.NewMilestonePost)
|
||||
// r.Get("/milestones/:index/edit", repo.UpdateMilestone)
|
||||
// r.Post("/milestones/:index/edit", bindIgnErr(auth.CreateMilestoneForm{}), repo.UpdateMilestonePost)
|
||||
// r.Get("/milestones/:index/:action", repo.UpdateMilestone)
|
||||
// })
|
||||
m.Group("/issues", func(r *macaron.Router) {
|
||||
r.Get("/new", repo.CreateIssue)
|
||||
r.Post("/new", bindIgnErr(auth.CreateIssueForm{}), repo.CreateIssuePost)
|
||||
r.Post("/:index", bindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue)
|
||||
r.Post("/:index/label", repo.UpdateIssueLabel)
|
||||
r.Post("/:index/milestone", repo.UpdateIssueMilestone)
|
||||
r.Post("/:index/assignee", repo.UpdateAssignee)
|
||||
r.Get("/:index/attachment/:id", repo.IssueGetAttachment)
|
||||
r.Post("/labels/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel)
|
||||
r.Post("/labels/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel)
|
||||
r.Post("/labels/delete", repo.DeleteLabel)
|
||||
r.Get("/milestones", repo.Milestones)
|
||||
r.Get("/milestones/new", repo.NewMilestone)
|
||||
r.Post("/milestones/new", bindIgnErr(auth.CreateMilestoneForm{}), repo.NewMilestonePost)
|
||||
r.Get("/milestones/:index/edit", repo.UpdateMilestone)
|
||||
r.Post("/milestones/:index/edit", bindIgnErr(auth.CreateMilestoneForm{}), repo.UpdateMilestonePost)
|
||||
r.Get("/milestones/:index/:action", repo.UpdateMilestone)
|
||||
})
|
||||
|
||||
// r.Post("/comment/:action", repo.Comment)
|
||||
// r.Get("/releases/new", repo.NewRelease)
|
||||
// r.Get("/releases/edit/:tagname", repo.EditRelease)
|
||||
// }, reqSignIn, middleware.RepoAssignment(true))
|
||||
r.Post("/comment/:action", repo.Comment)
|
||||
r.Get("/releases/new", repo.NewRelease)
|
||||
r.Get("/releases/edit/:tagname", repo.EditRelease)
|
||||
}, reqSignIn, middleware.RepoAssignment(true))
|
||||
|
||||
// m.Group("/:username/:reponame", func(r *macaron.Router) {
|
||||
// r.Post("/releases/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
|
||||
// r.Post("/releases/edit/:tagname", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
|
||||
// }, reqSignIn, middleware.RepoAssignment(true, true))
|
||||
m.Group("/:username/:reponame", func(r *macaron.Router) {
|
||||
r.Post("/releases/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
|
||||
r.Post("/releases/edit/:tagname", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
|
||||
}, reqSignIn, middleware.RepoAssignment(true, true))
|
||||
|
||||
// m.Group("/:username/:reponame", func(r *macaron.Router) {
|
||||
// r.Get("/issues", repo.Issues)
|
||||
// r.Get("/issues/:index", repo.ViewIssue)
|
||||
// r.Get("/pulls", repo.Pulls)
|
||||
// r.Get("/branches", repo.Branches)
|
||||
// }, ignSignIn, middleware.RepoAssignment(true))
|
||||
m.Group("/:username/:reponame", func(r *macaron.Router) {
|
||||
r.Get("/issues", repo.Issues)
|
||||
r.Get("/issues/:index", repo.ViewIssue)
|
||||
r.Get("/pulls", repo.Pulls)
|
||||
r.Get("/branches", repo.Branches)
|
||||
}, ignSignIn, middleware.RepoAssignment(true))
|
||||
|
||||
m.Group("/:username/:reponame", func(r *macaron.Router) {
|
||||
r.Get("/src/:branchname", repo.Home)
|
||||
r.Get("/src/:branchname/*", repo.Home)
|
||||
r.Get("/raw/:branchname/**", repo.SingleDownload)
|
||||
// r.Get("/commits/:branchname", repo.Commits)
|
||||
// r.Get("/commits/:branchname/search", repo.SearchCommits)
|
||||
// r.Get("/commits/:branchname/**", repo.FileHistory)
|
||||
// r.Get("/commit/:branchname", repo.Diff)
|
||||
// r.Get("/commit/:branchname/**", repo.Diff)
|
||||
// r.Get("/releases", repo.Releases)
|
||||
r.Get("/raw/:branchname/*", repo.SingleDownload)
|
||||
r.Get("/commits/:branchname", repo.Commits)
|
||||
r.Get("/commits/:branchname/search", repo.SearchCommits)
|
||||
r.Get("/commits/:branchname/*", repo.FileHistory)
|
||||
r.Get("/commit/:branchname", repo.Diff)
|
||||
r.Get("/commit/:branchname/*", repo.Diff)
|
||||
r.Get("/releases", repo.Releases)
|
||||
r.Get("/archive/*.*", repo.Download)
|
||||
}, ignSignIn, middleware.RepoAssignment(true, true))
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ profile = Profile
|
|||
password = Password
|
||||
ssh_keys = SSH Keys
|
||||
social = Social Accounts
|
||||
orgs = Organizations
|
||||
delete = Delete Accoount
|
||||
|
||||
public_profile = Public Profile
|
||||
|
@ -118,6 +119,7 @@ add_on = Added on
|
|||
last_used = Last used on
|
||||
no_activity = No recent activity
|
||||
|
||||
manage_orgs = Manage Organizations
|
||||
manage_social = Manage Associated Social Accounts
|
||||
|
||||
delete_account = Delete Your Account
|
||||
|
|
|
@ -89,6 +89,7 @@ profile = 个人信息
|
|||
password = 修改密码
|
||||
ssh_keys = 管理 SSH 密钥
|
||||
social = 社交帐号绑定
|
||||
orgs = 管理组织
|
||||
delete = 删除帐户
|
||||
|
||||
public_profile = 公开信息
|
||||
|
@ -118,6 +119,7 @@ add_on = 增加于
|
|||
last_used = 上次使用在
|
||||
no_activity = 没有最近活动
|
||||
|
||||
manage_orgs = 管理我的组织
|
||||
manage_social = 管理关联社交帐户
|
||||
|
||||
delete_account = 删除当前帐户
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.4.7.0725 Alpha"
|
||||
const APP_VER = "0.4.7.0726 Alpha"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gogits/git"
|
||||
"github.com/gogits/gogs/modules/git"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -106,7 +106,6 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
|
|||
"CreateCaptcha": func() string { return "" },
|
||||
}
|
||||
|
||||
// TODO: Legacy
|
||||
type Actioner interface {
|
||||
GetOpType() int
|
||||
GetActUserName() string
|
||||
|
|
|
@ -73,6 +73,14 @@ func (c *Commit) CommitsCount() (int, error) {
|
|||
return c.repo.commitsCount(c.Id)
|
||||
}
|
||||
|
||||
func (c *Commit) SearchCommits(keyword string) (*list.List, error) {
|
||||
return c.repo.searchCommits(c.Id, keyword)
|
||||
}
|
||||
|
||||
func (c *Commit) CommitsByRange(page int) (*list.List, error) {
|
||||
return c.repo.commitsByRange(c.Id, page)
|
||||
}
|
||||
|
||||
func (c *Commit) GetCommitOfRelPath(relPath string) (*Commit, error) {
|
||||
return c.repo.getCommitOfRelPath(c.Id, relPath)
|
||||
}
|
||||
|
|
|
@ -32,7 +32,18 @@ func (repo *Repository) GetCommitOfBranch(branchName string) (*Commit, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return repo.GetCommit(commitId)
|
||||
}
|
||||
|
||||
func (repo *Repository) GetCommitIdOfTag(tagName string) (string, error) {
|
||||
return repo.getCommitIdOfRef("refs/tags/" + tagName)
|
||||
}
|
||||
|
||||
func (repo *Repository) GetCommitOfTag(tagName string) (*Commit, error) {
|
||||
commitId, err := repo.GetCommitIdOfTag(tagName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return repo.GetCommit(commitId)
|
||||
}
|
||||
|
||||
|
@ -212,6 +223,32 @@ func (repo *Repository) commitsBefore(lock *sync.Mutex, l *list.List, parent *li
|
|||
return nil
|
||||
}
|
||||
|
||||
func (repo *Repository) CommitsCount(commitId string) (int, error) {
|
||||
id, err := NewIdFromString(commitId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return repo.commitsCount(id)
|
||||
}
|
||||
|
||||
func (repo *Repository) FileCommitsCount(branch, file string) (int, error) {
|
||||
stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "rev-list", "--count",
|
||||
branch, "--", file)
|
||||
if err != nil {
|
||||
return 0, errors.New(stderr)
|
||||
}
|
||||
return com.StrTo(strings.TrimSpace(stdout)).Int()
|
||||
}
|
||||
|
||||
func (repo *Repository) CommitsByFileAndRange(branch, file string, page int) (*list.List, error) {
|
||||
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", branch,
|
||||
"--skip="+com.ToStr((page-1)*50), "--max-count=50", prettyLogFormat, "--", file)
|
||||
if err != nil {
|
||||
return nil, errors.New(string(stderr))
|
||||
}
|
||||
return parsePrettyFormatLog(repo, stdout)
|
||||
}
|
||||
|
||||
func (repo *Repository) getCommitsBefore(id sha1) (*list.List, error) {
|
||||
l := list.New()
|
||||
lock := new(sync.Mutex)
|
||||
|
@ -219,6 +256,26 @@ func (repo *Repository) getCommitsBefore(id sha1) (*list.List, error) {
|
|||
return l, err
|
||||
}
|
||||
|
||||
func (repo *Repository) searchCommits(id sha1, keyword string) (*list.List, error) {
|
||||
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", id.String(), "-100",
|
||||
"-i", "--grep="+keyword, prettyLogFormat)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if len(stderr) > 0 {
|
||||
return nil, errors.New(string(stderr))
|
||||
}
|
||||
return parsePrettyFormatLog(repo, stdout)
|
||||
}
|
||||
|
||||
func (repo *Repository) commitsByRange(id sha1, page int) (*list.List, error) {
|
||||
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", id.String(),
|
||||
"--skip="+com.ToStr((page-1)*50), "--max-count=50", prettyLogFormat)
|
||||
if err != nil {
|
||||
return nil, errors.New(string(stderr))
|
||||
}
|
||||
return parsePrettyFormatLog(repo, stdout)
|
||||
}
|
||||
|
||||
func (repo *Repository) getCommitOfRelPath(id sha1, relPath string) (*Commit, error) {
|
||||
stdout, _, err := com.ExecCmdDir(repo.Path, "git", "log", "-1", prettyLogFormat, id.String(), "--", relPath)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,6 +30,14 @@ func (repo *Repository) GetTags() ([]string, error) {
|
|||
return tags[:len(tags)-1], nil
|
||||
}
|
||||
|
||||
func (repo *Repository) CreateTag(tagName, idStr string) error {
|
||||
_, stderr, err := com.ExecCmdDir(repo.Path, "git", "tag", tagName, idStr)
|
||||
if err != nil {
|
||||
return errors.New(stderr)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *Repository) getTag(id sha1) (*Tag, error) {
|
||||
if repo.tagCache != nil {
|
||||
if t, ok := repo.tagCache[id]; ok {
|
||||
|
|
|
@ -44,3 +44,16 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
|
|||
}
|
||||
return nil, fmt.Errorf("GetTreeEntryByPath: %v", ErrNotExist)
|
||||
}
|
||||
|
||||
func (t *Tree) GetBlobByPath(rpath string) (*Blob, error) {
|
||||
entry, err := t.GetTreeEntryByPath(rpath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !entry.IsDir() {
|
||||
return entry.Blob(), nil
|
||||
}
|
||||
|
||||
return nil, ErrNotExist
|
||||
}
|
||||
|
|
|
@ -5,12 +5,33 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"container/list"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const prettyLogFormat = `--pretty=format:%H`
|
||||
|
||||
func parsePrettyFormatLog(repo *Repository, logByts []byte) (*list.List, error) {
|
||||
l := list.New()
|
||||
if len(logByts) == 0 {
|
||||
return l, nil
|
||||
}
|
||||
|
||||
parts := bytes.Split(logByts, []byte{'\n'})
|
||||
|
||||
for _, commitId := range parts {
|
||||
commit, err := repo.GetCommit(string(commitId))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
l.PushBack(commit)
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
||||
|
||||
func RefEndName(refStr string) string {
|
||||
index := strings.LastIndex(refStr, "/")
|
||||
if index != -1 {
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
File diff suppressed because one or more lines are too long
|
@ -373,7 +373,7 @@ img.avatar-30 {
|
|||
display: inline-block;
|
||||
text-decoration: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
margin-right: 8px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
.markdown a span.octicon-link {
|
||||
opacity: 0;
|
||||
|
@ -1058,6 +1058,9 @@ The register and sign-in page style
|
|||
}
|
||||
#repo-bare-start pre {
|
||||
margin: 0 40px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #ddd;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
.repo-bare #repo-bare-start h2 {
|
||||
margin-top: 30px;
|
||||
|
@ -1073,6 +1076,7 @@ The register and sign-in page style
|
|||
margin-right: 200px;
|
||||
}
|
||||
.repo-bare #repo-clone-help {
|
||||
clear: both;
|
||||
width: 100%;
|
||||
}
|
||||
.repo-bare #repo-clone-url {
|
||||
|
|
|
@ -5,12 +5,10 @@
|
|||
package org
|
||||
|
||||
import (
|
||||
"github.com/go-martini/martini"
|
||||
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
func Members(ctx *middleware.Context, params martini.Params) {
|
||||
ctx.Data["Title"] = "Organization " + params["org"] + " Members"
|
||||
func Members(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Organization " + ctx.Params(":org") + " Members"
|
||||
ctx.HTML(200, "org/members")
|
||||
}
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
package org
|
||||
|
||||
import (
|
||||
"github.com/go-martini/martini"
|
||||
|
||||
"github.com/gogits/gogs-ng/models"
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
|
@ -21,10 +19,10 @@ const (
|
|||
SETTINGS base.TplName = "org/settings"
|
||||
)
|
||||
|
||||
func Home(ctx *middleware.Context, params martini.Params) {
|
||||
ctx.Data["Title"] = "Organization " + params["org"]
|
||||
func Home(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Organization " + ctx.Params(":org")
|
||||
|
||||
org, err := models.GetUserByName(params["org"])
|
||||
org, err := models.GetUserByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "org.Home(GetUserByName)", err)
|
||||
|
@ -99,12 +97,12 @@ func NewPost(ctx *middleware.Context, form auth.CreateOrgForm) {
|
|||
ctx.Redirect("/org/" + form.OrgName + "/dashboard")
|
||||
}
|
||||
|
||||
func Dashboard(ctx *middleware.Context, params martini.Params) {
|
||||
func Dashboard(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Dashboard"
|
||||
ctx.Data["PageIsUserDashboard"] = true
|
||||
ctx.Data["PageIsOrgDashboard"] = true
|
||||
|
||||
org, err := models.GetUserByName(params["org"])
|
||||
org, err := models.GetUserByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "org.Dashboard(GetUserByName)", err)
|
||||
|
@ -114,11 +112,11 @@ func Dashboard(ctx *middleware.Context, params martini.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
// if err := ctx.User.GetOrganizations(); err != nil {
|
||||
// ctx.Handle(500, "home.Dashboard(GetOrganizations)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
if err := ctx.User.GetOrganizations(); err != nil {
|
||||
ctx.Handle(500, "home.Dashboard(GetOrganizations)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
ctx.Data["ContextUser"] = org
|
||||
|
||||
ctx.Data["MyRepos"], err = models.GetRepositories(org.Id, true)
|
||||
|
@ -137,10 +135,10 @@ func Dashboard(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.HTML(200, user.DASHBOARD)
|
||||
}
|
||||
|
||||
func Settings(ctx *middleware.Context, params martini.Params) {
|
||||
func Settings(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Settings"
|
||||
|
||||
org, err := models.GetUserByName(params["org"])
|
||||
org, err := models.GetUserByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "org.Settings(GetUserByName)", err)
|
||||
|
@ -154,10 +152,10 @@ func Settings(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.HTML(200, SETTINGS)
|
||||
}
|
||||
|
||||
func SettingsPost(ctx *middleware.Context, params martini.Params, form auth.OrgSettingForm) {
|
||||
func SettingsPost(ctx *middleware.Context, form auth.OrgSettingForm) {
|
||||
ctx.Data["Title"] = "Settings"
|
||||
|
||||
org, err := models.GetUserByName(params["org"])
|
||||
org, err := models.GetUserByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "org.SettingsPost(GetUserByName)", err)
|
||||
|
@ -187,10 +185,10 @@ func SettingsPost(ctx *middleware.Context, params martini.Params, form auth.OrgS
|
|||
ctx.Redirect("/org/" + org.Name + "/settings")
|
||||
}
|
||||
|
||||
func DeletePost(ctx *middleware.Context, params martini.Params) {
|
||||
func DeletePost(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Settings"
|
||||
|
||||
org, err := models.GetUserByName(params["org"])
|
||||
org, err := models.GetUserByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "org.DeletePost(GetUserByName)", err)
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
package org
|
||||
|
||||
import (
|
||||
"github.com/go-martini/martini"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
|
@ -19,10 +17,10 @@ const (
|
|||
TEAM_NEW base.TplName = "org/team_new"
|
||||
)
|
||||
|
||||
func Teams(ctx *middleware.Context, params martini.Params) {
|
||||
ctx.Data["Title"] = "Organization " + params["org"] + " Teams"
|
||||
func Teams(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Organization " + ctx.Params(":org") + " Teams"
|
||||
|
||||
org, err := models.GetUserByName(params["org"])
|
||||
org, err := models.GetUserByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "org.Teams(GetUserByName)", err)
|
||||
|
@ -48,8 +46,8 @@ func Teams(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.HTML(200, TEAMS)
|
||||
}
|
||||
|
||||
func NewTeam(ctx *middleware.Context, params martini.Params) {
|
||||
org, err := models.GetUserByName(params["org"])
|
||||
func NewTeam(ctx *middleware.Context) {
|
||||
org, err := models.GetUserByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "org.NewTeam(GetUserByName)", err)
|
||||
|
@ -69,8 +67,8 @@ func NewTeam(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.HTML(200, TEAM_NEW)
|
||||
}
|
||||
|
||||
func NewTeamPost(ctx *middleware.Context, params martini.Params, form auth.CreateTeamForm) {
|
||||
org, err := models.GetUserByName(params["org"])
|
||||
func NewTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
|
||||
org, err := models.GetUserByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "org.NewTeamPost(GetUserByName)", err)
|
||||
|
@ -125,12 +123,12 @@ func NewTeamPost(ctx *middleware.Context, params martini.Params, form auth.Creat
|
|||
ctx.Redirect("/org/" + org.LowerName + "/teams/" + t.LowerName)
|
||||
}
|
||||
|
||||
func EditTeam(ctx *middleware.Context, params martini.Params) {
|
||||
ctx.Data["Title"] = "Organization " + params["org"] + " Edit Team"
|
||||
func EditTeam(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Organization " + ctx.Params(":org") + " Edit Team"
|
||||
ctx.HTML(200, "org/edit_team")
|
||||
}
|
||||
|
||||
func SingleTeam(ctx *middleware.Context,params martini.Params){
|
||||
ctx.Data["Title"] = "single-team"+params["org"]
|
||||
func SingleTeam(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "single-team" + ctx.Params(":org")
|
||||
ctx.HTML(200, "org/team")
|
||||
}
|
||||
|
|
|
@ -4,224 +4,221 @@
|
|||
|
||||
package repo
|
||||
|
||||
// import (
|
||||
// "path"
|
||||
import (
|
||||
"path"
|
||||
|
||||
// "github.com/Unknwon/com"
|
||||
// "github.com/go-martini/martini"
|
||||
"github.com/Unknwon/com"
|
||||
|
||||
// "github.com/gogits/gogs/models"
|
||||
// "github.com/gogits/gogs/modules/base"
|
||||
// "github.com/gogits/gogs/modules/middleware"
|
||||
// )
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
// const (
|
||||
// COMMITS base.TplName = "repo/commits"
|
||||
// DIFF base.TplName = "repo/diff"
|
||||
// )
|
||||
const (
|
||||
COMMITS base.TplName = "repo/commits"
|
||||
DIFF base.TplName = "repo/diff"
|
||||
)
|
||||
|
||||
// func Commits(ctx *middleware.Context, params martini.Params) {
|
||||
// ctx.Data["IsRepoToolbarCommits"] = true
|
||||
func Commits(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
|
||||
// userName := ctx.Repo.Owner.Name
|
||||
// repoName := ctx.Repo.Repository.Name
|
||||
userName := ctx.Repo.Owner.Name
|
||||
repoName := ctx.Repo.Repository.Name
|
||||
|
||||
// brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "repo.Commits(GetBranches)", err)
|
||||
// return
|
||||
// } else if len(brs) == 0 {
|
||||
// ctx.Handle(404, "repo.Commits(GetBranches)", nil)
|
||||
// return
|
||||
// }
|
||||
brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetBranches", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Handle(404, "GetBranches", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// commitsCount, err := ctx.Repo.Commit.CommitsCount()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "repo.Commits(GetCommitsCount)", err)
|
||||
// return
|
||||
// }
|
||||
commitsCount, err := ctx.Repo.Commit.CommitsCount()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetCommitsCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
// // Calculate and validate page number.
|
||||
// page, _ := com.StrTo(ctx.Query("p")).Int()
|
||||
// if page < 1 {
|
||||
// page = 1
|
||||
// }
|
||||
// lastPage := page - 1
|
||||
// if lastPage < 0 {
|
||||
// lastPage = 0
|
||||
// }
|
||||
// nextPage := page + 1
|
||||
// if nextPage*50 > commitsCount {
|
||||
// nextPage = 0
|
||||
// }
|
||||
// Calculate and validate page number.
|
||||
page, _ := com.StrTo(ctx.Query("p")).Int()
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
lastPage := page - 1
|
||||
if lastPage < 0 {
|
||||
lastPage = 0
|
||||
}
|
||||
nextPage := page + 1
|
||||
if nextPage*50 > commitsCount {
|
||||
nextPage = 0
|
||||
}
|
||||
|
||||
// // Both `git log branchName` and `git log commitId` work.
|
||||
// // ctx.Data["Commits"], err = ctx.Repo.Commit.CommitsByRange(page)
|
||||
// // if err != nil {
|
||||
// // ctx.Handle(500, "repo.Commits(CommitsByRange)", err)
|
||||
// // return
|
||||
// // }
|
||||
// Both `git log branchName` and `git log commitId` work.
|
||||
ctx.Data["Commits"], err = ctx.Repo.Commit.CommitsByRange(page)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "CommitsByRange", err)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Data["Username"] = userName
|
||||
// ctx.Data["Reponame"] = repoName
|
||||
// ctx.Data["CommitCount"] = commitsCount
|
||||
// ctx.Data["LastPageNum"] = lastPage
|
||||
// ctx.Data["NextPageNum"] = nextPage
|
||||
// ctx.HTML(200, COMMITS)
|
||||
// }
|
||||
ctx.Data["Username"] = userName
|
||||
ctx.Data["Reponame"] = repoName
|
||||
ctx.Data["CommitCount"] = commitsCount
|
||||
ctx.Data["LastPageNum"] = lastPage
|
||||
ctx.Data["NextPageNum"] = nextPage
|
||||
ctx.HTML(200, COMMITS)
|
||||
}
|
||||
|
||||
// func SearchCommits(ctx *middleware.Context, params martini.Params) {
|
||||
// ctx.Data["IsSearchPage"] = true
|
||||
// ctx.Data["IsRepoToolbarCommits"] = true
|
||||
func SearchCommits(ctx *middleware.Context) {
|
||||
ctx.Data["IsSearchPage"] = true
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
|
||||
// keyword := ctx.Query("q")
|
||||
// if len(keyword) == 0 {
|
||||
// ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchName)
|
||||
// return
|
||||
// }
|
||||
keyword := ctx.Query("q")
|
||||
if len(keyword) == 0 {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchName)
|
||||
return
|
||||
}
|
||||
|
||||
// userName := params["username"]
|
||||
// repoName := params["reponame"]
|
||||
userName := ctx.Params(":username")
|
||||
repoName := ctx.Params(":reponame")
|
||||
|
||||
// brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "repo.SearchCommits(GetBranches)", err)
|
||||
// return
|
||||
// } else if len(brs) == 0 {
|
||||
// ctx.Handle(404, "repo.SearchCommits(GetBranches)", nil)
|
||||
// return
|
||||
// }
|
||||
brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetBranches", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Handle(404, "GetBranches", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// // commits, err := ctx.Repo.Commit.SearchCommits(keyword)
|
||||
// // if err != nil {
|
||||
// // ctx.Handle(500, "repo.SearchCommits(SearchCommits)", err)
|
||||
// // return
|
||||
// // }
|
||||
commits, err := ctx.Repo.Commit.SearchCommits(keyword)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "repo.SearchCommits(SearchCommits)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Data["Keyword"] = keyword
|
||||
// ctx.Data["Username"] = userName
|
||||
// ctx.Data["Reponame"] = repoName
|
||||
// // ctx.Data["CommitCount"] = commits.Len()
|
||||
// // ctx.Data["Commits"] = commits
|
||||
// ctx.HTML(200, COMMITS)
|
||||
// }
|
||||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["Username"] = userName
|
||||
ctx.Data["Reponame"] = repoName
|
||||
ctx.Data["CommitCount"] = commits.Len()
|
||||
ctx.Data["Commits"] = commits
|
||||
ctx.HTML(200, COMMITS)
|
||||
}
|
||||
|
||||
// func Diff(ctx *middleware.Context, params martini.Params) {
|
||||
// ctx.Data["IsRepoToolbarCommits"] = true
|
||||
func Diff(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
|
||||
// userName := ctx.Repo.Owner.Name
|
||||
// repoName := ctx.Repo.Repository.Name
|
||||
// commitId := ctx.Repo.CommitId
|
||||
userName := ctx.Repo.Owner.Name
|
||||
repoName := ctx.Repo.Repository.Name
|
||||
commitId := ctx.Repo.CommitId
|
||||
|
||||
// commit := ctx.Repo.Commit
|
||||
commit := ctx.Repo.Commit
|
||||
|
||||
// diff, err := models.GetDiff(models.RepoPath(userName, repoName), commitId)
|
||||
// if err != nil {
|
||||
// ctx.Handle(404, "repo.Diff(GetDiff)", err)
|
||||
// return
|
||||
// }
|
||||
diff, err := models.GetDiff(models.RepoPath(userName, repoName), commitId)
|
||||
if err != nil {
|
||||
ctx.Handle(404, "GetDiff", err)
|
||||
return
|
||||
}
|
||||
|
||||
// isImageFile := func(name string) bool {
|
||||
// // blob, err := ctx.Repo.Commit.GetBlobByPath(name)
|
||||
// // if err != nil {
|
||||
// // return false
|
||||
// // }
|
||||
isImageFile := func(name string) bool {
|
||||
blob, err := ctx.Repo.Commit.GetBlobByPath(name)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// // dataRc, err := blob.Data()
|
||||
// // if err != nil {
|
||||
// // return false
|
||||
// // }
|
||||
// // buf := make([]byte, 1024)
|
||||
// // n, _ := dataRc.Read(buf)
|
||||
// // if n > 0 {
|
||||
// // buf = buf[:n]
|
||||
// // }
|
||||
// // dataRc.Close()
|
||||
// // _, isImage := base.IsImageFile(buf)
|
||||
// // return isImage
|
||||
// return false
|
||||
// }
|
||||
dataRc, err := blob.Data()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := dataRc.Read(buf)
|
||||
if n > 0 {
|
||||
buf = buf[:n]
|
||||
}
|
||||
_, isImage := base.IsImageFile(buf)
|
||||
return isImage
|
||||
}
|
||||
|
||||
// parents := make([]string, commit.ParentCount())
|
||||
// for i := 0; i < commit.ParentCount(); i++ {
|
||||
// sha, err := commit.ParentId(i)
|
||||
// parents[i] = sha.String()
|
||||
// if err != nil {
|
||||
// ctx.Handle(404, "repo.Diff", err)
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
parents := make([]string, commit.ParentCount())
|
||||
for i := 0; i < commit.ParentCount(); i++ {
|
||||
sha, err := commit.ParentId(i)
|
||||
parents[i] = sha.String()
|
||||
if err != nil {
|
||||
ctx.Handle(404, "repo.Diff", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// ctx.Data["Username"] = userName
|
||||
// ctx.Data["Reponame"] = repoName
|
||||
// ctx.Data["IsImageFile"] = isImageFile
|
||||
// ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitId)
|
||||
// ctx.Data["Commit"] = commit
|
||||
// ctx.Data["Diff"] = diff
|
||||
// ctx.Data["Parents"] = parents
|
||||
// ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
||||
// ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId)
|
||||
// ctx.Data["RawPath"] = "/" + path.Join(userName, repoName, "raw", commitId)
|
||||
// ctx.HTML(200, DIFF)
|
||||
// }
|
||||
ctx.Data["Username"] = userName
|
||||
ctx.Data["Reponame"] = repoName
|
||||
ctx.Data["IsImageFile"] = isImageFile
|
||||
ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitId)
|
||||
ctx.Data["Commit"] = commit
|
||||
ctx.Data["Diff"] = diff
|
||||
ctx.Data["Parents"] = parents
|
||||
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
||||
ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId)
|
||||
ctx.Data["RawPath"] = "/" + path.Join(userName, repoName, "raw", commitId)
|
||||
ctx.HTML(200, DIFF)
|
||||
}
|
||||
|
||||
// func FileHistory(ctx *middleware.Context, params martini.Params) {
|
||||
// ctx.Data["IsRepoToolbarCommits"] = true
|
||||
func FileHistory(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
|
||||
// fileName := params["_1"]
|
||||
// if len(fileName) == 0 {
|
||||
// Commits(ctx, params)
|
||||
// return
|
||||
// }
|
||||
fileName := ctx.Params("*")
|
||||
if len(fileName) == 0 {
|
||||
Commits(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// userName := ctx.Repo.Owner.Name
|
||||
// repoName := ctx.Repo.Repository.Name
|
||||
// branchName := params["branchname"]
|
||||
userName := ctx.Repo.Owner.Name
|
||||
repoName := ctx.Repo.Repository.Name
|
||||
branchName := ctx.Params(":branchname")
|
||||
|
||||
// brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "repo.FileHistory", err)
|
||||
// return
|
||||
// } else if len(brs) == 0 {
|
||||
// ctx.Handle(404, "repo.FileHistory", nil)
|
||||
// return
|
||||
// }
|
||||
brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetBranches", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Handle(404, "GetBranches", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// // commitsCount, err := ctx.Repo.GitRepo.FileCommitsCount(branchName, fileName)
|
||||
// // if err != nil {
|
||||
// // ctx.Handle(500, "repo.FileHistory(GetCommitsCount)", err)
|
||||
// // return
|
||||
// // } else if commitsCount == 0 {
|
||||
// // ctx.Handle(404, "repo.FileHistory", nil)
|
||||
// // return
|
||||
// // }
|
||||
commitsCount, err := ctx.Repo.GitRepo.FileCommitsCount(branchName, fileName)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "repo.FileHistory(GetCommitsCount)", err)
|
||||
return
|
||||
} else if commitsCount == 0 {
|
||||
ctx.Handle(404, "repo.FileHistory", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// // Calculate and validate page number.
|
||||
// // page, _ := base.StrTo(ctx.Query("p")).Int()
|
||||
// // if page < 1 {
|
||||
// // page = 1
|
||||
// // }
|
||||
// // lastPage := page - 1
|
||||
// // if lastPage < 0 {
|
||||
// // lastPage = 0
|
||||
// // }
|
||||
// // nextPage := page + 1
|
||||
// // if nextPage*50 > commitsCount {
|
||||
// // nextPage = 0
|
||||
// // }
|
||||
// Calculate and validate page number.
|
||||
page := com.StrTo(ctx.Query("p")).MustInt()
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
lastPage := page - 1
|
||||
if lastPage < 0 {
|
||||
lastPage = 0
|
||||
}
|
||||
nextPage := page + 1
|
||||
if nextPage*50 > commitsCount {
|
||||
nextPage = 0
|
||||
}
|
||||
|
||||
// // ctx.Data["Commits"], err = ctx.Repo.GitRepo.CommitsByFileAndRange(
|
||||
// // branchName, fileName, page)
|
||||
// // if err != nil {
|
||||
// // ctx.Handle(500, "repo.FileHistory(CommitsByRange)", err)
|
||||
// // return
|
||||
// // }
|
||||
ctx.Data["Commits"], err = ctx.Repo.GitRepo.CommitsByFileAndRange(
|
||||
branchName, fileName, page)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "repo.FileHistory(CommitsByRange)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Data["Username"] = userName
|
||||
// ctx.Data["Reponame"] = repoName
|
||||
// ctx.Data["FileName"] = fileName
|
||||
// // ctx.Data["CommitCount"] = commitsCount
|
||||
// // ctx.Data["LastPageNum"] = lastPage
|
||||
// // ctx.Data["NextPageNum"] = nextPage
|
||||
// ctx.HTML(200, COMMITS)
|
||||
// }
|
||||
ctx.Data["Username"] = userName
|
||||
ctx.Data["Reponame"] = repoName
|
||||
ctx.Data["FileName"] = fileName
|
||||
ctx.Data["CommitCount"] = commitsCount
|
||||
ctx.Data["LastPageNum"] = lastPage
|
||||
ctx.Data["NextPageNum"] = nextPage
|
||||
ctx.HTML(200, COMMITS)
|
||||
}
|
||||
|
|
|
@ -5,50 +5,41 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
// "io"
|
||||
// "os"
|
||||
// "path/filepath"
|
||||
"io"
|
||||
"path"
|
||||
|
||||
// "github.com/Unknwon/com"
|
||||
|
||||
// "github.com/gogits/git"
|
||||
|
||||
// "github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
func SingleDownload(ctx *middleware.Context) {
|
||||
// treename := params["_1"]
|
||||
treename := ctx.Params("*")
|
||||
|
||||
// blob, err := ctx.Repo.Commit.GetBlobByPath(treename)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "repo.SingleDownload(GetBlobByPath)", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// dataRc, err := blob.Data()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "repo.SingleDownload(Data)", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// buf := make([]byte, 1024)
|
||||
// n, _ := dataRc.Read(buf)
|
||||
// if n > 0 {
|
||||
// buf = buf[:n]
|
||||
// }
|
||||
|
||||
// defer func() {
|
||||
// dataRc.Close()
|
||||
// }()
|
||||
|
||||
// contentType, isTextFile := base.IsTextFile(buf)
|
||||
// _, isImageFile := base.IsImageFile(buf)
|
||||
// ctx.Res.Header().Set("Content-Type", contentType)
|
||||
// if !isTextFile && !isImageFile {
|
||||
// ctx.Res.Header().Set("Content-Disposition", "attachment; filename="+filepath.Base(treename))
|
||||
// ctx.Res.Header().Set("Content-Transfer-Encoding", "binary")
|
||||
// }
|
||||
// ctx.Res.Write(buf)
|
||||
// io.Copy(ctx.Res, dataRc)
|
||||
blob, err := ctx.Repo.Commit.GetBlobByPath(treename)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetBlobByPath", err)
|
||||
return
|
||||
}
|
||||
|
||||
dataRc, err := blob.Data()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "repo.SingleDownload(Data)", err)
|
||||
return
|
||||
}
|
||||
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := dataRc.Read(buf)
|
||||
if n > 0 {
|
||||
buf = buf[:n]
|
||||
}
|
||||
|
||||
contentType, isTextFile := base.IsTextFile(buf)
|
||||
_, isImageFile := base.IsImageFile(buf)
|
||||
ctx.Resp.Header().Set("Content-Type", contentType)
|
||||
if !isTextFile && !isImageFile {
|
||||
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+path.Base(treename))
|
||||
ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary")
|
||||
}
|
||||
ctx.Resp.Write(buf)
|
||||
io.Copy(ctx.Resp, dataRc)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,13 +5,11 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
// "github.com/go-martini/martini"
|
||||
|
||||
// "github.com/gogits/gogs/models"
|
||||
// "github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
// "github.com/gogits/gogs/modules/log"
|
||||
// "github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -20,215 +18,215 @@ const (
|
|||
RELEASE_EDIT base.TplName = "repo/release/edit"
|
||||
)
|
||||
|
||||
// func Releases(ctx *middleware.Context) {
|
||||
// ctx.Data["Title"] = "Releases"
|
||||
// ctx.Data["IsRepoToolbarReleases"] = true
|
||||
// ctx.Data["IsRepoReleaseNew"] = false
|
||||
// rawTags, err := ctx.Repo.GitRepo.GetTags()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.Releases(GetTags)", err)
|
||||
// return
|
||||
// }
|
||||
func Releases(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Releases"
|
||||
ctx.Data["IsRepoToolbarReleases"] = true
|
||||
ctx.Data["IsRepoReleaseNew"] = false
|
||||
rawTags, err := ctx.Repo.GitRepo.GetTags()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "release.Releases(GetTags)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// rels, err := models.GetReleasesByRepoId(ctx.Repo.Repository.Id)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.Releases(GetReleasesByRepoId)", err)
|
||||
// return
|
||||
// }
|
||||
rels, err := models.GetReleasesByRepoId(ctx.Repo.Repository.Id)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "release.Releases(GetReleasesByRepoId)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// commitsCount, err := ctx.Repo.Commit.CommitsCount()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.Releases(CommitsCount)", err)
|
||||
// return
|
||||
// }
|
||||
commitsCount, err := ctx.Repo.Commit.CommitsCount()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "release.Releases(CommitsCount)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// // Temproray cache commits count of used branches to speed up.
|
||||
// countCache := make(map[string]int)
|
||||
// Temproray cache commits count of used branches to speed up.
|
||||
countCache := make(map[string]int)
|
||||
|
||||
// tags := make([]*models.Release, len(rawTags))
|
||||
// for i, rawTag := range rawTags {
|
||||
// for _, rel := range rels {
|
||||
// if rel.IsDraft && !ctx.Repo.IsOwner {
|
||||
// continue
|
||||
// }
|
||||
// if rel.TagName == rawTag {
|
||||
// rel.Publisher, err = models.GetUserById(rel.PublisherId)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.Releases(GetUserById)", err)
|
||||
// return
|
||||
// }
|
||||
// // Get corresponding target if it's not the current branch.
|
||||
// if ctx.Repo.BranchName != rel.Target {
|
||||
// // Get count if not exists.
|
||||
// if _, ok := countCache[rel.Target]; !ok {
|
||||
// commit, err := ctx.Repo.GitRepo.GetCommitOfTag(rel.TagName)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.Releases(GetCommitOfTag)", err)
|
||||
// return
|
||||
// }
|
||||
// countCache[rel.Target], err = commit.CommitsCount()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.Releases(CommitsCount2)", err)
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
// rel.NumCommitsBehind = countCache[rel.Target] - rel.NumCommits
|
||||
// } else {
|
||||
// rel.NumCommitsBehind = commitsCount - rel.NumCommits
|
||||
// }
|
||||
tags := make([]*models.Release, len(rawTags))
|
||||
for i, rawTag := range rawTags {
|
||||
for _, rel := range rels {
|
||||
if rel.IsDraft && !ctx.Repo.IsOwner {
|
||||
continue
|
||||
}
|
||||
if rel.TagName == rawTag {
|
||||
rel.Publisher, err = models.GetUserById(rel.PublisherId)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetUserById", err)
|
||||
return
|
||||
}
|
||||
// Get corresponding target if it's not the current branch.
|
||||
if ctx.Repo.BranchName != rel.Target {
|
||||
// Get count if not exists.
|
||||
if _, ok := countCache[rel.Target]; !ok {
|
||||
commit, err := ctx.Repo.GitRepo.GetCommitOfTag(rel.TagName)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetCommitOfTag", err)
|
||||
return
|
||||
}
|
||||
countCache[rel.Target], err = commit.CommitsCount()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "CommitsCount2", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
rel.NumCommitsBehind = countCache[rel.Target] - rel.NumCommits
|
||||
} else {
|
||||
rel.NumCommitsBehind = commitsCount - rel.NumCommits
|
||||
}
|
||||
|
||||
// rel.Note = base.RenderMarkdownString(rel.Note, ctx.Repo.RepoLink)
|
||||
// tags[i] = rel
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
rel.Note = base.RenderMarkdownString(rel.Note, ctx.Repo.RepoLink)
|
||||
tags[i] = rel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// if tags[i] == nil {
|
||||
// commit, err := ctx.Repo.GitRepo.GetCommitOfTag(rawTag)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.Releases(GetCommitOfTag2)", err)
|
||||
// return
|
||||
// }
|
||||
if tags[i] == nil {
|
||||
commit, err := ctx.Repo.GitRepo.GetCommitOfTag(rawTag)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetCommitOfTag2", err)
|
||||
return
|
||||
}
|
||||
|
||||
// tags[i] = &models.Release{
|
||||
// Title: rawTag,
|
||||
// TagName: rawTag,
|
||||
// Sha1: commit.Id.String(),
|
||||
// }
|
||||
tags[i] = &models.Release{
|
||||
Title: rawTag,
|
||||
TagName: rawTag,
|
||||
Sha1: commit.Id.String(),
|
||||
}
|
||||
|
||||
// tags[i].NumCommits, err = ctx.Repo.GitRepo.CommitsCount(commit.Id.String())
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.Releases(CommitsCount)", err)
|
||||
// return
|
||||
// }
|
||||
// tags[i].NumCommitsBehind = commitsCount - tags[i].NumCommits
|
||||
// }
|
||||
// }
|
||||
// models.SortReleases(tags)
|
||||
// ctx.Data["Releases"] = tags
|
||||
// ctx.HTML(200, RELEASES)
|
||||
// }
|
||||
tags[i].NumCommits, err = ctx.Repo.GitRepo.CommitsCount(commit.Id.String())
|
||||
if err != nil {
|
||||
ctx.Handle(500, "CommitsCount", err)
|
||||
return
|
||||
}
|
||||
tags[i].NumCommitsBehind = commitsCount - tags[i].NumCommits
|
||||
}
|
||||
}
|
||||
models.SortReleases(tags)
|
||||
ctx.Data["Releases"] = tags
|
||||
ctx.HTML(200, RELEASES)
|
||||
}
|
||||
|
||||
// func NewRelease(ctx *middleware.Context) {
|
||||
// if !ctx.Repo.IsOwner {
|
||||
// ctx.Handle(403, "release.ReleasesNew", nil)
|
||||
// return
|
||||
// }
|
||||
func NewRelease(ctx *middleware.Context) {
|
||||
if !ctx.Repo.IsOwner {
|
||||
ctx.Handle(403, "release.ReleasesNew", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Data["Title"] = "New Release"
|
||||
// ctx.Data["IsRepoToolbarReleases"] = true
|
||||
// ctx.Data["IsRepoReleaseNew"] = true
|
||||
// ctx.HTML(200, RELEASE_NEW)
|
||||
// }
|
||||
ctx.Data["Title"] = "New Release"
|
||||
ctx.Data["IsRepoToolbarReleases"] = true
|
||||
ctx.Data["IsRepoReleaseNew"] = true
|
||||
ctx.HTML(200, RELEASE_NEW)
|
||||
}
|
||||
|
||||
// func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
|
||||
// if !ctx.Repo.IsOwner {
|
||||
// ctx.Handle(403, "release.ReleasesNew", nil)
|
||||
// return
|
||||
// }
|
||||
func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
|
||||
if !ctx.Repo.IsOwner {
|
||||
ctx.Handle(403, "release.ReleasesNew", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Data["Title"] = "New Release"
|
||||
// ctx.Data["IsRepoToolbarReleases"] = true
|
||||
// ctx.Data["IsRepoReleaseNew"] = true
|
||||
ctx.Data["Title"] = "New Release"
|
||||
ctx.Data["IsRepoToolbarReleases"] = true
|
||||
ctx.Data["IsRepoReleaseNew"] = true
|
||||
|
||||
// if ctx.HasError() {
|
||||
// ctx.HTML(200, RELEASE_NEW)
|
||||
// return
|
||||
// }
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, RELEASE_NEW)
|
||||
return
|
||||
}
|
||||
|
||||
// commitsCount, err := ctx.Repo.Commit.CommitsCount()
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "release.ReleasesNewPost(CommitsCount)", err)
|
||||
// return
|
||||
// }
|
||||
commitsCount, err := ctx.Repo.Commit.CommitsCount()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "release.ReleasesNewPost(CommitsCount)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// if !ctx.Repo.GitRepo.IsBranchExist(form.Target) {
|
||||
// ctx.RenderWithErr("Target branch does not exist", "release/new", &form)
|
||||
// return
|
||||
// }
|
||||
if !ctx.Repo.GitRepo.IsBranchExist(form.Target) {
|
||||
ctx.RenderWithErr("Target branch does not exist", "release/new", &form)
|
||||
return
|
||||
}
|
||||
|
||||
// rel := &models.Release{
|
||||
// RepoId: ctx.Repo.Repository.Id,
|
||||
// PublisherId: ctx.User.Id,
|
||||
// Title: form.Title,
|
||||
// TagName: form.TagName,
|
||||
// Target: form.Target,
|
||||
// Sha1: ctx.Repo.Commit.Id.String(),
|
||||
// NumCommits: commitsCount,
|
||||
// Note: form.Content,
|
||||
// IsDraft: len(form.Draft) > 0,
|
||||
// IsPrerelease: form.Prerelease,
|
||||
// }
|
||||
rel := &models.Release{
|
||||
RepoId: ctx.Repo.Repository.Id,
|
||||
PublisherId: ctx.User.Id,
|
||||
Title: form.Title,
|
||||
TagName: form.TagName,
|
||||
Target: form.Target,
|
||||
Sha1: ctx.Repo.Commit.Id.String(),
|
||||
NumCommits: commitsCount,
|
||||
Note: form.Content,
|
||||
IsDraft: len(form.Draft) > 0,
|
||||
IsPrerelease: form.Prerelease,
|
||||
}
|
||||
|
||||
// if err = models.CreateRelease(ctx.Repo.GitRepo, rel); err != nil {
|
||||
// if err == models.ErrReleaseAlreadyExist {
|
||||
// ctx.RenderWithErr("Release with this tag name has already existed", "release/new", &form)
|
||||
// } else {
|
||||
// ctx.Handle(500, "release.ReleasesNewPost(IsReleaseExist)", err)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// log.Trace("%s Release created: %s/%s:%s", ctx.Req.RequestURI, ctx.User.LowerName, ctx.Repo.Repository.Name, form.TagName)
|
||||
if err = models.CreateRelease(ctx.Repo.GitRepo, rel); err != nil {
|
||||
if err == models.ErrReleaseAlreadyExist {
|
||||
ctx.RenderWithErr("Release with this tag name has already existed", "release/new", &form)
|
||||
} else {
|
||||
ctx.Handle(500, "release.ReleasesNewPost(IsReleaseExist)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
log.Trace("%s Release created: %s/%s:%s", ctx.Req.RequestURI, ctx.User.LowerName, ctx.Repo.Repository.Name, form.TagName)
|
||||
|
||||
// ctx.Redirect(ctx.Repo.RepoLink + "/releases")
|
||||
// }
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/releases")
|
||||
}
|
||||
|
||||
// func EditRelease(ctx *middleware.Context, params martini.Params) {
|
||||
// if !ctx.Repo.IsOwner {
|
||||
// ctx.Handle(403, "release.ReleasesEdit", nil)
|
||||
// return
|
||||
// }
|
||||
func EditRelease(ctx *middleware.Context) {
|
||||
if !ctx.Repo.IsOwner {
|
||||
ctx.Handle(403, "release.ReleasesEdit", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// tagName := params["tagname"]
|
||||
// rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
|
||||
// if err != nil {
|
||||
// if err == models.ErrReleaseNotExist {
|
||||
// ctx.Handle(404, "release.ReleasesEdit(GetRelease)", err)
|
||||
// } else {
|
||||
// ctx.Handle(500, "release.ReleasesEdit(GetRelease)", err)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// ctx.Data["Release"] = rel
|
||||
tagName := ctx.Params(":tagname")
|
||||
rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
|
||||
if err != nil {
|
||||
if err == models.ErrReleaseNotExist {
|
||||
ctx.Handle(404, "release.ReleasesEdit(GetRelease)", err)
|
||||
} else {
|
||||
ctx.Handle(500, "release.ReleasesEdit(GetRelease)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
ctx.Data["Release"] = rel
|
||||
|
||||
// ctx.Data["Title"] = "Edit Release"
|
||||
// ctx.Data["IsRepoToolbarReleases"] = true
|
||||
// ctx.HTML(200, RELEASE_EDIT)
|
||||
// }
|
||||
ctx.Data["Title"] = "Edit Release"
|
||||
ctx.Data["IsRepoToolbarReleases"] = true
|
||||
ctx.HTML(200, RELEASE_EDIT)
|
||||
}
|
||||
|
||||
// func EditReleasePost(ctx *middleware.Context, params martini.Params, form auth.EditReleaseForm) {
|
||||
// if !ctx.Repo.IsOwner {
|
||||
// ctx.Handle(403, "release.EditReleasePost", nil)
|
||||
// return
|
||||
// }
|
||||
func EditReleasePost(ctx *middleware.Context, form auth.EditReleaseForm) {
|
||||
if !ctx.Repo.IsOwner {
|
||||
ctx.Handle(403, "release.EditReleasePost", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// tagName := params["tagname"]
|
||||
// rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
|
||||
// if err != nil {
|
||||
// if err == models.ErrReleaseNotExist {
|
||||
// ctx.Handle(404, "release.EditReleasePost(GetRelease)", err)
|
||||
// } else {
|
||||
// ctx.Handle(500, "release.EditReleasePost(GetRelease)", err)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// ctx.Data["Release"] = rel
|
||||
tagName := ctx.Params(":tagname")
|
||||
rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
|
||||
if err != nil {
|
||||
if err == models.ErrReleaseNotExist {
|
||||
ctx.Handle(404, "release.EditReleasePost(GetRelease)", err)
|
||||
} else {
|
||||
ctx.Handle(500, "release.EditReleasePost(GetRelease)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
ctx.Data["Release"] = rel
|
||||
|
||||
// if ctx.HasError() {
|
||||
// ctx.HTML(200, RELEASE_EDIT)
|
||||
// return
|
||||
// }
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, RELEASE_EDIT)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Data["Title"] = "Edit Release"
|
||||
// ctx.Data["IsRepoToolbarReleases"] = true
|
||||
ctx.Data["Title"] = "Edit Release"
|
||||
ctx.Data["IsRepoToolbarReleases"] = true
|
||||
|
||||
// rel.Title = form.Title
|
||||
// rel.Note = form.Content
|
||||
// rel.IsDraft = len(form.Draft) > 0
|
||||
// rel.IsPrerelease = form.Prerelease
|
||||
// if err = models.UpdateRelease(ctx.Repo.GitRepo, rel); err != nil {
|
||||
// ctx.Handle(500, "release.EditReleasePost(UpdateRelease)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Redirect(ctx.Repo.RepoLink + "/releases")
|
||||
// }
|
||||
rel.Title = form.Title
|
||||
rel.Note = form.Content
|
||||
rel.IsDraft = len(form.Draft) > 0
|
||||
rel.IsPrerelease = form.Prerelease
|
||||
if err = models.UpdateRelease(ctx.Repo.GitRepo, rel); err != nil {
|
||||
ctx.Handle(500, "release.EditReleasePost(UpdateRelease)", err)
|
||||
return
|
||||
}
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/releases")
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
|
||||
|
@ -34,22 +36,22 @@ func Create(ctx *middleware.Context) {
|
|||
ctx.Data["Licenses"] = models.Licenses
|
||||
|
||||
ctxUser := ctx.User
|
||||
// orgId := com.StrTo(ctx.Query("org")).MustInt64()
|
||||
// if orgId > 0 {
|
||||
// org, err := models.GetUserById(orgId)
|
||||
// if err != nil && err != models.ErrUserNotExist {
|
||||
// ctx.Handle(500, "home.Dashboard(GetUserById)", err)
|
||||
// return
|
||||
// }
|
||||
// ctxUser = org
|
||||
// }
|
||||
orgId := com.StrTo(ctx.Query("org")).MustInt64()
|
||||
if orgId > 0 {
|
||||
org, err := models.GetUserById(orgId)
|
||||
if err != nil && err != models.ErrUserNotExist {
|
||||
ctx.Handle(500, "home.Dashboard(GetUserById)", err)
|
||||
return
|
||||
}
|
||||
ctxUser = org
|
||||
}
|
||||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
// if err := ctx.User.GetOrganizations(); err != nil {
|
||||
// ctx.Handle(500, "home.Dashboard(GetOrganizations)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Data["AllUsers"] = append([]*models.User{ctx.User}, ctx.User.Orgs...)
|
||||
if err := ctx.User.GetOrganizations(); err != nil {
|
||||
ctx.Handle(500, "home.Dashboard(GetOrganizations)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["AllUsers"] = append([]*models.User{ctx.User}, ctx.User.Orgs...)
|
||||
|
||||
ctx.HTML(200, CREATE)
|
||||
}
|
||||
|
@ -62,22 +64,22 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
|||
ctx.Data["Licenses"] = models.Licenses
|
||||
|
||||
ctxUser := ctx.User
|
||||
// orgId := com.StrTo(ctx.Query("org")).MustInt64()
|
||||
// if orgId > 0 {
|
||||
// org, err := models.GetUserById(orgId)
|
||||
// if err != nil && err != models.ErrUserNotExist {
|
||||
// ctx.Handle(500, "home.Dashboard(GetUserById)", err)
|
||||
// return
|
||||
// }
|
||||
// ctxUser = org
|
||||
// }
|
||||
orgId := com.StrTo(ctx.Query("org")).MustInt64()
|
||||
if orgId > 0 {
|
||||
org, err := models.GetUserById(orgId)
|
||||
if err != nil && err != models.ErrUserNotExist {
|
||||
ctx.Handle(500, "home.Dashboard(GetUserById)", err)
|
||||
return
|
||||
}
|
||||
ctxUser = org
|
||||
}
|
||||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
// if err := ctx.User.GetOrganizations(); err != nil {
|
||||
// ctx.Handle(500, "home.CreatePost(GetOrganizations)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
if err := ctx.User.GetOrganizations(); err != nil {
|
||||
ctx.Handle(500, "home.CreatePost(GetOrganizations)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, CREATE)
|
||||
|
@ -127,78 +129,78 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
|||
ctx.Handle(500, "CreateRepository", err)
|
||||
}
|
||||
|
||||
// func Migrate(ctx *middleware.Context) {
|
||||
// ctx.Data["Title"] = "Migrate repository"
|
||||
// ctx.Data["PageIsNewRepo"] = true
|
||||
func Migrate(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Migrate repository"
|
||||
ctx.Data["PageIsNewRepo"] = true
|
||||
|
||||
// if err := ctx.User.GetOrganizations(); err != nil {
|
||||
// ctx.Handle(500, "home.Migrate(GetOrganizations)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
if err := ctx.User.GetOrganizations(); err != nil {
|
||||
ctx.Handle(500, "home.Migrate(GetOrganizations)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
|
||||
// ctx.HTML(200, MIGRATE)
|
||||
// }
|
||||
ctx.HTML(200, MIGRATE)
|
||||
}
|
||||
|
||||
// func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||
// ctx.Data["Title"] = "Migrate repository"
|
||||
// ctx.Data["PageIsNewRepo"] = true
|
||||
func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||
ctx.Data["Title"] = "Migrate repository"
|
||||
ctx.Data["PageIsNewRepo"] = true
|
||||
|
||||
// if err := ctx.User.GetOrganizations(); err != nil {
|
||||
// ctx.Handle(500, "home.MigratePost(GetOrganizations)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
if err := ctx.User.GetOrganizations(); err != nil {
|
||||
ctx.Handle(500, "home.MigratePost(GetOrganizations)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
|
||||
// if ctx.HasError() {
|
||||
// ctx.HTML(200, MIGRATE)
|
||||
// return
|
||||
// }
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, MIGRATE)
|
||||
return
|
||||
}
|
||||
|
||||
// u := ctx.User
|
||||
// // Not equal means current user is an organization.
|
||||
// if u.Id != form.Uid {
|
||||
// var err error
|
||||
// u, err = models.GetUserById(form.Uid)
|
||||
// if err != nil {
|
||||
// if err == models.ErrUserNotExist {
|
||||
// ctx.Handle(404, "home.MigratePost(GetUserById)", err)
|
||||
// } else {
|
||||
// ctx.Handle(500, "home.MigratePost(GetUserById)", err)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
u := ctx.User
|
||||
// Not equal means current user is an organization.
|
||||
if u.Id != form.Uid {
|
||||
var err error
|
||||
u, err = models.GetUserById(form.Uid)
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "home.MigratePost(GetUserById)", err)
|
||||
} else {
|
||||
ctx.Handle(500, "home.MigratePost(GetUserById)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// authStr := strings.Replace(fmt.Sprintf("://%s:%s",
|
||||
// form.AuthUserName, form.AuthPasswd), "@", "%40", -1)
|
||||
// url := strings.Replace(form.Url, "://", authStr+"@", 1)
|
||||
// repo, err := models.MigrateRepository(u, form.RepoName, form.Description, form.Private,
|
||||
// form.Mirror, url)
|
||||
// if err == nil {
|
||||
// log.Trace("%s Repository migrated: %s/%s", ctx.Req.RequestURI, u.LowerName, form.RepoName)
|
||||
// ctx.Redirect("/" + u.Name + "/" + form.RepoName)
|
||||
// return
|
||||
// } else if err == models.ErrRepoAlreadyExist {
|
||||
// ctx.RenderWithErr("Repository name has already been used", MIGRATE, &form)
|
||||
// return
|
||||
// } else if err == models.ErrRepoNameIllegal {
|
||||
// ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), MIGRATE, &form)
|
||||
// return
|
||||
// }
|
||||
authStr := strings.Replace(fmt.Sprintf("://%s:%s",
|
||||
form.AuthUserName, form.AuthPasswd), "@", "%40", -1)
|
||||
url := strings.Replace(form.Url, "://", authStr+"@", 1)
|
||||
repo, err := models.MigrateRepository(u, form.RepoName, form.Description, form.Private,
|
||||
form.Mirror, url)
|
||||
if err == nil {
|
||||
log.Trace("%s Repository migrated: %s/%s", ctx.Req.RequestURI, u.LowerName, form.RepoName)
|
||||
ctx.Redirect("/" + u.Name + "/" + form.RepoName)
|
||||
return
|
||||
} else if err == models.ErrRepoAlreadyExist {
|
||||
ctx.RenderWithErr("Repository name has already been used", MIGRATE, &form)
|
||||
return
|
||||
} else if err == models.ErrRepoNameIllegal {
|
||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), MIGRATE, &form)
|
||||
return
|
||||
}
|
||||
|
||||
// if repo != nil {
|
||||
// if errDelete := models.DeleteRepository(u.Id, repo.Id, u.Name); errDelete != nil {
|
||||
// log.Error("repo.MigratePost(DeleteRepository): %v", errDelete)
|
||||
// }
|
||||
// }
|
||||
if repo != nil {
|
||||
if errDelete := models.DeleteRepository(u.Id, repo.Id, u.Name); errDelete != nil {
|
||||
log.Error(4, "DeleteRepository: %v", errDelete)
|
||||
}
|
||||
}
|
||||
|
||||
// if strings.Contains(err.Error(), "Authentication failed") {
|
||||
// ctx.RenderWithErr(err.Error(), MIGRATE, &form)
|
||||
// return
|
||||
// }
|
||||
// ctx.Handle(500, "repo.Migrate(MigrateRepository)", err)
|
||||
// }
|
||||
if strings.Contains(err.Error(), "Authentication failed") {
|
||||
ctx.RenderWithErr(err.Error(), MIGRATE, &form)
|
||||
return
|
||||
}
|
||||
ctx.Handle(500, "MigrateRepository", err)
|
||||
}
|
||||
|
||||
// func Action(ctx *middleware.Context, params martini.Params) {
|
||||
// var err error
|
||||
|
|
|
@ -4,362 +4,362 @@
|
|||
|
||||
package repo
|
||||
|
||||
// import (
|
||||
// "fmt"
|
||||
// "strings"
|
||||
// "time"
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
// "github.com/go-martini/martini"
|
||||
"github.com/Unknwon/com"
|
||||
|
||||
// "github.com/gogits/gogs-ng/models"
|
||||
// "github.com/gogits/gogs/modules/auth"
|
||||
// "github.com/gogits/gogs/modules/base"
|
||||
// "github.com/gogits/gogs/modules/log"
|
||||
// "github.com/gogits/gogs/modules/mailer"
|
||||
// "github.com/gogits/gogs/modules/middleware"
|
||||
// "github.com/gogits/gogs/modules/setting"
|
||||
// )
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
// const (
|
||||
// SETTING base.TplName = "repo/setting"
|
||||
// COLLABORATION base.TplName = "repo/collaboration"
|
||||
const (
|
||||
SETTING base.TplName = "repo/setting"
|
||||
COLLABORATION base.TplName = "repo/collaboration"
|
||||
|
||||
// HOOKS base.TplName = "repo/hooks"
|
||||
// HOOK_ADD base.TplName = "repo/hook_add"
|
||||
// HOOK_EDIT base.TplName = "repo/hook_edit"
|
||||
// )
|
||||
HOOKS base.TplName = "repo/hooks"
|
||||
HOOK_ADD base.TplName = "repo/hook_add"
|
||||
HOOK_EDIT base.TplName = "repo/hook_edit"
|
||||
)
|
||||
|
||||
// func Setting(ctx *middleware.Context) {
|
||||
// ctx.Data["IsRepoToolbarSetting"] = true
|
||||
// ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - settings"
|
||||
// ctx.HTML(200, SETTING)
|
||||
// }
|
||||
func Setting(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarSetting"] = true
|
||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - settings"
|
||||
ctx.HTML(200, SETTING)
|
||||
}
|
||||
|
||||
// func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||
// ctx.Data["IsRepoToolbarSetting"] = true
|
||||
func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||
ctx.Data["IsRepoToolbarSetting"] = true
|
||||
|
||||
// switch ctx.Query("action") {
|
||||
// case "update":
|
||||
// if ctx.HasError() {
|
||||
// ctx.HTML(200, SETTING)
|
||||
// return
|
||||
// }
|
||||
switch ctx.Query("action") {
|
||||
case "update":
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, SETTING)
|
||||
return
|
||||
}
|
||||
|
||||
// newRepoName := form.RepoName
|
||||
// // Check if repository name has been changed.
|
||||
// if ctx.Repo.Repository.Name != newRepoName {
|
||||
// isExist, err := models.IsRepositoryExist(ctx.Repo.Owner, newRepoName)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "setting.SettingPost(update: check existence)", err)
|
||||
// return
|
||||
// } else if isExist {
|
||||
// ctx.RenderWithErr("Repository name has been taken in your repositories.", SETTING, nil)
|
||||
// return
|
||||
// } else if err = models.ChangeRepositoryName(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newRepoName); err != nil {
|
||||
// ctx.Handle(500, "setting.SettingPost(change repository name)", err)
|
||||
// return
|
||||
// }
|
||||
// log.Trace("%s Repository name changed: %s/%s -> %s", ctx.Req.RequestURI, ctx.User.Name, ctx.Repo.Repository.Name, newRepoName)
|
||||
newRepoName := form.RepoName
|
||||
// Check if repository name has been changed.
|
||||
if ctx.Repo.Repository.Name != newRepoName {
|
||||
isExist, err := models.IsRepositoryExist(ctx.Repo.Owner, newRepoName)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "setting.SettingPost(update: check existence)", err)
|
||||
return
|
||||
} else if isExist {
|
||||
ctx.RenderWithErr("Repository name has been taken in your repositories.", SETTING, nil)
|
||||
return
|
||||
} else if err = models.ChangeRepositoryName(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newRepoName); err != nil {
|
||||
ctx.Handle(500, "setting.SettingPost(change repository name)", err)
|
||||
return
|
||||
}
|
||||
log.Trace("%s Repository name changed: %s/%s -> %s", ctx.Req.RequestURI, ctx.User.Name, ctx.Repo.Repository.Name, newRepoName)
|
||||
|
||||
// ctx.Repo.Repository.Name = newRepoName
|
||||
// }
|
||||
ctx.Repo.Repository.Name = newRepoName
|
||||
}
|
||||
|
||||
// br := form.Branch
|
||||
br := form.Branch
|
||||
|
||||
// if ctx.Repo.GitRepo.IsBranchExist(br) {
|
||||
// ctx.Repo.Repository.DefaultBranch = br
|
||||
// }
|
||||
// ctx.Repo.Repository.Description = form.Description
|
||||
// ctx.Repo.Repository.Website = form.Website
|
||||
// ctx.Repo.Repository.IsPrivate = form.Private
|
||||
// ctx.Repo.Repository.IsGoget = form.GoGet
|
||||
// if err := models.UpdateRepository(ctx.Repo.Repository); err != nil {
|
||||
// ctx.Handle(404, "setting.SettingPost(update)", err)
|
||||
// return
|
||||
// }
|
||||
// log.Trace("%s Repository updated: %s/%s", ctx.Req.RequestURI, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
|
||||
if ctx.Repo.GitRepo.IsBranchExist(br) {
|
||||
ctx.Repo.Repository.DefaultBranch = br
|
||||
}
|
||||
ctx.Repo.Repository.Description = form.Description
|
||||
ctx.Repo.Repository.Website = form.Website
|
||||
ctx.Repo.Repository.IsPrivate = form.Private
|
||||
ctx.Repo.Repository.IsGoget = form.GoGet
|
||||
if err := models.UpdateRepository(ctx.Repo.Repository); err != nil {
|
||||
ctx.Handle(404, "UpdateRepository", err)
|
||||
return
|
||||
}
|
||||
log.Trace("%s Repository updated: %s/%s", ctx.Req.RequestURI, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
|
||||
|
||||
// if ctx.Repo.Repository.IsMirror {
|
||||
// if form.Interval > 0 {
|
||||
// ctx.Repo.Mirror.Interval = form.Interval
|
||||
// ctx.Repo.Mirror.NextUpdate = time.Now().Add(time.Duration(form.Interval) * time.Hour)
|
||||
// if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
|
||||
// log.Error("setting.SettingPost(UpdateMirror): %v", err)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if ctx.Repo.Repository.IsMirror {
|
||||
if form.Interval > 0 {
|
||||
ctx.Repo.Mirror.Interval = form.Interval
|
||||
ctx.Repo.Mirror.NextUpdate = time.Now().Add(time.Duration(form.Interval) * time.Hour)
|
||||
if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
|
||||
log.Error(4, "UpdateMirror: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ctx.Flash.Success("Repository options has been successfully updated.")
|
||||
// ctx.Redirect(fmt.Sprintf("/%s/%s/settings", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name))
|
||||
// case "transfer":
|
||||
// if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") {
|
||||
// ctx.RenderWithErr("Please make sure you entered repository name is correct.", SETTING, nil)
|
||||
// return
|
||||
// } else if ctx.Repo.Repository.IsMirror {
|
||||
// ctx.Error(404)
|
||||
// return
|
||||
// }
|
||||
ctx.Flash.Success("Repository options has been successfully updated.")
|
||||
ctx.Redirect(fmt.Sprintf("/%s/%s/settings", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name))
|
||||
case "transfer":
|
||||
if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") {
|
||||
ctx.RenderWithErr("Please make sure you entered repository name is correct.", SETTING, nil)
|
||||
return
|
||||
} else if ctx.Repo.Repository.IsMirror {
|
||||
ctx.Error(404)
|
||||
return
|
||||
}
|
||||
|
||||
// newOwner := ctx.Query("owner")
|
||||
// // Check if new owner exists.
|
||||
// isExist, err := models.IsUserExist(newOwner)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "setting.SettingPost(transfer: check existence)", err)
|
||||
// return
|
||||
// } else if !isExist {
|
||||
// ctx.RenderWithErr("Please make sure you entered owner name is correct.", SETTING, nil)
|
||||
// return
|
||||
// } else if err = models.TransferOwnership(ctx.Repo.Owner, newOwner, ctx.Repo.Repository); err != nil {
|
||||
// ctx.Handle(500, "setting.SettingPost(transfer repository)", err)
|
||||
// return
|
||||
// }
|
||||
// log.Trace("%s Repository transfered: %s/%s -> %s", ctx.Req.RequestURI, ctx.User.Name, ctx.Repo.Repository.Name, newOwner)
|
||||
newOwner := ctx.Query("owner")
|
||||
// Check if new owner exists.
|
||||
isExist, err := models.IsUserExist(newOwner)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "setting.SettingPost(transfer: check existence)", err)
|
||||
return
|
||||
} else if !isExist {
|
||||
ctx.RenderWithErr("Please make sure you entered owner name is correct.", SETTING, nil)
|
||||
return
|
||||
} else if err = models.TransferOwnership(ctx.Repo.Owner, newOwner, ctx.Repo.Repository); err != nil {
|
||||
ctx.Handle(500, "setting.SettingPost(transfer repository)", err)
|
||||
return
|
||||
}
|
||||
log.Trace("%s Repository transfered: %s/%s -> %s", ctx.Req.RequestURI, ctx.User.Name, ctx.Repo.Repository.Name, newOwner)
|
||||
|
||||
// ctx.Redirect("/")
|
||||
// case "delete":
|
||||
// if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") {
|
||||
// ctx.RenderWithErr("Please make sure you entered repository name is correct.", SETTING, nil)
|
||||
// return
|
||||
// }
|
||||
ctx.Redirect("/")
|
||||
case "delete":
|
||||
if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") {
|
||||
ctx.RenderWithErr("Please make sure you entered repository name is correct.", SETTING, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// if ctx.Repo.Owner.IsOrganization() &&
|
||||
// !ctx.Repo.Owner.IsOrgOwner(ctx.User.Id) {
|
||||
// ctx.Error(403)
|
||||
// return
|
||||
// }
|
||||
if ctx.Repo.Owner.IsOrganization() &&
|
||||
!ctx.Repo.Owner.IsOrgOwner(ctx.User.Id) {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
|
||||
// if err := models.DeleteRepository(ctx.Repo.Owner.Id, ctx.Repo.Repository.Id, ctx.Repo.Owner.Name); err != nil {
|
||||
// ctx.Handle(500, "setting.Delete(DeleteRepository)", err)
|
||||
// return
|
||||
// }
|
||||
// log.Trace("%s Repository deleted: %s/%s", ctx.Req.RequestURI, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.LowerName)
|
||||
if err := models.DeleteRepository(ctx.Repo.Owner.Id, ctx.Repo.Repository.Id, ctx.Repo.Owner.Name); err != nil {
|
||||
ctx.Handle(500, "setting.Delete(DeleteRepository)", err)
|
||||
return
|
||||
}
|
||||
log.Trace("%s Repository deleted: %s/%s", ctx.Req.RequestURI, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.LowerName)
|
||||
|
||||
// if ctx.Repo.Owner.IsOrganization() {
|
||||
// ctx.Redirect("/org/" + ctx.Repo.Owner.Name + "/dashboard")
|
||||
// } else {
|
||||
// ctx.Redirect("/")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if ctx.Repo.Owner.IsOrganization() {
|
||||
ctx.Redirect("/org/" + ctx.Repo.Owner.Name + "/dashboard")
|
||||
} else {
|
||||
ctx.Redirect("/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// func Collaboration(ctx *middleware.Context) {
|
||||
// repoLink := strings.TrimPrefix(ctx.Repo.RepoLink, "/")
|
||||
// ctx.Data["IsRepoToolbarCollaboration"] = true
|
||||
// ctx.Data["Title"] = repoLink + " - collaboration"
|
||||
func Collaboration(ctx *middleware.Context) {
|
||||
repoLink := strings.TrimPrefix(ctx.Repo.RepoLink, "/")
|
||||
ctx.Data["IsRepoToolbarCollaboration"] = true
|
||||
ctx.Data["Title"] = repoLink + " - collaboration"
|
||||
|
||||
// // Delete collaborator.
|
||||
// remove := strings.ToLower(ctx.Query("remove"))
|
||||
// if len(remove) > 0 && remove != ctx.Repo.Owner.LowerName {
|
||||
// if err := models.DeleteAccess(&models.Access{UserName: remove, RepoName: repoLink}); err != nil {
|
||||
// ctx.Handle(500, "setting.Collaboration(DeleteAccess)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Flash.Success("Collaborator has been removed.")
|
||||
// ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
|
||||
// return
|
||||
// }
|
||||
// Delete collaborator.
|
||||
remove := strings.ToLower(ctx.Query("remove"))
|
||||
if len(remove) > 0 && remove != ctx.Repo.Owner.LowerName {
|
||||
if err := models.DeleteAccess(&models.Access{UserName: remove, RepoName: repoLink}); err != nil {
|
||||
ctx.Handle(500, "setting.Collaboration(DeleteAccess)", err)
|
||||
return
|
||||
}
|
||||
ctx.Flash.Success("Collaborator has been removed.")
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
|
||||
return
|
||||
}
|
||||
|
||||
// names, err := models.GetCollaboratorNames(repoLink)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "setting.Collaboration(GetCollaborators)", err)
|
||||
// return
|
||||
// }
|
||||
names, err := models.GetCollaboratorNames(repoLink)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "setting.Collaboration(GetCollaborators)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// us := make([]*models.User, len(names))
|
||||
// for i, name := range names {
|
||||
// us[i], err = models.GetUserByName(name)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "setting.Collaboration(GetUserByName)", err)
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
us := make([]*models.User, len(names))
|
||||
for i, name := range names {
|
||||
us[i], err = models.GetUserByName(name)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "setting.Collaboration(GetUserByName)", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// ctx.Data["Collaborators"] = us
|
||||
// ctx.HTML(200, COLLABORATION)
|
||||
// }
|
||||
ctx.Data["Collaborators"] = us
|
||||
ctx.HTML(200, COLLABORATION)
|
||||
}
|
||||
|
||||
// func CollaborationPost(ctx *middleware.Context) {
|
||||
// repoLink := strings.TrimPrefix(ctx.Repo.RepoLink, "/")
|
||||
// name := strings.ToLower(ctx.Query("collaborator"))
|
||||
// if len(name) == 0 || ctx.Repo.Owner.LowerName == name {
|
||||
// ctx.Redirect(ctx.Req.RequestURI)
|
||||
// return
|
||||
// }
|
||||
// has, err := models.HasAccess(name, repoLink, models.WRITABLE)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "setting.CollaborationPost(HasAccess)", err)
|
||||
// return
|
||||
// } else if has {
|
||||
// ctx.Redirect(ctx.Req.RequestURI)
|
||||
// return
|
||||
// }
|
||||
func CollaborationPost(ctx *middleware.Context) {
|
||||
repoLink := strings.TrimPrefix(ctx.Repo.RepoLink, "/")
|
||||
name := strings.ToLower(ctx.Query("collaborator"))
|
||||
if len(name) == 0 || ctx.Repo.Owner.LowerName == name {
|
||||
ctx.Redirect(ctx.Req.RequestURI)
|
||||
return
|
||||
}
|
||||
has, err := models.HasAccess(name, repoLink, models.WRITABLE)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "setting.CollaborationPost(HasAccess)", err)
|
||||
return
|
||||
} else if has {
|
||||
ctx.Redirect(ctx.Req.RequestURI)
|
||||
return
|
||||
}
|
||||
|
||||
// u, err := models.GetUserByName(name)
|
||||
// if err != nil {
|
||||
// if err == models.ErrUserNotExist {
|
||||
// ctx.Flash.Error("Given user does not exist.")
|
||||
// ctx.Redirect(ctx.Req.RequestURI)
|
||||
// } else {
|
||||
// ctx.Handle(500, "setting.CollaborationPost(GetUserByName)", err)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
u, err := models.GetUserByName(name)
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Flash.Error("Given user does not exist.")
|
||||
ctx.Redirect(ctx.Req.RequestURI)
|
||||
} else {
|
||||
ctx.Handle(500, "setting.CollaborationPost(GetUserByName)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// if err = models.AddAccess(&models.Access{UserName: name, RepoName: repoLink,
|
||||
// Mode: models.WRITABLE}); err != nil {
|
||||
// ctx.Handle(500, "setting.CollaborationPost(AddAccess)", err)
|
||||
// return
|
||||
// }
|
||||
if err = models.AddAccess(&models.Access{UserName: name, RepoName: repoLink,
|
||||
Mode: models.WRITABLE}); err != nil {
|
||||
ctx.Handle(500, "setting.CollaborationPost(AddAccess)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// if setting.Service.EnableNotifyMail {
|
||||
// if err = mailer.SendCollaboratorMail(ctx.Render, u, ctx.User, ctx.Repo.Repository); err != nil {
|
||||
// ctx.Handle(500, "setting.CollaborationPost(SendCollaboratorMail)", err)
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
if setting.Service.EnableNotifyMail {
|
||||
if err = mailer.SendCollaboratorMail(ctx.Render, u, ctx.User, ctx.Repo.Repository); err != nil {
|
||||
ctx.Handle(500, "setting.CollaborationPost(SendCollaboratorMail)", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// ctx.Flash.Success("New collaborator has been added.")
|
||||
// ctx.Redirect(ctx.Req.RequestURI)
|
||||
// }
|
||||
ctx.Flash.Success("New collaborator has been added.")
|
||||
ctx.Redirect(ctx.Req.RequestURI)
|
||||
}
|
||||
|
||||
// func WebHooks(ctx *middleware.Context) {
|
||||
// ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
// ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhooks"
|
||||
func WebHooks(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhooks"
|
||||
|
||||
// // Delete webhook.
|
||||
// remove, _ := base.StrTo(ctx.Query("remove")).Int64()
|
||||
// if remove > 0 {
|
||||
// if err := models.DeleteWebhook(remove); err != nil {
|
||||
// ctx.Handle(500, "setting.WebHooks(DeleteWebhook)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Flash.Success("Webhook has been removed.")
|
||||
// ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks")
|
||||
// return
|
||||
// }
|
||||
// Delete webhook.
|
||||
remove := com.StrTo(ctx.Query("remove")).MustInt64()
|
||||
if remove > 0 {
|
||||
if err := models.DeleteWebhook(remove); err != nil {
|
||||
ctx.Handle(500, "setting.WebHooks(DeleteWebhook)", err)
|
||||
return
|
||||
}
|
||||
ctx.Flash.Success("Webhook has been removed.")
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks")
|
||||
return
|
||||
}
|
||||
|
||||
// ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "setting.WebHooks(GetWebhooksByRepoId)", err)
|
||||
// return
|
||||
// }
|
||||
ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "setting.WebHooks(GetWebhooksByRepoId)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Data["Webhooks"] = ws
|
||||
// ctx.HTML(200, HOOKS)
|
||||
// }
|
||||
ctx.Data["Webhooks"] = ws
|
||||
ctx.HTML(200, HOOKS)
|
||||
}
|
||||
|
||||
// func WebHooksAdd(ctx *middleware.Context) {
|
||||
// ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
// ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
|
||||
// ctx.HTML(200, HOOK_ADD)
|
||||
// }
|
||||
func WebHooksAdd(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
|
||||
ctx.HTML(200, HOOK_ADD)
|
||||
}
|
||||
|
||||
// func WebHooksAddPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||
// ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
// ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
|
||||
func WebHooksAddPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||
ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
|
||||
|
||||
// if ctx.HasError() {
|
||||
// ctx.HTML(200, HOOK_ADD)
|
||||
// return
|
||||
// }
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, HOOK_ADD)
|
||||
return
|
||||
}
|
||||
|
||||
// ct := models.JSON
|
||||
// if form.ContentType == "2" {
|
||||
// ct = models.FORM
|
||||
// }
|
||||
ct := models.JSON
|
||||
if form.ContentType == "2" {
|
||||
ct = models.FORM
|
||||
}
|
||||
|
||||
// w := &models.Webhook{
|
||||
// RepoId: ctx.Repo.Repository.Id,
|
||||
// Url: form.Url,
|
||||
// ContentType: ct,
|
||||
// Secret: form.Secret,
|
||||
// HookEvent: &models.HookEvent{
|
||||
// PushOnly: form.PushOnly,
|
||||
// },
|
||||
// IsActive: form.Active,
|
||||
// }
|
||||
// if err := w.UpdateEvent(); err != nil {
|
||||
// ctx.Handle(500, "setting.WebHooksAddPost(UpdateEvent)", err)
|
||||
// return
|
||||
// } else if err := models.CreateWebhook(w); err != nil {
|
||||
// ctx.Handle(500, "setting.WebHooksAddPost(CreateWebhook)", err)
|
||||
// return
|
||||
// }
|
||||
w := &models.Webhook{
|
||||
RepoId: ctx.Repo.Repository.Id,
|
||||
Url: form.Url,
|
||||
ContentType: ct,
|
||||
Secret: form.Secret,
|
||||
HookEvent: &models.HookEvent{
|
||||
PushOnly: form.PushOnly,
|
||||
},
|
||||
IsActive: form.Active,
|
||||
}
|
||||
if err := w.UpdateEvent(); err != nil {
|
||||
ctx.Handle(500, "setting.WebHooksAddPost(UpdateEvent)", err)
|
||||
return
|
||||
} else if err := models.CreateWebhook(w); err != nil {
|
||||
ctx.Handle(500, "setting.WebHooksAddPost(CreateWebhook)", err)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Flash.Success("New webhook has been added.")
|
||||
// ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks")
|
||||
// }
|
||||
ctx.Flash.Success("New webhook has been added.")
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks")
|
||||
}
|
||||
|
||||
// func WebHooksEdit(ctx *middleware.Context, params martini.Params) {
|
||||
// ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
// ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhook"
|
||||
func WebHooksEdit(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhook"
|
||||
|
||||
// hookId, _ := base.StrTo(params["id"]).Int64()
|
||||
// if hookId == 0 {
|
||||
// ctx.Handle(404, "setting.WebHooksEdit", nil)
|
||||
// return
|
||||
// }
|
||||
hookId := com.StrTo(ctx.Params(":id")).MustInt64()
|
||||
if hookId == 0 {
|
||||
ctx.Handle(404, "setting.WebHooksEdit", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// w, err := models.GetWebhookById(hookId)
|
||||
// if err != nil {
|
||||
// if err == models.ErrWebhookNotExist {
|
||||
// ctx.Handle(404, "setting.WebHooksEdit(GetWebhookById)", nil)
|
||||
// } else {
|
||||
// ctx.Handle(500, "setting.WebHooksEdit(GetWebhookById)", err)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
w, err := models.GetWebhookById(hookId)
|
||||
if err != nil {
|
||||
if err == models.ErrWebhookNotExist {
|
||||
ctx.Handle(404, "setting.WebHooksEdit(GetWebhookById)", nil)
|
||||
} else {
|
||||
ctx.Handle(500, "setting.WebHooksEdit(GetWebhookById)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// w.GetEvent()
|
||||
// ctx.Data["Webhook"] = w
|
||||
// ctx.HTML(200, HOOK_EDIT)
|
||||
// }
|
||||
w.GetEvent()
|
||||
ctx.Data["Webhook"] = w
|
||||
ctx.HTML(200, HOOK_EDIT)
|
||||
}
|
||||
|
||||
// func WebHooksEditPost(ctx *middleware.Context, params martini.Params, form auth.NewWebhookForm) {
|
||||
// ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
// ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhook"
|
||||
func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||
ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhook"
|
||||
|
||||
// hookId, _ := base.StrTo(params["id"]).Int64()
|
||||
// if hookId == 0 {
|
||||
// ctx.Handle(404, "setting.WebHooksEditPost", nil)
|
||||
// return
|
||||
// }
|
||||
hookId := com.StrTo(ctx.Params(":id")).MustInt64()
|
||||
if hookId == 0 {
|
||||
ctx.Handle(404, "setting.WebHooksEditPost", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// w, err := models.GetWebhookById(hookId)
|
||||
// if err != nil {
|
||||
// if err == models.ErrWebhookNotExist {
|
||||
// ctx.Handle(404, "setting.WebHooksEditPost(GetWebhookById)", nil)
|
||||
// } else {
|
||||
// ctx.Handle(500, "setting.WebHooksEditPost(GetWebhookById)", err)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
w, err := models.GetWebhookById(hookId)
|
||||
if err != nil {
|
||||
if err == models.ErrWebhookNotExist {
|
||||
ctx.Handle(404, "GetWebhookById", nil)
|
||||
} else {
|
||||
ctx.Handle(500, "GetWebhookById", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// if ctx.HasError() {
|
||||
// ctx.HTML(200, HOOK_EDIT)
|
||||
// return
|
||||
// }
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, HOOK_EDIT)
|
||||
return
|
||||
}
|
||||
|
||||
// ct := models.JSON
|
||||
// if form.ContentType == "2" {
|
||||
// ct = models.FORM
|
||||
// }
|
||||
ct := models.JSON
|
||||
if form.ContentType == "2" {
|
||||
ct = models.FORM
|
||||
}
|
||||
|
||||
// w.Url = form.Url
|
||||
// w.ContentType = ct
|
||||
// w.Secret = form.Secret
|
||||
// w.HookEvent = &models.HookEvent{
|
||||
// PushOnly: form.PushOnly,
|
||||
// }
|
||||
// w.IsActive = form.Active
|
||||
// if err := w.UpdateEvent(); err != nil {
|
||||
// ctx.Handle(500, "setting.WebHooksEditPost(UpdateEvent)", err)
|
||||
// return
|
||||
// } else if err := models.UpdateWebhook(w); err != nil {
|
||||
// ctx.Handle(500, "setting.WebHooksEditPost(WebHooksEditPost)", err)
|
||||
// return
|
||||
// }
|
||||
w.Url = form.Url
|
||||
w.ContentType = ct
|
||||
w.Secret = form.Secret
|
||||
w.HookEvent = &models.HookEvent{
|
||||
PushOnly: form.PushOnly,
|
||||
}
|
||||
w.IsActive = form.Active
|
||||
if err := w.UpdateEvent(); err != nil {
|
||||
ctx.Handle(500, "UpdateEvent", err)
|
||||
return
|
||||
} else if err := models.UpdateWebhook(w); err != nil {
|
||||
ctx.Handle(500, "WebHooksEditPost", err)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Flash.Success("Webhook has been updated.")
|
||||
// ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", ctx.Repo.RepoLink, hookId))
|
||||
// }
|
||||
ctx.Flash.Success("Webhook has been updated.")
|
||||
ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", ctx.Repo.RepoLink, hookId))
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ func Dashboard(ctx *middleware.Context) {
|
|||
ctx.Data["PageIsDashboard"] = true
|
||||
ctx.Data["PageIsNews"] = true
|
||||
|
||||
// if err := ctx.User.GetOrganizations(); err != nil {
|
||||
// ctx.Handle(500, "home.Dashboard(GetOrganizations)", err)
|
||||
// return
|
||||
// }
|
||||
// ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
if err := ctx.User.GetOrganizations(); err != nil {
|
||||
ctx.Handle(500, "home.Dashboard(GetOrganizations)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Orgs"] = ctx.User.Orgs
|
||||
ctx.Data["ContextUser"] = ctx.User
|
||||
|
||||
repos, err := models.GetRepositories(ctx.User.Id, true)
|
||||
|
@ -40,13 +40,16 @@ func Dashboard(ctx *middleware.Context) {
|
|||
ctx.Handle(500, "GetRepositories", err)
|
||||
return
|
||||
}
|
||||
for _, repo := range repos {
|
||||
repo.Owner = ctx.User
|
||||
}
|
||||
ctx.Data["Repos"] = repos
|
||||
|
||||
// ctx.Data["CollaborativeRepos"], err = models.GetCollaborativeRepos(ctx.User.Name)
|
||||
// if err != nil {
|
||||
// ctx.Handle(500, "home.Dashboard(GetCollaborativeRepos)", err)
|
||||
// return
|
||||
// }
|
||||
ctx.Data["CollaborativeRepos"], err = models.GetCollaborativeRepos(ctx.User.Name)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetCollaborativeRepos", err)
|
||||
return
|
||||
}
|
||||
|
||||
actions, err := models.GetFeeds(ctx.User.Id, 0, true)
|
||||
if err != nil {
|
||||
|
|
|
@ -19,6 +19,7 @@ const (
|
|||
SETTINGS_PASSWORD base.TplName = "user/settings/password"
|
||||
SETTINGS_SSH_KEYS base.TplName = "user/settings/sshkeys"
|
||||
SETTINGS_SOCIAL base.TplName = "user/settings/social"
|
||||
SETTINGS_ORGS base.TplName = "user/settings/orgs"
|
||||
SETTINGS_DELETE base.TplName = "user/settings/delete"
|
||||
NOTIFICATION base.TplName = "user/notification"
|
||||
SECURITY base.TplName = "user/security"
|
||||
|
@ -232,6 +233,13 @@ func SettingsSocial(ctx *middleware.Context) {
|
|||
ctx.HTML(200, SETTINGS_SOCIAL)
|
||||
}
|
||||
|
||||
func SettingsOrgs(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsUserSettings"] = true
|
||||
ctx.Data["PageIsSettingsOrgs"] = true
|
||||
ctx.HTML(200, SETTINGS_ORGS)
|
||||
}
|
||||
|
||||
func SettingsDelete(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsUserSettings"] = true
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.4.7.0725 Alpha
|
||||
0.4.7.0726 Alpha
|
|
@ -176,11 +176,11 @@
|
|||
<dt>Enable Set Cookie</dt>
|
||||
<dd><i class="fa fa{{if .SessionConfig.EnableSetCookie}}-check{{end}}-square-o"></i></dd>
|
||||
<dt>GC Interval Time</dt>
|
||||
<dd>{{.SessionConfig.GcIntervalTime}} seconds</dd>
|
||||
<dd>{{.SessionConfig.Gclifetime}} seconds</dd>
|
||||
<dt>Session Life Time</dt>
|
||||
<dd>{{.SessionConfig.SessionLifeTime}} seconds</dd>
|
||||
<dd>{{.SessionConfig.Maxlifetime}} seconds</dd>
|
||||
<dt>HTTPS Only</dt>
|
||||
<dd><i class="fa fa{{if .SessionConfig.CookieSecure}}-check{{end}}-square-o"></i></dd>
|
||||
<dd><i class="fa fa{{if .SessionConfig.Secure}}-check{{end}}-square-o"></i></dd>
|
||||
<dt>Cookie Life Time</dt>
|
||||
<dd>{{.SessionConfig.CookieLifeTime}} seconds</dd>
|
||||
<dt>Session ID Hash Function</dt>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<!-- Stylesheet -->
|
||||
<link rel="stylesheet" href="/ng/css/ui.css">
|
||||
<link rel="stylesheet" href="/ng/css/gogs.css">
|
||||
<link rel="stylesheet" href="/ng/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="/ng/fonts/octicons.css">
|
||||
<!-- <link rel="stylesheet" href="http://cdn.bootcss.com/highlight.js/8.1/styles/github.min.css"> -->
|
||||
<link rel="stylesheet" href="/ng/css/github.min.css">
|
||||
<link rel="stylesheet" href="/css/github.min.css">
|
||||
|
||||
<!-- JavaScript -->
|
||||
<script src="/ng/js/lib/jquery-1.11.1.min.js"></script>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<td class="author"><img class="avatar" src="{{AvatarLink .Author.Email}}" alt=""/><a href="/user/email2user?email={{.Author.Email}}">{{.Author.Name}}</a></td>
|
||||
<td class="sha"><a rel="nofollow" class="label label-success" href="/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
||||
<td class="message">{{.Summary}} </td>
|
||||
<td class="date">{{TimeSince .Author.When}}</td>
|
||||
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<p class="author">
|
||||
<img class="avatar" src="{{AvatarLink .Commit.Author.Email}}" alt=""/>
|
||||
<a class="name" href="/user/email2user?email={{.Commit.Author.Email}}"><strong>{{.Commit.Author.Name}}</strong></a>
|
||||
<span class="time">{{TimeSince .Commit.Author.When}}</span>
|
||||
<span class="time">{{TimeSince .Commit.Author.When $.Lang}}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
<p class="info">
|
||||
<span class="author"><img class="avatar" src="{{.Poster.AvatarLink}}" alt="" width="20"/>
|
||||
<a href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a></span>
|
||||
<span class="time">{{TimeSince .Created}}</span>
|
||||
<span class="time">{{TimeSince .Created $.Lang}}</span>
|
||||
<span class="comment"><i class="fa fa-comments"></i> {{.NumComments}}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<a class="btn btn-primary pull-right issue-edit-save hidden" href="#" data-ajax="{{.RepoLink}}/issues/{{.Issue.Index}}" data-ajax-name="issue-edit-save" data-ajax-method="post">Save</a>{{end}}
|
||||
<span class="status label label-{{if .Issue.IsClosed}}danger{{else}}success{{end}}">{{if .Issue.IsClosed}}Closed{{else}}Open{{end}}</span>
|
||||
<a href="/user/{{.Issue.Poster.Name}}" class="author"><strong>{{.Issue.Poster.Name}}</strong></a> opened this issue
|
||||
<span class="time">{{TimeSince .Issue.Created}}</span> · {{.Issue.NumComments}} comments
|
||||
<span class="time">{{TimeSince .Issue.Created $.Lang}}</span> · {{.Issue.NumComments}} comments
|
||||
</p>
|
||||
</div>
|
||||
<div class="issue-main">
|
||||
|
@ -66,7 +66,7 @@
|
|||
<a class="user pull-left" href="/user/{{.Poster.Name}}"><img class="avatar" src="{{.Poster.AvatarLink}}" alt=""/></a>
|
||||
<div class="issue-content panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<a href="/user/{{.Poster.Name}}" class="user">{{.Poster.Name}}</a> commented <span class="time">{{TimeSince .Created}}</span>
|
||||
<a href="/user/{{.Poster.Name}}" class="user">{{.Poster.Name}}</a> commented <span class="time">{{TimeSince .Created $.Lang}}</span>
|
||||
<!-- <a class="issue-comment-del pull-right issue-action" href="#" title="Edit Comment"><i class="fa fa-times-circle"></i></a>
|
||||
<a class="issue-comment-edit pull-right issue-action" href="#" title="Remove Comment" data-url="{remove-link}"><i class="fa fa-edit"></i></a> -->
|
||||
<span class="role label label-default pull-right">Owner</span>
|
||||
|
@ -95,14 +95,14 @@
|
|||
<div class="issue-child issue-opened">
|
||||
<a class="user pull-left" href="/user/{{.Poster.Name}}"><img class="avatar" src="{{.Poster.AvatarLink}}" alt="" /></a>
|
||||
<div class="issue-content">
|
||||
<a class="user pull-left" href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a> <span class="label label-success">Reopened</span> this issue <span class="time">{{TimeSince .Created}}</span>
|
||||
<a class="user pull-left" href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a> <span class="label label-success">Reopened</span> this issue <span class="time">{{TimeSince .Created $.Lang}}</span>
|
||||
</div>
|
||||
</div>
|
||||
{{else if eq .Type 2}}
|
||||
<div class="issue-child issue-closed">
|
||||
<a class="user pull-left" href="/user/{{.Poster.Name}}"><img class="avatar" src="{{.Poster.AvatarLink}}" alt=""/></a>
|
||||
<div class="issue-content">
|
||||
<a class="user pull-left" href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a> <span class="label label-danger">Closed</span> this issue <span class="time">{{TimeSince .Created}}</span>
|
||||
<a class="user pull-left" href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a> <span class="label label-danger">Closed</span> this issue <span class="time">{{TimeSince .Created $.Lang}}</span>
|
||||
</div>
|
||||
</div>
|
||||
{{else if eq .Type 4}}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{template "base/head" .}}
|
||||
{{template "base/header" .}}
|
||||
{{template "ng/base/head" .}}
|
||||
{{template "ng/base/header" .}}
|
||||
<div class="container">
|
||||
401 Unauthorized: {{.ErrorMsg}}
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
||||
{{template "ng/base/footer" .}}
|
|
@ -6,5 +6,6 @@
|
|||
<br>
|
||||
<p>Application Version: {{AppVer}}</p>
|
||||
<p>If you think this is an error, please open an issue on <a href="https://github.com/gogits/gogs/issues/new">GitHub</a>.</p>
|
||||
<h3>We're currently working on 0.5 beta version, many pages may be missing at this time. Sorry for confusion!</h3>
|
||||
</div>
|
||||
{{template "ng/base/footer" .}}
|
||||
|
|
|
@ -70,15 +70,7 @@
|
|||
<div class="panel-body">
|
||||
<ul class="list-no-style">
|
||||
{{range .Repos}}
|
||||
<li {{if .IsPrivate}}class="private"{{end}}>
|
||||
<a href="{{$.ContextUser.Name}}/{{.Name}}">
|
||||
<i class="octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i>
|
||||
<span class="repo-name">
|
||||
<!-- <span class="repo-name-prefix">gogits / </span> -->
|
||||
<strong class="repo">{{.Name}}</strong>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{{template "user/dashboard/repo_list" .}}
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -87,42 +79,9 @@
|
|||
</div>
|
||||
<div class="panel-body">
|
||||
<ul class="list-no-style">
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="octicon octicon-repo"></i>
|
||||
<span class="repo-name">
|
||||
<span class="repo-name-prefix">gogits / </span>
|
||||
<strong class="repo">gogs</strong>
|
||||
</span>
|
||||
<span class="right repo-star">
|
||||
<i class="octicon octicon-star"></i>2048
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="octicon octicon-repo"></i>
|
||||
<span class="repo-name">
|
||||
<span class="repo-name-prefix">astaxie / </span>
|
||||
<strong class="repo">beego</strong>
|
||||
</span>
|
||||
<span class="right repo-star">
|
||||
<i class="octicon octicon-star"></i>2301
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="octicon octicon-repo"></i>
|
||||
<span class="repo-name">
|
||||
<span class="repo-name-prefix">gogits / </span>
|
||||
<strong class="repo">scaffold</strong>
|
||||
</span>
|
||||
<span class="right repo-star">
|
||||
<i class="octicon octicon-star"></i>0
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{{range .CollaborativeRepos}}
|
||||
{{template "user/dashboard/repo_list" .}}
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<li {{if .IsPrivate}}class="private"{{end}}>
|
||||
<a href="{{.Owner.Name}}/{{.Name}}">
|
||||
<i class="octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i>
|
||||
<span class="repo-name">
|
||||
<!-- <span class="repo-name-prefix">gogits / </span> -->
|
||||
<strong class="repo">{{.Name}}</strong>
|
||||
</span>
|
||||
<span class="right repo-star">
|
||||
<i class="octicon octicon-star"></i>{{.NumStars}}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
|
@ -41,7 +41,7 @@
|
|||
<p class="info">
|
||||
<span class="author"><img class="avatar" src="{{.Poster.AvatarLink}}" alt="" width="20"/>
|
||||
<a href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a></span>
|
||||
<span class="time">{{TimeSince .Created}}</span>
|
||||
<span class="time">{{TimeSince .Created $.Lang}}</span>
|
||||
<span class="comment"><i class="fa fa-comments"></i> {{.NumComments}}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
<ul class="list-unstyled activity-list">
|
||||
{{range .Feeds}}
|
||||
<li>
|
||||
<i class="icon fa fa-{{ActionIcon .OpType}}"></i>
|
||||
<div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . | str2html}}</div>
|
||||
<i class="icon fa fa-{{ActionIcon .GetOpType}}"></i>
|
||||
<div class="info"><span class="meta">{{TimeSince .Created $.Lang}}</span><br>{{ActionDesc . | str2html}}</div>
|
||||
<span class="clearfix"></span>
|
||||
</li>
|
||||
{{else}}
|
||||
|
@ -69,7 +69,7 @@
|
|||
<a href="/{{$.Owner.Name}}/{{.Name}}">{{.Name}}{{if .IsPrivate}} <span class="label label-default">Private</span>{{end}}</a>
|
||||
</h4>
|
||||
<p class="desc">{{.Description}}</p>
|
||||
<div class="info">Last updated {{.Updated|TimeSince}}</div>
|
||||
<div class="info">Last updated {{TimeSince .Updated $.Lang}}</div>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<li {{if .PageIsSettingsPassword}}class="current"{{end}}><a href="/user/settings/password">{{.i18n.Tr "settings.password"}}</a></li>
|
||||
<li {{if .PageIsSettingsSSHKeys}}class="current"{{end}}><a href="/user/settings/ssh">{{.i18n.Tr "settings.ssh_keys"}}</a></li>
|
||||
<li {{if .PageIsSettingsSocial}}class="current"{{end}}><a href="/user/settings/social">{{.i18n.Tr "settings.social"}}</a></li>
|
||||
<li {{if .PageIsSettingsOrgs}}class="current"{{end}}><a href="/user/settings/orgs">{{.i18n.Tr "settings.orgs"}}</a></li>
|
||||
<li {{if .PageIsSettingsDelete}}class="current"{{end}}><a href="/user/settings/delete">{{.i18n.Tr "settings.delete"}}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{{template "ng/base/head" .}}
|
||||
{{template "ng/base/header" .}}
|
||||
<div id="setting-wrapper" class="main-wrapper">
|
||||
<div id="user-profile-setting" class="container clear">
|
||||
{{template "user/settings/nav" .}}
|
||||
<div class="grid-4-5 left">
|
||||
<div class="setting-content">
|
||||
{{template "ng/base/alert" .}}
|
||||
<div id="setting-content">
|
||||
<div id="user-profile-setting-content" class="panel panel-radius">
|
||||
<p class="panel-header"><strong>{{.i18n.Tr "settings.manage_orgs"}}</strong></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{template "ng/base/footer" .}}
|
Loading…
Reference in New Issue