Work on admin

This commit is contained in:
Unknown 2014-03-20 07:50:26 -04:00
parent 5cb2d3d2e2
commit 9f9cd6bfc6
19 changed files with 177 additions and 41 deletions

4
.gitignore vendored
View file

@ -5,4 +5,6 @@ gogs
*.db *.db
*.log *.log
custom/ custom/
.vendor/ .vendor/
.idea/
*.iml

View file

@ -27,6 +27,10 @@ PASSWD =
; For "postgres" only, either "disable", "require" or "verify-full" ; For "postgres" only, either "disable", "require" or "verify-full"
SSL_MODE = disable SSL_MODE = disable
[admin]
; Administor's name, which should be same as the user name you want to authorize
NAME = admin
[security] [security]
; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!! ; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!!
SECRET_KEY = !#@FDEWREWR&*( SECRET_KEY = !#@FDEWREWR&*(

View file

@ -51,6 +51,7 @@ type User struct {
Location string Location string
Website string Website string
IsActive bool IsActive bool
IsAdmin bool
Rands string `xorm:"VARCHAR(10)"` Rands string `xorm:"VARCHAR(10)"`
Created time.Time `xorm:"created"` Created time.Time `xorm:"created"`
Updated time.Time `xorm:"updated"` Updated time.Time `xorm:"updated"`

View file

@ -32,6 +32,7 @@ var (
AppUrl string AppUrl string
Domain string Domain string
SecretKey string SecretKey string
AdminName string
Cfg *goconfig.ConfigFile Cfg *goconfig.ConfigFile
MailService *Mailer MailService *Mailer
) )
@ -173,6 +174,7 @@ func init() {
AppUrl = Cfg.MustValue("server", "ROOT_URL") AppUrl = Cfg.MustValue("server", "ROOT_URL")
Domain = Cfg.MustValue("server", "DOMAIN") Domain = Cfg.MustValue("server", "DOMAIN")
SecretKey = Cfg.MustValue("security", "SECRET_KEY") SecretKey = Cfg.MustValue("security", "SECRET_KEY")
AdminName = strings.ToLower(Cfg.MustValue("admin", "NAME"))
} }
func NewServices() { func NewServices() {

View file

@ -20,7 +20,7 @@ func SignInRequire(redirect bool) martini.Handler {
return return
} else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm { } else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm {
ctx.Data["Title"] = "Activate Your Account" ctx.Data["Title"] = "Activate Your Account"
ctx.Render.HTML(200, "user/active", ctx.Data) ctx.HTML(200, "user/active")
return return
} }
} }
@ -31,6 +31,18 @@ func SignOutRequire() martini.Handler {
return func(ctx *Context) { return func(ctx *Context) {
if ctx.IsSigned { if ctx.IsSigned {
ctx.Redirect("/") ctx.Redirect("/")
return
} }
} }
} }
// AdminRequire requires user signed in as administor.
func AdminRequire() martini.Handler {
return func(ctx *Context) {
if ctx.User.LowerName != base.AdminName && !ctx.User.IsAdmin {
ctx.Error(403)
return
}
ctx.Data["PageIsAdmin"] = true
}
}

View file

@ -14,6 +14,7 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/log"
) )
@ -61,24 +62,29 @@ func (ctx *Context) HasError() bool {
return hasErr.(bool) return hasErr.(bool)
} }
// HTML calls render.HTML underlying but reduce one argument.
func (ctx *Context) HTML(status int, name string, htmlOpt ...HTMLOptions) {
ctx.Render.HTML(status, name, ctx.Data, htmlOpt...)
}
// RenderWithErr used for page has form validation but need to prompt error to users. // RenderWithErr used for page has form validation but need to prompt error to users.
func (ctx *Context) RenderWithErr(msg, tpl string, form auth.Form) { func (ctx *Context) RenderWithErr(msg, tpl string, form auth.Form) {
ctx.Data["HasError"] = true ctx.Data["HasError"] = true
ctx.Data["ErrorMsg"] = msg ctx.Data["ErrorMsg"] = msg
auth.AssignForm(form, ctx.Data) auth.AssignForm(form, ctx.Data)
ctx.HTML(200, tpl, ctx.Data) ctx.HTML(200, tpl)
} }
// Handle handles and logs error by given status. // Handle handles and logs error by given status.
func (ctx *Context) Handle(status int, title string, err error) { func (ctx *Context) Handle(status int, title string, err error) {
log.Error("%s: %v", title, err) log.Error("%s: %v", title, err)
if martini.Dev == martini.Prod { if martini.Dev == martini.Prod {
ctx.HTML(500, "status/500", ctx.Data) ctx.HTML(500, "status/500")
return return
} }
ctx.Data["ErrorMsg"] = err ctx.Data["ErrorMsg"] = err
ctx.HTML(status, fmt.Sprintf("status/%d", status), ctx.Data) ctx.HTML(status, fmt.Sprintf("status/%d", status))
} }
// InitContext initializes a classic context for a request. // InitContext initializes a classic context for a request.
@ -106,6 +112,10 @@ func InitContext() martini.Handler {
ctx.Data["SignedUser"] = user ctx.Data["SignedUser"] = user
ctx.Data["SignedUserId"] = user.Id ctx.Data["SignedUserId"] = user.Id
ctx.Data["SignedUserName"] = user.LowerName ctx.Data["SignedUserName"] = user.LowerName
if ctx.User.IsAdmin || ctx.User.LowerName == base.AdminName {
ctx.Data["IsAdmin"] = true
}
} }
ctx.Data["PageStartTime"] = time.Now() ctx.Data["PageStartTime"] = time.Now()

