Browse Source

Refactoring: remove tool.TplName

pull/4248/merge
Unknwon 8 years ago
parent
commit
edaf14f2b6
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 6
      pkg/context/api.go
  2. 11
      pkg/context/context.go
  3. 21
      pkg/mailer/mail.go
  4. 11
      pkg/tool/base.go
  5. 8
      routers/admin/admin.go
  6. 7
      routers/admin/auths.go
  7. 3
      routers/admin/notice.go
  8. 3
      routers/admin/orgs.go
  9. 3
      routers/admin/repos.go
  10. 7
      routers/admin/users.go
  11. 3
      routers/dev/template.go
  12. 11
      routers/home.go
  13. 4
      routers/install.go
  14. 5
      routers/org/members.go
  15. 5
      routers/org/org.go
  16. 7
      routers/org/setting.go
  17. 9
      routers/org/teams.go
  18. 5
      routers/repo/branch.go
  19. 6
      routers/repo/commit.go
  20. 10
      routers/repo/editor.go
  21. 16
      routers/repo/issue.go
  22. 10
      routers/repo/pull.go
  23. 5
      routers/repo/release.go
  24. 8
      routers/repo/repo.go
  25. 15
      routers/repo/setting.go
  26. 12
      routers/repo/view.go
  27. 9
      routers/repo/webhook.go
  28. 9
      routers/repo/wiki.go
  29. 11
      routers/user/auth.go
  30. 11
      routers/user/home.go
  31. 5
      routers/user/profile.go
  32. 24
      routers/user/setting.go

6
pkg/context/api.go

@ -12,7 +12,6 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
@ -21,6 +20,9 @@ type APIContext struct {
Org *APIOrganization Org *APIOrganization
} }
// FIXME: move to github.com/gogits/go-gogs-client
const DOC_URL = "https://github.com/gogits/go-gogs-client/wiki"
// Error responses error message to client with given message. // Error responses error message to client with given message.
// If status is 500, also it prints error to log. // If status is 500, also it prints error to log.
func (ctx *APIContext) Error(status int, title string, obj interface{}) { func (ctx *APIContext) Error(status int, title string, obj interface{}) {
@ -37,7 +39,7 @@ func (ctx *APIContext) Error(status int, title string, obj interface{}) {
ctx.JSON(status, map[string]string{ ctx.JSON(status, map[string]string{
"message": message, "message": message,
"url": tool.DOC_URL, "url": DOC_URL,
}) })
} }

11
pkg/context/context.go

@ -21,7 +21,6 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/auth" "github.com/gogits/gogs/pkg/auth"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
@ -80,18 +79,18 @@ func (ctx *Context) HasValue(name string) bool {
} }
// HTML responses template with given status. // HTML responses template with given status.
func (ctx *Context) HTML(status int, name tool.TplName) { func (ctx *Context) HTML(status int, name string) {
log.Trace("Template: %s", name) log.Trace("Template: %s", name)
ctx.Context.HTML(status, string(name)) ctx.Context.HTML(status, name)
} }
// Success responses template with status http.StatusOK. // Success responses template with status http.StatusOK.
func (c *Context) Success(name tool.TplName) { func (c *Context) Success(name string) {
c.HTML(http.StatusOK, name) c.HTML(http.StatusOK, name)
} }
// 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 string, tpl tool.TplName, f interface{}) { func (ctx *Context) RenderWithErr(msg, tpl string, f interface{}) {
if f != nil { if f != nil {
form.Assign(f, ctx.Data) form.Assign(f, ctx.Data)
} }
@ -112,7 +111,7 @@ func (ctx *Context) Handle(status int, title string, err error) {
ctx.Data["ErrorMsg"] = err ctx.Data["ErrorMsg"] = err
} }
} }
ctx.HTML(status, tool.TplName(fmt.Sprintf("status/%d", status))) ctx.HTML(status, fmt.Sprintf("status/%d", status))
} }
// NotFound renders the 404 page. // NotFound renders the 404 page.

