Merge branch 'master' of github.com:gogits/gogs
Conflicts: public/js/app.js
This commit is contained in:
commit
c6bd723ce1
25 changed files with 280 additions and 58 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,3 +6,5 @@ gogs
|
|||
*.log
|
||||
custom/
|
||||
.vendor/
|
||||
.idea/
|
||||
*.iml
|
|
@ -16,6 +16,7 @@ There are some very good products in this category such as [gitlab](http://gitla
|
|||
- Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, develop specification, change log and road map.
|
||||
- See [Trello Broad](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team.
|
||||
- Try it before anything? Go down to **Installation -> Install from binary** section!.
|
||||
- Having troubles? Get help from [Troubleshooting](https://github.com/gogits/gogs/wiki/Troubleshooting).
|
||||
|
||||
## Features
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ type User struct {
|
|||
Location string
|
||||
Website string
|
||||
IsActive bool
|
||||
IsAdmin bool
|
||||
Rands string `xorm:"VARCHAR(10)"`
|
||||
Created time.Time `xorm:"created"`
|
||||
Updated time.Time `xorm:"updated"`
|
||||
|
@ -136,7 +137,13 @@ func RegisterUser(user *User) (*User, error) {
|
|||
}
|
||||
return nil, err
|
||||
}
|
||||
return user, nil
|
||||
|
||||
if user.Id == 1 {
|
||||
user.IsAdmin = true
|
||||
user.IsActive = true
|
||||
_, err = orm.Id(user.Id).UseBool().Update(user)
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
|
||||
// get user by erify code
|
||||
|
|
|
@ -57,9 +57,9 @@ func processMailQueue() {
|
|||
info = ", info: " + msg.Info
|
||||
}
|
||||
log.Error(fmt.Sprintf("Async sent email %d succeed, not send emails: %s%s err: %s", num, tos, info, err))
|
||||
return
|
||||
} else {
|
||||
log.Trace(fmt.Sprintf("Async sent email %d succeed, sent emails: %s%s", num, tos, info))
|
||||
}
|
||||
log.Trace(fmt.Sprintf("Async sent email %d succeed, sent emails: %s%s", num, tos, info))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func SignInRequire(redirect bool) martini.Handler {
|
|||
return
|
||||
} else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm {
|
||||
ctx.Data["Title"] = "Activate Your Account"
|
||||
ctx.Render.HTML(200, "user/active", ctx.Data)
|
||||
ctx.HTML(200, "user/active")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,18 @@ func SignOutRequire() martini.Handler {
|
|||
return func(ctx *Context) {
|
||||
if ctx.IsSigned {
|
||||
ctx.Redirect("/")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AdminRequire requires user signed in as administor.
|
||||
func AdminRequire() martini.Handler {
|
||||
return func(ctx *Context) {
|
||||
if !ctx.User.IsAdmin {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,24 +61,29 @@ func (ctx *Context) HasError() 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.
|
||||
func (ctx *Context) RenderWithErr(msg, tpl string, form auth.Form) {
|
||||
ctx.Data["HasError"] = true
|
||||
ctx.Data["ErrorMsg"] = msg
|
||||
auth.AssignForm(form, ctx.Data)
|
||||
ctx.HTML(200, tpl, ctx.Data)
|
||||
ctx.HTML(200, tpl)
|
||||
}
|
||||
|
||||
// Handle handles and logs error by given status.
|
||||
func (ctx *Context) Handle(status int, title string, err error) {
|
||||
log.Error("%s: %v", title, err)
|
||||
if martini.Dev == martini.Prod {
|
||||
ctx.HTML(500, "status/500", ctx.Data)
|
||||
ctx.HTML(500, "status/500")
|
||||
return
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -106,6 +111,7 @@ func InitContext() martini.Handler {
|
|||
ctx.Data["SignedUser"] = user
|
||||
ctx.Data["SignedUserId"] = user.Id
|
||||
ctx.Data["SignedUserName"] = user.LowerName
|
||||
ctx.Data["IsAdmin"] = ctx.User.IsAdmin
|
||||
}
|
||||
|
||||
ctx.Data["PageStartTime"] = time.Now()
|
||||
|
|
|
@ -65,9 +65,12 @@ func RepoAssignment(redirect bool) martini.Handler {
|
|||
}
|
||||
|
||||
ctx.Repo.IsValid = true
|
||||
ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id)
|
||||
if ctx.User != nil {
|
||||
ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id)
|
||||
}
|
||||
ctx.Repo.Repository = repo
|
||||
ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, ctx.User.LowerName, repo.LowerName)
|
||||
ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, user.LowerName, repo.LowerName)
|
||||
ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("https://%s/%s/%s.git", base.Domain, user.LowerName, repo.LowerName)
|
||||
|
||||
ctx.Data["IsRepositoryValid"] = true
|
||||
ctx.Data["Repository"] = repo
|
||||
|
|
|
@ -644,7 +644,19 @@ html, body {
|
|||
}
|
||||
|
||||
.file-content .file-body {
|
||||
padding: 30px 30px 50px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.file-content .file-body pre {
|
||||
background-color: #FFF;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.file-content .markdown > pre > ol.linenums > li:first-child {
|
||||
padding-top: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.file-content .file-body.file-code {
|
||||
|
@ -732,6 +744,24 @@ html, body {
|
|||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.commit-list .date {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.guide-box pre, .guide-box .input-group {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 30px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.guide-box input[readonly] {
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.guide-box {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
/* wrapper and footer */
|
||||
|
||||
#wrapper {
|
||||
|
|
|
@ -41,15 +41,15 @@ var Gogits = {
|
|||
});
|
||||
};
|
||||
Gogits.initPopovers = function () {
|
||||
var hideAllPopovers = function() {
|
||||
$('[data-toggle=popover]').each(function() {
|
||||
var hideAllPopovers = function () {
|
||||
$('[data-toggle=popover]').each(function () {
|
||||
$(this).popover('hide');
|
||||
});
|
||||
};
|
||||
|
||||
$(document).on('click', function(e) {
|
||||
$(document).on('click', function (e) {
|
||||
var $e = $(e.target);
|
||||
if($e.data('toggle') == 'popover'||$e.parents("[data-toggle=popover], .popover").length > 0){
|
||||
if ($e.data('toggle') == 'popover' || $e.parents("[data-toggle=popover], .popover").length > 0) {
|
||||
return;
|
||||
}
|
||||
hideAllPopovers();
|
||||
|
@ -161,6 +161,23 @@ function initUserSetting() {
|
|||
});
|
||||
}
|
||||
|
||||
function initRepository() {
|
||||
var $guide = $('.guide-box');
|
||||
if ($guide.length) {
|
||||
var $url = $('#guide-clone-url');
|
||||
$guide.find('button[data-url]').on("click",function () {
|
||||
var $this = $(this);
|
||||
if (!$this.hasClass('btn-primary')) {
|
||||
$guide.find('.btn-primary').removeClass('btn-primary').addClass("btn-default");
|
||||
$(this).addClass('btn-primary').removeClass('btn-default');
|
||||
$url.val($this.data("url"));
|
||||
$guide.find('span.clone-url').text($this.data('url'));
|
||||
}
|
||||
}).eq(0).trigger("click");
|
||||
// todo copy to clipboard
|
||||
}
|
||||
}
|
||||
|
||||
(function ($) {
|
||||
$(function () {
|
||||
initCore();
|
||||
|
@ -171,5 +188,8 @@ function initUserSetting() {
|
|||
if (body.data("page") == "user") {
|
||||
initUserSetting();
|
||||
}
|
||||
if ($('.gogs-repo-nav').length) {
|
||||
initRepository();
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
24
routers/admin/admin.go
Normal file
24
routers/admin/admin.go
Normal 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")
|
||||
}
|
|
@ -15,10 +15,10 @@ func Home(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
ctx.Data["PageIsHome"] = true
|
||||
ctx.HTML(200, "home", ctx.Data)
|
||||
ctx.HTML(200, "home")
|
||||
}
|
||||
|
||||
func Help(ctx *middleware.Context) {
|
||||
ctx.Data["PageIsHelp"] = true
|
||||
ctx.HTML(200, "help", ctx.Data)
|
||||
ctx.HTML(200, "help")
|
||||
}
|
||||
|
|
|
@ -21,5 +21,5 @@ func TemplatePreview(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374"
|
||||
ctx.Data["ActiveCodeLives"] = base.Service.ActiveCodeLives / 60
|
||||
ctx.Data["ResetPwdCodeLives"] = base.Service.ResetPwdCodeLives / 60
|
||||
ctx.HTML(200, params["_1"], ctx.Data)
|
||||
ctx.HTML(200, params["_1"])
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) {
|
|||
ctx.Data["Licenses"] = models.Licenses
|
||||
|
||||
if ctx.Req.Method == "GET" {
|
||||
ctx.HTML(200, "repo/create", ctx.Data)
|
||||
ctx.HTML(200, "repo/create")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ func SettingPost(ctx *middleware.Context) {
|
|||
case "delete":
|
||||
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.HTML(200, "repo/setting", ctx.Data)
|
||||
ctx.HTML(200, "repo/setting")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ func Branches(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.Data["Branches"] = brs
|
||||
ctx.Data["IsRepoToolbarBranches"] = true
|
||||
|
||||
ctx.HTML(200, "repo/branches", ctx.Data)
|
||||
ctx.HTML(200, "repo/branches")
|
||||
}
|
||||
|
||||
func Single(ctx *middleware.Context, params martini.Params) {
|
||||
|
@ -59,6 +59,8 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Data["IsRepoToolbarSource"] = true
|
||||
|
||||
// Branches.
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
|
@ -67,7 +69,7 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
|||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Data["IsBareRepo"] = true
|
||||
ctx.HTML(200, "repo/single", ctx.Data)
|
||||
ctx.HTML(200, "repo/single")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -175,9 +177,8 @@ func Single(ctx *middleware.Context, params martini.Params) {
|
|||
|
||||
ctx.Data["Paths"] = Paths
|
||||
ctx.Data["Treenames"] = treenames
|
||||
ctx.Data["IsRepoToolbarSource"] = true
|
||||
ctx.Data["BranchLink"] = branchLink
|
||||
ctx.HTML(200, "repo/single", ctx.Data)
|
||||
ctx.HTML(200, "repo/single")
|
||||
}
|
||||
|
||||
func Setting(ctx *middleware.Context, params martini.Params) {
|
||||
|
@ -186,6 +187,8 @@ func Setting(ctx *middleware.Context, params martini.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Data["IsRepoToolbarSetting"] = true
|
||||
|
||||
// Branches.
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
|
@ -194,7 +197,7 @@ func Setting(ctx *middleware.Context, params martini.Params) {
|
|||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Data["IsBareRepo"] = true
|
||||
ctx.HTML(200, "repo/setting", ctx.Data)
|
||||
ctx.HTML(200, "repo/setting")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -204,8 +207,7 @@ func Setting(ctx *middleware.Context, params martini.Params) {
|
|||
}
|
||||
|
||||
ctx.Data["Title"] = title + " - settings"
|
||||
ctx.Data["IsRepoToolbarSetting"] = true
|
||||
ctx.HTML(200, "repo/setting", ctx.Data)
|
||||
ctx.HTML(200, "repo/setting")
|
||||
}
|
||||
|
||||
func Commits(ctx *middleware.Context, params martini.Params) {
|
||||
|
@ -229,17 +231,17 @@ func Commits(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.Data["Reponame"] = params["reponame"]
|
||||
ctx.Data["CommitCount"] = commits.Len()
|
||||
ctx.Data["Commits"] = commits
|
||||
ctx.HTML(200, "repo/commits", ctx.Data)
|
||||
ctx.HTML(200, "repo/commits")
|
||||
}
|
||||
|
||||
func Issues(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarIssues"] = true
|
||||
ctx.HTML(200, "repo/issues", ctx.Data)
|
||||
ctx.HTML(200, "repo/issues")
|
||||
}
|
||||
|
||||
func Pulls(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarPulls"] = true
|
||||
ctx.HTML(200, "repo/pulls", ctx.Data)
|
||||
ctx.HTML(200, "repo/pulls")
|
||||
}
|
||||
|
||||
func Action(ctx *middleware.Context, params martini.Params) {
|
||||
|
|
|
@ -24,13 +24,13 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
|||
ctx.Data["Owner"] = user
|
||||
|
||||
if ctx.Req.Method == "GET" {
|
||||
ctx.HTML(200, "user/setting", ctx.Data)
|
||||
ctx.HTML(200, "user/setting")
|
||||
return
|
||||
}
|
||||
|
||||
// below is for POST requests
|
||||
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
|
||||
ctx.HTML(200, "user/setting", ctx.Data)
|
||||
ctx.HTML(200, "user/setting")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ func SettingPassword(ctx *middleware.Context, form auth.UpdatePasswdForm) {
|
|||
ctx.Data["IsUserPageSettingPasswd"] = true
|
||||
|
||||
if ctx.Req.Method == "GET" {
|
||||
ctx.HTML(200, "user/password", ctx.Data)
|
||||
ctx.HTML(200, "user/password")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ func SettingPassword(ctx *middleware.Context, form auth.UpdatePasswdForm) {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
|||
// Add new SSH key.
|
||||
if ctx.Req.Method == "POST" {
|
||||
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
|
||||
ctx.HTML(200, "user/publickey", ctx.Data)
|
||||
ctx.HTML(200, "user/publickey")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
|||
ctx.Data["PageIsUserSetting"] = true
|
||||
ctx.Data["IsUserPageSettingSSH"] = true
|
||||
ctx.Data["Keys"] = keys
|
||||
ctx.HTML(200, "user/publickey", ctx.Data)
|
||||
ctx.HTML(200, "user/publickey")
|
||||
}
|
||||
|
||||
func SettingNotification(ctx *middleware.Context) {
|
||||
|
@ -163,7 +163,7 @@ func SettingNotification(ctx *middleware.Context) {
|
|||
ctx.Data["Title"] = "Notification"
|
||||
ctx.Data["PageIsUserSetting"] = true
|
||||
ctx.Data["IsUserPageSettingNotify"] = true
|
||||
ctx.HTML(200, "user/notification", ctx.Data)
|
||||
ctx.HTML(200, "user/notification")
|
||||
}
|
||||
|
||||
func SettingSecurity(ctx *middleware.Context) {
|
||||
|
@ -171,5 +171,5 @@ func SettingSecurity(ctx *middleware.Context) {
|
|||
ctx.Data["Title"] = "Security"
|
||||
ctx.Data["PageIsUserSetting"] = true
|
||||
ctx.Data["IsUserPageSettingSecurity"] = true
|
||||
ctx.HTML(200, "user/security", ctx.Data)
|
||||
ctx.HTML(200, "user/security")
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func Dashboard(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
ctx.Data["Feeds"] = feeds
|
||||
ctx.HTML(200, "user/dashboard", ctx.Data)
|
||||
ctx.HTML(200, "user/dashboard")
|
||||
}
|
||||
|
||||
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.HTML(200, "user/profile", ctx.Data)
|
||||
ctx.HTML(200, "user/profile")
|
||||
}
|
||||
|
||||
func SignIn(ctx *middleware.Context, form auth.LogInForm) {
|
||||
ctx.Data["Title"] = "Log In"
|
||||
|
||||
if ctx.Req.Method == "GET" {
|
||||
ctx.HTML(200, "user/signin", ctx.Data)
|
||||
ctx.HTML(200, "user/signin")
|
||||
return
|
||||
}
|
||||
|
||||
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
|
||||
ctx.HTML(200, "user/signin", ctx.Data)
|
||||
ctx.HTML(200, "user/signin")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
|
|||
ctx.Data["PageIsSignUp"] = true
|
||||
|
||||
if ctx.Req.Method == "GET" {
|
||||
ctx.HTML(200, "user/signup", ctx.Data)
|
||||
ctx.HTML(200, "user/signup")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, "user/signup", ctx.Data)
|
||||
ctx.HTML(200, "user/signup")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -153,12 +153,12 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
|
|||
log.Trace("%s User created: %s", ctx.Req.RequestURI, strings.ToLower(form.UserName))
|
||||
|
||||
// Send confirmation e-mail.
|
||||
if base.Service.RegisterEmailConfirm {
|
||||
if base.Service.RegisterEmailConfirm && u.Id > 1 {
|
||||
mailer.SendRegisterMail(ctx.Render, u)
|
||||
ctx.Data["IsSendRegisterMail"] = true
|
||||
ctx.Data["Email"] = u.Email
|
||||
ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60
|
||||
ctx.Render.HTML(200, "user/active", ctx.Data)
|
||||
ctx.HTML(200, "user/active")
|
||||
return
|
||||
}
|
||||
ctx.Redirect("/user/login")
|
||||
|
@ -170,7 +170,7 @@ func Delete(ctx *middleware.Context) {
|
|||
ctx.Data["IsUserPageSettingDelete"] = true
|
||||
|
||||
if ctx.Req.Method == "GET" {
|
||||
ctx.HTML(200, "user/delete", ctx.Data)
|
||||
ctx.HTML(200, "user/delete")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ func Delete(ctx *middleware.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.HTML(200, "user/delete", ctx.Data)
|
||||
ctx.HTML(200, "user/delete")
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -218,21 +218,25 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
|
|||
}
|
||||
|
||||
func Issues(ctx *middleware.Context) {
|
||||
ctx.HTML(200, "user/issues", ctx.Data)
|
||||
ctx.HTML(200, "user/issues")
|
||||
}
|
||||
|
||||
func Pulls(ctx *middleware.Context) {
|
||||
ctx.HTML(200, "user/pulls", ctx.Data)
|
||||
ctx.HTML(200, "user/pulls")
|
||||
}
|
||||
|
||||
func Stars(ctx *middleware.Context) {
|
||||
ctx.HTML(200, "user/stars", ctx.Data)
|
||||
ctx.HTML(200, "user/stars")
|
||||
}
|
||||
|
||||
func Activate(ctx *middleware.Context) {
|
||||
code := ctx.Query("code")
|
||||
if len(code) == 0 {
|
||||
ctx.Data["IsActivatePage"] = true
|
||||
if ctx.User.IsActive {
|
||||
ctx.Error(404)
|
||||
return
|
||||
}
|
||||
// Resend confirmation e-mail.
|
||||
if base.Service.RegisterEmailConfirm {
|
||||
ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60
|
||||
|
@ -240,7 +244,7 @@ func Activate(ctx *middleware.Context) {
|
|||
} else {
|
||||
ctx.Data["ServiceNotEnabled"] = true
|
||||
}
|
||||
ctx.Render.HTML(200, "user/active", ctx.Data)
|
||||
ctx.HTML(200, "user/active")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -259,5 +263,5 @@ func Activate(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
ctx.Data["IsActivateFailed"] = true
|
||||
ctx.Render.HTML(200, "user/active", ctx.Data)
|
||||
ctx.HTML(200, "user/active")
|
||||
}
|
||||
|
|
24
templates/admin/dashboard.tmpl
Normal file
24
templates/admin/dashboard.tmpl
Normal 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" .}}
|
23
templates/admin/repos.tmpl
Normal file
23
templates/admin/repos.tmpl
Normal 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" .}}
|
23
templates/admin/users.tmpl
Normal file
23
templates/admin/users.tmpl
Normal 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" .}}
|
|
@ -10,6 +10,7 @@
|
|||
</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>
|
||||
{{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}}
|
||||
</nav>
|
||||
</div>
|
||||
|
|
|
@ -10,20 +10,24 @@
|
|||
<li class="list-group-item"><a href="#">Notifications</a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="gogs-repo-setting-container" class="col-md-9">
|
||||
{{if .ErrorMsg}}<p class="alert alert-danger">{{.ErrorMsg}}</p>{{end}}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Repository Options
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-warning">
|
||||
<div class="panel-heading">
|
||||
Danger Zone
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<button type="button" class="btn btn-default pull-right" href="#delete-repository-modal" data-toggle="modal">
|
||||
Delete this repository
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div id="gogs-body" class="container">
|
||||
<div id="gogs-source">
|
||||
{{if .IsBareRepo}}
|
||||
Need to fill in some guide.
|
||||
{{template "repo/single_bare" .}}
|
||||
{{else}}
|
||||
<div class="source-toolbar">
|
||||
{{ $n := len .Treenames}}
|
||||
|
|
31
templates/repo/single_bare.tmpl
Normal file
31
templates/repo/single_bare.tmpl
Normal file
|
@ -0,0 +1,31 @@
|
|||
<div class="panel panel-default guide-box">
|
||||
<div class="panel-heading guide-head">
|
||||
<h4>Quick Guide</h4>
|
||||
</div>
|
||||
<div class="panel-body guide-content text-center">
|
||||
<h3>Clone this repository</h3>
|
||||
<div class="input-group col-md-8 col-md-offset-2 guide-buttons">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" data-url="{{.CloneLink.SSH}}" type="button">SSH</button>
|
||||
<button class="btn btn-default" data-url="{{.CloneLink.HTTPS}}" type="button">HTTPS</button>
|
||||
</span>
|
||||
<input type="text" class="form-control" id="guide-clone-url" value="" readonly/>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button"><i class="fa fa-copy" data-toggle="tooltip" title="copy to clipboard" data-placement="top"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
<p>We recommend every repository include a <strong>README</strong>, <strong>LICENSE</strong>, and <strong>.gitignore</strong>.</p>
|
||||
<hr/>
|
||||
<h3>Create a new repository on the command line</h3>
|
||||
<pre class="text-left"><code>touch README.md
|
||||
git init
|
||||
git add README.md
|
||||
git commit -m "first commit"
|
||||
git remote add origin <span class="clone-url"></span>
|
||||
git push -u origin master</code></pre>
|
||||
<hr/>
|
||||
<h3>Push an existing repository from the command line</h3>
|
||||
<pre class="text-left"><code>git remote add origin <span class="clone-url"></span>
|
||||
git push -u origin master</code></pre>
|
||||
</div>
|
||||
</div>
|
|
@ -15,9 +15,8 @@
|
|||
<li><a href="/{{.RepositoryLink}}/release">Release</a></li>
|
||||
<li><a href="//{{.RepositoryLink}}/wiki">Wiki</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</li>{{end}}
|
||||
</ul>
|
||||
{{end}}
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{{if not .IsBareRepo}}
|
||||
<li class="dropdown">
|
||||
|
|
6
web.go
6
web.go
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/routers"
|
||||
"github.com/gogits/gogs/routers/admin"
|
||||
"github.com/gogits/gogs/routers/dev"
|
||||
"github.com/gogits/gogs/routers/repo"
|
||||
"github.com/gogits/gogs/routers/user"
|
||||
|
@ -99,6 +100,11 @@ func runWeb(*cli.Context) {
|
|||
|
||||
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.Get("/:username/:reponame/settings", reqSignIn, middleware.RepoAssignment(true), repo.Setting)
|
||||
|
||||
|
|
Reference in a new issue