24
routers/admin/admin.go Normal file
View file

@ -0,0 +1,24 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package admin
import (
"github.com/gogits/gogs/modules/middleware"
)
func Dashboard(ctx *middleware.Context) {
ctx.Data["Title"] = "Admin Dashboard"
ctx.HTML(200, "admin/dashboard")
}
func Users(ctx *middleware.Context) {
ctx.Data["Title"] = "User Management"
ctx.HTML(200, "admin/users")
}
func Repositories(ctx *middleware.Context) {
ctx.Data["Title"] = "Repository Management"
ctx.HTML(200, "admin/repos")
}

View file

@ -15,10 +15,10 @@ func Home(ctx *middleware.Context) {
return return
} }
ctx.Data["PageIsHome"] = true ctx.Data["PageIsHome"] = true
ctx.HTML(200, "home", ctx.Data) ctx.HTML(200, "home")
} }
func Help(ctx *middleware.Context) { func Help(ctx *middleware.Context) {
ctx.Data["PageIsHelp"] = true ctx.Data["PageIsHelp"] = true
ctx.HTML(200, "help", ctx.Data) ctx.HTML(200, "help")
} }

View file

@ -21,5 +21,5 @@ func TemplatePreview(ctx *middleware.Context, params martini.Params) {
ctx.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374" ctx.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374"
ctx.Data["ActiveCodeLives"] = base.Service.ActiveCodeLives / 60 ctx.Data["ActiveCodeLives"] = base.Service.ActiveCodeLives / 60
ctx.Data["ResetPwdCodeLives"] = base.Service.ResetPwdCodeLives / 60 ctx.Data["ResetPwdCodeLives"] = base.Service.ResetPwdCodeLives / 60
ctx.HTML(200, params["_1"], ctx.Data) ctx.HTML(200, params["_1"])
} }

View file

@ -18,7 +18,7 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) {
ctx.Data["Licenses"] = models.Licenses ctx.Data["Licenses"] = models.Licenses
if ctx.Req.Method == "GET" { if ctx.Req.Method == "GET" {
ctx.HTML(200, "repo/create", ctx.Data) ctx.HTML(200, "repo/create")
return return
} }
@ -45,7 +45,7 @@ func SettingPost(ctx *middleware.Context) {
case "delete": case "delete":
if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") { if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") {
ctx.Data["ErrorMsg"] = "Please make sure you entered repository name is correct." ctx.Data["ErrorMsg"] = "Please make sure you entered repository name is correct."
ctx.HTML(200, "repo/setting", ctx.Data) ctx.HTML(200, "repo/setting")
return return
} }

View file

