Use constants to name template file
This commit is contained in:
parent
9c82073091
commit
314193029a
16 changed files with 226 additions and 134 deletions
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.4.5.0621 Alpha"
|
const APP_VER = "0.4.5.0622 Alpha"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -7,22 +7,27 @@ package repo
|
||||||
import (
|
import (
|
||||||
"github.com/go-martini/martini"
|
"github.com/go-martini/martini"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
BRANCH base.TplName = "repo/branch"
|
||||||
|
)
|
||||||
|
|
||||||
func Branches(ctx *middleware.Context, params martini.Params) {
|
func Branches(ctx *middleware.Context, params martini.Params) {
|
||||||
ctx.Data["Title"] = "Branches"
|
ctx.Data["Title"] = "Branches"
|
||||||
ctx.Data["IsRepoToolbarBranches"] = true
|
ctx.Data["IsRepoToolbarBranches"] = true
|
||||||
|
|
||||||
brs, err := ctx.Repo.GitRepo.GetBranches()
|
brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "repo.Branches", err)
|
ctx.Handle(500, "repo.Branches(GetBranches)", err)
|
||||||
return
|
return
|
||||||
} else if len(brs) == 0 {
|
} else if len(brs) == 0 {
|
||||||
ctx.Handle(404, "repo.Branches", nil)
|
ctx.Handle(404, "repo.Branches(GetBranches)", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["Branches"] = brs
|
ctx.Data["Branches"] = brs
|
||||||
ctx.HTML(200, "repo/branches")
|
ctx.HTML(200, BRANCH)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ import (
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
COMMITS base.TplName = "repo/commits"
|
||||||
|
DIFF base.TplName = "repo/diff"
|
||||||
|
)
|
||||||
|
|
||||||
func Commits(ctx *middleware.Context, params martini.Params) {
|
func Commits(ctx *middleware.Context, params martini.Params) {
|
||||||
ctx.Data["IsRepoToolbarCommits"] = true
|
ctx.Data["IsRepoToolbarCommits"] = true
|
||||||
|
|
||||||
|
@ -22,10 +27,10 @@ func Commits(ctx *middleware.Context, params martini.Params) {
|
||||||
|
|
||||||
brs, err := ctx.Repo.GitRepo.GetBranches()
|
brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "repo.Commits", err)
|
ctx.Handle(500, "repo.Commits(GetBranches)", err)
|
||||||
return
|
return
|
||||||
} else if len(brs) == 0 {
|
} else if len(brs) == 0 {
|
||||||
ctx.Handle(404, "repo.Commits", nil)
|
ctx.Handle(404, "repo.Commits(GetBranches)", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +66,43 @@ func Commits(ctx *middleware.Context, params martini.Params) {
|
||||||
ctx.Data["CommitCount"] = commitsCount
|
ctx.Data["CommitCount"] = commitsCount
|
||||||
ctx.Data["LastPageNum"] = lastPage
|
ctx.Data["LastPageNum"] = lastPage
|
||||||
ctx.Data["NextPageNum"] = nextPage
|
ctx.Data["NextPageNum"] = nextPage
|
||||||
ctx.HTML(200, "repo/commits")
|
ctx.HTML(200, COMMITS)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SearchCommits(ctx *middleware.Context, params martini.Params) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
userName := params["username"]
|
||||||
|
repoName := 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
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Diff(ctx *middleware.Context, params martini.Params) {
|
func Diff(ctx *middleware.Context, params martini.Params) {
|
||||||
|
@ -75,7 +116,7 @@ func Diff(ctx *middleware.Context, params martini.Params) {
|
||||||
|
|
||||||
diff, err := models.GetDiff(models.RepoPath(userName, repoName), commitId)
|
diff, err := models.GetDiff(models.RepoPath(userName, repoName), commitId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(404, "repo.Diff", err)
|
ctx.Handle(404, "repo.Diff(GetDiff)", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,43 +160,7 @@ func Diff(ctx *middleware.Context, params martini.Params) {
|
||||||
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
||||||
ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId)
|
ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId)
|
||||||
ctx.Data["RawPath"] = "/" + path.Join(userName, repoName, "raw", commitId)
|
ctx.Data["RawPath"] = "/" + path.Join(userName, repoName, "raw", commitId)
|
||||||
ctx.HTML(200, "repo/diff")
|
ctx.HTML(200, DIFF)
|
||||||
}
|
|
||||||
|
|
||||||
func SearchCommits(ctx *middleware.Context, params martini.Params) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
userName := params["username"]
|
|
||||||
repoName := 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
|
|
||||||
}
|
|
||||||
|
|
||||||
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, "repo/commits")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func FileHistory(ctx *middleware.Context, params martini.Params) {
|
func FileHistory(ctx *middleware.Context, params martini.Params) {
|
||||||
|
@ -184,8 +189,7 @@ func FileHistory(ctx *middleware.Context, params martini.Params) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "repo.FileHistory(GetCommitsCount)", err)
|
ctx.Handle(500, "repo.FileHistory(GetCommitsCount)", err)
|
||||||
return
|
return
|
||||||
}
|
} else if commitsCount == 0 {
|
||||||
if commitsCount == 0 {
|
|
||||||
ctx.Handle(404, "repo.FileHistory", nil)
|
ctx.Handle(404, "repo.FileHistory", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -217,5 +221,5 @@ func FileHistory(ctx *middleware.Context, params martini.Params) {
|
||||||
ctx.Data["CommitCount"] = commitsCount
|
ctx.Data["CommitCount"] = commitsCount
|
||||||
ctx.Data["LastPageNum"] = lastPage
|
ctx.Data["LastPageNum"] = lastPage
|
||||||
ctx.Data["NextPageNum"] = nextPage
|
ctx.Data["NextPageNum"] = nextPage
|
||||||
ctx.HTML(200, "repo/commits")
|
ctx.HTML(200, COMMITS)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,16 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ISSUES base.TplName = "repo/issue/list"
|
||||||
|
ISSUE_CREATE base.TplName = "repo/issue/create"
|
||||||
|
ISSUE_VIEW base.TplName = "repo/issue/view"
|
||||||
|
|
||||||
|
MILESTONE base.TplName = "repo/issue/milestone"
|
||||||
|
MILESTONE_NEW base.TplName = "repo/issue/milestone_new"
|
||||||
|
MILESTONE_EDIT base.TplName = "repo/issue/milestone_edit"
|
||||||
|
)
|
||||||
|
|
||||||
func Issues(ctx *middleware.Context) {
|
func Issues(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Issues"
|
ctx.Data["Title"] = "Issues"
|
||||||
ctx.Data["IsRepoToolbarIssues"] = true
|
ctx.Data["IsRepoToolbarIssues"] = true
|
||||||
|
@ -134,7 +144,7 @@ func Issues(ctx *middleware.Context) {
|
||||||
} else {
|
} else {
|
||||||
ctx.Data["ShowCount"] = issueStats.OpenCount
|
ctx.Data["ShowCount"] = issueStats.OpenCount
|
||||||
}
|
}
|
||||||
ctx.HTML(200, "issue/list")
|
ctx.HTML(200, ISSUES)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateIssue(ctx *middleware.Context, params martini.Params) {
|
func CreateIssue(ctx *middleware.Context, params martini.Params) {
|
||||||
|
@ -161,7 +171,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["Collaborators"] = us
|
ctx.Data["Collaborators"] = us
|
||||||
ctx.HTML(200, "issue/create")
|
ctx.HTML(200, ISSUE_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
|
func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
|
||||||
|
@ -190,7 +200,7 @@ func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.C
|
||||||
ctx.Data["Collaborators"] = us
|
ctx.Data["Collaborators"] = us
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "issue/create")
|
ctx.HTML(200, ISSUE_CREATE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +402,7 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
||||||
ctx.Data["IsIssueOwner"] = ctx.Repo.IsOwner || (ctx.IsSigned && issue.PosterId == ctx.User.Id)
|
ctx.Data["IsIssueOwner"] = ctx.Repo.IsOwner || (ctx.IsSigned && issue.PosterId == ctx.User.Id)
|
||||||
ctx.Data["IsRepoToolbarIssues"] = true
|
ctx.Data["IsRepoToolbarIssues"] = true
|
||||||
ctx.Data["IsRepoToolbarIssuesList"] = false
|
ctx.Data["IsRepoToolbarIssuesList"] = false
|
||||||
ctx.HTML(200, "issue/view")
|
ctx.HTML(200, ISSUE_VIEW)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
|
func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
|
||||||
|
@ -794,14 +804,14 @@ func Milestones(ctx *middleware.Context) {
|
||||||
} else {
|
} else {
|
||||||
ctx.Data["State"] = "open"
|
ctx.Data["State"] = "open"
|
||||||
}
|
}
|
||||||
ctx.HTML(200, "issue/milestone")
|
ctx.HTML(200, MILESTONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMilestone(ctx *middleware.Context) {
|
func NewMilestone(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "New Milestone"
|
ctx.Data["Title"] = "New Milestone"
|
||||||
ctx.Data["IsRepoToolbarIssues"] = true
|
ctx.Data["IsRepoToolbarIssues"] = true
|
||||||
ctx.Data["IsRepoToolbarIssuesList"] = true
|
ctx.Data["IsRepoToolbarIssuesList"] = true
|
||||||
ctx.HTML(200, "issue/milestone_new")
|
ctx.HTML(200, MILESTONE_NEW)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
||||||
|
@ -809,6 +819,11 @@ func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
||||||
ctx.Data["IsRepoToolbarIssues"] = true
|
ctx.Data["IsRepoToolbarIssues"] = true
|
||||||
ctx.Data["IsRepoToolbarIssuesList"] = true
|
ctx.Data["IsRepoToolbarIssuesList"] = true
|
||||||
|
|
||||||
|
if ctx.HasError() {
|
||||||
|
ctx.HTML(200, MILESTONE_NEW)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var deadline time.Time
|
var deadline time.Time
|
||||||
var err error
|
var err error
|
||||||
if len(form.Deadline) == 0 {
|
if len(form.Deadline) == 0 {
|
||||||
|
@ -890,7 +905,7 @@ func UpdateMilestone(ctx *middleware.Context, params martini.Params) {
|
||||||
}
|
}
|
||||||
ctx.Data["Milestone"] = mile
|
ctx.Data["Milestone"] = mile
|
||||||
|
|
||||||
ctx.HTML(200, "issue/milestone_edit")
|
ctx.HTML(200, MILESTONE_EDIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateMilestonePost(ctx *middleware.Context, params martini.Params, form auth.CreateMilestoneForm) {
|
func UpdateMilestonePost(ctx *middleware.Context, params martini.Params, form auth.CreateMilestoneForm) {
|
||||||
|
@ -914,6 +929,11 @@ func UpdateMilestonePost(ctx *middleware.Context, params martini.Params, form au
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.HasError() {
|
||||||
|
ctx.HTML(200, MILESTONE_EDIT)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var deadline time.Time
|
var deadline time.Time
|
||||||
if len(form.Deadline) == 0 {
|
if len(form.Deadline) == 0 {
|
||||||
form.Deadline = "12/31/9999"
|
form.Deadline = "12/31/9999"
|
||||||
|
|
|
@ -7,10 +7,15 @@ package repo
|
||||||
import (
|
import (
|
||||||
"github.com/go-martini/martini"
|
"github.com/go-martini/martini"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PULLS base.TplName = "repo/pulls"
|
||||||
|
)
|
||||||
|
|
||||||
func Pulls(ctx *middleware.Context, params martini.Params) {
|
func Pulls(ctx *middleware.Context, params martini.Params) {
|
||||||
ctx.Data["IsRepoToolbarPulls"] = true
|
ctx.Data["IsRepoToolbarPulls"] = true
|
||||||
ctx.HTML(200, "repo/pulls")
|
ctx.HTML(200, PULLS)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,12 @@ import (
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
RELEASES base.TplName = "repo/release/list"
|
||||||
|
RELEASE_NEW base.TplName = "repo/release/new"
|
||||||
|
RELEASE_EDIT base.TplName = "repo/release/edit"
|
||||||
|
)
|
||||||
|
|
||||||
func Releases(ctx *middleware.Context) {
|
func Releases(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Releases"
|
ctx.Data["Title"] = "Releases"
|
||||||
ctx.Data["IsRepoToolbarReleases"] = true
|
ctx.Data["IsRepoToolbarReleases"] = true
|
||||||
|
@ -100,7 +106,7 @@ func Releases(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
models.SortReleases(tags)
|
models.SortReleases(tags)
|
||||||
ctx.Data["Releases"] = tags
|
ctx.Data["Releases"] = tags
|
||||||
ctx.HTML(200, "release/list")
|
ctx.HTML(200, RELEASES)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRelease(ctx *middleware.Context) {
|
func NewRelease(ctx *middleware.Context) {
|
||||||
|
@ -112,7 +118,7 @@ func NewRelease(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "New Release"
|
ctx.Data["Title"] = "New Release"
|
||||||
ctx.Data["IsRepoToolbarReleases"] = true
|
ctx.Data["IsRepoToolbarReleases"] = true
|
||||||
ctx.Data["IsRepoReleaseNew"] = true
|
ctx.Data["IsRepoReleaseNew"] = true
|
||||||
ctx.HTML(200, "release/new")
|
ctx.HTML(200, RELEASE_NEW)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
|
func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
|
||||||
|
@ -126,7 +132,7 @@ func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
|
||||||
ctx.Data["IsRepoReleaseNew"] = true
|
ctx.Data["IsRepoReleaseNew"] = true
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "release/new")
|
ctx.HTML(200, RELEASE_NEW)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +193,7 @@ func EditRelease(ctx *middleware.Context, params martini.Params) {
|
||||||
|
|
||||||
ctx.Data["Title"] = "Edit Release"
|
ctx.Data["Title"] = "Edit Release"
|
||||||
ctx.Data["IsRepoToolbarReleases"] = true
|
ctx.Data["IsRepoToolbarReleases"] = true
|
||||||
ctx.HTML(200, "release/edit")
|
ctx.HTML(200, RELEASE_EDIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EditReleasePost(ctx *middleware.Context, params martini.Params, form auth.EditReleaseForm) {
|
func EditReleasePost(ctx *middleware.Context, params martini.Params, form auth.EditReleaseForm) {
|
||||||
|
@ -208,6 +214,11 @@ func EditReleasePost(ctx *middleware.Context, params martini.Params, form auth.E
|
||||||
}
|
}
|
||||||
ctx.Data["Release"] = rel
|
ctx.Data["Release"] = rel
|
||||||
|
|
||||||
|
if ctx.HasError() {
|
||||||
|
ctx.HTML(200, RELEASE_EDIT)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Data["Title"] = "Edit Release"
|
ctx.Data["Title"] = "Edit Release"
|
||||||
ctx.Data["IsRepoToolbarReleases"] = true
|
ctx.Data["IsRepoToolbarReleases"] = true
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,18 @@ import (
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CREATE base.TplName = "repo/create"
|
||||||
|
MIGRATE base.TplName = "repo/migrate"
|
||||||
|
SINGLE base.TplName = "repo/single"
|
||||||
|
)
|
||||||
|
|
||||||
func Create(ctx *middleware.Context) {
|
func Create(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Create repository"
|
ctx.Data["Title"] = "Create repository"
|
||||||
ctx.Data["PageIsNewRepo"] = true
|
ctx.Data["PageIsNewRepo"] = true
|
||||||
ctx.Data["LanguageIgns"] = models.LanguageIgns
|
ctx.Data["LanguageIgns"] = models.LanguageIgns
|
||||||
ctx.Data["Licenses"] = models.Licenses
|
ctx.Data["Licenses"] = models.Licenses
|
||||||
ctx.HTML(200, "repo/create")
|
ctx.HTML(200, CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
||||||
|
@ -40,7 +46,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
||||||
ctx.Data["Licenses"] = models.Licenses
|
ctx.Data["Licenses"] = models.Licenses
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "repo/create")
|
ctx.HTML(200, CREATE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,25 +57,25 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
||||||
ctx.Redirect("/" + ctx.User.Name + "/" + form.RepoName)
|
ctx.Redirect("/" + ctx.User.Name + "/" + form.RepoName)
|
||||||
return
|
return
|
||||||
} else if err == models.ErrRepoAlreadyExist {
|
} else if err == models.ErrRepoAlreadyExist {
|
||||||
ctx.RenderWithErr("Repository name has already been used", "repo/create", &form)
|
ctx.RenderWithErr("Repository name has already been used", CREATE, &form)
|
||||||
return
|
return
|
||||||
} else if err == models.ErrRepoNameIllegal {
|
} else if err == models.ErrRepoNameIllegal {
|
||||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "repo/create", &form)
|
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), CREATE, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if repo != nil {
|
if repo != nil {
|
||||||
if errDelete := models.DeleteRepository(ctx.User.Id, repo.Id, ctx.User.Name); errDelete != nil {
|
if errDelete := models.DeleteRepository(ctx.User.Id, repo.Id, ctx.User.Name); errDelete != nil {
|
||||||
log.Error("repo.MigratePost(CreatePost): %v", errDelete)
|
log.Error("repo.CreatePost(DeleteRepository): %v", errDelete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.Handle(500, "repo.Create", err)
|
ctx.Handle(500, "repo.CreatePost", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Migrate(ctx *middleware.Context) {
|
func Migrate(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Migrate repository"
|
ctx.Data["Title"] = "Migrate repository"
|
||||||
ctx.Data["PageIsNewRepo"] = true
|
ctx.Data["PageIsNewRepo"] = true
|
||||||
ctx.HTML(200, "repo/migrate")
|
ctx.HTML(200, MIGRATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||||
|
@ -77,7 +83,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||||
ctx.Data["PageIsNewRepo"] = true
|
ctx.Data["PageIsNewRepo"] = true
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "repo/migrate")
|
ctx.HTML(200, MIGRATE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,10 +97,10 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||||
ctx.Redirect("/" + ctx.User.Name + "/" + form.RepoName)
|
ctx.Redirect("/" + ctx.User.Name + "/" + form.RepoName)
|
||||||
return
|
return
|
||||||
} else if err == models.ErrRepoAlreadyExist {
|
} else if err == models.ErrRepoAlreadyExist {
|
||||||
ctx.RenderWithErr("Repository name has already been used", "repo/migrate", &form)
|
ctx.RenderWithErr("Repository name has already been used", MIGRATE, &form)
|
||||||
return
|
return
|
||||||
} else if err == models.ErrRepoNameIllegal {
|
} else if err == models.ErrRepoNameIllegal {
|
||||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "repo/migrate", &form)
|
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), MIGRATE, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +111,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(err.Error(), "Authentication failed") {
|
if strings.Contains(err.Error(), "Authentication failed") {
|
||||||
ctx.RenderWithErr(err.Error(), "repo/migrate", &form)
|
ctx.RenderWithErr(err.Error(), MIGRATE, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Handle(500, "repo.Migrate", err)
|
ctx.Handle(500, "repo.Migrate", err)
|
||||||
|
@ -291,7 +297,7 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
||||||
ctx.Data["Treenames"] = treenames
|
ctx.Data["Treenames"] = treenames
|
||||||
ctx.Data["TreePath"] = treePath
|
ctx.Data["TreePath"] = treePath
|
||||||
ctx.Data["BranchLink"] = branchLink
|
ctx.Data["BranchLink"] = branchLink
|
||||||
ctx.HTML(200, "repo/single")
|
ctx.HTML(200, SINGLE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func basicEncode(username, password string) string {
|
func basicEncode(username, password string) string {
|
||||||
|
|
|
@ -20,10 +20,19 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
func Setting(ctx *middleware.Context) {
|
func Setting(ctx *middleware.Context) {
|
||||||
ctx.Data["IsRepoToolbarSetting"] = true
|
ctx.Data["IsRepoToolbarSetting"] = true
|
||||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - settings"
|
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - settings"
|
||||||
ctx.HTML(200, "repo/setting")
|
ctx.HTML(200, SETTING)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||||
|
@ -32,7 +41,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||||
switch ctx.Query("action") {
|
switch ctx.Query("action") {
|
||||||
case "update":
|
case "update":
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "repo/setting")
|
ctx.HTML(200, SETTING)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +53,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||||
ctx.Handle(500, "setting.SettingPost(update: check existence)", err)
|
ctx.Handle(500, "setting.SettingPost(update: check existence)", err)
|
||||||
return
|
return
|
||||||
} else if isExist {
|
} else if isExist {
|
||||||
ctx.RenderWithErr("Repository name has been taken in your repositories.", "repo/setting", nil)
|
ctx.RenderWithErr("Repository name has been taken in your repositories.", SETTING, nil)
|
||||||
return
|
return
|
||||||
} else if err = models.ChangeRepositoryName(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newRepoName); err != nil {
|
} 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)
|
ctx.Handle(500, "setting.SettingPost(change repository name)", err)
|
||||||
|
@ -84,7 +93,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||||
ctx.Redirect(fmt.Sprintf("/%s/%s/settings", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name))
|
ctx.Redirect(fmt.Sprintf("/%s/%s/settings", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name))
|
||||||
case "transfer":
|
case "transfer":
|
||||||
if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") {
|
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.", "repo/setting", nil)
|
ctx.RenderWithErr("Please make sure you entered repository name is correct.", SETTING, nil)
|
||||||
return
|
return
|
||||||
} else if ctx.Repo.Repository.IsMirror {
|
} else if ctx.Repo.Repository.IsMirror {
|
||||||
ctx.Error(404)
|
ctx.Error(404)
|
||||||
|
@ -98,7 +107,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||||
ctx.Handle(500, "setting.SettingPost(transfer: check existence)", err)
|
ctx.Handle(500, "setting.SettingPost(transfer: check existence)", err)
|
||||||
return
|
return
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
ctx.RenderWithErr("Please make sure you entered owner name is correct.", "repo/setting", nil)
|
ctx.RenderWithErr("Please make sure you entered owner name is correct.", SETTING, nil)
|
||||||
return
|
return
|
||||||
} else if err = models.TransferOwnership(ctx.User, newOwner, ctx.Repo.Repository); err != nil {
|
} else if err = models.TransferOwnership(ctx.User, newOwner, ctx.Repo.Repository); err != nil {
|
||||||
ctx.Handle(500, "setting.SettingPost(transfer repository)", err)
|
ctx.Handle(500, "setting.SettingPost(transfer repository)", err)
|
||||||
|
@ -109,7 +118,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||||
ctx.Redirect("/")
|
ctx.Redirect("/")
|
||||||
case "delete":
|
case "delete":
|
||||||
if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") {
|
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.", "repo/setting", nil)
|
ctx.RenderWithErr("Please make sure you entered repository name is correct.", SETTING, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +165,7 @@ func Collaboration(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["Collaborators"] = us
|
ctx.Data["Collaborators"] = us
|
||||||
ctx.HTML(200, "repo/collaboration")
|
ctx.HTML(200, COLLABORATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CollaborationPost(ctx *middleware.Context) {
|
func CollaborationPost(ctx *middleware.Context) {
|
||||||
|
@ -226,13 +235,13 @@ func WebHooks(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["Webhooks"] = ws
|
ctx.Data["Webhooks"] = ws
|
||||||
ctx.HTML(200, "repo/hooks")
|
ctx.HTML(200, HOOKS)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WebHooksAdd(ctx *middleware.Context) {
|
func WebHooksAdd(ctx *middleware.Context) {
|
||||||
ctx.Data["IsRepoToolbarWebHooks"] = true
|
ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
|
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
|
||||||
ctx.HTML(200, "repo/hooks_add")
|
ctx.HTML(200, HOOK_ADD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WebHooksAddPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
func WebHooksAddPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||||
|
@ -240,7 +249,7 @@ func WebHooksAddPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
|
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "repo/hooks_add")
|
ctx.HTML(200, HOOK_ADD)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,40 +302,46 @@ func WebHooksEdit(ctx *middleware.Context, params martini.Params) {
|
||||||
|
|
||||||
w.GetEvent()
|
w.GetEvent()
|
||||||
ctx.Data["Webhook"] = w
|
ctx.Data["Webhook"] = w
|
||||||
ctx.HTML(200, "repo/hooks_edit")
|
ctx.HTML(200, HOOK_EDIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WebHooksEditPost(ctx *middleware.Context, params martini.Params, form auth.NewWebhookForm) {
|
func WebHooksEditPost(ctx *middleware.Context, params martini.Params, form auth.NewWebhookForm) {
|
||||||
ctx.Data["IsRepoToolbarWebHooks"] = true
|
ctx.Data["IsRepoToolbarWebHooks"] = true
|
||||||
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhook"
|
ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhook"
|
||||||
|
|
||||||
if ctx.HasError() {
|
|
||||||
ctx.HTML(200, "repo/hooks_add")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
hookId, _ := base.StrTo(params["id"]).Int64()
|
hookId, _ := base.StrTo(params["id"]).Int64()
|
||||||
if hookId == 0 {
|
if hookId == 0 {
|
||||||
ctx.Handle(404, "setting.WebHooksEditPost", nil)
|
ctx.Handle(404, "setting.WebHooksEditPost", nil)
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.HasError() {
|
||||||
|
ctx.HTML(200, HOOK_EDIT)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ct := models.JSON
|
ct := models.JSON
|
||||||
if form.ContentType == "2" {
|
if form.ContentType == "2" {
|
||||||
ct = models.FORM
|
ct = models.FORM
|
||||||
}
|
}
|
||||||
|
|
||||||
w := &models.Webhook{
|
w.Url = form.Url
|
||||||
Id: hookId,
|
w.ContentType = ct
|
||||||
RepoId: ctx.Repo.Repository.Id,
|
w.Secret = form.Secret
|
||||||
Url: form.Url,
|
w.HookEvent = &models.HookEvent{
|
||||||
ContentType: ct,
|
PushOnly: form.PushOnly,
|
||||||
Secret: form.Secret,
|
|
||||||
HookEvent: &models.HookEvent{
|
|
||||||
PushOnly: form.PushOnly,
|
|
||||||
},
|
|
||||||
IsActive: form.Active,
|
|
||||||
}
|
}
|
||||||
|
w.IsActive = form.Active
|
||||||
if err := w.UpdateEvent(); err != nil {
|
if err := w.UpdateEvent(); err != nil {
|
||||||
ctx.Handle(500, "setting.WebHooksEditPost(UpdateEvent)", err)
|
ctx.Handle(500, "setting.WebHooksEditPost(UpdateEvent)", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -17,6 +17,14 @@ import (
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DASHBOARD base.TplName = "user/dashboard"
|
||||||
|
PROFILE base.TplName = "user/profile"
|
||||||
|
ISSUES base.TplName = "user/issue"
|
||||||
|
PULLS base.TplName = "user/pulls"
|
||||||
|
STARS base.TplName = "user/stars"
|
||||||
|
)
|
||||||
|
|
||||||
func Dashboard(ctx *middleware.Context) {
|
func Dashboard(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Dashboard"
|
ctx.Data["Title"] = "Dashboard"
|
||||||
ctx.Data["PageIsUserDashboard"] = true
|
ctx.Data["PageIsUserDashboard"] = true
|
||||||
|
@ -52,7 +60,7 @@ func Dashboard(ctx *middleware.Context) {
|
||||||
feeds = append(feeds, act)
|
feeds = append(feeds, act)
|
||||||
}
|
}
|
||||||
ctx.Data["Feeds"] = feeds
|
ctx.Data["Feeds"] = feeds
|
||||||
ctx.HTML(200, "user/dashboard")
|
ctx.HTML(200, DASHBOARD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Profile(ctx *middleware.Context, params martini.Params) {
|
func Profile(ctx *middleware.Context, params martini.Params) {
|
||||||
|
@ -87,7 +95,7 @@ func Profile(ctx *middleware.Context, params martini.Params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.HTML(200, "user/profile")
|
ctx.HTML(200, PROFILE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Email2User(ctx *middleware.Context) {
|
func Email2User(ctx *middleware.Context) {
|
||||||
|
@ -254,13 +262,13 @@ func Issues(ctx *middleware.Context) {
|
||||||
} else {
|
} else {
|
||||||
ctx.Data["ShowCount"] = issueStats.OpenCount
|
ctx.Data["ShowCount"] = issueStats.OpenCount
|
||||||
}
|
}
|
||||||
ctx.HTML(200, "user/issue")
|
ctx.HTML(200, ISSUES)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Pulls(ctx *middleware.Context) {
|
func Pulls(ctx *middleware.Context) {
|
||||||
ctx.HTML(200, "user/pulls")
|
ctx.HTML(200, PULLS)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Stars(ctx *middleware.Context) {
|
func Stars(ctx *middleware.Context) {
|
||||||
ctx.HTML(200, "user/stars")
|
ctx.HTML(200, STARS)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,21 @@ import (
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SETTING base.TplName = "user/setting"
|
||||||
|
SOCIAL base.TplName = "user/social"
|
||||||
|
PASSWORD base.TplName = "user/password"
|
||||||
|
PUBLICKEY base.TplName = "user/publickey"
|
||||||
|
NOTIFICATION base.TplName = "user/notification"
|
||||||
|
SECURITY base.TplName = "user/security"
|
||||||
|
)
|
||||||
|
|
||||||
func Setting(ctx *middleware.Context) {
|
func Setting(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Setting"
|
ctx.Data["Title"] = "Setting"
|
||||||
ctx.Data["PageIsUserSetting"] = true
|
ctx.Data["PageIsUserSetting"] = true
|
||||||
ctx.Data["IsUserPageSetting"] = true
|
ctx.Data["IsUserPageSetting"] = true
|
||||||
ctx.Data["Owner"] = ctx.User
|
ctx.Data["Owner"] = ctx.User
|
||||||
ctx.HTML(200, "user/setting")
|
ctx.HTML(200, SETTING)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||||
|
@ -28,7 +37,7 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||||
ctx.Data["IsUserPageSetting"] = true
|
ctx.Data["IsUserPageSetting"] = true
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "user/setting")
|
ctx.HTML(200, SETTING)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,14 +99,14 @@ func SettingSocial(ctx *middleware.Context) {
|
||||||
ctx.Handle(500, "user.SettingSocial(GetOauthByUserId)", err)
|
ctx.Handle(500, "user.SettingSocial(GetOauthByUserId)", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.HTML(200, "user/social")
|
ctx.HTML(200, SOCIAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SettingPassword(ctx *middleware.Context) {
|
func SettingPassword(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Password"
|
ctx.Data["Title"] = "Password"
|
||||||
ctx.Data["PageIsUserSetting"] = true
|
ctx.Data["PageIsUserSetting"] = true
|
||||||
ctx.Data["IsUserPageSettingPasswd"] = true
|
ctx.Data["IsUserPageSettingPasswd"] = true
|
||||||
ctx.HTML(200, "user/password")
|
ctx.HTML(200, PASSWORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SettingPasswordPost(ctx *middleware.Context, form auth.UpdatePasswdForm) {
|
func SettingPasswordPost(ctx *middleware.Context, form auth.UpdatePasswdForm) {
|
||||||
|
@ -106,7 +115,7 @@ func SettingPasswordPost(ctx *middleware.Context, form auth.UpdatePasswdForm) {
|
||||||
ctx.Data["IsUserPageSettingPasswd"] = true
|
ctx.Data["IsUserPageSettingPasswd"] = true
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "user/password")
|
ctx.HTML(200, PASSWORD)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +216,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.HTML(200, "user/publickey")
|
ctx.HTML(200, PUBLICKEY)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SettingNotification(ctx *middleware.Context) {
|
func SettingNotification(ctx *middleware.Context) {
|
||||||
|
@ -215,7 +224,7 @@ func SettingNotification(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Notification"
|
ctx.Data["Title"] = "Notification"
|
||||||
ctx.Data["PageIsUserSetting"] = true
|
ctx.Data["PageIsUserSetting"] = true
|
||||||
ctx.Data["IsUserPageSettingNotify"] = true
|
ctx.Data["IsUserPageSettingNotify"] = true
|
||||||
ctx.HTML(200, "user/notification")
|
ctx.HTML(200, NOTIFICATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SettingSecurity(ctx *middleware.Context) {
|
func SettingSecurity(ctx *middleware.Context) {
|
||||||
|
@ -223,5 +232,5 @@ func SettingSecurity(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Security"
|
ctx.Data["Title"] = "Security"
|
||||||
ctx.Data["PageIsUserSetting"] = true
|
ctx.Data["PageIsUserSetting"] = true
|
||||||
ctx.Data["IsUserPageSettingSecurity"] = true
|
ctx.Data["IsUserPageSettingSecurity"] = true
|
||||||
ctx.HTML(200, "user/security")
|
ctx.HTML(200, SECURITY)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,21 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SIGNIN base.TplName = "user/signin"
|
||||||
|
SIGNUP base.TplName = "user/signup"
|
||||||
|
DELETE base.TplName = "user/delete"
|
||||||
|
ACTIVATE base.TplName = "user/activate"
|
||||||
|
FORGOT_PASSWORD base.TplName = "user/forgot_passwd"
|
||||||
|
RESET_PASSWORD base.TplName = "user/reset_passwd"
|
||||||
|
)
|
||||||
|
|
||||||
func SignIn(ctx *middleware.Context) {
|
func SignIn(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Log In"
|
ctx.Data["Title"] = "Log In"
|
||||||
|
|
||||||
if _, ok := ctx.Session.Get("socialId").(int64); ok {
|
if _, ok := ctx.Session.Get("socialId").(int64); ok {
|
||||||
ctx.Data["IsSocialLogin"] = true
|
ctx.Data["IsSocialLogin"] = true
|
||||||
ctx.HTML(200, "user/signin")
|
ctx.HTML(200, SIGNIN)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +43,7 @@ func SignIn(ctx *middleware.Context) {
|
||||||
// Check auto-login.
|
// Check auto-login.
|
||||||
uname := ctx.GetCookie(setting.CookieUserName)
|
uname := ctx.GetCookie(setting.CookieUserName)
|
||||||
if len(uname) == 0 {
|
if len(uname) == 0 {
|
||||||
ctx.HTML(200, "user/signin")
|
ctx.HTML(200, SIGNIN)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +66,7 @@ func SignIn(ctx *middleware.Context) {
|
||||||
secret := base.EncodeMd5(user.Rands + user.Passwd)
|
secret := base.EncodeMd5(user.Rands + user.Passwd)
|
||||||
value, _ := ctx.GetSecureCookie(secret, setting.CookieRememberName)
|
value, _ := ctx.GetSecureCookie(secret, setting.CookieRememberName)
|
||||||
if value != user.Name {
|
if value != user.Name {
|
||||||
ctx.HTML(200, "user/signin")
|
ctx.HTML(200, SIGNIN)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +95,7 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "user/signin")
|
ctx.HTML(200, SIGNIN)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +103,7 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if err == models.ErrUserNotExist {
|
||||||
log.Trace("%s Log in failed: %s", ctx.Req.RequestURI, form.UserName)
|
log.Trace("%s Log in failed: %s", ctx.Req.RequestURI, form.UserName)
|
||||||
ctx.RenderWithErr("Username or password is not correct", "user/signin", &form)
|
ctx.RenderWithErr("Username or password is not correct", SIGNIN, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +160,7 @@ func SignUp(ctx *middleware.Context) {
|
||||||
|
|
||||||
if setting.Service.DisableRegistration {
|
if setting.Service.DisableRegistration {
|
||||||
ctx.Data["DisableRegistration"] = true
|
ctx.Data["DisableRegistration"] = true
|
||||||
ctx.HTML(200, "user/signup")
|
ctx.HTML(200, SIGNUP)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +169,7 @@ func SignUp(ctx *middleware.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.HTML(200, "user/signup")
|
ctx.HTML(200, SIGNUP)
|
||||||
}
|
}
|
||||||
|
|
||||||
func oauthSignUp(ctx *middleware.Context, sid int64) {
|
func oauthSignUp(ctx *middleware.Context, sid int64) {
|
||||||
|
@ -180,7 +189,7 @@ func oauthSignUp(ctx *middleware.Context, sid int64) {
|
||||||
ctx.Data["username"] = strings.Replace(ctx.Session.Get("socialName").(string), " ", "", -1)
|
ctx.Data["username"] = strings.Replace(ctx.Session.Get("socialName").(string), " ", "", -1)
|
||||||
ctx.Data["email"] = ctx.Session.Get("socialEmail")
|
ctx.Data["email"] = ctx.Session.Get("socialEmail")
|
||||||
log.Trace("user.oauthSignUp(social ID): %v", ctx.Session.Get("socialId"))
|
log.Trace("user.oauthSignUp(social ID): %v", ctx.Session.Get("socialId"))
|
||||||
ctx.HTML(200, "user/signup")
|
ctx.HTML(200, SIGNUP)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||||
|
@ -198,14 +207,14 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, "user/signup")
|
ctx.HTML(200, SIGNUP)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if form.Password != form.RetypePasswd {
|
if form.Password != form.RetypePasswd {
|
||||||
ctx.Data["Err_Password"] = true
|
ctx.Data["Err_Password"] = true
|
||||||
ctx.Data["Err_RetypePasswd"] = true
|
ctx.Data["Err_RetypePasswd"] = true
|
||||||
ctx.RenderWithErr("Password and re-type password are not same.", "user/signup", &form)
|
ctx.RenderWithErr("Password and re-type password are not same.", SIGNUP, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,12 +230,12 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||||
switch err {
|
switch err {
|
||||||
case models.ErrUserAlreadyExist:
|
case models.ErrUserAlreadyExist:
|
||||||
ctx.Data["Err_UserName"] = true
|
ctx.Data["Err_UserName"] = true
|
||||||
ctx.RenderWithErr("Username has been already taken", "user/signup", &form)
|
ctx.RenderWithErr("Username has been already taken", SIGNUP, &form)
|
||||||
case models.ErrEmailAlreadyUsed:
|
case models.ErrEmailAlreadyUsed:
|
||||||
ctx.Data["Err_Email"] = true
|
ctx.Data["Err_Email"] = true
|
||||||
ctx.RenderWithErr("E-mail address has been already used", "user/signup", &form)
|
ctx.RenderWithErr("E-mail address has been already used", SIGNUP, &form)
|
||||||
case models.ErrUserNameIllegal:
|
case models.ErrUserNameIllegal:
|
||||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "user/signup", &form)
|
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), SIGNUP, &form)
|
||||||
default:
|
default:
|
||||||
ctx.Handle(500, "user.SignUpPost(RegisterUser)", err)
|
ctx.Handle(500, "user.SignUpPost(RegisterUser)", err)
|
||||||
}
|
}
|
||||||
|
@ -265,7 +274,7 @@ func Delete(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = "Delete Account"
|
ctx.Data["Title"] = "Delete Account"
|
||||||
ctx.Data["PageIsUserSetting"] = true
|
ctx.Data["PageIsUserSetting"] = true
|
||||||
ctx.Data["IsUserPageSettingDelete"] = true
|
ctx.Data["IsUserPageSettingDelete"] = true
|
||||||
ctx.HTML(200, "user/delete")
|
ctx.HTML(200, DELETE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeletePost(ctx *middleware.Context) {
|
func DeletePost(ctx *middleware.Context) {
|
||||||
|
@ -321,7 +330,7 @@ func Activate(ctx *middleware.Context) {
|
||||||
} else {
|
} else {
|
||||||
ctx.Data["ServiceNotEnabled"] = true
|
ctx.Data["ServiceNotEnabled"] = true
|
||||||
}
|
}
|
||||||
ctx.HTML(200, "user/activate")
|
ctx.HTML(200, ACTIVATE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +352,7 @@ func Activate(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["IsActivateFailed"] = true
|
ctx.Data["IsActivateFailed"] = true
|
||||||
ctx.HTML(200, "user/activate")
|
ctx.HTML(200, ACTIVATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ForgotPasswd(ctx *middleware.Context) {
|
func ForgotPasswd(ctx *middleware.Context) {
|
||||||
|
@ -351,12 +360,12 @@ func ForgotPasswd(ctx *middleware.Context) {
|
||||||
|
|
||||||
if setting.MailService == nil {
|
if setting.MailService == nil {
|
||||||
ctx.Data["IsResetDisable"] = true
|
ctx.Data["IsResetDisable"] = true
|
||||||
ctx.HTML(200, "user/forgot_passwd")
|
ctx.HTML(200, FORGOT_PASSWORD)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["IsResetRequest"] = true
|
ctx.Data["IsResetRequest"] = true
|
||||||
ctx.HTML(200, "user/forgot_passwd")
|
ctx.HTML(200, FORGOT_PASSWORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ForgotPasswdPost(ctx *middleware.Context) {
|
func ForgotPasswdPost(ctx *middleware.Context) {
|
||||||
|
@ -381,7 +390,7 @@ func ForgotPasswdPost(ctx *middleware.Context) {
|
||||||
|
|
||||||
if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) {
|
if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) {
|
||||||
ctx.Data["ResendLimited"] = true
|
ctx.Data["ResendLimited"] = true
|
||||||
ctx.HTML(200, "user/forgot_passwd")
|
ctx.HTML(200, FORGOT_PASSWORD)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +402,7 @@ func ForgotPasswdPost(ctx *middleware.Context) {
|
||||||
ctx.Data["Email"] = email
|
ctx.Data["Email"] = email
|
||||||
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
||||||
ctx.Data["IsResetSent"] = true
|
ctx.Data["IsResetSent"] = true
|
||||||
ctx.HTML(200, "user/forgot_passwd")
|
ctx.HTML(200, FORGOT_PASSWORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResetPasswd(ctx *middleware.Context) {
|
func ResetPasswd(ctx *middleware.Context) {
|
||||||
|
@ -406,7 +415,7 @@ func ResetPasswd(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
ctx.Data["Code"] = code
|
ctx.Data["Code"] = code
|
||||||
ctx.Data["IsResetForm"] = true
|
ctx.Data["IsResetForm"] = true
|
||||||
ctx.HTML(200, "user/reset_passwd")
|
ctx.HTML(200, RESET_PASSWORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResetPasswdPost(ctx *middleware.Context) {
|
func ResetPasswdPost(ctx *middleware.Context) {
|
||||||
|
@ -443,5 +452,5 @@ func ResetPasswdPost(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["IsResetFailed"] = true
|
ctx.Data["IsResetFailed"] = true
|
||||||
ctx.HTML(200, "user/reset_passwd")
|
ctx.HTML(200, RESET_PASSWORD)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.4.5.0621 Alpha
|
0.4.5.0622 Alpha
|
Reference in a new issue