21
pkg/mailer/mail.go

@ -12,21 +12,20 @@ import (
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/markup" "github.com/gogits/gogs/pkg/markup"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const ( const (
MAIL_AUTH_ACTIVATE tool.TplName = "auth/activate" MAIL_AUTH_ACTIVATE = "auth/activate"
MAIL_AUTH_ACTIVATE_EMAIL tool.TplName = "auth/activate_email" MAIL_AUTH_ACTIVATE_EMAIL = "auth/activate_email"
MAIL_AUTH_RESET_PASSWORD tool.TplName = "auth/reset_passwd" MAIL_AUTH_RESET_PASSWORD = "auth/reset_passwd"
MAIL_AUTH_REGISTER_NOTIFY tool.TplName = "auth/register_notify" MAIL_AUTH_REGISTER_NOTIFY = "auth/register_notify"
MAIL_ISSUE_COMMENT tool.TplName = "issue/comment" MAIL_ISSUE_COMMENT = "issue/comment"
MAIL_ISSUE_MENTION tool.TplName = "issue/mention" MAIL_ISSUE_MENTION = "issue/mention"
MAIL_NOTIFY_COLLABORATOR tool.TplName = "notify/collaborator" MAIL_NOTIFY_COLLABORATOR = "notify/collaborator"
) )
type MailRender interface { type MailRender interface {
@ -79,7 +78,7 @@ type Issue interface {
HTMLURL() string HTMLURL() string
} }
func SendUserMail(c *macaron.Context, u User, tpl tool.TplName, code, subject, info string) { func SendUserMail(c *macaron.Context, u User, tpl, code, subject, info string) {
data := map[string]interface{}{ data := map[string]interface{}{
"Username": u.DisplayName(), "Username": u.DisplayName(),
"ActiveCodeLives": setting.Service.ActiveCodeLives / 60, "ActiveCodeLives": setting.Service.ActiveCodeLives / 60,
@ -172,12 +171,12 @@ func composeTplData(subject, body, link string) map[string]interface{} {
return data return data
} }
func composeIssueMessage(issue Issue, repo Repository, doer User, tplName tool.TplName, tos []string, info string) *Message { func composeIssueMessage(issue Issue, repo Repository, doer User, tplName string, tos []string, info string) *Message {
subject := issue.MailSubject() subject := issue.MailSubject()
body := string(markup.RenderSpecialLink([]byte(issue.Content()), repo.HTMLURL(), repo.ComposeMetas())) body := string(markup.RenderSpecialLink([]byte(issue.Content()), repo.HTMLURL(), repo.ComposeMetas()))
data := composeTplData(subject, body, issue.HTMLURL()) data := composeTplData(subject, body, issue.HTMLURL())
data["Doer"] = doer data["Doer"] = doer
content, err := mailRender.HTMLString(string(tplName), data) content, err := mailRender.HTMLString(tplName, data)
if err != nil { if err != nil {
log.Error(3, "HTMLString (%s): %v", tplName, err) log.Error(3, "HTMLString (%s): %v", tplName, err)
} }

11
pkg/tool/base.go

@ -1,11 +0,0 @@
// 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 tool
const DOC_URL = "https://github.com/gogits/go-gogs-client/wiki"
type (
TplName string
)

8
routers/admin/admin.go

@ -15,18 +15,18 @@ import (
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/cron" "github.com/gogits/gogs/pkg/cron"
"github.com/gogits/gogs/pkg/mailer" "github.com/gogits/gogs/pkg/mailer"
"github.com/gogits/gogs/pkg/process" "github.com/gogits/gogs/pkg/process"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/tool"
) )
const ( const (
DASHBOARD tool.TplName = "admin/dashboard" DASHBOARD = "admin/dashboard"
CONFIG tool.TplName = "admin/config" CONFIG = "admin/config"
MONITOR tool.TplName = "admin/monitor" MONITOR = "admin/monitor"
) )
var ( var (

7
routers/admin/auths.go

@ -13,16 +13,15 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/auth/ldap" "github.com/gogits/gogs/pkg/auth/ldap"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const ( const (
AUTHS tool.TplName = "admin/auth/list" AUTHS = "admin/auth/list"
AUTH_NEW tool.TplName = "admin/auth/new" AUTH_NEW = "admin/auth/new"
AUTH_EDIT tool.TplName = "admin/auth/edit" AUTH_EDIT = "admin/auth/edit"
) )
func Authentications(ctx *context.Context) { func Authentications(ctx *context.Context) {

3
routers/admin/notice.go

@ -10,13 +10,12 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const ( const (
NOTICES tool.TplName = "admin/notice" NOTICES = "admin/notice"
) )
func Notices(ctx *context.Context) { func Notices(ctx *context.Context) {

3
routers/admin/orgs.go

@ -6,14 +6,13 @@ package admin
import ( import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers"
) )
const ( const (
ORGS tool.TplName = "admin/org/list" ORGS = "admin/org/list"
) )
func Organizations(ctx *context.Context) { func Organizations(ctx *context.Context) {

3
routers/admin/repos.go

@ -9,13 +9,12 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const ( const (
REPOS tool.TplName = "admin/repo/list" REPOS = "admin/repo/list"
) )
func Repos(ctx *context.Context) { func Repos(ctx *context.Context) {

7
routers/admin/users.go

@ -11,7 +11,6 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/mailer" "github.com/gogits/gogs/pkg/mailer"
@ -20,9 +19,9 @@ import (
) )
const ( const (
USERS tool.TplName = "admin/user/list" USERS = "admin/user/list"
USER_NEW tool.TplName = "admin/user/new" USER_NEW = "admin/user/new"
USER_EDIT tool.TplName = "admin/user/edit" USER_EDIT = "admin/user/edit"
) )
func Users(ctx *context.Context) { func Users(ctx *context.Context) {

3
routers/dev/template.go

@ -6,7 +6,6 @@ package dev
import ( import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
@ -21,5 +20,5 @@ func TemplatePreview(ctx *context.Context) {
ctx.Data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60 ctx.Data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60
ctx.Data["CurDbValue"] = "" ctx.Data["CurDbValue"] = ""
ctx.HTML(200, tool.TplName(ctx.Params("*"))) ctx.HTML(200, (ctx.Params("*")))
} }

11
routers/home.go

@ -8,17 +8,16 @@ import (
"github.com/Unknwon/paginater" "github.com/Unknwon/paginater"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/routers/user" "github.com/gogits/gogs/routers/user"
) )
const ( const (
HOME tool.TplName = "home" HOME = "home"
EXPLORE_REPOS tool.TplName = "explore/repos" EXPLORE_REPOS = "explore/repos"
EXPLORE_USERS tool.TplName = "explore/users" EXPLORE_USERS = "explore/users"
EXPLORE_ORGANIZATIONS tool.TplName = "explore/organizations" EXPLORE_ORGANIZATIONS = "explore/organizations"
) )
func Home(ctx *context.Context) { func Home(ctx *context.Context) {
@ -84,7 +83,7 @@ type UserSearchOptions struct {
Ranger func(int, int) ([]*models.User, error) Ranger func(int, int) ([]*models.User, error)
PageSize int PageSize int
OrderBy string OrderBy string
TplName tool.TplName TplName string
} }
func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) { func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {

4
routers/install.go

@ -21,7 +21,6 @@ import (
"github.com/gogits/git-module" "github.com/gogits/git-module"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/cron" "github.com/gogits/gogs/pkg/cron"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
@ -30,11 +29,12 @@ import (
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/ssh" "github.com/gogits/gogs/pkg/ssh"
"github.com/gogits/gogs/pkg/template/highlight" "github.com/gogits/gogs/pkg/template/highlight"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/user" "github.com/gogits/gogs/pkg/user"
) )
const ( const (
INSTALL tool.TplName = "install" INSTALL = "install"
) )
func checkRunMode() { func checkRunMode() {

5
routers/org/members.go

@ -10,14 +10,13 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const ( const (
MEMBERS tool.TplName = "org/member/members" MEMBERS = "org/member/members"
MEMBER_INVITE tool.TplName = "org/member/invite" MEMBER_INVITE = "org/member/invite"
) )
func Members(ctx *context.Context) { func Members(ctx *context.Context) {

5
routers/org/org.go

@ -8,14 +8,13 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const ( const (
CREATE tool.TplName = "org/create" CREATE = "org/create"
) )
func Create(ctx *context.Context) { func Create(ctx *context.Context) {

7
routers/org/setting.go

@ -11,7 +11,6 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
@ -19,9 +18,9 @@ import (
) )
const ( const (
SETTINGS_OPTIONS tool.TplName = "org/settings/options" SETTINGS_OPTIONS = "org/settings/options"
SETTINGS_DELETE tool.TplName = "org/settings/delete" SETTINGS_DELETE = "org/settings/delete"
SETTINGS_WEBHOOKS tool.TplName = "org/settings/webhooks" SETTINGS_WEBHOOKS = "org/settings/webhooks"
) )
func Settings(ctx *context.Context) { func Settings(ctx *context.Context) {

9
routers/org/teams.go

@ -12,16 +12,15 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
) )
const ( const (
TEAMS tool.TplName = "org/team/teams" TEAMS = "org/team/teams"
TEAM_NEW tool.TplName = "org/team/new" TEAM_NEW = "org/team/new"
TEAM_MEMBERS tool.TplName = "org/team/members" TEAM_MEMBERS = "org/team/members"
TEAM_REPOSITORIES tool.TplName = "org/team/repositories" TEAM_REPOSITORIES = "org/team/repositories"
) )
func Teams(ctx *context.Context) { func Teams(ctx *context.Context) {

5
routers/repo/branch.go

@ -12,13 +12,12 @@ import (
"github.com/gogits/git-module" "github.com/gogits/git-module"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
) )
const ( const (
BRANCHES_OVERVIEW tool.TplName = "repo/branches/overview" BRANCHES_OVERVIEW = "repo/branches/overview"
BRANCHES_ALL tool.TplName = "repo/branches/all" BRANCHES_ALL = "repo/branches/all"
) )
type Branch struct { type Branch struct {

6
routers/repo/commit.go

@ -11,14 +11,14 @@ import (
"github.com/gogits/git-module" "github.com/gogits/git-module"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/tool"
) )
const ( const (
COMMITS tool.TplName = "repo/commits" COMMITS = "repo/commits"
DIFF tool.TplName = "repo/diff/page" DIFF = "repo/diff/page"
) )
func RefCommits(ctx *context.Context) { func RefCommits(ctx *context.Context) {

10
routers/repo/editor.go

@ -15,18 +15,18 @@ import (
"github.com/gogits/git-module" "github.com/gogits/git-module"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/template" "github.com/gogits/gogs/pkg/template"
"github.com/gogits/gogs/pkg/tool"
) )
const ( const (
EDIT_FILE tool.TplName = "repo/editor/edit" EDIT_FILE = "repo/editor/edit"
EDIT_DIFF_PREVIEW tool.TplName = "repo/editor/diff_preview" EDIT_DIFF_PREVIEW = "repo/editor/diff_preview"
DELETE_FILE tool.TplName = "repo/editor/delete" DELETE_FILE = "repo/editor/delete"
UPLOAD_FILE tool.TplName = "repo/editor/upload" UPLOAD_FILE = "repo/editor/upload"
) )
// getParentTreeFields returns list of parent tree names and corresponding tree paths // getParentTreeFields returns list of parent tree names and corresponding tree paths

16
routers/repo/issue.go

@ -19,23 +19,23 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/markup" "github.com/gogits/gogs/pkg/markup"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/tool"
) )
const ( const (
ISSUES tool.TplName = "repo/issue/list" ISSUES = "repo/issue/list"
ISSUE_NEW tool.TplName = "repo/issue/new" ISSUE_NEW = "repo/issue/new"
ISSUE_VIEW tool.TplName = "repo/issue/view" ISSUE_VIEW = "repo/issue/view"
LABELS tool.TplName = "repo/issue/labels" LABELS = "repo/issue/labels"
MILESTONE tool.TplName = "repo/issue/milestones" MILESTONE = "repo/issue/milestones"
MILESTONE_NEW tool.TplName = "repo/issue/milestone_new" MILESTONE_NEW = "repo/issue/milestone_new"
MILESTONE_EDIT tool.TplName = "repo/issue/milestone_edit" MILESTONE_EDIT = "repo/issue/milestone_edit"
ISSUE_TEMPLATE_KEY = "IssueTemplate" ISSUE_TEMPLATE_KEY = "IssueTemplate"
) )

10
routers/repo/pull.go

@ -16,17 +16,17 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/tool"
) )
const ( const (
FORK tool.TplName = "repo/pulls/fork" FORK = "repo/pulls/fork"
COMPARE_PULL tool.TplName = "repo/pulls/compare" COMPARE_PULL = "repo/pulls/compare"
PULL_COMMITS tool.TplName = "repo/pulls/commits" PULL_COMMITS = "repo/pulls/commits"
PULL_FILES tool.TplName = "repo/pulls/files" PULL_FILES = "repo/pulls/files"
PULL_REQUEST_TEMPLATE_KEY = "PullRequestTemplate" PULL_REQUEST_TEMPLATE_KEY = "PullRequestTemplate"
) )

5
routers/repo/release.go

@ -11,7 +11,6 @@ import (
log "gopkg.in/clog.v1" log "gopkg.in/clog.v1"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/markup" "github.com/gogits/gogs/pkg/markup"
@ -19,8 +18,8 @@ import (
) )
const ( const (
RELEASES tool.TplName = "repo/release/list" RELEASES = "repo/release/list"
RELEASE_NEW tool.TplName = "repo/release/new" RELEASE_NEW = "repo/release/new"
) )
// calReleaseNumCommitsBehind calculates given release has how many commits behind release target. // calReleaseNumCommitsBehind calculates given release has how many commits behind release target.

8
routers/repo/repo.go

@ -17,15 +17,15 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/tool"
) )
const ( const (
CREATE tool.TplName = "repo/create" CREATE = "repo/create"
MIGRATE tool.TplName = "repo/migrate" MIGRATE = "repo/migrate"
) )
func MustBeNotBare(ctx *context.Context) { func MustBeNotBare(ctx *context.Context) {
@ -85,7 +85,7 @@ func Create(ctx *context.Context) {
ctx.HTML(200, CREATE) ctx.HTML(200, CREATE)
} }
func handleCreateError(ctx *context.Context, owner *models.User, err error, name string, tpl tool.TplName, form interface{}) { func handleCreateError(ctx *context.Context, owner *models.User, err error, name, tpl string, form interface{}) {
switch { switch {
case models.IsErrReachLimitOfRepo(err): case models.IsErrReachLimitOfRepo(err):
ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.RepoCreationNum()), tpl, form) ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.RepoCreationNum()), tpl, form)

15
routers/repo/setting.go

@ -15,7 +15,6 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/mailer" "github.com/gogits/gogs/pkg/mailer"
@ -23,13 +22,13 @@ import (
) )
const ( const (
SETTINGS_OPTIONS tool.TplName = "repo/settings/options" SETTINGS_OPTIONS = "repo/settings/options"
SETTINGS_COLLABORATION tool.TplName = "repo/settings/collaboration" SETTINGS_COLLABORATION = "repo/settings/collaboration"
SETTINGS_BRANCHES tool.TplName = "repo/settings/branches" SETTINGS_BRANCHES = "repo/settings/branches"
SETTINGS_PROTECTED_BRANCH tool.TplName = "repo/settings/protected_branch" SETTINGS_PROTECTED_BRANCH = "repo/settings/protected_branch"
SETTINGS_GITHOOKS tool.TplName = "repo/settings/githooks" SETTINGS_GITHOOKS = "repo/settings/githooks"
SETTINGS_GITHOOK_EDIT tool.TplName = "repo/settings/githook_edit" SETTINGS_GITHOOK_EDIT = "repo/settings/githook_edit"
SETTINGS_DEPLOY_KEYS tool.TplName = "repo/settings/deploy_keys" SETTINGS_DEPLOY_KEYS = "repo/settings/deploy_keys"
) )
func Settings(ctx *context.Context) { func Settings(ctx *context.Context) {

12
routers/repo/view.go

@ -18,19 +18,19 @@ import (
"github.com/gogits/git-module" "github.com/gogits/git-module"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/markup" "github.com/gogits/gogs/pkg/markup"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/template" "github.com/gogits/gogs/pkg/template"
"github.com/gogits/gogs/pkg/template/highlight" "github.com/gogits/gogs/pkg/template/highlight"
"github.com/gogits/gogs/pkg/tool"
) )
const ( const (
BARE tool.TplName = "repo/bare" BARE = "repo/bare"
HOME tool.TplName = "repo/home" HOME = "repo/home"
WATCHERS tool.TplName = "repo/watchers" WATCHERS = "repo/watchers"
FORKS tool.TplName = "repo/forks" FORKS = "repo/forks"
) )
func renderDirectory(ctx *context.Context, treeLink string) { func renderDirectory(ctx *context.Context, treeLink string) {
@ -304,7 +304,7 @@ func Home(ctx *context.Context) {
ctx.HTML(200, HOME) ctx.HTML(200, HOME)
} }
func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*models.User, error), tpl tool.TplName) { func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*models.User, error), tpl string) {
page := ctx.QueryInt("page") page := ctx.QueryInt("page")
if page <= 0 { if page <= 0 {
page = 1 page = 1

9
routers/repo/webhook.go

@ -16,16 +16,15 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const ( const (
WEBHOOKS tool.TplName = "repo/settings/webhook/base" WEBHOOKS = "repo/settings/webhook/base"
WEBHOOK_NEW tool.TplName = "repo/settings/webhook/new" WEBHOOK_NEW = "repo/settings/webhook/new"
ORG_WEBHOOK_NEW tool.TplName = "org/settings/webhook_new" ORG_WEBHOOK_NEW = "org/settings/webhook_new"
) )
func Webhooks(ctx *context.Context) { func Webhooks(ctx *context.Context) {
@ -49,7 +48,7 @@ type OrgRepoCtx struct {
OrgID int64 OrgID int64
RepoID int64 RepoID int64
Link string Link string
NewTemplate tool.TplName NewTemplate string
} }
// getOrgRepoCtx determines whether this is a repo context or organization context. // getOrgRepoCtx determines whether this is a repo context or organization context.

9
routers/repo/wiki.go

@ -12,17 +12,16 @@ import (
"github.com/gogits/git-module" "github.com/gogits/git-module"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/markup" "github.com/gogits/gogs/pkg/markup"
) )
const ( const (
WIKI_START tool.TplName = "repo/wiki/start" WIKI_START = "repo/wiki/start"
WIKI_VIEW tool.TplName = "repo/wiki/view" WIKI_VIEW = "repo/wiki/view"
WIKI_NEW tool.TplName = "repo/wiki/new" WIKI_NEW = "repo/wiki/new"
WIKI_PAGES tool.TplName = "repo/wiki/pages" WIKI_PAGES = "repo/wiki/pages"
) )
func MustEnableWiki(ctx *context.Context) { func MustEnableWiki(ctx *context.Context) {

11
routers/user/auth.go

@ -13,7 +13,6 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/mailer" "github.com/gogits/gogs/pkg/mailer"
@ -21,11 +20,11 @@ import (
) )
const ( const (
SIGNIN tool.TplName = "user/auth/signin" SIGNIN = "user/auth/signin"
SIGNUP tool.TplName = "user/auth/signup" SIGNUP = "user/auth/signup"
ACTIVATE tool.TplName = "user/auth/activate" ACTIVATE = "user/auth/activate"
FORGOT_PASSWORD tool.TplName = "user/auth/forgot_passwd" FORGOT_PASSWORD = "user/auth/forgot_passwd"
RESET_PASSWORD tool.TplName = "user/auth/reset_passwd" RESET_PASSWORD = "user/auth/reset_passwd"
) )
// AutoSignIn reads cookie and try to auto-login. // AutoSignIn reads cookie and try to auto-login.

11
routers/user/home.go

@ -13,17 +13,16 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const ( const (
DASHBOARD tool.TplName = "user/dashboard/dashboard" DASHBOARD = "user/dashboard/dashboard"
NEWS_FEED tool.TplName = "user/dashboard/feeds" NEWS_FEED = "user/dashboard/feeds"
ISSUES tool.TplName = "user/dashboard/issues" ISSUES = "user/dashboard/issues"
PROFILE tool.TplName = "user/profile" PROFILE = "user/profile"
ORG_HOME tool.TplName = "org/home" ORG_HOME = "org/home"
) )
// getDashboardContextUser finds out dashboard is viewing as which context user. // getDashboardContextUser finds out dashboard is viewing as which context user.

5
routers/user/profile.go

@ -13,15 +13,14 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/routers/repo" "github.com/gogits/gogs/routers/repo"
) )
const ( const (
FOLLOWERS tool.TplName = "user/meta/followers" FOLLOWERS = "user/meta/followers"
STARS tool.TplName = "user/meta/stars" STARS = "user/meta/stars"
) )
func GetUserByName(ctx *context.Context, name string) *models.User { func GetUserByName(ctx *context.Context, name string) *models.User {

24
routers/user/setting.go

@ -14,25 +14,25 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/errors" "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
"github.com/gogits/gogs/pkg/context" "github.com/gogits/gogs/pkg/context"
"github.com/gogits/gogs/pkg/form" "github.com/gogits/gogs/pkg/form"
"github.com/gogits/gogs/pkg/mailer" "github.com/gogits/gogs/pkg/mailer"
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
"github.com/gogits/gogs/pkg/tool"
) )
const ( const (
SETTINGS_PROFILE tool.TplName = "user/settings/profile" SETTINGS_PROFILE = "user/settings/profile"
SETTINGS_AVATAR tool.TplName = "user/settings/avatar" SETTINGS_AVATAR = "user/settings/avatar"
SETTINGS_PASSWORD tool.TplName = "user/settings/password" SETTINGS_PASSWORD = "user/settings/password"
SETTINGS_EMAILS tool.TplName = "user/settings/email" SETTINGS_EMAILS = "user/settings/email"
SETTINGS_SSH_KEYS tool.TplName = "user/settings/sshkeys" SETTINGS_SSH_KEYS = "user/settings/sshkeys"
SETTINGS_SECURITY tool.TplName = "user/settings/security" SETTINGS_SECURITY = "user/settings/security"
SETTINGS_REPOSITORIES tool.TplName = "user/settings/repositories" SETTINGS_REPOSITORIES = "user/settings/repositories"
SETTINGS_ORGANIZATIONS tool.TplName = "user/settings/organizations" SETTINGS_ORGANIZATIONS = "user/settings/organizations"
SETTINGS_APPLICATIONS tool.TplName = "user/settings/applications" SETTINGS_APPLICATIONS = "user/settings/applications"
SETTINGS_DELETE tool.TplName = "user/settings/delete" SETTINGS_DELETE = "user/settings/delete"
NOTIFICATION tool.TplName = "user/notification" NOTIFICATION = "user/notification"
) )
func Settings(c *context.Context) { func Settings(c *context.Context) {

Loading…
Cancel
Save