@ -38,7 +38,7 @@ func Branches(ctx *middleware.Context, params martini.Params) {
ctx.Data["Branches"] = brs ctx.Data["Branches"] = brs
ctx.Data["IsRepoToolbarBranches"] = true ctx.Data["IsRepoToolbarBranches"] = true
ctx.HTML(200, "repo/branches", ctx.Data) ctx.HTML(200, "repo/branches")
} }
func Single(ctx *middleware.Context, params martini.Params) { func Single(ctx *middleware.Context, params martini.Params) {
@ -67,7 +67,7 @@ func Single(ctx *middleware.Context, params martini.Params) {
return return
} else if len(brs) == 0 { } else if len(brs) == 0 {
ctx.Data["IsBareRepo"] = true ctx.Data["IsBareRepo"] = true
ctx.HTML(200, "repo/single", ctx.Data) ctx.HTML(200, "repo/single")
return return
} }
@ -178,7 +178,7 @@ func Single(ctx *middleware.Context, params martini.Params) {
ctx.Data["Treenames"] = treenames ctx.Data["Treenames"] = treenames
ctx.Data["IsRepoToolbarSource"] = true ctx.Data["IsRepoToolbarSource"] = true
ctx.Data["BranchLink"] = branchLink ctx.Data["BranchLink"] = branchLink
ctx.HTML(200, "repo/single", ctx.Data) ctx.HTML(200, "repo/single")
} }
func Setting(ctx *middleware.Context, params martini.Params) { func Setting(ctx *middleware.Context, params martini.Params) {
@ -195,7 +195,7 @@ func Setting(ctx *middleware.Context, params martini.Params) {
return return
} else if len(brs) == 0 { } else if len(brs) == 0 {
ctx.Data["IsBareRepo"] = true ctx.Data["IsBareRepo"] = true
ctx.HTML(200, "repo/setting", ctx.Data) ctx.HTML(200, "repo/setting")
return return
} }
@ -206,7 +206,7 @@ func Setting(ctx *middleware.Context, params martini.Params) {
ctx.Data["Title"] = title + " - settings" ctx.Data["Title"] = title + " - settings"
ctx.Data["IsRepoToolbarSetting"] = true ctx.Data["IsRepoToolbarSetting"] = true
ctx.HTML(200, "repo/setting", ctx.Data) ctx.HTML(200, "repo/setting")
} }
func Commits(ctx *middleware.Context, params martini.Params) { func Commits(ctx *middleware.Context, params martini.Params) {
@ -230,17 +230,17 @@ func Commits(ctx *middleware.Context, params martini.Params) {
ctx.Data["Reponame"] = params["reponame"] ctx.Data["Reponame"] = params["reponame"]
ctx.Data["CommitCount"] = commits.Len() ctx.Data["CommitCount"] = commits.Len()
ctx.Data["Commits"] = commits ctx.Data["Commits"] = commits
ctx.HTML(200, "repo/commits", ctx.Data) ctx.HTML(200, "repo/commits")
} }
func Issues(ctx *middleware.Context) { func Issues(ctx *middleware.Context) {
ctx.Data["IsRepoToolbarIssues"] = true ctx.Data["IsRepoToolbarIssues"] = true
ctx.HTML(200, "repo/issues", ctx.Data) ctx.HTML(200, "repo/issues")
} }
func Pulls(ctx *middleware.Context) { func Pulls(ctx *middleware.Context) {
ctx.Data["IsRepoToolbarPulls"] = true ctx.Data["IsRepoToolbarPulls"] = true
ctx.HTML(200, "repo/pulls", ctx.Data) ctx.HTML(200, "repo/pulls")
} }
func Action(ctx *middleware.Context, params martini.Params) { func Action(ctx *middleware.Context, params martini.Params) {

View file

@ -24,13 +24,13 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) {
ctx.Data["Owner"] = user ctx.Data["Owner"] = user
if ctx.Req.Method == "GET" { if ctx.Req.Method == "GET" {
ctx.HTML(200, "user/setting", ctx.Data) ctx.HTML(200, "user/setting")
return return
} }
// below is for POST requests // below is for POST requests
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) { if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
ctx.HTML(200, "user/setting", ctx.Data) ctx.HTML(200, "user/setting")
return return
} }
@ -45,7 +45,7 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) {
} }
ctx.Data["IsSuccess"] = true ctx.Data["IsSuccess"] = true
ctx.HTML(200, "user/setting", ctx.Data) ctx.HTML(200, "user/setting")
log.Trace("%s User setting updated: %s", ctx.Req.RequestURI, ctx.User.LowerName) log.Trace("%s User setting updated: %s", ctx.Req.RequestURI, ctx.User.LowerName)
} }
@ -55,7 +55,7 @@ func SettingPassword(ctx *middleware.Context, form auth.UpdatePasswdForm) {
ctx.Data["IsUserPageSettingPasswd"] = true ctx.Data["IsUserPageSettingPasswd"] = true
if ctx.Req.Method == "GET" { if ctx.Req.Method == "GET" {
ctx.HTML(200, "user/password", ctx.Data) ctx.HTML(200, "user/password")
return return
} }
@ -82,7 +82,7 @@ func SettingPassword(ctx *middleware.Context, form auth.UpdatePasswdForm) {
} }
ctx.Data["Owner"] = user ctx.Data["Owner"] = user
ctx.HTML(200, "user/password", ctx.Data) ctx.HTML(200, "user/password")
log.Trace("%s User password updated: %s", ctx.Req.RequestURI, ctx.User.LowerName) log.Trace("%s User password updated: %s", ctx.Req.RequestURI, ctx.User.LowerName)
} }
@ -123,7 +123,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
// Add new SSH key. // Add new SSH key.
if ctx.Req.Method == "POST" { if ctx.Req.Method == "POST" {
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) { if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
ctx.HTML(200, "user/publickey", ctx.Data) ctx.HTML(200, "user/publickey")
return return
} }
@ -155,7 +155,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
ctx.Data["PageIsUserSetting"] = true ctx.Data["PageIsUserSetting"] = true
ctx.Data["IsUserPageSettingSSH"] = true ctx.Data["IsUserPageSettingSSH"] = true
ctx.Data["Keys"] = keys ctx.Data["Keys"] = keys
ctx.HTML(200, "user/publickey", ctx.Data) ctx.HTML(200, "user/publickey")
} }
func SettingNotification(ctx *middleware.Context) { func SettingNotification(ctx *middleware.Context) {
@ -163,7 +163,7 @@ func SettingNotification(ctx *middleware.Context) {
ctx.Data["Title"] = "Notification" ctx.Data["Title"] = "Notification"
ctx.Data["PageIsUserSetting"] = true ctx.Data["PageIsUserSetting"] = true
ctx.Data["IsUserPageSettingNotify"] = true ctx.Data["IsUserPageSettingNotify"] = true
ctx.HTML(200, "user/notification", ctx.Data) ctx.HTML(200, "user/notification")
} }
func SettingSecurity(ctx *middleware.Context) { func SettingSecurity(ctx *middleware.Context) {
@ -171,5 +171,5 @@ func SettingSecurity(ctx *middleware.Context) {
ctx.Data["Title"] = "Security" ctx.Data["Title"] = "Security"
ctx.Data["PageIsUserSetting"] = true ctx.Data["PageIsUserSetting"] = true
ctx.Data["IsUserPageSettingSecurity"] = true ctx.Data["IsUserPageSettingSecurity"] = true
ctx.HTML(200, "user/security", ctx.Data) ctx.HTML(200, "user/security")
} }

View file

@ -34,7 +34,7 @@ func Dashboard(ctx *middleware.Context) {
return return
} }
ctx.Data["Feeds"] = feeds ctx.Data["Feeds"] = feeds
ctx.HTML(200, "user/dashboard", ctx.Data) ctx.HTML(200, "user/dashboard")
} }
func Profile(ctx *middleware.Context, params martini.Params) { func Profile(ctx *middleware.Context, params martini.Params) {
@ -70,19 +70,19 @@ func Profile(ctx *middleware.Context, params martini.Params) {
} }
ctx.Data["PageIsUserProfile"] = true ctx.Data["PageIsUserProfile"] = true
ctx.HTML(200, "user/profile", ctx.Data) ctx.HTML(200, "user/profile")
} }
func SignIn(ctx *middleware.Context, form auth.LogInForm) { func SignIn(ctx *middleware.Context, form auth.LogInForm) {
ctx.Data["Title"] = "Log In" ctx.Data["Title"] = "Log In"
if ctx.Req.Method == "GET" { if ctx.Req.Method == "GET" {
ctx.HTML(200, "user/signin", ctx.Data) ctx.HTML(200, "user/signin")
return return
} }
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) { if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
ctx.HTML(200, "user/signin", ctx.Data) ctx.HTML(200, "user/signin")
return return
} }
@ -113,7 +113,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
ctx.Data["PageIsSignUp"] = true ctx.Data["PageIsSignUp"] = true
if ctx.Req.Method == "GET" { if ctx.Req.Method == "GET" {
ctx.HTML(200, "user/signup", ctx.Data) ctx.HTML(200, "user/signup")
return return
} }
@ -126,7 +126,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
} }
if ctx.HasError() { if ctx.HasError() {
ctx.HTML(200, "user/signup", ctx.Data) ctx.HTML(200, "user/signup")
return return
} }
@ -158,7 +158,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
ctx.Data["IsSendRegisterMail"] = true ctx.Data["IsSendRegisterMail"] = true
ctx.Data["Email"] = u.Email ctx.Data["Email"] = u.Email
ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60 ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60
ctx.Render.HTML(200, "user/active", ctx.Data) ctx.HTML(200, "user/active")
return return
} }
ctx.Redirect("/user/login") ctx.Redirect("/user/login")
@ -170,7 +170,7 @@ func Delete(ctx *middleware.Context) {
ctx.Data["IsUserPageSettingDelete"] = true ctx.Data["IsUserPageSettingDelete"] = true
if ctx.Req.Method == "GET" { if ctx.Req.Method == "GET" {
ctx.HTML(200, "user/delete", ctx.Data) ctx.HTML(200, "user/delete")
return return
} }
@ -195,7 +195,7 @@ func Delete(ctx *middleware.Context) {
} }
} }
ctx.HTML(200, "user/delete", ctx.Data) ctx.HTML(200, "user/delete")
} }
const ( const (
@ -218,15 +218,15 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
} }
func Issues(ctx *middleware.Context) { func Issues(ctx *middleware.Context) {
ctx.HTML(200, "user/issues", ctx.Data) ctx.HTML(200, "user/issues")
} }
func Pulls(ctx *middleware.Context) { func Pulls(ctx *middleware.Context) {
ctx.HTML(200, "user/pulls", ctx.Data) ctx.HTML(200, "user/pulls")
} }
func Stars(ctx *middleware.Context) { func Stars(ctx *middleware.Context) {
ctx.HTML(200, "user/stars", ctx.Data) ctx.HTML(200, "user/stars")
} }
func Activate(ctx *middleware.Context) { func Activate(ctx *middleware.Context) {
@ -244,7 +244,7 @@ func Activate(ctx *middleware.Context) {
} else { } else {
ctx.Data["ServiceNotEnabled"] = true ctx.Data["ServiceNotEnabled"] = true
} }
ctx.Render.HTML(200, "user/active", ctx.Data) ctx.HTML(200, "user/active")
return return
} }
@ -263,5 +263,5 @@ func Activate(ctx *middleware.Context) {
} }
ctx.Data["IsActivateFailed"] = true ctx.Data["IsActivateFailed"] = true
ctx.Render.HTML(200, "user/active", ctx.Data) ctx.HTML(200, "user/active")
} }

