mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-25 19:26:09 +01:00
add some comment
This commit is contained in:
parent
76644c2fcc
commit
ccd43b09b2
|
@ -22,8 +22,8 @@ const (
|
|||
// Action represents user operation type and information to the repository.
|
||||
type Action struct {
|
||||
Id int64
|
||||
UserId int64 // Receiver user id.
|
||||
OpType int
|
||||
UserId int64 // Receiver user id.
|
||||
OpType int // Operations: CREATE DELETE STAR ...
|
||||
ActUserId int64 // Action user id.
|
||||
ActUserName string // Action user name.
|
||||
RepoId int64
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
// render user setting page (email, website modify)
|
||||
func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||
ctx.Data["Title"] = "Setting"
|
||||
ctx.Data["PageIsUserSetting"] = true
|
||||
|
@ -26,6 +27,7 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
|||
return
|
||||
}
|
||||
|
||||
// below is for POST requests
|
||||
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
|
||||
ctx.Render.HTML(200, "user/setting", ctx.Data)
|
||||
return
|
||||
|
|
|
@ -10,8 +10,7 @@ import (
|
|||
|
||||
"github.com/codegangsta/cli"
|
||||
|
||||
git "github.com/gogits/git"
|
||||
|
||||
"github.com/gogits/git"
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
)
|
||||
|
@ -25,6 +24,7 @@ gogs serv provide access auth for repositories`,
|
|||
Flags: []cli.Flag{},
|
||||
}
|
||||
|
||||
// for command: ./gogs update
|
||||
func runUpdate(*cli.Context) {
|
||||
userName := os.Getenv("userName")
|
||||
userId := os.Getenv("userId")
|
||||
|
|
58
web.go
58
web.go
|
@ -61,48 +61,52 @@ func runWeb(*cli.Context) {
|
|||
|
||||
m.Use(middleware.InitContext())
|
||||
|
||||
ignSignIn := middleware.SignInRequire(false)
|
||||
reqSignIn, reqSignOut := middleware.SignInRequire(true), middleware.SignOutRequire()
|
||||
// Routers.
|
||||
m.Get("/", middleware.SignInRequire(false), routers.Home)
|
||||
m.Get("/issues", middleware.SignInRequire(true), user.Issues)
|
||||
m.Get("/pulls", middleware.SignInRequire(true), user.Pulls)
|
||||
m.Get("/stars", middleware.SignInRequire(true), user.Stars)
|
||||
m.Any("/user/login", middleware.SignOutRequire(), binding.BindIgnErr(auth.LogInForm{}), user.SignIn)
|
||||
m.Any("/user/logout", middleware.SignInRequire(true), user.SignOut)
|
||||
m.Any("/user/sign_up", middleware.SignOutRequire(), binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
||||
m.Any("/user/delete", middleware.SignInRequire(true), user.Delete)
|
||||
m.Get("/", ignSignIn, routers.Home)
|
||||
m.Get("/issues", reqSignIn, user.Issues)
|
||||
m.Get("/pulls", reqSignIn, user.Pulls)
|
||||
m.Get("/stars", reqSignIn, user.Stars)
|
||||
m.Any("/user/login", reqSignOut, binding.BindIgnErr(auth.LogInForm{}), user.SignIn)
|
||||
m.Any("/user/logout", reqSignIn, user.SignOut)
|
||||
m.Any("/user/sign_up", reqSignOut, binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
||||
m.Any("/user/delete", reqSignIn, user.Delete)
|
||||
m.Get("/user/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
|
||||
|
||||
m.Any("/user/setting", middleware.SignInRequire(true), binding.BindIgnErr(auth.UpdateProfileForm{}), user.Setting)
|
||||
m.Any("/user/setting/password", middleware.SignInRequire(true), binding.BindIgnErr(auth.UpdatePasswdForm{}), user.SettingPassword)
|
||||
m.Any("/user/setting/ssh", middleware.SignInRequire(true), binding.BindIgnErr(auth.AddSSHKeyForm{}), user.SettingSSHKeys)
|
||||
m.Any("/user/setting/notification", middleware.SignInRequire(true), user.SettingNotification)
|
||||
m.Any("/user/setting/security", middleware.SignInRequire(true), user.SettingSecurity)
|
||||
m.Any("/user/setting", reqSignIn, binding.BindIgnErr(auth.UpdateProfileForm{}), user.Setting)
|
||||
m.Any("/user/setting/password", reqSignIn, binding.BindIgnErr(auth.UpdatePasswdForm{}), user.SettingPassword)
|
||||
m.Any("/user/setting/ssh", reqSignIn, binding.BindIgnErr(auth.AddSSHKeyForm{}), user.SettingSSHKeys)
|
||||
m.Any("/user/setting/notification", reqSignIn, user.SettingNotification)
|
||||
m.Any("/user/setting/security", reqSignIn, user.SettingSecurity)
|
||||
|
||||
m.Get("/user/:username", middleware.SignInRequire(false), user.Profile)
|
||||
m.Get("/user/:username", ignSignIn, user.Profile)
|
||||
|
||||
m.Any("/repo/create", middleware.SignInRequire(true), binding.BindIgnErr(auth.CreateRepoForm{}), repo.Create)
|
||||
m.Any("/repo/create", reqSignIn, binding.BindIgnErr(auth.CreateRepoForm{}), repo.Create)
|
||||
|
||||
m.Get("/help", routers.Help)
|
||||
|
||||
m.Post("/:username/:reponame/settings", middleware.SignInRequire(true), middleware.RepoAssignment(true), repo.SettingPost)
|
||||
m.Get("/:username/:reponame/settings", middleware.SignInRequire(true), middleware.RepoAssignment(true), repo.Setting)
|
||||
m.Post("/:username/:reponame/settings", reqSignIn, middleware.RepoAssignment(true), repo.SettingPost)
|
||||
m.Get("/:username/:reponame/settings", reqSignIn, middleware.RepoAssignment(true), repo.Setting)
|
||||
|
||||
m.Get("/:username/:reponame/commits/:branchname", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Commits)
|
||||
m.Get("/:username/:reponame/issues", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Issues)
|
||||
m.Get("/:username/:reponame/pulls", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Pulls)
|
||||
m.Get("/:username/:reponame/branches", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Branches)
|
||||
m.Get("/:username/:reponame/commits/:branchname", ignSignIn, middleware.RepoAssignment(true), repo.Commits)
|
||||
m.Get("/:username/:reponame/issues", ignSignIn, middleware.RepoAssignment(true), repo.Issues)
|
||||
m.Get("/:username/:reponame/pulls", ignSignIn, middleware.RepoAssignment(true), repo.Pulls)
|
||||
m.Get("/:username/:reponame/branches", ignSignIn, middleware.RepoAssignment(true), repo.Branches)
|
||||
m.Get("/:username/:reponame/tree/:branchname/**",
|
||||
middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
||||
ignSignIn, middleware.RepoAssignment(true), repo.Single)
|
||||
m.Get("/:username/:reponame/tree/:branchname",
|
||||
middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
||||
m.Get("/:username/:reponame/commit/:commitid/**", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
||||
m.Get("/:username/:reponame/commit/:commitid", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
||||
ignSignIn, middleware.RepoAssignment(true), repo.Single)
|
||||
m.Get("/:username/:reponame/commit/:commitid/**", ignSignIn, middleware.RepoAssignment(true), repo.Single)
|
||||
m.Get("/:username/:reponame/commit/:commitid", ignSignIn, middleware.RepoAssignment(true), repo.Single)
|
||||
|
||||
m.Get("/:username/:reponame", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
||||
m.Get("/:username/:reponame", ignSignIn, middleware.RepoAssignment(true), repo.Single)
|
||||
|
||||
listenAddr := fmt.Sprintf("%s:%s",
|
||||
base.Cfg.MustValue("server", "HTTP_ADDR"),
|
||||
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
||||
log.Info("Listen: %s", listenAddr)
|
||||
http.ListenAndServe(listenAddr, m)
|
||||
if err := http.ListenAndServe(listenAddr, m); err != nil {
|
||||
log.Critical(err.Error())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue