Rename module: middleware -> context
This commit is contained in:
parent
cb1eadc276
commit
514382e2eb
54 changed files with 666 additions and 669 deletions
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
|||
|
||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||
|
||||
##### Current version: 0.9.4
|
||||
##### Current version: 0.9.5
|
||||
|
||||
| Web | UI | Preview |
|
||||
|:-------------:|:-------:|:-------:|
|
||||
|
|
64
cmd/web.go
64
cmd/web.go
|
@ -34,8 +34,8 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/bindata"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/modules/template"
|
||||
"github.com/gogits/gogs/routers"
|
||||
|
@ -169,7 +169,7 @@ func newMacaron() *macaron.Macaron {
|
|||
},
|
||||
},
|
||||
}))
|
||||
m.Use(middleware.Contexter())
|
||||
m.Use(context.Contexter())
|
||||
return m
|
||||
}
|
||||
|
||||
|
@ -182,10 +182,10 @@ func runWeb(ctx *cli.Context) {
|
|||
|
||||
m := newMacaron()
|
||||
|
||||
reqSignIn := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: true})
|
||||
ignSignIn := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: setting.Service.RequireSignInView})
|
||||
ignSignInAndCsrf := middleware.Toggle(&middleware.ToggleOptions{DisableCsrf: true})
|
||||
reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true})
|
||||
reqSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: true})
|
||||
ignSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: setting.Service.RequireSignInView})
|
||||
ignSignInAndCsrf := context.Toggle(&context.ToggleOptions{DisableCSRF: true})
|
||||
reqSignOut := context.Toggle(&context.ToggleOptions{SignOutRequired: true})
|
||||
|
||||
bindIgnErr := binding.BindIgnErr
|
||||
|
||||
|
@ -231,7 +231,7 @@ func runWeb(ctx *cli.Context) {
|
|||
Post(bindIgnErr(auth.NewAccessTokenForm{}), user.SettingsApplicationsPost)
|
||||
m.Post("/applications/delete", user.SettingsDeleteApplication)
|
||||
m.Route("/delete", "GET,POST", user.SettingsDelete)
|
||||
}, reqSignIn, func(ctx *middleware.Context) {
|
||||
}, reqSignIn, func(ctx *context.Context) {
|
||||
ctx.Data["PageIsUserSettings"] = true
|
||||
})
|
||||
|
||||
|
@ -246,7 +246,7 @@ func runWeb(ctx *cli.Context) {
|
|||
})
|
||||
// ***** END: User *****
|
||||
|
||||
adminReq := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: true, AdminRequire: true})
|
||||
adminReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, AdminRequired: true})
|
||||
|
||||
// ***** START: Admin *****
|
||||
m.Group("/admin", func() {
|
||||
|
@ -295,7 +295,7 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Get("/stars", user.Stars)
|
||||
})
|
||||
|
||||
m.Get("/attachments/:uuid", func(ctx *middleware.Context) {
|
||||
m.Get("/attachments/:uuid", func(ctx *context.Context) {
|
||||
attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid"))
|
||||
if err != nil {
|
||||
if models.IsErrAttachmentNotExist(err) {
|
||||
|
@ -332,8 +332,8 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Get("/template/*", dev.TemplatePreview)
|
||||
}
|
||||
|
||||
reqRepoAdmin := middleware.RequireRepoAdmin()
|
||||
reqRepoWriter := middleware.RequireRepoWriter()
|
||||
reqRepoAdmin := context.RequireRepoAdmin()
|
||||
reqRepoWriter := context.RequireRepoWriter()
|
||||
|
||||
// ***** START: Organization *****
|
||||
m.Group("/org", func() {
|
||||
|
@ -347,14 +347,14 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Get("/members/action/:action", org.MembersAction)
|
||||
|
||||
m.Get("/teams", org.Teams)
|
||||
}, middleware.OrgAssignment(true))
|
||||
}, context.OrgAssignment(true))
|
||||
|
||||
m.Group("/:org", func() {
|
||||
m.Get("/teams/:team", org.TeamMembers)
|
||||
m.Get("/teams/:team/repositories", org.TeamRepositories)
|
||||
m.Route("/teams/:team/action/:action", "GET,POST", org.TeamsAction)
|
||||
m.Route("/teams/:team/action/repo/:action", "GET,POST", org.TeamsRepoAction)
|
||||
}, middleware.OrgAssignment(true, false, true))
|
||||
}, context.OrgAssignment(true, false, true))
|
||||
|
||||
m.Group("/:org", func() {
|
||||
m.Get("/teams/new", org.NewTeam)
|
||||
|
@ -384,7 +384,7 @@ func runWeb(ctx *cli.Context) {
|
|||
})
|
||||
|
||||
m.Route("/invitations/new", "GET,POST", org.Invitation)
|
||||
}, middleware.OrgAssignment(true, true))
|
||||
}, context.OrgAssignment(true, true))
|
||||
}, reqSignIn)
|
||||
// ***** END: Organization *****
|
||||
|
||||
|
@ -423,7 +423,7 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Get("", repo.GitHooks)
|
||||
m.Combo("/:name").Get(repo.GitHooksEdit).
|
||||
Post(repo.GitHooksEditPost)
|
||||
}, middleware.GitHookService())
|
||||
}, context.GitHookService())
|
||||
})
|
||||
|
||||
m.Group("/keys", func() {
|
||||
|
@ -432,15 +432,15 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Post("/delete", repo.DeleteDeployKey)
|
||||
})
|
||||
|
||||
}, func(ctx *middleware.Context) {
|
||||
}, func(ctx *context.Context) {
|
||||
ctx.Data["PageIsSettings"] = true
|
||||
})
|
||||
}, reqSignIn, middleware.RepoAssignment(), reqRepoAdmin, middleware.RepoRef())
|
||||
}, reqSignIn, context.RepoAssignment(), reqRepoAdmin, context.RepoRef())
|
||||
|
||||
m.Get("/:username/:reponame/action/:action", reqSignIn, middleware.RepoAssignment(), repo.Action)
|
||||
m.Get("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), repo.Action)
|
||||
m.Group("/:username/:reponame", func() {
|
||||
m.Group("/issues", func() {
|
||||
m.Combo("/new", repo.MustEnableIssues).Get(middleware.RepoRef(), repo.NewIssue).
|
||||
m.Combo("/new", repo.MustEnableIssues).Get(context.RepoRef(), repo.NewIssue).
|
||||
Post(bindIgnErr(auth.CreateIssueForm{}), repo.NewIssuePost)
|
||||
|
||||
m.Combo("/:index/comments").Post(bindIgnErr(auth.CreateCommentForm{}), repo.NewComment)
|
||||
|
@ -460,7 +460,7 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel)
|
||||
m.Post("/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel)
|
||||
m.Post("/delete", repo.DeleteLabel)
|
||||
}, reqRepoWriter, middleware.RepoRef())
|
||||
}, reqRepoWriter, context.RepoRef())
|
||||
m.Group("/milestones", func() {
|
||||
m.Combo("/new").Get(repo.NewMilestone).
|
||||
Post(bindIgnErr(auth.CreateMilestoneForm{}), repo.NewMilestonePost)
|
||||
|
@ -468,7 +468,7 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Post("/:id/edit", bindIgnErr(auth.CreateMilestoneForm{}), repo.EditMilestonePost)
|
||||
m.Get("/:id/:action", repo.ChangeMilestonStatus)
|
||||
m.Post("/delete", repo.DeleteMilestone)
|
||||
}, reqRepoWriter, middleware.RepoRef())
|
||||
}, reqRepoWriter, context.RepoRef())
|
||||
|
||||
m.Group("/releases", func() {
|
||||
m.Get("/new", repo.NewRelease)
|
||||
|
@ -476,11 +476,11 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Get("/edit/:tagname", repo.EditRelease)
|
||||
m.Post("/edit/:tagname", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
|
||||
m.Post("/delete", repo.DeleteRelease)
|
||||
}, reqRepoWriter, middleware.RepoRef())
|
||||
}, reqRepoWriter, context.RepoRef())
|
||||
|
||||
m.Combo("/compare/*", repo.MustAllowPulls).Get(repo.CompareAndPullRequest).
|
||||
Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
|
||||
}, reqSignIn, middleware.RepoAssignment(), repo.MustBeNotBare)
|
||||
}, reqSignIn, context.RepoAssignment(), repo.MustBeNotBare)
|
||||
|
||||
m.Group("/:username/:reponame", func() {
|
||||
m.Group("", func() {
|
||||
|
@ -489,7 +489,7 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue)
|
||||
m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
|
||||
m.Get("/milestones", repo.Milestones)
|
||||
}, middleware.RepoRef())
|
||||
}, context.RepoRef())
|
||||
|
||||
// m.Get("/branches", repo.Branches)
|
||||
|
||||
|
@ -504,13 +504,13 @@ func runWeb(ctx *cli.Context) {
|
|||
Post(bindIgnErr(auth.NewWikiForm{}), repo.EditWikiPost)
|
||||
m.Post("/:page/delete", repo.DeleteWikiPagePost)
|
||||
}, reqSignIn, reqRepoWriter)
|
||||
}, repo.MustEnableWiki, middleware.RepoRef())
|
||||
}, repo.MustEnableWiki, context.RepoRef())
|
||||
|
||||
m.Get("/archive/*", repo.Download)
|
||||
|
||||
m.Group("/pulls/:index", func() {
|
||||
m.Get("/commits", middleware.RepoRef(), repo.ViewPullCommits)
|
||||
m.Get("/files", middleware.RepoRef(), repo.ViewPullFiles)
|
||||
m.Get("/commits", context.RepoRef(), repo.ViewPullCommits)
|
||||
m.Get("/files", context.RepoRef(), repo.ViewPullFiles)
|
||||
m.Post("/merge", reqRepoWriter, repo.MergePullRequest)
|
||||
}, repo.MustAllowPulls)
|
||||
|
||||
|
@ -520,20 +520,20 @@ func runWeb(ctx *cli.Context) {
|
|||
m.Get("/commits/*", repo.RefCommits)
|
||||
m.Get("/commit/*", repo.Diff)
|
||||
m.Get("/forks", repo.Forks)
|
||||
}, middleware.RepoRef())
|
||||
}, context.RepoRef())
|
||||
|
||||
m.Get("/compare/:before([a-z0-9]{40})\\.\\.\\.:after([a-z0-9]{40})", repo.CompareDiff)
|
||||
}, ignSignIn, middleware.RepoAssignment(), repo.MustBeNotBare)
|
||||
}, ignSignIn, context.RepoAssignment(), repo.MustBeNotBare)
|
||||
m.Group("/:username/:reponame", func() {
|
||||
m.Get("/stars", repo.Stars)
|
||||
m.Get("/watchers", repo.Watchers)
|
||||
}, ignSignIn, middleware.RepoAssignment(), middleware.RepoRef())
|
||||
}, ignSignIn, context.RepoAssignment(), context.RepoRef())
|
||||
|
||||
m.Group("/:username", func() {
|
||||
m.Group("/:reponame", func() {
|
||||
m.Get("", repo.Home)
|
||||
m.Get("\\.git$", repo.Home)
|
||||
}, ignSignIn, middleware.RepoAssignment(true), middleware.RepoRef())
|
||||
}, ignSignIn, context.RepoAssignment(true), context.RepoRef())
|
||||
|
||||
m.Group("/:reponame", func() {
|
||||
m.Any("/*", ignSignInAndCsrf, repo.HTTP)
|
||||
|
@ -543,7 +543,7 @@ func runWeb(ctx *cli.Context) {
|
|||
// ***** END: Repository *****
|
||||
|
||||
// robots.txt
|
||||
m.Get("/robots.txt", func(ctx *middleware.Context) {
|
||||
m.Get("/robots.txt", func(ctx *context.Context) {
|
||||
if setting.HasRobotsTxt {
|
||||
ctx.ServeFileContent(path.Join(setting.CustomPath, "robots.txt"))
|
||||
} else {
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.9.4.0311"
|
||||
const APP_VER = "0.9.5.0311"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,66 +2,23 @@
|
|||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package middleware
|
||||
package context
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/go-macaron/csrf"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"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/setting"
|
||||
)
|
||||
|
||||
type ToggleOptions struct {
|
||||
SignInRequire bool
|
||||
SignOutRequire bool
|
||||
AdminRequire bool
|
||||
DisableCsrf bool
|
||||
}
|
||||
|
||||
// AutoSignIn reads cookie and try to auto-login.
|
||||
func AutoSignIn(ctx *Context) (bool, error) {
|
||||
if !models.HasEngine {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
uname := ctx.GetCookie(setting.CookieUserName)
|
||||
if len(uname) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
isSucceed := false
|
||||
defer func() {
|
||||
if !isSucceed {
|
||||
log.Trace("auto-login cookie cleared: %s", uname)
|
||||
ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl)
|
||||
ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl)
|
||||
}
|
||||
}()
|
||||
|
||||
u, err := models.GetUserByName(uname)
|
||||
if err != nil {
|
||||
if !models.IsErrUserNotExist(err) {
|
||||
return false, fmt.Errorf("GetUserByName: %v", err)
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if val, _ := ctx.GetSuperSecureCookie(
|
||||
base.EncodeMD5(u.Rands+u.Passwd), setting.CookieRememberName); val != u.Name {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
isSucceed = true
|
||||
ctx.Session.Set("uid", u.Id)
|
||||
ctx.Session.Set("uname", u.Name)
|
||||
return true, nil
|
||||
SignInRequired bool
|
||||
SignOutRequired bool
|
||||
AdminRequired bool
|
||||
DisableCSRF bool
|
||||
}
|
||||
|
||||
func Toggle(options *ToggleOptions) macaron.Handler {
|
||||
|
@ -79,19 +36,19 @@ func Toggle(options *ToggleOptions) macaron.Handler {
|
|||
}
|
||||
|
||||
// Redirect to dashboard if user tries to visit any non-login page.
|
||||
if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" {
|
||||
if options.SignOutRequired && ctx.IsSigned && ctx.Req.RequestURI != "/" {
|
||||
ctx.Redirect(setting.AppSubUrl + "/")
|
||||
return
|
||||
}
|
||||
|
||||
if !options.SignOutRequire && !options.DisableCsrf && ctx.Req.Method == "POST" && !auth.IsAPIPath(ctx.Req.URL.Path) {
|
||||
if !options.SignOutRequired && !options.DisableCSRF && ctx.Req.Method == "POST" && !auth.IsAPIPath(ctx.Req.URL.Path) {
|
||||
csrf.Validate(ctx.Context, ctx.csrf)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if options.SignInRequire {
|
||||
if options.SignInRequired {
|
||||
if !ctx.IsSigned {
|
||||
// Restrict API calls with error message.
|
||||
if auth.IsAPIPath(ctx.Req.URL.Path) {
|
||||
|
@ -109,15 +66,15 @@ func Toggle(options *ToggleOptions) macaron.Handler {
|
|||
}
|
||||
}
|
||||
|
||||
// Auto-signin info is provided and has not signed in.
|
||||
if !options.SignOutRequire && !ctx.IsSigned && !auth.IsAPIPath(ctx.Req.URL.Path) &&
|
||||
// Redirect to log in page if auto-signin info is provided and has not signed in.
|
||||
if !options.SignOutRequired && !ctx.IsSigned && !auth.IsAPIPath(ctx.Req.URL.Path) &&
|
||||
len(ctx.GetCookie(setting.CookieUserName)) > 0 {
|
||||
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl)
|
||||
ctx.Redirect(setting.AppSubUrl + "/user/login")
|
||||
return
|
||||
}
|
||||
|
||||
if options.AdminRequire {
|
||||
if options.AdminRequired {
|
||||
if !ctx.User.IsAdmin {
|
||||
ctx.Error(403)
|
||||
return
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package middleware
|
||||
package context
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -27,14 +27,14 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
type PullRequestContext struct {
|
||||
type PullRequest struct {
|
||||
BaseRepo *models.Repository
|
||||
Allowed bool
|
||||
SameRepo bool
|
||||
HeadInfo string // [<user>:]<branch>
|
||||
}
|
||||
|
||||
type RepoContext struct {
|
||||
type Repository struct {
|
||||
AccessMode models.AccessMode
|
||||
IsWatching bool
|
||||
IsViewBranch bool
|
||||
|
@ -54,7 +54,27 @@ type RepoContext struct {
|
|||
CommitsCount int64
|
||||
Mirror *models.Mirror
|
||||
|
||||
PullRequest *PullRequestContext
|
||||
PullRequest *PullRequest
|
||||
}
|
||||
|
||||
// IsOwner returns true if current user is the owner of repository.
|
||||
func (r *Repository) IsOwner() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_OWNER
|
||||
}
|
||||
|
||||
// IsAdmin returns true if current user has admin or higher access of repository.
|
||||
func (r *Repository) IsAdmin() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_ADMIN
|
||||
}
|
||||
|
||||
// IsWriter returns true if current user has write or higher access of repository.
|
||||
func (r *Repository) IsWriter() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_WRITE
|
||||
}
|
||||
|
||||
// HasAccess returns true if the current user has at least read access for this repository
|
||||
func (r *Repository) HasAccess() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_READ
|
||||
}
|
||||
|
||||
// Context represents context of a request.
|
||||
|
@ -69,7 +89,7 @@ type Context struct {
|
|||
IsSigned bool
|
||||
IsBasicAuth bool
|
||||
|
||||
Repo *RepoContext
|
||||
Repo *Repository
|
||||
|
||||
Org struct {
|
||||
IsOwner bool
|
||||
|
@ -83,26 +103,6 @@ type Context struct {
|
|||
}
|
||||
}
|
||||
|
||||
// IsOwner returns true if current user is the owner of repository.
|
||||
func (r *RepoContext) IsOwner() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_OWNER
|
||||
}
|
||||
|
||||
// IsAdmin returns true if current user has admin or higher access of repository.
|
||||
func (r *RepoContext) IsAdmin() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_ADMIN
|
||||
}
|
||||
|
||||
// IsWriter returns true if current user has write or higher access of repository.
|
||||
func (r *RepoContext) IsWriter() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_WRITE
|
||||
}
|
||||
|
||||
// HasAccess returns true if the current user has at least read access for this repository
|
||||
func (r *RepoContext) HasAccess() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_READ
|
||||
}
|
||||
|
||||
// HasError returns true if error occurs in form validation.
|
||||
func (ctx *Context) HasApiError() bool {
|
||||
hasErr, ok := ctx.Data["HasError"]
|
||||
|
@ -220,8 +220,8 @@ func Contexter() macaron.Handler {
|
|||
csrf: x,
|
||||
Flash: f,
|
||||
Session: sess,
|
||||
Repo: &RepoContext{
|
||||
PullRequest: &PullRequestContext{},
|
||||
Repo: &Repository{
|
||||
PullRequest: &PullRequest{},
|
||||
},
|
||||
}
|
||||
// Compute current URL for real-time change language.
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package middleware
|
||||
package context
|
||||
|
||||
import (
|
||||
"strings"
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package middleware
|
||||
package context
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -15,9 +15,9 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/cron"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/process"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
@ -124,7 +124,7 @@ const (
|
|||
REINIT_MISSING_REPOSITORY
|
||||
)
|
||||
|
||||
func Dashboard(ctx *middleware.Context) {
|
||||
func Dashboard(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.dashboard")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminDashboard"] = true
|
||||
|
@ -175,7 +175,7 @@ func Dashboard(ctx *middleware.Context) {
|
|||
ctx.HTML(200, DASHBOARD)
|
||||
}
|
||||
|
||||
func SendTestMail(ctx *middleware.Context) {
|
||||
func SendTestMail(ctx *context.Context) {
|
||||
email := ctx.Query("email")
|
||||
// Send a test email to the user's email address and redirect back to Config
|
||||
if err := mailer.SendTestMail(email); err != nil {
|
||||
|
@ -187,7 +187,7 @@ func SendTestMail(ctx *middleware.Context) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/admin/config")
|
||||
}
|
||||
|
||||
func Config(ctx *middleware.Context) {
|
||||
func Config(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.config")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminConfig"] = true
|
||||
|
@ -236,7 +236,7 @@ func Config(ctx *middleware.Context) {
|
|||
ctx.HTML(200, CONFIG)
|
||||
}
|
||||
|
||||
func Monitor(ctx *middleware.Context) {
|
||||
func Monitor(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.monitor")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminMonitor"] = true
|
||||
|
|
|
@ -14,8 +14,8 @@ import (
|
|||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/auth/ldap"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -25,7 +25,7 @@ const (
|
|||
AUTH_EDIT base.TplName = "admin/auth/edit"
|
||||
)
|
||||
|
||||
func Authentications(ctx *middleware.Context) {
|
||||
func Authentications(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.authentication")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminAuthentications"] = true
|
||||
|
@ -53,7 +53,7 @@ var authSources = []AuthSource{
|
|||
{models.LoginNames[models.LOGIN_PAM], models.LOGIN_PAM},
|
||||
}
|
||||
|
||||
func NewAuthSource(ctx *middleware.Context) {
|
||||
func NewAuthSource(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.auths.new")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminAuthentications"] = true
|
||||
|
@ -102,7 +102,7 @@ func parseSMTPConfig(form auth.AuthenticationForm) *models.SMTPConfig {
|
|||
}
|
||||
}
|
||||
|
||||
func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
|
||||
func NewAuthSourcePost(ctx *context.Context, form auth.AuthenticationForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.auths.new")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminAuthentications"] = true
|
||||
|
@ -147,7 +147,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/admin/auths")
|
||||
}
|
||||
|
||||
func EditAuthSource(ctx *middleware.Context) {
|
||||
func EditAuthSource(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.auths.edit")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminAuthentications"] = true
|
||||
|
@ -163,7 +163,7 @@ func EditAuthSource(ctx *middleware.Context) {
|
|||
ctx.HTML(200, AUTH_EDIT)
|
||||
}
|
||||
|
||||
func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
|
||||
func EditAuthSourcePost(ctx *context.Context, form auth.AuthenticationForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.auths.edit")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminAuthentications"] = true
|
||||
|
@ -210,7 +210,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + com.ToStr(form.ID))
|
||||
}
|
||||
|
||||
func DeleteAuthSource(ctx *middleware.Context) {
|
||||
func DeleteAuthSource(ctx *context.Context) {
|
||||
source, err := models.GetLoginSourceByID(ctx.ParamsInt64(":authid"))
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetLoginSourceByID", err)
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -19,7 +19,7 @@ const (
|
|||
NOTICES base.TplName = "admin/notice"
|
||||
)
|
||||
|
||||
func Notices(ctx *middleware.Context) {
|
||||
func Notices(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.notices")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminNotices"] = true
|
||||
|
@ -42,7 +42,7 @@ func Notices(ctx *middleware.Context) {
|
|||
ctx.HTML(200, NOTICES)
|
||||
}
|
||||
|
||||
func DeleteNotices(ctx *middleware.Context) {
|
||||
func DeleteNotices(ctx *context.Context) {
|
||||
strs := ctx.QueryStrings("ids[]")
|
||||
ids := make([]int64, 0, len(strs))
|
||||
for i := range strs {
|
||||
|
@ -61,7 +61,7 @@ func DeleteNotices(ctx *middleware.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func EmptyNotices(ctx *middleware.Context) {
|
||||
func EmptyNotices(ctx *context.Context) {
|
||||
if err := models.DeleteNotices(0, 0); err != nil {
|
||||
ctx.Handle(500, "DeleteNotices", err)
|
||||
return
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -17,7 +17,7 @@ const (
|
|||
ORGS base.TplName = "admin/org/list"
|
||||
)
|
||||
|
||||
func Organizations(ctx *middleware.Context) {
|
||||
func Organizations(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.organizations")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminOrganizations"] = true
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -18,7 +18,7 @@ const (
|
|||
REPOS base.TplName = "admin/repo/list"
|
||||
)
|
||||
|
||||
func Repos(ctx *middleware.Context) {
|
||||
func Repos(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.repositories")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminRepositories"] = true
|
||||
|
@ -41,7 +41,7 @@ func Repos(ctx *middleware.Context) {
|
|||
ctx.HTML(200, REPOS)
|
||||
}
|
||||
|
||||
func DeleteRepo(ctx *middleware.Context) {
|
||||
func DeleteRepo(ctx *context.Context) {
|
||||
repo, err := models.GetRepositoryByID(ctx.QueryInt64("id"))
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetRepositoryByID", err)
|
||||
|
|
|
@ -13,9 +13,9 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -25,7 +25,7 @@ const (
|
|||
USER_EDIT base.TplName = "admin/user/edit"
|
||||
)
|
||||
|
||||
func Users(ctx *middleware.Context) {
|
||||
func Users(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.users")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminUsers"] = true
|
||||
|
@ -48,7 +48,7 @@ func Users(ctx *middleware.Context) {
|
|||
ctx.HTML(200, USERS)
|
||||
}
|
||||
|
||||
func NewUser(ctx *middleware.Context) {
|
||||
func NewUser(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.users.new_account")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminUsers"] = true
|
||||
|
@ -66,7 +66,7 @@ func NewUser(ctx *middleware.Context) {
|
|||
ctx.HTML(200, USER_NEW)
|
||||
}
|
||||
|
||||
func NewUserPost(ctx *middleware.Context, form auth.AdminCrateUserForm) {
|
||||
func NewUserPost(ctx *context.Context, form auth.AdminCrateUserForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.users.new_account")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminUsers"] = true
|
||||
|
@ -132,7 +132,7 @@ func NewUserPost(ctx *middleware.Context, form auth.AdminCrateUserForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/admin/users/" + com.ToStr(u.Id))
|
||||
}
|
||||
|
||||
func prepareUserInfo(ctx *middleware.Context) *models.User {
|
||||
func prepareUserInfo(ctx *context.Context) *models.User {
|
||||
u, err := models.GetUserByID(ctx.ParamsInt64(":userid"))
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetUserByID", err)
|
||||
|
@ -160,7 +160,7 @@ func prepareUserInfo(ctx *middleware.Context) *models.User {
|
|||
return u
|
||||
}
|
||||
|
||||
func EditUser(ctx *middleware.Context) {
|
||||
func EditUser(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.users.edit_account")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminUsers"] = true
|
||||
|
@ -173,7 +173,7 @@ func EditUser(ctx *middleware.Context) {
|
|||
ctx.HTML(200, USER_EDIT)
|
||||
}
|
||||
|
||||
func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
|
||||
func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.users.edit_account")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminUsers"] = true
|
||||
|
@ -231,7 +231,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid"))
|
||||
}
|
||||
|
||||
func DeleteUser(ctx *middleware.Context) {
|
||||
func DeleteUser(ctx *context.Context) {
|
||||
u, err := models.GetUserByID(ctx.ParamsInt64(":userid"))
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetUserByID", err)
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
"github.com/gogits/gogs/routers/api/v1/user"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Organizations#create-a-new-organization
|
||||
func CreateOrg(ctx *middleware.Context, form api.CreateOrgOption) {
|
||||
func CreateOrg(ctx *context.Context, form api.CreateOrgOption) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
|
|
@ -7,13 +7,13 @@ package admin
|
|||
import (
|
||||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/routers/api/v1/repo"
|
||||
"github.com/gogits/gogs/routers/api/v1/user"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Repositories#create-a-new-repository
|
||||
func CreateRepo(ctx *middleware.Context, form api.CreateRepoOption) {
|
||||
func CreateRepo(ctx *context.Context, form api.CreateRepoOption) {
|
||||
owner := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
|
|
@ -8,15 +8,15 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"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/routers/api/v1/convert"
|
||||
"github.com/gogits/gogs/routers/api/v1/user"
|
||||
)
|
||||
|
||||
func parseLoginSource(ctx *middleware.Context, u *models.User, sourceID int64, loginName string) {
|
||||
func parseLoginSource(ctx *context.Context, u *models.User, sourceID int64, loginName string) {
|
||||
if sourceID == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func parseLoginSource(ctx *middleware.Context, u *models.User, sourceID int64, l
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-new-user
|
||||
func CreateUser(ctx *middleware.Context, form api.CreateUserOption) {
|
||||
func CreateUser(ctx *context.Context, form api.CreateUserOption) {
|
||||
u := &models.User{
|
||||
Name: form.Username,
|
||||
Email: form.Email,
|
||||
|
@ -73,7 +73,7 @@ func CreateUser(ctx *middleware.Context, form api.CreateUserOption) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#edit-an-existing-user
|
||||
func EditUser(ctx *middleware.Context, form api.EditUserOption) {
|
||||
func EditUser(ctx *context.Context, form api.EditUserOption) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -122,7 +122,7 @@ func EditUser(ctx *middleware.Context, form api.EditUserOption) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#delete-a-user
|
||||
func DeleteUser(ctx *middleware.Context) {
|
||||
func DeleteUser(ctx *context.Context) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -143,7 +143,7 @@ func DeleteUser(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-public-key-for-user
|
||||
func CreatePublicKey(ctx *middleware.Context, form api.CreateKeyOption) {
|
||||
func CreatePublicKey(ctx *context.Context, form api.CreateKeyOption) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/routers/api/v1/admin"
|
||||
"github.com/gogits/gogs/routers/api/v1/misc"
|
||||
"github.com/gogits/gogs/routers/api/v1/org"
|
||||
|
@ -23,7 +23,7 @@ import (
|
|||
)
|
||||
|
||||
func RepoAssignment() macaron.Handler {
|
||||
return func(ctx *middleware.Context) {
|
||||
return func(ctx *context.Context) {
|
||||
userName := ctx.Params(":username")
|
||||
repoName := ctx.Params(":reponame")
|
||||
|
||||
|
@ -82,7 +82,7 @@ func RepoAssignment() macaron.Handler {
|
|||
|
||||
// Contexter middleware already checks token for user sign in process.
|
||||
func ReqToken() macaron.Handler {
|
||||
return func(ctx *middleware.Context) {
|
||||
return func(ctx *context.Context) {
|
||||
if !ctx.IsSigned {
|
||||
ctx.Error(401)
|
||||
return
|
||||
|
@ -91,7 +91,7 @@ func ReqToken() macaron.Handler {
|
|||
}
|
||||
|
||||
func ReqBasicAuth() macaron.Handler {
|
||||
return func(ctx *middleware.Context) {
|
||||
return func(ctx *context.Context) {
|
||||
if !ctx.IsBasicAuth {
|
||||
ctx.Error(401)
|
||||
return
|
||||
|
@ -100,7 +100,7 @@ func ReqBasicAuth() macaron.Handler {
|
|||
}
|
||||
|
||||
func ReqAdmin() macaron.Handler {
|
||||
return func(ctx *middleware.Context) {
|
||||
return func(ctx *context.Context) {
|
||||
if !ctx.User.IsAdmin {
|
||||
ctx.Error(403)
|
||||
return
|
||||
|
@ -181,11 +181,11 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
m.Combo("/hooks").Get(repo.ListHooks).
|
||||
Post(bind(api.CreateHookOption{}), repo.CreateHook)
|
||||
m.Patch("/hooks/:id:int", bind(api.EditHookOption{}), repo.EditHook)
|
||||
m.Get("/raw/*", middleware.RepoRef(), repo.GetRawFile)
|
||||
m.Get("/raw/*", context.RepoRef(), repo.GetRawFile)
|
||||
m.Get("/archive/*", repo.GetArchive)
|
||||
m.Group("/branches", func() {
|
||||
m.Get("",repo.ListBranches)
|
||||
m.Get("/:branchname",repo.GetBranch)
|
||||
m.Get("", repo.ListBranches)
|
||||
m.Get("/:branchname", repo.GetBranch)
|
||||
})
|
||||
m.Group("/keys", func() {
|
||||
m.Combo("").Get(repo.ListDeployKeys).
|
||||
|
@ -201,7 +201,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||
m.Get("/users/:username/orgs", org.ListUserOrgs)
|
||||
m.Combo("/orgs/:orgname").Get(org.Get).Patch(bind(api.EditOrgOption{}), org.Edit)
|
||||
|
||||
m.Any("/*", func(ctx *middleware.Context) {
|
||||
m.Any("/*", func(ctx *context.Context) {
|
||||
ctx.Error(404)
|
||||
})
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ package misc
|
|||
import (
|
||||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/markdown"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-an-arbitrary-markdown-document
|
||||
func Markdown(ctx *middleware.Context, form api.MarkdownOption) {
|
||||
func Markdown(ctx *context.Context, form api.MarkdownOption) {
|
||||
if ctx.HasApiError() {
|
||||
ctx.APIError(422, "", ctx.GetErrMsg())
|
||||
return
|
||||
|
@ -32,7 +32,7 @@ func Markdown(ctx *middleware.Context, form api.MarkdownOption) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-a-markdown-document-in-raw-mode
|
||||
func MarkdownRaw(ctx *middleware.Context) {
|
||||
func MarkdownRaw(ctx *context.Context) {
|
||||
body, err := ctx.Req.Body().Bytes()
|
||||
if err != nil {
|
||||
ctx.APIError(422, "", err)
|
||||
|
|
|
@ -8,12 +8,12 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
"github.com/gogits/gogs/routers/api/v1/user"
|
||||
)
|
||||
|
||||
func listUserOrgs(ctx *middleware.Context, u *models.User, all bool) {
|
||||
func listUserOrgs(ctx *context.Context, u *models.User, all bool) {
|
||||
if err := u.GetOrganizations(all); err != nil {
|
||||
ctx.APIError(500, "GetOrganizations", err)
|
||||
return
|
||||
|
@ -27,12 +27,12 @@ func listUserOrgs(ctx *middleware.Context, u *models.User, all bool) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Organizations#list-your-organizations
|
||||
func ListMyOrgs(ctx *middleware.Context) {
|
||||
func ListMyOrgs(ctx *context.Context) {
|
||||
listUserOrgs(ctx, ctx.User, true)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Organizations#list-user-organizations
|
||||
func ListUserOrgs(ctx *middleware.Context) {
|
||||
func ListUserOrgs(ctx *context.Context) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -41,7 +41,7 @@ func ListUserOrgs(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Organizations#get-an-organization
|
||||
func Get(ctx *middleware.Context) {
|
||||
func Get(ctx *context.Context) {
|
||||
org := user.GetUserByParamsName(ctx, ":orgname")
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -50,7 +50,7 @@ func Get(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization
|
||||
func Edit(ctx *middleware.Context, form api.EditOrgOption) {
|
||||
func Edit(ctx *context.Context, form api.EditOrgOption) {
|
||||
org := user.GetUserByParamsName(ctx, ":orgname")
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
|
|
@ -7,12 +7,12 @@ package repo
|
|||
import (
|
||||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch
|
||||
func GetBranch(ctx *middleware.Context) {
|
||||
func GetBranch(ctx *context.Context) {
|
||||
branch, err := ctx.Repo.Repository.GetBranch(ctx.Params(":branchname"))
|
||||
if err != nil {
|
||||
ctx.APIError(500, "GetBranch", err)
|
||||
|
@ -29,7 +29,7 @@ func GetBranch(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches
|
||||
func ListBranches(ctx *middleware.Context) {
|
||||
func ListBranches(ctx *context.Context) {
|
||||
branches, err := ctx.Repo.Repository.GetBranches()
|
||||
if err != nil {
|
||||
ctx.APIError(500, "GetBranches", err)
|
||||
|
|
|
@ -8,12 +8,12 @@ import (
|
|||
"github.com/gogits/git-module"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/routers/repo"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
|
||||
func GetRawFile(ctx *middleware.Context) {
|
||||
func GetRawFile(ctx *context.Context) {
|
||||
if !ctx.Repo.HasAccess() {
|
||||
ctx.Error(404)
|
||||
return
|
||||
|
@ -34,7 +34,7 @@ func GetRawFile(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
|
||||
func GetArchive(ctx *middleware.Context) {
|
||||
func GetArchive(ctx *context.Context) {
|
||||
repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
|
||||
gitRepo, err := git.OpenRepository(repoPath)
|
||||
if err != nil {
|
||||
|
|
|
@ -12,12 +12,12 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks
|
||||
func ListHooks(ctx *middleware.Context) {
|
||||
func ListHooks(ctx *context.Context) {
|
||||
hooks, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.APIError(500, "GetWebhooksByRepoID", err)
|
||||
|
@ -33,7 +33,7 @@ func ListHooks(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#create-a-hook
|
||||
func CreateHook(ctx *middleware.Context, form api.CreateHookOption) {
|
||||
func CreateHook(ctx *context.Context, form api.CreateHookOption) {
|
||||
if !models.IsValidHookTaskType(form.Type) {
|
||||
ctx.APIError(422, "", "Invalid hook type")
|
||||
return
|
||||
|
@ -98,7 +98,7 @@ func CreateHook(ctx *middleware.Context, form api.CreateHookOption) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
|
||||
func EditHook(ctx *middleware.Context, form api.EditHookOption) {
|
||||
func EditHook(ctx *context.Context, form api.EditHookOption) {
|
||||
w, err := models.GetWebhookByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrWebhookNotExist(err) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ func composeDeployKeysAPILink(repoPath string) string {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys
|
||||
func ListDeployKeys(ctx *middleware.Context) {
|
||||
func ListDeployKeys(ctx *context.Context) {
|
||||
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "ListDeployKeys", err)
|
||||
|
@ -41,7 +41,7 @@ func ListDeployKeys(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#get-a-deploy-key
|
||||
func GetDeployKey(ctx *middleware.Context) {
|
||||
func GetDeployKey(ctx *context.Context) {
|
||||
key, err := models.GetDeployKeyByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrDeployKeyNotExist(err) {
|
||||
|
@ -61,7 +61,7 @@ func GetDeployKey(ctx *middleware.Context) {
|
|||
ctx.JSON(200, convert.ToApiDeployKey(apiLink, key))
|
||||
}
|
||||
|
||||
func HandleCheckKeyStringError(ctx *middleware.Context, err error) {
|
||||
func HandleCheckKeyStringError(ctx *context.Context, err error) {
|
||||
if models.IsErrKeyUnableVerify(err) {
|
||||
ctx.APIError(422, "", "Unable to verify key content")
|
||||
} else {
|
||||
|
@ -69,7 +69,7 @@ func HandleCheckKeyStringError(ctx *middleware.Context, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
func HandleAddKeyError(ctx *middleware.Context, err error) {
|
||||
func HandleAddKeyError(ctx *context.Context, err error) {
|
||||
switch {
|
||||
case models.IsErrKeyAlreadyExist(err):
|
||||
ctx.APIError(422, "", "Key content has been used as non-deploy key")
|
||||
|
@ -81,7 +81,7 @@ func HandleAddKeyError(ctx *middleware.Context, err error) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#add-a-new-deploy-key
|
||||
func CreateDeployKey(ctx *middleware.Context, form api.CreateKeyOption) {
|
||||
func CreateDeployKey(ctx *context.Context, form api.CreateKeyOption) {
|
||||
content, err := models.CheckPublicKeyString(form.Key)
|
||||
if err != nil {
|
||||
HandleCheckKeyStringError(ctx, err)
|
||||
|
@ -100,7 +100,7 @@ func CreateDeployKey(ctx *middleware.Context, form api.CreateKeyOption) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key
|
||||
func DeleteDeploykey(ctx *middleware.Context) {
|
||||
func DeleteDeploykey(ctx *context.Context) {
|
||||
if err := models.DeleteDeployKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||
if models.IsErrKeyAccessDenied(err) {
|
||||
ctx.APIError(403, "", "You do not have access to this key")
|
||||
|
|
|
@ -13,14 +13,14 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories
|
||||
func Search(ctx *middleware.Context) {
|
||||
func Search(ctx *context.Context) {
|
||||
opt := models.SearchOption{
|
||||
Keyword: path.Base(ctx.Query("q")),
|
||||
Uid: com.StrTo(ctx.Query("uid")).MustInt64(),
|
||||
|
@ -81,7 +81,7 @@ func Search(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories
|
||||
func ListMyRepos(ctx *middleware.Context) {
|
||||
func ListMyRepos(ctx *context.Context) {
|
||||
ownRepos, err := models.GetRepositories(ctx.User.Id, true)
|
||||
if err != nil {
|
||||
ctx.APIError(500, "GetRepositories", err)
|
||||
|
@ -113,7 +113,7 @@ func ListMyRepos(ctx *middleware.Context) {
|
|||
ctx.JSON(200, &repos)
|
||||
}
|
||||
|
||||
func CreateUserRepo(ctx *middleware.Context, owner *models.User, opt api.CreateRepoOption) {
|
||||
func CreateUserRepo(ctx *context.Context, owner *models.User, opt api.CreateRepoOption) {
|
||||
repo, err := models.CreateRepository(owner, models.CreateRepoOptions{
|
||||
Name: opt.Name,
|
||||
Description: opt.Description,
|
||||
|
@ -143,7 +143,7 @@ func CreateUserRepo(ctx *middleware.Context, owner *models.User, opt api.CreateR
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#create
|
||||
func Create(ctx *middleware.Context, opt api.CreateRepoOption) {
|
||||
func Create(ctx *context.Context, opt api.CreateRepoOption) {
|
||||
// Shouldn't reach this condition, but just in case.
|
||||
if ctx.User.IsOrganization() {
|
||||
ctx.APIError(422, "", "not allowed creating repository for organization")
|
||||
|
@ -152,7 +152,7 @@ func Create(ctx *middleware.Context, opt api.CreateRepoOption) {
|
|||
CreateUserRepo(ctx, ctx.User, opt)
|
||||
}
|
||||
|
||||
func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) {
|
||||
func CreateOrgRepo(ctx *context.Context, opt api.CreateRepoOption) {
|
||||
org, err := models.GetOrgByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
@ -171,7 +171,7 @@ func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#migrate
|
||||
func Migrate(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||
func Migrate(ctx *context.Context, form auth.MigrateRepoForm) {
|
||||
ctxUser := ctx.User
|
||||
// Not equal means context user is an organization,
|
||||
// or is another user/organization if current user is admin.
|
||||
|
@ -242,7 +242,7 @@ func Migrate(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
|||
ctx.JSON(201, convert.ToApiRepository(ctxUser, repo, api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
func parseOwnerAndRepo(ctx *middleware.Context) (*models.User, *models.Repository) {
|
||||
func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository) {
|
||||
owner, err := models.GetUserByName(ctx.Params(":username"))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
@ -267,7 +267,7 @@ func parseOwnerAndRepo(ctx *middleware.Context) (*models.User, *models.Repositor
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#get
|
||||
func Get(ctx *middleware.Context) {
|
||||
func Get(ctx *context.Context) {
|
||||
owner, repo := parseOwnerAndRepo(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -277,7 +277,7 @@ func Get(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#delete
|
||||
func Delete(ctx *middleware.Context) {
|
||||
func Delete(ctx *context.Context) {
|
||||
owner, repo := parseOwnerAndRepo(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user
|
||||
func ListAccessTokens(ctx *middleware.Context) {
|
||||
func ListAccessTokens(ctx *context.Context) {
|
||||
tokens, err := models.ListAccessTokens(ctx.User.Id)
|
||||
if err != nil {
|
||||
ctx.APIError(500, "ListAccessTokens", err)
|
||||
|
@ -27,7 +27,7 @@ func ListAccessTokens(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token
|
||||
func CreateAccessToken(ctx *middleware.Context, form api.CreateAccessTokenOption) {
|
||||
func CreateAccessToken(ctx *context.Context, form api.CreateAccessTokenOption) {
|
||||
t := &models.AccessToken{
|
||||
UID: ctx.User.Id,
|
||||
Name: form.Name,
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user
|
||||
func ListEmails(ctx *middleware.Context) {
|
||||
func ListEmails(ctx *context.Context) {
|
||||
emails, err := models.GetEmailAddresses(ctx.User.Id)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetEmailAddresses", err)
|
||||
|
@ -28,7 +28,7 @@ func ListEmails(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses
|
||||
func AddEmail(ctx *middleware.Context, form api.CreateEmailOption) {
|
||||
func AddEmail(ctx *context.Context, form api.CreateEmailOption) {
|
||||
if len(form.Emails) == 0 {
|
||||
ctx.Status(422)
|
||||
return
|
||||
|
@ -60,7 +60,7 @@ func AddEmail(ctx *middleware.Context, form api.CreateEmailOption) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses
|
||||
func DeleteEmail(ctx *middleware.Context, form api.CreateEmailOption) {
|
||||
func DeleteEmail(ctx *context.Context, form api.CreateEmailOption) {
|
||||
if len(form.Emails) == 0 {
|
||||
ctx.Status(204)
|
||||
return
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
func responseApiUsers(ctx *middleware.Context, users []*models.User) {
|
||||
func responseApiUsers(ctx *context.Context, users []*models.User) {
|
||||
apiUsers := make([]*api.User, len(users))
|
||||
for i := range users {
|
||||
apiUsers[i] = convert.ToApiUser(users[i])
|
||||
|
@ -20,7 +20,7 @@ func responseApiUsers(ctx *middleware.Context, users []*models.User) {
|
|||
ctx.JSON(200, &apiUsers)
|
||||
}
|
||||
|
||||
func listUserFollowers(ctx *middleware.Context, u *models.User) {
|
||||
func listUserFollowers(ctx *context.Context, u *models.User) {
|
||||
users, err := u.GetFollowers(ctx.QueryInt("page"))
|
||||
if err != nil {
|
||||
ctx.APIError(500, "GetUserFollowers", err)
|
||||
|
@ -29,12 +29,12 @@ func listUserFollowers(ctx *middleware.Context, u *models.User) {
|
|||
responseApiUsers(ctx, users)
|
||||
}
|
||||
|
||||
func ListMyFollowers(ctx *middleware.Context) {
|
||||
func ListMyFollowers(ctx *context.Context) {
|
||||
listUserFollowers(ctx, ctx.User)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-followers-of-a-user
|
||||
func ListFollowers(ctx *middleware.Context) {
|
||||
func ListFollowers(ctx *context.Context) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -42,7 +42,7 @@ func ListFollowers(ctx *middleware.Context) {
|
|||
listUserFollowers(ctx, u)
|
||||
}
|
||||
|
||||
func listUserFollowing(ctx *middleware.Context, u *models.User) {
|
||||
func listUserFollowing(ctx *context.Context, u *models.User) {
|
||||
users, err := u.GetFollowing(ctx.QueryInt("page"))
|
||||
if err != nil {
|
||||
ctx.APIError(500, "GetFollowing", err)
|
||||
|
@ -51,12 +51,12 @@ func listUserFollowing(ctx *middleware.Context, u *models.User) {
|
|||
responseApiUsers(ctx, users)
|
||||
}
|
||||
|
||||
func ListMyFollowing(ctx *middleware.Context) {
|
||||
func ListMyFollowing(ctx *context.Context) {
|
||||
listUserFollowing(ctx, ctx.User)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-users-followed-by-another-user
|
||||
func ListFollowing(ctx *middleware.Context) {
|
||||
func ListFollowing(ctx *context.Context) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -64,7 +64,7 @@ func ListFollowing(ctx *middleware.Context) {
|
|||
listUserFollowing(ctx, u)
|
||||
}
|
||||
|
||||
func checkUserFollowing(ctx *middleware.Context, u *models.User, followID int64) {
|
||||
func checkUserFollowing(ctx *context.Context, u *models.User, followID int64) {
|
||||
if u.IsFollowing(followID) {
|
||||
ctx.Status(204)
|
||||
} else {
|
||||
|
@ -73,7 +73,7 @@ func checkUserFollowing(ctx *middleware.Context, u *models.User, followID int64)
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-you-are-following-a-user
|
||||
func CheckMyFollowing(ctx *middleware.Context) {
|
||||
func CheckMyFollowing(ctx *context.Context) {
|
||||
target := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -82,7 +82,7 @@ func CheckMyFollowing(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another
|
||||
func CheckFollowing(ctx *middleware.Context) {
|
||||
func CheckFollowing(ctx *context.Context) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -95,7 +95,7 @@ func CheckFollowing(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user
|
||||
func Follow(ctx *middleware.Context) {
|
||||
func Follow(ctx *context.Context) {
|
||||
target := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -108,7 +108,7 @@ func Follow(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#unfollow-a-user
|
||||
func Unfollow(ctx *middleware.Context) {
|
||||
func Unfollow(ctx *context.Context) {
|
||||
target := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/routers/api/v1/convert"
|
||||
"github.com/gogits/gogs/routers/api/v1/repo"
|
||||
)
|
||||
|
||||
func GetUserByParamsName(ctx *middleware.Context, name string) *models.User {
|
||||
func GetUserByParamsName(ctx *context.Context, name string) *models.User {
|
||||
user, err := models.GetUserByName(ctx.Params(name))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
@ -28,7 +28,7 @@ func GetUserByParamsName(ctx *middleware.Context, name string) *models.User {
|
|||
}
|
||||
|
||||
// GetUserByParams returns user whose name is presented in URL paramenter.
|
||||
func GetUserByParams(ctx *middleware.Context) *models.User {
|
||||
func GetUserByParams(ctx *context.Context) *models.User {
|
||||
return GetUserByParamsName(ctx, ":username")
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ func composePublicKeysAPILink() string {
|
|||
return setting.AppUrl + "api/v1/user/keys/"
|
||||
}
|
||||
|
||||
func listPublicKeys(ctx *middleware.Context, uid int64) {
|
||||
func listPublicKeys(ctx *context.Context, uid int64) {
|
||||
keys, err := models.ListPublicKeys(uid)
|
||||
if err != nil {
|
||||
ctx.APIError(500, "ListPublicKeys", err)
|
||||
|
@ -53,12 +53,12 @@ func listPublicKeys(ctx *middleware.Context, uid int64) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys
|
||||
func ListMyPublicKeys(ctx *middleware.Context) {
|
||||
func ListMyPublicKeys(ctx *context.Context) {
|
||||
listPublicKeys(ctx, ctx.User.Id)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user
|
||||
func ListPublicKeys(ctx *middleware.Context) {
|
||||
func ListPublicKeys(ctx *context.Context) {
|
||||
user := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -67,7 +67,7 @@ func ListPublicKeys(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key
|
||||
func GetPublicKey(ctx *middleware.Context) {
|
||||
func GetPublicKey(ctx *context.Context) {
|
||||
key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrKeyNotExist(err) {
|
||||
|
@ -83,7 +83,7 @@ func GetPublicKey(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// CreateUserPublicKey creates new public key to given user by ID.
|
||||
func CreateUserPublicKey(ctx *middleware.Context, form api.CreateKeyOption, uid int64) {
|
||||
func CreateUserPublicKey(ctx *context.Context, form api.CreateKeyOption, uid int64) {
|
||||
content, err := models.CheckPublicKeyString(form.Key)
|
||||
if err != nil {
|
||||
repo.HandleCheckKeyStringError(ctx, err)
|
||||
|
@ -100,12 +100,12 @@ func CreateUserPublicKey(ctx *middleware.Context, form api.CreateKeyOption, uid
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key
|
||||
func CreatePublicKey(ctx *middleware.Context, form api.CreateKeyOption) {
|
||||
func CreatePublicKey(ctx *context.Context, form api.CreateKeyOption) {
|
||||
CreateUserPublicKey(ctx, form, ctx.User.Id)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key
|
||||
func DeletePublicKey(ctx *middleware.Context) {
|
||||
func DeletePublicKey(ctx *context.Context) {
|
||||
if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||
if models.IsErrKeyAccessDenied(err) {
|
||||
ctx.APIError(403, "", "You do not have access to this key")
|
||||
|
|
|
@ -10,11 +10,11 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users#search-users
|
||||
func Search(ctx *middleware.Context) {
|
||||
func Search(ctx *context.Context) {
|
||||
opt := models.SearchOption{
|
||||
Keyword: ctx.Query("q"),
|
||||
Limit: com.StrTo(ctx.Query("limit")).MustInt(),
|
||||
|
@ -52,7 +52,7 @@ func Search(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users#get-a-single-user
|
||||
func GetInfo(ctx *middleware.Context) {
|
||||
func GetInfo(ctx *context.Context) {
|
||||
u, err := models.GetUserByName(ctx.Params(":username"))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
|
|
@ -7,11 +7,11 @@ package dev
|
|||
import (
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
func TemplatePreview(ctx *middleware.Context) {
|
||||
func TemplatePreview(ctx *context.Context) {
|
||||
ctx.Data["User"] = models.User{Name: "Unknown"}
|
||||
ctx.Data["AppName"] = setting.AppName
|
||||
ctx.Data["AppVer"] = setting.AppVer
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/routers/user"
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ const (
|
|||
EXPLORE_REPOS base.TplName = "explore/repos"
|
||||
)
|
||||
|
||||
func Home(ctx *middleware.Context) {
|
||||
func Home(ctx *context.Context) {
|
||||
if ctx.IsSigned {
|
||||
if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.active_your_account")
|
||||
|
@ -43,7 +43,7 @@ func Home(ctx *middleware.Context) {
|
|||
ctx.HTML(200, HOME)
|
||||
}
|
||||
|
||||
func Explore(ctx *middleware.Context) {
|
||||
func Explore(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("explore")
|
||||
ctx.Data["PageIsExplore"] = true
|
||||
ctx.Data["PageIsExploreRepositories"] = true
|
||||
|
@ -71,7 +71,7 @@ func Explore(ctx *middleware.Context) {
|
|||
ctx.HTML(200, EXPLORE_REPOS)
|
||||
}
|
||||
|
||||
func NotFound(ctx *middleware.Context) {
|
||||
func NotFound(ctx *context.Context) {
|
||||
ctx.Data["Title"] = "Page Not Found"
|
||||
ctx.Handle(404, "home.NotFound", nil)
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/cron"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/markdown"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/modules/ssh"
|
||||
"github.com/gogits/gogs/modules/template/highlight"
|
||||
|
@ -97,7 +97,7 @@ func GlobalInit() {
|
|||
markdown.BuildSanitizer()
|
||||
}
|
||||
|
||||
func InstallInit(ctx *middleware.Context) {
|
||||
func InstallInit(ctx *context.Context) {
|
||||
if setting.InstallLock {
|
||||
ctx.Handle(404, "Install", errors.New("Installation is prohibited"))
|
||||
return
|
||||
|
@ -116,7 +116,7 @@ func InstallInit(ctx *middleware.Context) {
|
|||
ctx.Data["DbOptions"] = dbOpts
|
||||
}
|
||||
|
||||
func Install(ctx *middleware.Context) {
|
||||
func Install(ctx *context.Context) {
|
||||
form := auth.InstallForm{}
|
||||
|
||||
// Database settings
|
||||
|
@ -177,7 +177,7 @@ func Install(ctx *middleware.Context) {
|
|||
ctx.HTML(200, INSTALL)
|
||||
}
|
||||
|
||||
func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
|
||||
func InstallPost(ctx *context.Context, form auth.InstallForm) {
|
||||
ctx.Data["CurDbOption"] = form.DbType
|
||||
|
||||
if ctx.HasError() {
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -19,7 +19,7 @@ const (
|
|||
MEMBER_INVITE base.TplName = "org/member/invite"
|
||||
)
|
||||
|
||||
func Members(ctx *middleware.Context) {
|
||||
func Members(ctx *context.Context) {
|
||||
org := ctx.Org.Organization
|
||||
ctx.Data["Title"] = org.FullName
|
||||
ctx.Data["PageIsOrgMembers"] = true
|
||||
|
@ -33,7 +33,7 @@ func Members(ctx *middleware.Context) {
|
|||
ctx.HTML(200, MEMBERS)
|
||||
}
|
||||
|
||||
func MembersAction(ctx *middleware.Context) {
|
||||
func MembersAction(ctx *context.Context) {
|
||||
uid := com.StrTo(ctx.Query("uid")).MustInt64()
|
||||
if uid == 0 {
|
||||
ctx.Redirect(ctx.Org.OrgLink + "/members")
|
||||
|
@ -91,7 +91,7 @@ func MembersAction(ctx *middleware.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func Invitation(ctx *middleware.Context) {
|
||||
func Invitation(ctx *context.Context) {
|
||||
org := ctx.Org.Organization
|
||||
ctx.Data["Title"] = org.FullName
|
||||
ctx.Data["PageIsOrgMembers"] = true
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -17,12 +17,12 @@ const (
|
|||
CREATE base.TplName = "org/create"
|
||||
)
|
||||
|
||||
func Create(ctx *middleware.Context) {
|
||||
func Create(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_org")
|
||||
ctx.HTML(200, CREATE)
|
||||
}
|
||||
|
||||
func CreatePost(ctx *middleware.Context, form auth.CreateOrgForm) {
|
||||
func CreatePost(ctx *context.Context, form auth.CreateOrgForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_org")
|
||||
|
||||
if ctx.HasError() {
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/routers/user"
|
||||
)
|
||||
|
@ -24,13 +24,13 @@ const (
|
|||
SETTINGS_HOOKS base.TplName = "org/settings/hooks"
|
||||
)
|
||||
|
||||
func Settings(ctx *middleware.Context) {
|
||||
func Settings(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("org.settings")
|
||||
ctx.Data["PageIsSettingsOptions"] = true
|
||||
ctx.HTML(200, SETTINGS_OPTIONS)
|
||||
}
|
||||
|
||||
func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) {
|
||||
func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("org.settings")
|
||||
ctx.Data["PageIsSettingsOptions"] = true
|
||||
|
||||
|
@ -85,7 +85,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) {
|
|||
ctx.Redirect(ctx.Org.OrgLink + "/settings")
|
||||
}
|
||||
|
||||
func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
|
||||
func SettingsAvatar(ctx *context.Context, form auth.UploadAvatarForm) {
|
||||
form.Enable = true
|
||||
if err := user.UpdateAvatarSetting(ctx, form, ctx.Org.Organization); err != nil {
|
||||
ctx.Flash.Error(err.Error())
|
||||
|
@ -96,7 +96,7 @@ func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
|
|||
ctx.Redirect(ctx.Org.OrgLink + "/settings")
|
||||
}
|
||||
|
||||
func SettingsDeleteAvatar(ctx *middleware.Context) {
|
||||
func SettingsDeleteAvatar(ctx *context.Context) {
|
||||
if err := ctx.Org.Organization.DeleteAvatar(); err != nil {
|
||||
ctx.Flash.Error(err.Error())
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ func SettingsDeleteAvatar(ctx *middleware.Context) {
|
|||
ctx.Redirect(ctx.Org.OrgLink + "/settings")
|
||||
}
|
||||
|
||||
func SettingsDelete(ctx *middleware.Context) {
|
||||
func SettingsDelete(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("org.settings")
|
||||
ctx.Data["PageIsSettingsDelete"] = true
|
||||
|
||||
|
@ -136,7 +136,7 @@ func SettingsDelete(ctx *middleware.Context) {
|
|||
ctx.HTML(200, SETTINGS_DELETE)
|
||||
}
|
||||
|
||||
func Webhooks(ctx *middleware.Context) {
|
||||
func Webhooks(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("org.settings")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["BaseLink"] = ctx.Org.OrgLink
|
||||
|
@ -164,7 +164,7 @@ func Webhooks(ctx *middleware.Context) {
|
|||
ctx.HTML(200, SETTINGS_HOOKS)
|
||||
}
|
||||
|
||||
func DeleteWebhook(ctx *middleware.Context) {
|
||||
func DeleteWebhook(ctx *context.Context) {
|
||||
if err := models.DeleteWebhook(ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteWebhook: " + err.Error())
|
||||
} else {
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -23,7 +23,7 @@ const (
|
|||
TEAM_REPOSITORIES base.TplName = "org/team/repositories"
|
||||
)
|
||||
|
||||
func Teams(ctx *middleware.Context) {
|
||||
func Teams(ctx *context.Context) {
|
||||
org := ctx.Org.Organization
|
||||
ctx.Data["Title"] = org.FullName
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
|
@ -39,7 +39,7 @@ func Teams(ctx *middleware.Context) {
|
|||
ctx.HTML(200, TEAMS)
|
||||
}
|
||||
|
||||
func TeamsAction(ctx *middleware.Context) {
|
||||
func TeamsAction(ctx *context.Context) {
|
||||
uid := com.StrTo(ctx.Query("uid")).MustInt64()
|
||||
if uid == 0 {
|
||||
ctx.Redirect(ctx.Org.OrgLink + "/teams")
|
||||
|
@ -107,7 +107,7 @@ func TeamsAction(ctx *middleware.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func TeamsRepoAction(ctx *middleware.Context) {
|
||||
func TeamsRepoAction(ctx *context.Context) {
|
||||
if !ctx.Org.IsOwner {
|
||||
ctx.Error(404)
|
||||
return
|
||||
|
@ -141,7 +141,7 @@ func TeamsRepoAction(ctx *middleware.Context) {
|
|||
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + ctx.Org.Team.LowerName + "/repositories")
|
||||
}
|
||||
|
||||
func NewTeam(ctx *middleware.Context) {
|
||||
func NewTeam(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Org.Organization.FullName
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
ctx.Data["PageIsOrgTeamsNew"] = true
|
||||
|
@ -149,7 +149,7 @@ func NewTeam(ctx *middleware.Context) {
|
|||
ctx.HTML(200, TEAM_NEW)
|
||||
}
|
||||
|
||||
func NewTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
|
||||
func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
|
||||
ctx.Data["Title"] = ctx.Org.Organization.FullName
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
ctx.Data["PageIsOrgTeamsNew"] = true
|
||||
|
@ -195,7 +195,7 @@ func NewTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
|
|||
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + t.LowerName)
|
||||
}
|
||||
|
||||
func TeamMembers(ctx *middleware.Context) {
|
||||
func TeamMembers(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Org.Team.Name
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
if err := ctx.Org.Team.GetMembers(); err != nil {
|
||||
|
@ -205,7 +205,7 @@ func TeamMembers(ctx *middleware.Context) {
|
|||
ctx.HTML(200, TEAM_MEMBERS)
|
||||
}
|
||||
|
||||
func TeamRepositories(ctx *middleware.Context) {
|
||||
func TeamRepositories(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Org.Team.Name
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
if err := ctx.Org.Team.GetRepositories(); err != nil {
|
||||
|
@ -215,7 +215,7 @@ func TeamRepositories(ctx *middleware.Context) {
|
|||
ctx.HTML(200, TEAM_REPOSITORIES)
|
||||
}
|
||||
|
||||
func EditTeam(ctx *middleware.Context) {
|
||||
func EditTeam(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Org.Organization.FullName
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
ctx.Data["team_name"] = ctx.Org.Team.Name
|
||||
|
@ -223,7 +223,7 @@ func EditTeam(ctx *middleware.Context) {
|
|||
ctx.HTML(200, TEAM_NEW)
|
||||
}
|
||||
|
||||
func EditTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
|
||||
func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
|
||||
t := ctx.Org.Team
|
||||
ctx.Data["Title"] = ctx.Org.Organization.FullName
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
|
@ -270,7 +270,7 @@ func EditTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
|
|||
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + t.LowerName)
|
||||
}
|
||||
|
||||
func DeleteTeam(ctx *middleware.Context) {
|
||||
func DeleteTeam(ctx *context.Context) {
|
||||
if err := models.DeleteTeam(ctx.Org.Team); err != nil {
|
||||
ctx.Flash.Error("DeleteTeam: " + err.Error())
|
||||
} else {
|
||||
|
|
|
@ -6,14 +6,14 @@ package repo
|
|||
|
||||
import (
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
)
|
||||
|
||||
const (
|
||||
BRANCH base.TplName = "repo/branch"
|
||||
)
|
||||
|
||||
func Branches(ctx *middleware.Context) {
|
||||
func Branches(ctx *context.Context) {
|
||||
ctx.Data["Title"] = "Branches"
|
||||
ctx.Data["IsRepoToolbarBranches"] = true
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -23,7 +23,7 @@ const (
|
|||
DIFF base.TplName = "repo/diff"
|
||||
)
|
||||
|
||||
func RefCommits(ctx *middleware.Context) {
|
||||
func RefCommits(ctx *context.Context) {
|
||||
switch {
|
||||
case len(ctx.Repo.TreeName) == 0:
|
||||
Commits(ctx)
|
||||
|
@ -43,7 +43,7 @@ func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List {
|
|||
return newCommits
|
||||
}
|
||||
|
||||
func Commits(ctx *middleware.Context) {
|
||||
func Commits(ctx *context.Context) {
|
||||
ctx.Data["PageIsCommits"] = true
|
||||
|
||||
commitsCount, err := ctx.Repo.Commit.CommitsCount()
|
||||
|
@ -75,7 +75,7 @@ func Commits(ctx *middleware.Context) {
|
|||
ctx.HTML(200, COMMITS)
|
||||
}
|
||||
|
||||
func SearchCommits(ctx *middleware.Context) {
|
||||
func SearchCommits(ctx *context.Context) {
|
||||
ctx.Data["PageIsCommits"] = true
|
||||
|
||||
keyword := ctx.Query("q")
|
||||
|
@ -101,7 +101,7 @@ func SearchCommits(ctx *middleware.Context) {
|
|||
ctx.HTML(200, COMMITS)
|
||||
}
|
||||
|
||||
func FileHistory(ctx *middleware.Context) {
|
||||
func FileHistory(ctx *context.Context) {
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
|
||||
fileName := ctx.Repo.TreeName
|
||||
|
@ -143,7 +143,7 @@ func FileHistory(ctx *middleware.Context) {
|
|||
ctx.HTML(200, COMMITS)
|
||||
}
|
||||
|
||||
func Diff(ctx *middleware.Context) {
|
||||
func Diff(ctx *context.Context) {
|
||||
ctx.Data["PageIsDiff"] = true
|
||||
|
||||
userName := ctx.Repo.Owner.Name
|
||||
|
@ -187,7 +187,7 @@ func Diff(ctx *middleware.Context) {
|
|||
ctx.HTML(200, DIFF)
|
||||
}
|
||||
|
||||
func CompareDiff(ctx *middleware.Context) {
|
||||
func CompareDiff(ctx *context.Context) {
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
ctx.Data["IsDiffCompare"] = true
|
||||
userName := ctx.Repo.Owner.Name
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
"github.com/gogits/git-module"
|
||||
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
)
|
||||
|
||||
func ServeData(ctx *middleware.Context, name string, reader io.Reader) error {
|
||||
func ServeData(ctx *context.Context, name string, reader io.Reader) error {
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := reader.Read(buf)
|
||||
if n > 0 {
|
||||
|
@ -36,7 +36,7 @@ func ServeData(ctx *middleware.Context, name string, reader io.Reader) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func ServeBlob(ctx *middleware.Context, blob *git.Blob) error {
|
||||
func ServeBlob(ctx *context.Context, blob *git.Blob) error {
|
||||
dataRc, err := blob.Data()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -45,7 +45,7 @@ func ServeBlob(ctx *middleware.Context, blob *git.Blob) error {
|
|||
return ServeData(ctx, ctx.Repo.TreeName, dataRc)
|
||||
}
|
||||
|
||||
func SingleDownload(ctx *middleware.Context) {
|
||||
func SingleDownload(ctx *context.Context) {
|
||||
blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreeName)
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
|
|
|
@ -23,18 +23,18 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
func authRequired(ctx *middleware.Context) {
|
||||
func authRequired(ctx *context.Context) {
|
||||
ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=\".\"")
|
||||
ctx.Data["ErrorMsg"] = "no basic auth and digit auth"
|
||||
ctx.Error(401)
|
||||
}
|
||||
|
||||
func HTTP(ctx *middleware.Context) {
|
||||
func HTTP(ctx *context.Context) {
|
||||
username := ctx.Params(":username")
|
||||
reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
|
||||
|
||||
|
@ -293,7 +293,7 @@ func getGitDir(config *Config, fPath string) (string, error) {
|
|||
}
|
||||
|
||||
// Request handling function
|
||||
func HTTPBackend(ctx *middleware.Context, config *Config) http.HandlerFunc {
|
||||
func HTTPBackend(ctx *context.Context, config *Config) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
for _, route := range routes {
|
||||
r.URL.Path = strings.ToLower(r.URL.Path) // blue: In case some repo name has upper case name
|
||||
|
|
|
@ -20,10 +20,10 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/markdown"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -52,14 +52,14 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
func MustEnableIssues(ctx *middleware.Context) {
|
||||
func MustEnableIssues(ctx *context.Context) {
|
||||
if !ctx.Repo.Repository.EnableIssues {
|
||||
ctx.Handle(404, "MustEnableIssues", nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func MustAllowPulls(ctx *middleware.Context) {
|
||||
func MustAllowPulls(ctx *context.Context) {
|
||||
if !ctx.Repo.Repository.AllowsPulls() {
|
||||
ctx.Handle(404, "MustAllowPulls", nil)
|
||||
return
|
||||
|
@ -72,7 +72,7 @@ func MustAllowPulls(ctx *middleware.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func RetrieveLabels(ctx *middleware.Context) {
|
||||
func RetrieveLabels(ctx *context.Context) {
|
||||
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "RetrieveLabels.GetLabels: %v", err)
|
||||
|
@ -85,7 +85,7 @@ func RetrieveLabels(ctx *middleware.Context) {
|
|||
ctx.Data["NumLabels"] = len(labels)
|
||||
}
|
||||
|
||||
func Issues(ctx *middleware.Context) {
|
||||
func Issues(ctx *context.Context) {
|
||||
isPullList := ctx.Params(":type") == "pulls"
|
||||
if isPullList {
|
||||
MustAllowPulls(ctx)
|
||||
|
@ -250,7 +250,7 @@ func Issues(ctx *middleware.Context) {
|
|||
ctx.HTML(200, ISSUES)
|
||||
}
|
||||
|
||||
func renderAttachmentSettings(ctx *middleware.Context) {
|
||||
func renderAttachmentSettings(ctx *context.Context) {
|
||||
ctx.Data["RequireDropzone"] = true
|
||||
ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled
|
||||
ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes
|
||||
|
@ -258,7 +258,7 @@ func renderAttachmentSettings(ctx *middleware.Context) {
|
|||
ctx.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles
|
||||
}
|
||||
|
||||
func RetrieveRepoMilestonesAndAssignees(ctx *middleware.Context, repo *models.Repository) {
|
||||
func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repository) {
|
||||
var err error
|
||||
ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
|
||||
if err != nil {
|
||||
|
@ -278,7 +278,7 @@ func RetrieveRepoMilestonesAndAssignees(ctx *middleware.Context, repo *models.Re
|
|||
}
|
||||
}
|
||||
|
||||
func RetrieveRepoMetas(ctx *middleware.Context, repo *models.Repository) []*models.Label {
|
||||
func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.Label {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
return nil
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ func RetrieveRepoMetas(ctx *middleware.Context, repo *models.Repository) []*mode
|
|||
return labels
|
||||
}
|
||||
|
||||
func getFileContentFromDefaultBranch(ctx *middleware.Context, filename string) (string, bool) {
|
||||
func getFileContentFromDefaultBranch(ctx *context.Context, filename string) (string, bool) {
|
||||
var r io.Reader
|
||||
var bytes []byte
|
||||
|
||||
|
@ -325,7 +325,7 @@ func getFileContentFromDefaultBranch(ctx *middleware.Context, filename string) (
|
|||
return string(bytes), true
|
||||
}
|
||||
|
||||
func setTemplateIfExists(ctx *middleware.Context, ctxDataKey string, possibleFiles []string) {
|
||||
func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles []string) {
|
||||
for _, filename := range possibleFiles {
|
||||
content, found := getFileContentFromDefaultBranch(ctx, filename)
|
||||
if found {
|
||||
|
@ -335,7 +335,7 @@ func setTemplateIfExists(ctx *middleware.Context, ctxDataKey string, possibleFil
|
|||
}
|
||||
}
|
||||
|
||||
func NewIssue(ctx *middleware.Context) {
|
||||
func NewIssue(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
setTemplateIfExists(ctx, ISSUE_TEMPLATE_KEY, IssueTemplateCandidates)
|
||||
|
@ -351,7 +351,7 @@ func NewIssue(ctx *middleware.Context) {
|
|||
ctx.HTML(200, ISSUE_NEW)
|
||||
}
|
||||
|
||||
func ValidateRepoMetas(ctx *middleware.Context, form auth.CreateIssueForm) ([]int64, int64, int64) {
|
||||
func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm) ([]int64, int64, int64) {
|
||||
var (
|
||||
repo = ctx.Repo.Repository
|
||||
err error
|
||||
|
@ -405,7 +405,7 @@ func ValidateRepoMetas(ctx *middleware.Context, form auth.CreateIssueForm) ([]in
|
|||
return labelIDs, milestoneID, assigneeID
|
||||
}
|
||||
|
||||
func notifyWatchersAndMentions(ctx *middleware.Context, issue *models.Issue) {
|
||||
func notifyWatchersAndMentions(ctx *context.Context, issue *models.Issue) {
|
||||
// Update mentions
|
||||
mentions := markdown.MentionPattern.FindAllString(issue.Content, -1)
|
||||
if len(mentions) > 0 {
|
||||
|
@ -446,7 +446,7 @@ func notifyWatchersAndMentions(ctx *middleware.Context, issue *models.Issue) {
|
|||
}
|
||||
}
|
||||
|
||||
func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
||||
func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
renderAttachmentSettings(ctx)
|
||||
|
@ -494,7 +494,7 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index))
|
||||
}
|
||||
|
||||
func UploadIssueAttachment(ctx *middleware.Context) {
|
||||
func UploadIssueAttachment(ctx *context.Context) {
|
||||
if !setting.AttachmentEnabled {
|
||||
ctx.Error(404, "attachment is not enabled")
|
||||
return
|
||||
|
@ -541,7 +541,7 @@ func UploadIssueAttachment(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func ViewIssue(ctx *middleware.Context) {
|
||||
func ViewIssue(ctx *context.Context) {
|
||||
ctx.Data["RequireDropzone"] = true
|
||||
renderAttachmentSettings(ctx)
|
||||
|
||||
|
@ -706,7 +706,7 @@ func ViewIssue(ctx *middleware.Context) {
|
|||
ctx.HTML(200, ISSUE_VIEW)
|
||||
}
|
||||
|
||||
func getActionIssue(ctx *middleware.Context) *models.Issue {
|
||||
func getActionIssue(ctx *context.Context) *models.Issue {
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
if models.IsErrIssueNotExist(err) {
|
||||
|
@ -719,7 +719,7 @@ func getActionIssue(ctx *middleware.Context) *models.Issue {
|
|||
return issue
|
||||
}
|
||||
|
||||
func UpdateIssueTitle(ctx *middleware.Context) {
|
||||
func UpdateIssueTitle(ctx *context.Context) {
|
||||
issue := getActionIssue(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -746,7 +746,7 @@ func UpdateIssueTitle(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func UpdateIssueContent(ctx *middleware.Context) {
|
||||
func UpdateIssueContent(ctx *context.Context) {
|
||||
issue := getActionIssue(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -768,7 +768,7 @@ func UpdateIssueContent(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func UpdateIssueLabel(ctx *middleware.Context) {
|
||||
func UpdateIssueLabel(ctx *context.Context) {
|
||||
issue := getActionIssue(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -809,7 +809,7 @@ func UpdateIssueLabel(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func UpdateIssueMilestone(ctx *middleware.Context) {
|
||||
func UpdateIssueMilestone(ctx *context.Context) {
|
||||
issue := getActionIssue(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -836,7 +836,7 @@ func UpdateIssueMilestone(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func UpdateIssueAssignee(ctx *middleware.Context) {
|
||||
func UpdateIssueAssignee(ctx *context.Context) {
|
||||
issue := getActionIssue(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -862,7 +862,7 @@ func UpdateIssueAssignee(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) {
|
||||
func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
if models.IsErrIssueNotExist(err) {
|
||||
|
@ -968,7 +968,7 @@ func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) {
|
|||
log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
|
||||
}
|
||||
|
||||
func UpdateCommentContent(ctx *middleware.Context) {
|
||||
func UpdateCommentContent(ctx *context.Context) {
|
||||
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrCommentNotExist(err) {
|
||||
|
@ -1004,7 +1004,7 @@ func UpdateCommentContent(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func Labels(ctx *middleware.Context) {
|
||||
func Labels(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.labels")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
ctx.Data["PageIsLabels"] = true
|
||||
|
@ -1012,7 +1012,7 @@ func Labels(ctx *middleware.Context) {
|
|||
ctx.HTML(200, LABELS)
|
||||
}
|
||||
|
||||
func NewLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
|
||||
func NewLabel(ctx *context.Context, form auth.CreateLabelForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.labels")
|
||||
ctx.Data["PageIsLabels"] = true
|
||||
|
||||
|
@ -1034,7 +1034,7 @@ func NewLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/labels")
|
||||
}
|
||||
|
||||
func UpdateLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
|
||||
func UpdateLabel(ctx *context.Context, form auth.CreateLabelForm) {
|
||||
l, err := models.GetLabelByID(form.ID)
|
||||
if err != nil {
|
||||
switch {
|
||||
|
@ -1056,7 +1056,7 @@ func UpdateLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/labels")
|
||||
}
|
||||
|
||||
func DeleteLabel(ctx *middleware.Context) {
|
||||
func DeleteLabel(ctx *context.Context) {
|
||||
if err := models.DeleteLabel(ctx.Repo.Repository.ID, ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteLabel: " + err.Error())
|
||||
} else {
|
||||
|
@ -1069,7 +1069,7 @@ func DeleteLabel(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
func Milestones(ctx *middleware.Context) {
|
||||
func Milestones(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
|
@ -1113,7 +1113,7 @@ func Milestones(ctx *middleware.Context) {
|
|||
ctx.HTML(200, MILESTONE)
|
||||
}
|
||||
|
||||
func NewMilestone(ctx *middleware.Context) {
|
||||
func NewMilestone(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
|
@ -1122,7 +1122,7 @@ func NewMilestone(ctx *middleware.Context) {
|
|||
ctx.HTML(200, MILESTONE_NEW)
|
||||
}
|
||||
|
||||
func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
||||
func NewMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
|
@ -1158,7 +1158,7 @@ func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/milestones")
|
||||
}
|
||||
|
||||
func EditMilestone(ctx *middleware.Context) {
|
||||
func EditMilestone(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones.edit")
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
ctx.Data["PageIsEditMilestone"] = true
|
||||
|
@ -1182,7 +1182,7 @@ func EditMilestone(ctx *middleware.Context) {
|
|||
ctx.HTML(200, MILESTONE_NEW)
|
||||
}
|
||||
|
||||
func EditMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
||||
func EditMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.milestones.edit")
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
ctx.Data["PageIsEditMilestone"] = true
|
||||
|
@ -1225,7 +1225,7 @@ func EditMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/milestones")
|
||||
}
|
||||
|
||||
func ChangeMilestonStatus(ctx *middleware.Context) {
|
||||
func ChangeMilestonStatus(ctx *context.Context) {
|
||||
m, err := models.GetMilestoneByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrMilestoneNotExist(err) {
|
||||
|
@ -1259,7 +1259,7 @@ func ChangeMilestonStatus(ctx *middleware.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func DeleteMilestone(ctx *middleware.Context) {
|
||||
func DeleteMilestone(ctx *context.Context) {
|
||||
if err := models.DeleteMilestoneByID(ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteMilestoneByID: " + err.Error())
|
||||
} else {
|
||||
|
|
|
@ -16,8 +16,8 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -38,7 +38,7 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
func getForkRepository(ctx *middleware.Context) *models.Repository {
|
||||
func getForkRepository(ctx *context.Context) *models.Repository {
|
||||
forkRepo, err := models.GetRepositoryByID(ctx.ParamsInt64(":repoid"))
|
||||
if err != nil {
|
||||
if models.IsErrRepoNotExist(err) {
|
||||
|
@ -73,7 +73,7 @@ func getForkRepository(ctx *middleware.Context) *models.Repository {
|
|||
return forkRepo
|
||||
}
|
||||
|
||||
func Fork(ctx *middleware.Context) {
|
||||
func Fork(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_fork")
|
||||
|
||||
getForkRepository(ctx)
|
||||
|
@ -85,7 +85,7 @@ func Fork(ctx *middleware.Context) {
|
|||
ctx.HTML(200, FORK)
|
||||
}
|
||||
|
||||
func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
||||
func ForkPost(ctx *context.Context, form auth.CreateRepoForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_fork")
|
||||
|
||||
forkRepo := getForkRepository(ctx)
|
||||
|
@ -138,7 +138,7 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
|
||||
}
|
||||
|
||||
func checkPullInfo(ctx *middleware.Context) *models.Issue {
|
||||
func checkPullInfo(ctx *context.Context) *models.Issue {
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
if models.IsErrIssueNotExist(err) {
|
||||
|
@ -178,7 +178,7 @@ func checkPullInfo(ctx *middleware.Context) *models.Issue {
|
|||
return issue
|
||||
}
|
||||
|
||||
func PrepareMergedViewPullInfo(ctx *middleware.Context, pull *models.Issue) {
|
||||
func PrepareMergedViewPullInfo(ctx *context.Context, pull *models.Issue) {
|
||||
ctx.Data["HasMerged"] = true
|
||||
|
||||
var err error
|
||||
|
@ -203,7 +203,7 @@ func PrepareMergedViewPullInfo(ctx *middleware.Context, pull *models.Issue) {
|
|||
}
|
||||
}
|
||||
|
||||
func PrepareViewPullInfo(ctx *middleware.Context, pull *models.Issue) *git.PullRequestInfo {
|
||||
func PrepareViewPullInfo(ctx *context.Context, pull *models.Issue) *git.PullRequestInfo {
|
||||
repo := ctx.Repo.Repository
|
||||
|
||||
ctx.Data["HeadTarget"] = pull.HeadUserName + "/" + pull.HeadBranch
|
||||
|
@ -246,7 +246,7 @@ func PrepareViewPullInfo(ctx *middleware.Context, pull *models.Issue) *git.PullR
|
|||
return prInfo
|
||||
}
|
||||
|
||||
func ViewPullCommits(ctx *middleware.Context) {
|
||||
func ViewPullCommits(ctx *context.Context) {
|
||||
ctx.Data["PageIsPullCommits"] = true
|
||||
|
||||
pull := checkPullInfo(ctx)
|
||||
|
@ -296,7 +296,7 @@ func ViewPullCommits(ctx *middleware.Context) {
|
|||
ctx.HTML(200, PULL_COMMITS)
|
||||
}
|
||||
|
||||
func ViewPullFiles(ctx *middleware.Context) {
|
||||
func ViewPullFiles(ctx *context.Context) {
|
||||
ctx.Data["PageIsPullFiles"] = true
|
||||
|
||||
pull := checkPullInfo(ctx)
|
||||
|
@ -377,7 +377,7 @@ func ViewPullFiles(ctx *middleware.Context) {
|
|||
ctx.HTML(200, PULL_FILES)
|
||||
}
|
||||
|
||||
func MergePullRequest(ctx *middleware.Context) {
|
||||
func MergePullRequest(ctx *context.Context) {
|
||||
issue := checkPullInfo(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -413,7 +413,7 @@ func MergePullRequest(ctx *middleware.Context) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
|
||||
}
|
||||
|
||||
func ParseCompareInfo(ctx *middleware.Context) (*models.User, *models.Repository, *git.Repository, *git.PullRequestInfo, string, string) {
|
||||
func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *git.Repository, *git.PullRequestInfo, string, string) {
|
||||
baseRepo := ctx.Repo.Repository
|
||||
|
||||
// Get compared branches information
|
||||
|
@ -520,7 +520,7 @@ func ParseCompareInfo(ctx *middleware.Context) (*models.User, *models.Repository
|
|||
}
|
||||
|
||||
func PrepareCompareDiff(
|
||||
ctx *middleware.Context,
|
||||
ctx *context.Context,
|
||||
headUser *models.User,
|
||||
headRepo *models.Repository,
|
||||
headGitRepo *git.Repository,
|
||||
|
@ -576,7 +576,7 @@ func PrepareCompareDiff(
|
|||
return false
|
||||
}
|
||||
|
||||
func CompareAndPullRequest(ctx *middleware.Context) {
|
||||
func CompareAndPullRequest(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes")
|
||||
ctx.Data["PageIsComparePull"] = true
|
||||
ctx.Data["IsDiffCompare"] = true
|
||||
|
@ -618,7 +618,7 @@ func CompareAndPullRequest(ctx *middleware.Context) {
|
|||
ctx.HTML(200, COMPARE_PULL)
|
||||
}
|
||||
|
||||
func CompareAndPullRequestPost(ctx *middleware.Context, form auth.CreateIssueForm) {
|
||||
func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes")
|
||||
ctx.Data["PageIsComparePull"] = true
|
||||
ctx.Data["IsDiffCompare"] = true
|
||||
|
@ -693,7 +693,7 @@ func CompareAndPullRequestPost(ctx *middleware.Context, form auth.CreateIssueFor
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pullIssue.Index))
|
||||
}
|
||||
|
||||
func TriggerTask(ctx *middleware.Context) {
|
||||
func TriggerTask(ctx *context.Context) {
|
||||
branch := ctx.Query("branch")
|
||||
secret := ctx.Query("secret")
|
||||
if len(branch) == 0 || len(secret) == 0 {
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/markdown"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -21,7 +21,7 @@ const (
|
|||
)
|
||||
|
||||
// calReleaseNumCommitsBehind calculates given release has how many commits behind default branch.
|
||||
func calReleaseNumCommitsBehind(repoCtx *middleware.RepoContext, release *models.Release, countCache map[string]int64) error {
|
||||
func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *models.Release, countCache map[string]int64) error {
|
||||
// Fast return if release target is same as default branch.
|
||||
if repoCtx.BranchName == release.Target {
|
||||
release.NumCommitsBehind = repoCtx.CommitsCount - release.NumCommits
|
||||
|
@ -43,7 +43,7 @@ func calReleaseNumCommitsBehind(repoCtx *middleware.RepoContext, release *models
|
|||
return nil
|
||||
}
|
||||
|
||||
func Releases(ctx *middleware.Context) {
|
||||
func Releases(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.release.releases")
|
||||
ctx.Data["PageIsReleaseList"] = true
|
||||
|
||||
|
@ -141,14 +141,14 @@ func Releases(ctx *middleware.Context) {
|
|||
ctx.HTML(200, RELEASES)
|
||||
}
|
||||
|
||||
func NewRelease(ctx *middleware.Context) {
|
||||
func NewRelease(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.release.new_release")
|
||||
ctx.Data["PageIsReleaseList"] = true
|
||||
ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch
|
||||
ctx.HTML(200, RELEASE_NEW)
|
||||
}
|
||||
|
||||
func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
|
||||
func NewReleasePost(ctx *context.Context, form auth.NewReleaseForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.release.new_release")
|
||||
ctx.Data["PageIsReleaseList"] = true
|
||||
|
||||
|
@ -201,7 +201,7 @@ func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/releases")
|
||||
}
|
||||
|
||||
func EditRelease(ctx *middleware.Context) {
|
||||
func EditRelease(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.release.edit_release")
|
||||
ctx.Data["PageIsReleaseList"] = true
|
||||
ctx.Data["PageIsEditRelease"] = true
|
||||
|
@ -226,7 +226,7 @@ func EditRelease(ctx *middleware.Context) {
|
|||
ctx.HTML(200, RELEASE_NEW)
|
||||
}
|
||||
|
||||
func EditReleasePost(ctx *middleware.Context, form auth.EditReleaseForm) {
|
||||
func EditReleasePost(ctx *context.Context, form auth.EditReleaseForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.release.edit_release")
|
||||
ctx.Data["PageIsReleaseList"] = true
|
||||
ctx.Data["PageIsEditRelease"] = true
|
||||
|
@ -263,7 +263,7 @@ func EditReleasePost(ctx *middleware.Context, form auth.EditReleaseForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/releases")
|
||||
}
|
||||
|
||||
func DeleteRelease(ctx *middleware.Context) {
|
||||
func DeleteRelease(ctx *context.Context) {
|
||||
if err := models.DeleteReleaseByID(ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteReleaseByID: " + err.Error())
|
||||
} else {
|
||||
|
|
|
@ -17,8 +17,8 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -27,13 +27,13 @@ const (
|
|||
MIGRATE base.TplName = "repo/migrate"
|
||||
)
|
||||
|
||||
func MustBeNotBare(ctx *middleware.Context) {
|
||||
func MustBeNotBare(ctx *context.Context) {
|
||||
if ctx.Repo.Repository.IsBare {
|
||||
ctx.Handle(404, "MustBeNotBare", nil)
|
||||
}
|
||||
}
|
||||
|
||||
func checkContextUser(ctx *middleware.Context, uid int64) *models.User {
|
||||
func checkContextUser(ctx *context.Context, uid int64) *models.User {
|
||||
orgs, err := models.GetOwnedOrgsByUserIDDesc(ctx.User.Id, "updated_unix")
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetOwnedOrgsByUserIDDesc", err)
|
||||
|
@ -64,7 +64,7 @@ func checkContextUser(ctx *middleware.Context, uid int64) *models.User {
|
|||
return org
|
||||
}
|
||||
|
||||
func Create(ctx *middleware.Context) {
|
||||
func Create(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_repo")
|
||||
|
||||
// Give default value for template to render.
|
||||
|
@ -84,7 +84,7 @@ func Create(ctx *middleware.Context) {
|
|||
ctx.HTML(200, CREATE)
|
||||
}
|
||||
|
||||
func handleCreateError(ctx *middleware.Context, owner *models.User, err error, name string, tpl base.TplName, form interface{}) {
|
||||
func handleCreateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form interface{}) {
|
||||
switch {
|
||||
case models.IsErrReachLimitOfRepo(err):
|
||||
ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.RepoCreationNum()), tpl, form)
|
||||
|
@ -102,7 +102,7 @@ func handleCreateError(ctx *middleware.Context, owner *models.User, err error, n
|
|||
}
|
||||
}
|
||||
|
||||
func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
||||
func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_repo")
|
||||
|
||||
ctx.Data["Gitignores"] = models.Gitignores
|
||||
|
@ -144,7 +144,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
|
|||
handleCreateError(ctx, ctxUser, err, "CreatePost", CREATE, &form)
|
||||
}
|
||||
|
||||
func Migrate(ctx *middleware.Context) {
|
||||
func Migrate(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_migrate")
|
||||
ctx.Data["private"] = ctx.User.LastRepoVisibility
|
||||
ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
|
||||
|
@ -159,7 +159,7 @@ func Migrate(ctx *middleware.Context) {
|
|||
ctx.HTML(200, MIGRATE)
|
||||
}
|
||||
|
||||
func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||
func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_migrate")
|
||||
|
||||
ctxUser := checkContextUser(ctx, form.Uid)
|
||||
|
@ -227,7 +227,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
|||
handleCreateError(ctx, ctxUser, err, "MigratePost", MIGRATE, &form)
|
||||
}
|
||||
|
||||
func Action(ctx *middleware.Context) {
|
||||
func Action(ctx *context.Context) {
|
||||
var err error
|
||||
switch ctx.Params(":action") {
|
||||
case "watch":
|
||||
|
@ -261,7 +261,7 @@ func Action(ctx *middleware.Context) {
|
|||
ctx.Redirect(redirectTo)
|
||||
}
|
||||
|
||||
func Download(ctx *middleware.Context) {
|
||||
func Download(ctx *context.Context) {
|
||||
var (
|
||||
uri = ctx.Params("*")
|
||||
refName string
|
||||
|
|
|
@ -13,9 +13,9 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -27,13 +27,13 @@ const (
|
|||
DEPLOY_KEYS base.TplName = "repo/settings/deploy_keys"
|
||||
)
|
||||
|
||||
func Settings(ctx *middleware.Context) {
|
||||
func Settings(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
||||
ctx.Data["PageIsSettingsOptions"] = true
|
||||
ctx.HTML(200, SETTINGS_OPTIONS)
|
||||
}
|
||||
|
||||
func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||
func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
||||
ctx.Data["PageIsSettingsOptions"] = true
|
||||
|
||||
|
@ -271,7 +271,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
|||
}
|
||||
}
|
||||
|
||||
func Collaboration(ctx *middleware.Context) {
|
||||
func Collaboration(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
||||
ctx.Data["PageIsSettingsCollaboration"] = true
|
||||
|
||||
|
@ -285,7 +285,7 @@ func Collaboration(ctx *middleware.Context) {
|
|||
ctx.HTML(200, COLLABORATION)
|
||||
}
|
||||
|
||||
func CollaborationPost(ctx *middleware.Context) {
|
||||
func CollaborationPost(ctx *context.Context) {
|
||||
name := strings.ToLower(ctx.Query("collaborator"))
|
||||
if len(name) == 0 || ctx.Repo.Owner.LowerName == name {
|
||||
ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path)
|
||||
|
@ -333,7 +333,7 @@ func CollaborationPost(ctx *middleware.Context) {
|
|||
ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path)
|
||||
}
|
||||
|
||||
func ChangeCollaborationAccessMode(ctx *middleware.Context) {
|
||||
func ChangeCollaborationAccessMode(ctx *context.Context) {
|
||||
if err := ctx.Repo.Repository.ChangeCollaborationAccessMode(
|
||||
ctx.QueryInt64("uid"),
|
||||
models.AccessMode(ctx.QueryInt("mode"))); err != nil {
|
||||
|
@ -341,7 +341,7 @@ func ChangeCollaborationAccessMode(ctx *middleware.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func DeleteCollaboration(ctx *middleware.Context) {
|
||||
func DeleteCollaboration(ctx *context.Context) {
|
||||
if err := ctx.Repo.Repository.DeleteCollaboration(ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteCollaboration: " + err.Error())
|
||||
} else {
|
||||
|
@ -353,7 +353,7 @@ func DeleteCollaboration(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func parseOwnerAndRepo(ctx *middleware.Context) (*models.User, *models.Repository) {
|
||||
func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository) {
|
||||
owner, err := models.GetUserByName(ctx.Params(":username"))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
@ -377,7 +377,7 @@ func parseOwnerAndRepo(ctx *middleware.Context) (*models.User, *models.Repositor
|
|||
return owner, repo
|
||||
}
|
||||
|
||||
func GitHooks(ctx *middleware.Context) {
|
||||
func GitHooks(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.githooks")
|
||||
ctx.Data["PageIsSettingsGitHooks"] = true
|
||||
|
||||
|
@ -391,7 +391,7 @@ func GitHooks(ctx *middleware.Context) {
|
|||
ctx.HTML(200, GITHOOKS)
|
||||
}
|
||||
|
||||
func GitHooksEdit(ctx *middleware.Context) {
|
||||
func GitHooksEdit(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.githooks")
|
||||
ctx.Data["PageIsSettingsGitHooks"] = true
|
||||
|
||||
|
@ -409,7 +409,7 @@ func GitHooksEdit(ctx *middleware.Context) {
|
|||
ctx.HTML(200, GITHOOK_EDIT)
|
||||
}
|
||||
|
||||
func GitHooksEditPost(ctx *middleware.Context) {
|
||||
func GitHooksEditPost(ctx *context.Context) {
|
||||
name := ctx.Params(":name")
|
||||
hook, err := ctx.Repo.GitRepo.GetHook(name)
|
||||
if err != nil {
|
||||
|
@ -428,7 +428,7 @@ func GitHooksEditPost(ctx *middleware.Context) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks/git")
|
||||
}
|
||||
|
||||
func DeployKeys(ctx *middleware.Context) {
|
||||
func DeployKeys(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.deploy_keys")
|
||||
ctx.Data["PageIsSettingsKeys"] = true
|
||||
|
||||
|
@ -442,7 +442,7 @@ func DeployKeys(ctx *middleware.Context) {
|
|||
ctx.HTML(200, DEPLOY_KEYS)
|
||||
}
|
||||
|
||||
func DeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
func DeployKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.deploy_keys")
|
||||
ctx.Data["PageIsSettingsKeys"] = true
|
||||
|
||||
|
@ -492,7 +492,7 @@ func DeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/keys")
|
||||
}
|
||||
|
||||
func DeleteDeployKey(ctx *middleware.Context) {
|
||||
func DeleteDeployKey(ctx *context.Context) {
|
||||
if err := models.DeleteDeployKey(ctx.User, ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteDeployKey: " + err.Error())
|
||||
} else {
|
||||
|
|
|
@ -16,9 +16,9 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/markdown"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/template"
|
||||
"github.com/gogits/gogs/modules/template/highlight"
|
||||
)
|
||||
|
@ -29,7 +29,7 @@ const (
|
|||
FORKS base.TplName = "repo/forks"
|
||||
)
|
||||
|
||||
func Home(ctx *middleware.Context) {
|
||||
func Home(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Repo.Repository.Name
|
||||
ctx.Data["PageIsViewCode"] = true
|
||||
ctx.Data["RequireHighlightJS"] = true
|
||||
|
@ -219,7 +219,7 @@ func Home(ctx *middleware.Context) {
|
|||
ctx.HTML(200, HOME)
|
||||
}
|
||||
|
||||
func RenderUserCards(ctx *middleware.Context, total int, getter func(page int) ([]*models.User, error), tpl base.TplName) {
|
||||
func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*models.User, error), tpl base.TplName) {
|
||||
page := ctx.QueryInt("page")
|
||||
if page <= 0 {
|
||||
page = 1
|
||||
|
@ -237,21 +237,21 @@ func RenderUserCards(ctx *middleware.Context, total int, getter func(page int) (
|
|||
ctx.HTML(200, tpl)
|
||||
}
|
||||
|
||||
func Watchers(ctx *middleware.Context) {
|
||||
func Watchers(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.watchers")
|
||||
ctx.Data["CardsTitle"] = ctx.Tr("repo.watchers")
|
||||
ctx.Data["PageIsWatchers"] = true
|
||||
RenderUserCards(ctx, ctx.Repo.Repository.NumWatches, ctx.Repo.Repository.GetWatchers, WATCHERS)
|
||||
}
|
||||
|
||||
func Stars(ctx *middleware.Context) {
|
||||
func Stars(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.stargazers")
|
||||
ctx.Data["CardsTitle"] = ctx.Tr("repo.stargazers")
|
||||
ctx.Data["PageIsStargazers"] = true
|
||||
RenderUserCards(ctx, ctx.Repo.Repository.NumStars, ctx.Repo.Repository.GetStargazers, WATCHERS)
|
||||
}
|
||||
|
||||
func Forks(ctx *middleware.Context) {
|
||||
func Forks(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repos.forks")
|
||||
|
||||
forks, err := ctx.Repo.Repository.GetForks()
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -28,7 +28,7 @@ const (
|
|||
ORG_HOOK_NEW base.TplName = "org/settings/hook_new"
|
||||
)
|
||||
|
||||
func Webhooks(ctx *middleware.Context) {
|
||||
func Webhooks(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.hooks")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["BaseLink"] = ctx.Repo.RepoLink
|
||||
|
@ -52,7 +52,7 @@ type OrgRepoCtx struct {
|
|||
}
|
||||
|
||||
// getOrgRepoCtx determines whether this is a repo context or organization context.
|
||||
func getOrgRepoCtx(ctx *middleware.Context) (*OrgRepoCtx, error) {
|
||||
func getOrgRepoCtx(ctx *context.Context) (*OrgRepoCtx, error) {
|
||||
if len(ctx.Repo.RepoLink) > 0 {
|
||||
return &OrgRepoCtx{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
|
@ -72,7 +72,7 @@ func getOrgRepoCtx(ctx *middleware.Context) (*OrgRepoCtx, error) {
|
|||
return nil, errors.New("Unable to set OrgRepo context")
|
||||
}
|
||||
|
||||
func checkHookType(ctx *middleware.Context) string {
|
||||
func checkHookType(ctx *context.Context) string {
|
||||
hookType := strings.ToLower(ctx.Params(":type"))
|
||||
if !com.IsSliceContainsStr(setting.Webhook.Types, hookType) {
|
||||
ctx.Handle(404, "checkHookType", nil)
|
||||
|
@ -81,7 +81,7 @@ func checkHookType(ctx *middleware.Context) string {
|
|||
return hookType
|
||||
}
|
||||
|
||||
func WebhooksNew(ctx *middleware.Context) {
|
||||
func WebhooksNew(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.add_webhook")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["PageIsSettingsHooksNew"] = true
|
||||
|
@ -114,7 +114,7 @@ func ParseHookEvent(form auth.WebhookForm) *models.HookEvent {
|
|||
}
|
||||
}
|
||||
|
||||
func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||
func WebHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.add_webhook")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["PageIsSettingsHooksNew"] = true
|
||||
|
@ -160,7 +160,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
|||
ctx.Redirect(orCtx.Link + "/settings/hooks")
|
||||
}
|
||||
|
||||
func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
||||
func SlackHooksNewPost(ctx *context.Context, form auth.NewSlackHookForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["PageIsSettingsHooksNew"] = true
|
||||
|
@ -210,7 +210,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
|||
ctx.Redirect(orCtx.Link + "/settings/hooks")
|
||||
}
|
||||
|
||||
func checkWebhook(ctx *middleware.Context) (*OrgRepoCtx, *models.Webhook) {
|
||||
func checkWebhook(ctx *context.Context) (*OrgRepoCtx, *models.Webhook) {
|
||||
ctx.Data["RequireHighlightJS"] = true
|
||||
|
||||
orCtx, err := getOrgRepoCtx(ctx)
|
||||
|
@ -245,7 +245,7 @@ func checkWebhook(ctx *middleware.Context) (*OrgRepoCtx, *models.Webhook) {
|
|||
return orCtx, w
|
||||
}
|
||||
|
||||
func WebHooksEdit(ctx *middleware.Context) {
|
||||
func WebHooksEdit(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.update_webhook")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["PageIsSettingsHooksEdit"] = true
|
||||
|
@ -259,7 +259,7 @@ func WebHooksEdit(ctx *middleware.Context) {
|
|||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
}
|
||||
|
||||
func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||
func WebHooksEditPost(ctx *context.Context, form auth.NewWebhookForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings.update_webhook")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["PageIsSettingsHooksEdit"] = true
|
||||
|
@ -297,7 +297,7 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
|||
ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, w.ID))
|
||||
}
|
||||
|
||||
func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
||||
func SlackHooksEditPost(ctx *context.Context, form auth.NewSlackHookForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
||||
ctx.Data["PageIsSettingsHooks"] = true
|
||||
ctx.Data["PageIsSettingsHooksEdit"] = true
|
||||
|
@ -340,7 +340,7 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
|||
ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, w.ID))
|
||||
}
|
||||
|
||||
func TestWebhook(ctx *middleware.Context) {
|
||||
func TestWebhook(ctx *context.Context) {
|
||||
p := &api.PushPayload{
|
||||
Ref: git.BRANCH_PREFIX + ctx.Repo.Repository.DefaultBranch,
|
||||
Before: ctx.Repo.CommitID,
|
||||
|
@ -378,7 +378,7 @@ func TestWebhook(ctx *middleware.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func DeleteWebhook(ctx *middleware.Context) {
|
||||
func DeleteWebhook(ctx *context.Context) {
|
||||
if err := models.DeleteWebhook(ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteWebhook: " + err.Error())
|
||||
} else {
|
||||
|
|
|
@ -14,8 +14,8 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/markdown"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -25,7 +25,7 @@ const (
|
|||
WIKI_PAGES base.TplName = "repo/wiki/pages"
|
||||
)
|
||||
|
||||
func MustEnableWiki(ctx *middleware.Context) {
|
||||
func MustEnableWiki(ctx *context.Context) {
|
||||
if !ctx.Repo.Repository.EnableWiki {
|
||||
ctx.Handle(404, "MustEnableWiki", nil)
|
||||
return
|
||||
|
@ -43,7 +43,7 @@ type PageMeta struct {
|
|||
Updated time.Time
|
||||
}
|
||||
|
||||
func renderWikiPage(ctx *middleware.Context, isViewPage bool) (*git.Repository, string) {
|
||||
func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, string) {
|
||||
wikiRepo, err := git.OpenRepository(ctx.Repo.Repository.WikiPath())
|
||||
if err != nil {
|
||||
ctx.Handle(500, "OpenRepository", err)
|
||||
|
@ -115,7 +115,7 @@ func renderWikiPage(ctx *middleware.Context, isViewPage bool) (*git.Repository,
|
|||
return wikiRepo, pageName
|
||||
}
|
||||
|
||||
func Wiki(ctx *middleware.Context) {
|
||||
func Wiki(ctx *context.Context) {
|
||||
ctx.Data["PageIsWiki"] = true
|
||||
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
|
@ -140,7 +140,7 @@ func Wiki(ctx *middleware.Context) {
|
|||
ctx.HTML(200, WIKI_VIEW)
|
||||
}
|
||||
|
||||
func WikiPages(ctx *middleware.Context) {
|
||||
func WikiPages(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki.pages")
|
||||
ctx.Data["PageIsWiki"] = true
|
||||
|
||||
|
@ -186,7 +186,7 @@ func WikiPages(ctx *middleware.Context) {
|
|||
ctx.HTML(200, WIKI_PAGES)
|
||||
}
|
||||
|
||||
func NewWiki(ctx *middleware.Context) {
|
||||
func NewWiki(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
|
||||
ctx.Data["PageIsWiki"] = true
|
||||
ctx.Data["RequireSimpleMDE"] = true
|
||||
|
@ -198,7 +198,7 @@ func NewWiki(ctx *middleware.Context) {
|
|||
ctx.HTML(200, WIKI_NEW)
|
||||
}
|
||||
|
||||
func NewWikiPost(ctx *middleware.Context, form auth.NewWikiForm) {
|
||||
func NewWikiPost(ctx *context.Context, form auth.NewWikiForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
|
||||
ctx.Data["PageIsWiki"] = true
|
||||
ctx.Data["RequireSimpleMDE"] = true
|
||||
|
@ -221,7 +221,7 @@ func NewWikiPost(ctx *middleware.Context, form auth.NewWikiForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.ToWikiPageURL(form.Title))
|
||||
}
|
||||
|
||||
func EditWiki(ctx *middleware.Context) {
|
||||
func EditWiki(ctx *context.Context) {
|
||||
ctx.Data["PageIsWiki"] = true
|
||||
ctx.Data["PageIsWikiEdit"] = true
|
||||
ctx.Data["RequireSimpleMDE"] = true
|
||||
|
@ -239,7 +239,7 @@ func EditWiki(ctx *middleware.Context) {
|
|||
ctx.HTML(200, WIKI_NEW)
|
||||
}
|
||||
|
||||
func EditWikiPost(ctx *middleware.Context, form auth.NewWikiForm) {
|
||||
func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
|
||||
ctx.Data["PageIsWiki"] = true
|
||||
ctx.Data["RequireSimpleMDE"] = true
|
||||
|
@ -257,7 +257,7 @@ func EditWikiPost(ctx *middleware.Context, form auth.NewWikiForm) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.ToWikiPageURL(form.Title))
|
||||
}
|
||||
|
||||
func DeleteWikiPagePost(ctx *middleware.Context) {
|
||||
func DeleteWikiPagePost(ctx *context.Context) {
|
||||
pageURL := ctx.Params(":page")
|
||||
if len(pageURL) == 0 {
|
||||
pageURL = "Home"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/go-macaron/captcha"
|
||||
|
@ -12,9 +13,9 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -26,11 +27,50 @@ const (
|
|||
RESET_PASSWORD base.TplName = "user/auth/reset_passwd"
|
||||
)
|
||||
|
||||
func SignIn(ctx *middleware.Context) {
|
||||
// AutoSignIn reads cookie and try to auto-login.
|
||||
func AutoSignIn(ctx *context.Context) (bool, error) {
|
||||
if !models.HasEngine {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
uname := ctx.GetCookie(setting.CookieUserName)
|
||||
if len(uname) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
isSucceed := false
|
||||
defer func() {
|
||||
if !isSucceed {
|
||||
log.Trace("auto-login cookie cleared: %s", uname)
|
||||
ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl)
|
||||
ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl)
|
||||
}
|
||||
}()
|
||||
|
||||
u, err := models.GetUserByName(uname)
|
||||
if err != nil {
|
||||
if !models.IsErrUserNotExist(err) {
|
||||
return false, fmt.Errorf("GetUserByName: %v", err)
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if val, _ := ctx.GetSuperSecureCookie(
|
||||
base.EncodeMD5(u.Rands+u.Passwd), setting.CookieRememberName); val != u.Name {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
isSucceed = true
|
||||
ctx.Session.Set("uid", u.Id)
|
||||
ctx.Session.Set("uname", u.Name)
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func SignIn(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("sign_in")
|
||||
|
||||
// Check auto-login.
|
||||
isSucceed, err := middleware.AutoSignIn(ctx)
|
||||
isSucceed, err := AutoSignIn(ctx)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "AutoSignIn", err)
|
||||
return
|
||||
|
@ -49,7 +89,7 @@ func SignIn(ctx *middleware.Context) {
|
|||
ctx.HTML(200, SIGNIN)
|
||||
}
|
||||
|
||||
func SignInPost(ctx *middleware.Context, form auth.SignInForm) {
|
||||
func SignInPost(ctx *context.Context, form auth.SignInForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("sign_in")
|
||||
|
||||
if ctx.HasError() {
|
||||
|
@ -85,7 +125,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/")
|
||||
}
|
||||
|
||||
func SignOut(ctx *middleware.Context) {
|
||||
func SignOut(ctx *context.Context) {
|
||||
ctx.Session.Delete("uid")
|
||||
ctx.Session.Delete("uname")
|
||||
ctx.Session.Delete("socialId")
|
||||
|
@ -96,7 +136,7 @@ func SignOut(ctx *middleware.Context) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/")
|
||||
}
|
||||
|
||||
func SignUp(ctx *middleware.Context) {
|
||||
func SignUp(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("sign_up")
|
||||
|
||||
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
|
||||
|
@ -110,7 +150,7 @@ func SignUp(ctx *middleware.Context) {
|
|||
ctx.HTML(200, SIGNUP)
|
||||
}
|
||||
|
||||
func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.RegisterForm) {
|
||||
func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("sign_up")
|
||||
|
||||
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
|
||||
|
@ -191,7 +231,7 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe
|
|||
ctx.Redirect(setting.AppSubUrl + "/user/login")
|
||||
}
|
||||
|
||||
func Activate(ctx *middleware.Context) {
|
||||
func Activate(ctx *context.Context) {
|
||||
code := ctx.Query("code")
|
||||
if len(code) == 0 {
|
||||
ctx.Data["IsActivatePage"] = true
|
||||
|
@ -243,7 +283,7 @@ func Activate(ctx *middleware.Context) {
|
|||
ctx.HTML(200, ACTIVATE)
|
||||
}
|
||||
|
||||
func ActivateEmail(ctx *middleware.Context) {
|
||||
func ActivateEmail(ctx *context.Context) {
|
||||
code := ctx.Query("code")
|
||||
email_string := ctx.Query("email")
|
||||
|
||||
|
@ -261,7 +301,7 @@ func ActivateEmail(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
func ForgotPasswd(ctx *middleware.Context) {
|
||||
func ForgotPasswd(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.forgot_password")
|
||||
|
||||
if setting.MailService == nil {
|
||||
|
@ -274,7 +314,7 @@ func ForgotPasswd(ctx *middleware.Context) {
|
|||
ctx.HTML(200, FORGOT_PASSWORD)
|
||||
}
|
||||
|
||||
func ForgotPasswdPost(ctx *middleware.Context) {
|
||||
func ForgotPasswdPost(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.forgot_password")
|
||||
|
||||
if setting.MailService == nil {
|
||||
|
@ -313,7 +353,7 @@ func ForgotPasswdPost(ctx *middleware.Context) {
|
|||
ctx.HTML(200, FORGOT_PASSWORD)
|
||||
}
|
||||
|
||||
func ResetPasswd(ctx *middleware.Context) {
|
||||
func ResetPasswd(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.reset_password")
|
||||
|
||||
code := ctx.Query("code")
|
||||
|
@ -326,7 +366,7 @@ func ResetPasswd(ctx *middleware.Context) {
|
|||
ctx.HTML(200, RESET_PASSWORD)
|
||||
}
|
||||
|
||||
func ResetPasswdPost(ctx *middleware.Context) {
|
||||
func ResetPasswdPost(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.reset_password")
|
||||
|
||||
code := ctx.Query("code")
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -24,7 +24,7 @@ const (
|
|||
ORG_HOME base.TplName = "org/home"
|
||||
)
|
||||
|
||||
func getDashboardContextUser(ctx *middleware.Context) *models.User {
|
||||
func getDashboardContextUser(ctx *context.Context) *models.User {
|
||||
ctxUser := ctx.User
|
||||
orgName := ctx.Params(":org")
|
||||
if len(orgName) > 0 {
|
||||
|
@ -51,7 +51,7 @@ func getDashboardContextUser(ctx *middleware.Context) *models.User {
|
|||
return ctxUser
|
||||
}
|
||||
|
||||
func retrieveFeeds(ctx *middleware.Context, ctxUserID, userID, offset int64, isProfile bool) {
|
||||
func retrieveFeeds(ctx *context.Context, ctxUserID, userID, offset int64, isProfile bool) {
|
||||
actions, err := models.GetFeeds(ctxUserID, userID, offset, isProfile)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "GetFeeds", err)
|
||||
|
@ -82,7 +82,7 @@ func retrieveFeeds(ctx *middleware.Context, ctxUserID, userID, offset int64, isP
|
|||
ctx.Data["Feeds"] = feeds
|
||||
}
|
||||
|
||||
func Dashboard(ctx *middleware.Context) {
|
||||
func Dashboard(ctx *context.Context) {
|
||||
ctxUser := getDashboardContextUser(ctx)
|
||||
ctx.Data["Title"] = ctxUser.DisplayName() + " - " + ctx.Tr("dashboard")
|
||||
ctx.Data["PageIsDashboard"] = true
|
||||
|
@ -147,7 +147,7 @@ func Dashboard(ctx *middleware.Context) {
|
|||
ctx.HTML(200, DASHBOARD)
|
||||
}
|
||||
|
||||
func Issues(ctx *middleware.Context) {
|
||||
func Issues(ctx *context.Context) {
|
||||
isPullList := ctx.Params(":type") == "pulls"
|
||||
if isPullList {
|
||||
ctx.Data["Title"] = ctx.Tr("pull_requests")
|
||||
|
@ -306,7 +306,7 @@ func Issues(ctx *middleware.Context) {
|
|||
ctx.HTML(200, ISSUES)
|
||||
}
|
||||
|
||||
func ShowSSHKeys(ctx *middleware.Context, uid int64) {
|
||||
func ShowSSHKeys(ctx *context.Context, uid int64) {
|
||||
keys, err := models.ListPublicKeys(uid)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "ListPublicKeys", err)
|
||||
|
@ -321,9 +321,9 @@ func ShowSSHKeys(ctx *middleware.Context, uid int64) {
|
|||
ctx.PlainText(200, buf.Bytes())
|
||||
}
|
||||
|
||||
func showOrgProfile(ctx *middleware.Context) {
|
||||
func showOrgProfile(ctx *context.Context) {
|
||||
ctx.SetParams(":org", ctx.Params(":username"))
|
||||
middleware.HandleOrgAssignment(ctx)
|
||||
context.HandleOrgAssignment(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ func showOrgProfile(ctx *middleware.Context) {
|
|||
ctx.HTML(200, ORG_HOME)
|
||||
}
|
||||
|
||||
func Email2User(ctx *middleware.Context) {
|
||||
func Email2User(ctx *context.Context) {
|
||||
u, err := models.GetUserByEmail(ctx.Query("email"))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
"github.com/gogits/gogs/routers/repo"
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ const (
|
|||
STARS base.TplName = "user/meta/stars"
|
||||
)
|
||||
|
||||
func GetUserByName(ctx *middleware.Context, name string) *models.User {
|
||||
func GetUserByName(ctx *context.Context, name string) *models.User {
|
||||
user, err := models.GetUserByName(name)
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
@ -35,11 +35,11 @@ func GetUserByName(ctx *middleware.Context, name string) *models.User {
|
|||
}
|
||||
|
||||
// GetUserByParams returns user whose name is presented in URL paramenter.
|
||||
func GetUserByParams(ctx *middleware.Context) *models.User {
|
||||
func GetUserByParams(ctx *context.Context) *models.User {
|
||||
return GetUserByName(ctx, ctx.Params(":username"))
|
||||
}
|
||||
|
||||
func Profile(ctx *middleware.Context) {
|
||||
func Profile(ctx *context.Context) {
|
||||
uname := ctx.Params(":username")
|
||||
// Special handle for FireFox requests favicon.ico.
|
||||
if uname == "favicon.ico" {
|
||||
|
@ -103,7 +103,7 @@ func Profile(ctx *middleware.Context) {
|
|||
ctx.HTML(200, PROFILE)
|
||||
}
|
||||
|
||||
func Followers(ctx *middleware.Context) {
|
||||
func Followers(ctx *context.Context) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -115,7 +115,7 @@ func Followers(ctx *middleware.Context) {
|
|||
repo.RenderUserCards(ctx, u.NumFollowers, u.GetFollowers, FOLLOWERS)
|
||||
}
|
||||
|
||||
func Following(ctx *middleware.Context) {
|
||||
func Following(ctx *context.Context) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -127,11 +127,11 @@ func Following(ctx *middleware.Context) {
|
|||
repo.RenderUserCards(ctx, u.NumFollowing, u.GetFollowing, FOLLOWERS)
|
||||
}
|
||||
|
||||
func Stars(ctx *middleware.Context) {
|
||||
func Stars(ctx *context.Context) {
|
||||
|
||||
}
|
||||
|
||||
func Action(ctx *middleware.Context) {
|
||||
func Action(ctx *context.Context) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
|
|
@ -15,9 +15,9 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/context"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -33,13 +33,13 @@ const (
|
|||
SECURITY base.TplName = "user/security"
|
||||
)
|
||||
|
||||
func Settings(ctx *middleware.Context) {
|
||||
func Settings(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsProfile"] = true
|
||||
ctx.HTML(200, SETTINGS_PROFILE)
|
||||
}
|
||||
|
||||
func handleUsernameChange(ctx *middleware.Context, newName string) {
|
||||
func handleUsernameChange(ctx *context.Context, newName string) {
|
||||
// Non-local users are not allowed to change their username.
|
||||
if len(newName) == 0 || !ctx.User.IsLocal() {
|
||||
return
|
||||
|
@ -74,7 +74,7 @@ func handleUsernameChange(ctx *middleware.Context, newName string) {
|
|||
ctx.User.LowerName = strings.ToLower(newName)
|
||||
}
|
||||
|
||||
func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||
func SettingsPost(ctx *context.Context, form auth.UpdateProfileForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsProfile"] = true
|
||||
|
||||
|
@ -107,7 +107,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
|||
}
|
||||
|
||||
// FIXME: limit size.
|
||||
func UpdateAvatarSetting(ctx *middleware.Context, form auth.UploadAvatarForm, ctxUser *models.User) error {
|
||||
func UpdateAvatarSetting(ctx *context.Context, form auth.UploadAvatarForm, ctxUser *models.User) error {
|
||||
ctxUser.UseCustomAvatar = form.Enable
|
||||
|
||||
if form.Avatar != nil {
|
||||
|
@ -144,7 +144,7 @@ func UpdateAvatarSetting(ctx *middleware.Context, form auth.UploadAvatarForm, ct
|
|||
return nil
|
||||
}
|
||||
|
||||
func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
|
||||
func SettingsAvatar(ctx *context.Context, form auth.UploadAvatarForm) {
|
||||
if err := UpdateAvatarSetting(ctx, form, ctx.User); err != nil {
|
||||
ctx.Flash.Error(err.Error())
|
||||
} else {
|
||||
|
@ -154,7 +154,7 @@ func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/user/settings")
|
||||
}
|
||||
|
||||
func SettingsDeleteAvatar(ctx *middleware.Context) {
|
||||
func SettingsDeleteAvatar(ctx *context.Context) {
|
||||
if err := ctx.User.DeleteAvatar(); err != nil {
|
||||
ctx.Flash.Error(err.Error())
|
||||
}
|
||||
|
@ -162,13 +162,13 @@ func SettingsDeleteAvatar(ctx *middleware.Context) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/user/settings")
|
||||
}
|
||||
|
||||
func SettingsPassword(ctx *middleware.Context) {
|
||||
func SettingsPassword(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsPassword"] = true
|
||||
ctx.HTML(200, SETTINGS_PASSWORD)
|
||||
}
|
||||
|
||||
func SettingsPasswordPost(ctx *middleware.Context, form auth.ChangePasswordForm) {
|
||||
func SettingsPasswordPost(ctx *context.Context, form auth.ChangePasswordForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsPassword"] = true
|
||||
|
||||
|
@ -196,7 +196,7 @@ func SettingsPasswordPost(ctx *middleware.Context, form auth.ChangePasswordForm)
|
|||
ctx.Redirect(setting.AppSubUrl + "/user/settings/password")
|
||||
}
|
||||
|
||||
func SettingsEmails(ctx *middleware.Context) {
|
||||
func SettingsEmails(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsEmails"] = true
|
||||
|
||||
|
@ -210,7 +210,7 @@ func SettingsEmails(ctx *middleware.Context) {
|
|||
ctx.HTML(200, SETTINGS_EMAILS)
|
||||
}
|
||||
|
||||
func SettingsEmailPost(ctx *middleware.Context, form auth.AddEmailForm) {
|
||||
func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsEmails"] = true
|
||||
|
||||
|
@ -269,7 +269,7 @@ func SettingsEmailPost(ctx *middleware.Context, form auth.AddEmailForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/user/settings/email")
|
||||
}
|
||||
|
||||
func DeleteEmail(ctx *middleware.Context) {
|
||||
func DeleteEmail(ctx *context.Context) {
|
||||
if err := models.DeleteEmailAddress(&models.EmailAddress{ID: ctx.QueryInt64("id")}); err != nil {
|
||||
ctx.Handle(500, "DeleteEmail", err)
|
||||
return
|
||||
|
@ -282,7 +282,7 @@ func DeleteEmail(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func SettingsSSHKeys(ctx *middleware.Context) {
|
||||
func SettingsSSHKeys(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsSSHKeys"] = true
|
||||
|
||||
|
@ -296,7 +296,7 @@ func SettingsSSHKeys(ctx *middleware.Context) {
|
|||
ctx.HTML(200, SETTINGS_SSH_KEYS)
|
||||
}
|
||||
|
||||
func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
func SettingsSSHKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsSSHKeys"] = true
|
||||
|
||||
|
@ -342,7 +342,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh")
|
||||
}
|
||||
|
||||
func DeleteSSHKey(ctx *middleware.Context) {
|
||||
func DeleteSSHKey(ctx *context.Context) {
|
||||
if err := models.DeletePublicKey(ctx.User, ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeletePublicKey: " + err.Error())
|
||||
} else {
|
||||
|
@ -354,7 +354,7 @@ func DeleteSSHKey(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func SettingsApplications(ctx *middleware.Context) {
|
||||
func SettingsApplications(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsApplications"] = true
|
||||
|
||||
|
@ -368,7 +368,7 @@ func SettingsApplications(ctx *middleware.Context) {
|
|||
ctx.HTML(200, SETTINGS_APPLICATIONS)
|
||||
}
|
||||
|
||||
func SettingsApplicationsPost(ctx *middleware.Context, form auth.NewAccessTokenForm) {
|
||||
func SettingsApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsApplications"] = true
|
||||
|
||||
|
@ -398,7 +398,7 @@ func SettingsApplicationsPost(ctx *middleware.Context, form auth.NewAccessTokenF
|
|||
ctx.Redirect(setting.AppSubUrl + "/user/settings/applications")
|
||||
}
|
||||
|
||||
func SettingsDeleteApplication(ctx *middleware.Context) {
|
||||
func SettingsDeleteApplication(ctx *context.Context) {
|
||||
if err := models.DeleteAccessTokenByID(ctx.QueryInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteAccessTokenByID: " + err.Error())
|
||||
} else {
|
||||
|
@ -410,7 +410,7 @@ func SettingsDeleteApplication(ctx *middleware.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func SettingsDelete(ctx *middleware.Context) {
|
||||
func SettingsDelete(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("settings")
|
||||
ctx.Data["PageIsSettingsDelete"] = true
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.9.4.0311
|
||||
0.9.5.0311
|
Loading…
Reference in a new issue