View file

@ -0,0 +1,24 @@
{{template "base/head" .}}
{{template "base/navbar" .}}
<div id="gogs-body" class="container" data-page="admin">
<div id="gogs-user-setting-nav" class="col-md-3">
<ul class="list-group" data-init="tabs">
<li class="list-group-item active"><a href="/admin"><i class="fa fa-tachometer fa-lg"></i> Dashboard</a></li>
<li class="list-group-item"><a href="/admin/users"><i class="fa fa-users fa-lg"></i> Users</a></li>
<li class="list-group-item"><a href="/admin/repos"><i class="fa fa-book fa-lg"></i> Repositories</a></li>
</ul>
</div>
<div id="gogs-admin-container" class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
Statistic
</div>
<div class="panel-body">
Gogs database has 4 users, 3 repositories, 4 SSH keys.
</div>
</div>
</div>
</div>
{{template "base/footer" .}}

View file

@ -0,0 +1,23 @@
{{template "base/head" .}}
{{template "base/navbar" .}}
<div id="gogs-body" class="container" data-page="admin">
<div id="gogs-user-setting-nav" class="col-md-3">
<ul class="list-group" data-init="tabs">
<li class="list-group-item"><a href="/admin"><i class="fa fa-tachometer fa-lg"></i> Dashboard</a></li>
<li class="list-group-item"><a href="/admin/users"><i class="fa fa-users fa-lg"></i> Users</a></li>
<li class="list-group-item active"><a href="/admin/repos"><i class="fa fa-book fa-lg"></i> Repositories</a></li>
</ul>
</div>
<div id="gogs-admin-container" class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
Repository Management
</div>
<div class="panel-body">
</div>
</div>
</div>
</div>
{{template "base/footer" .}}

View file

@ -0,0 +1,23 @@
{{template "base/head" .}}
{{template "base/navbar" .}}
<div id="gogs-body" class="container" data-page="admin">
<div id="gogs-user-setting-nav" class="col-md-3">
<ul class="list-group" data-init="tabs">
<li class="list-group-item"><a href="/admin"><i class="fa fa-tachometer fa-lg"></i> Dashboard</a></li>
<li class="list-group-item active"><a href="/admin/users"><i class="fa fa-users fa-lg"></i> Users</a></li>
<li class="list-group-item"><a href="/admin/repos"><i class="fa fa-book fa-lg"></i> Repositories</a></li>
</ul>
</div>
<div id="gogs-admin-container" class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
User Management
</div>
<div class="panel-body">
</div>
</div>
</div>
</div>
{{template "base/footer" .}}

View file

@ -10,6 +10,7 @@
</a> </a>
<a class="navbar-right gogs-nav-item{{if .PageIsNewRepo}} active{{end}}" href="/repo/create" data-toggle="tooltip" data-placement="bottom" title="New Repository"><i class="fa fa-plus fa-lg"></i></a> <a class="navbar-right gogs-nav-item{{if .PageIsNewRepo}} active{{end}}" href="/repo/create" data-toggle="tooltip" data-placement="bottom" title="New Repository"><i class="fa fa-plus fa-lg"></i></a>
<a class="navbar-right gogs-nav-item{{if .PageIsUserSetting}} active{{end}}" href="/user/setting" data-toggle="tooltip" data-placement="bottom" title="Setting"><i class="fa fa-cogs fa-lg"></i></a> <a class="navbar-right gogs-nav-item{{if .PageIsUserSetting}} active{{end}}" href="/user/setting" data-toggle="tooltip" data-placement="bottom" title="Setting"><i class="fa fa-cogs fa-lg"></i></a>
{{if .IsAdmin}}<a class="navbar-right gogs-nav-item{{if .PageIsAdmin}} active{{end}}" href="/admin" data-toggle="tooltip" data-placement="bottom" title="Admin"><i class="fa fa-gear fa-lg"></i></a>{{end}}
{{else}}<a id="gogs-nav-signin" class="gogs-nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/">Sign in</a>{{end}} {{else}}<a id="gogs-nav-signin" class="gogs-nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/">Sign in</a>{{end}}
</nav> </nav>
</div> </div>

View file

@ -10,20 +10,24 @@
<li class="list-group-item"><a href="#">Notifications</a></li>--> <li class="list-group-item"><a href="#">Notifications</a></li>-->
</ul> </ul>
</div> </div>
<div id="gogs-repo-setting-container" class="col-md-9"> <div id="gogs-repo-setting-container" class="col-md-9">
{{if .ErrorMsg}}<p class="alert alert-danger">{{.ErrorMsg}}</p>{{end}} {{if .ErrorMsg}}<p class="alert alert-danger">{{.ErrorMsg}}</p>{{end}}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
Repository Options Repository Options
</div> </div>
<div class="panel-body"> <div class="panel-body">
</div> </div>
</div> </div>
<div class="panel panel-warning"> <div class="panel panel-warning">
<div class="panel-heading"> <div class="panel-heading">
Danger Zone Danger Zone
</div> </div>
<div class="panel-body"> <div class="panel-body">
<button type="button" class="btn btn-default pull-right" href="#delete-repository-modal" data-toggle="modal"> <button type="button" class="btn btn-default pull-right" href="#delete-repository-modal" data-toggle="modal">
Delete this repository Delete this repository

6
web.go
View file

@ -21,6 +21,7 @@ import (
"github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers"
"github.com/gogits/gogs/routers/admin"
"github.com/gogits/gogs/routers/dev" "github.com/gogits/gogs/routers/dev"
"github.com/gogits/gogs/routers/repo" "github.com/gogits/gogs/routers/repo"
"github.com/gogits/gogs/routers/user" "github.com/gogits/gogs/routers/user"
@ -99,6 +100,11 @@ func runWeb(*cli.Context) {
m.Get("/help", routers.Help) m.Get("/help", routers.Help)
adminReq := middleware.AdminRequire()
m.Any("/admin", reqSignIn, adminReq, admin.Dashboard)
m.Any("/admin/users", reqSignIn, adminReq, admin.Users)
m.Any("/admin/repos", reqSignIn, adminReq, admin.Repositories)
m.Post("/:username/:reponame/settings", reqSignIn, middleware.RepoAssignment(true), repo.SettingPost) 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/settings", reqSignIn, middleware.RepoAssignment(true), repo.Setting)