From 3549fb0ea8c4e039ec55caf90e8cabf78cde87a2 Mon Sep 17 00:00:00 2001 From: Mathieu Gagnon Date: Sat, 13 Sep 2014 03:52:51 -0400 Subject: Remove APP_LOGO setting --- modules/setting/setting.go | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/modules/setting/setting.go b/modules/setting/setting.go index ebc1020a..199b4f2c 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -32,7 +32,6 @@ var ( // App settings. AppVer string AppName string - AppLogo string AppUrl string // Server settings. @@ -155,7 +154,6 @@ func NewConfigContext() { } AppName = Cfg.MustValue("", "APP_NAME", "Gogs: Go Git Service") - AppLogo = Cfg.MustValue("", "APP_LOGO", "img/favicon.png") AppUrl = Cfg.MustValue("server", "ROOT_URL", "http://localhost:3000/") if AppUrl[len(AppUrl)-1] != '/' { AppUrl += "/" -- cgit v1.2.3 From ebb4f1b78cdf7ce877eafc346be94b8e8ac3217b Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 16 Sep 2014 13:34:09 -0400 Subject: Work #475 and #458 --- models/publickey.go | 15 +++++++++++---- modules/setting/setting.go | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/models/publickey.go b/models/publickey.go index dccb8936..1824e887 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -14,7 +14,6 @@ import ( "os/exec" "path" "path/filepath" - "runtime" "strings" "sync" "time" @@ -23,6 +22,7 @@ import ( "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/process" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -120,23 +120,30 @@ func CheckPublicKeyString(content string) (bool, error) { tmpFile.WriteString(content) tmpFile.Close() - // … see if ssh-keygen recognizes its contents + // Check if ssh-keygen recognizes its contents. stdout, stderr, err := process.Exec("CheckPublicKeyString", "ssh-keygen", "-l", "-f", tmpPath) if err != nil { return false, errors.New("ssh-keygen -l -f: " + stderr) } else if len(stdout) < 2 { return false, errors.New("ssh-keygen returned not enough output to evaluate the key") } + + // The ssh-keygen in Windows does not print key type, so no need go further. + if setting.IsWindows { + return true, nil + } + sshKeygenOutput := strings.Split(stdout, " ") if len(sshKeygenOutput) < 4 { return false, errors.New("Not enough fields returned by ssh-keygen -l -f") } + + // Check if key type and key size match. keySize, err := com.StrTo(sshKeygenOutput[0]).Int() if err != nil { return false, errors.New("Cannot get key size of the given key") } keyType := strings.TrimSpace(sshKeygenOutput[len(sshKeygenOutput)-1]) - if minimumKeySize := MinimumKeySize[keyType]; minimumKeySize == 0 { return false, errors.New("Sorry, unrecognized public key type") } else if keySize < minimumKeySize { @@ -163,7 +170,7 @@ func saveAuthorizedKeyFile(key *PublicKey) error { } // FIXME: following command does not support in Windows. - if runtime.GOOS != "windows" { + if !setting.IsWindows { if finfo.Mode().Perm() > 0600 { log.Error(4, "authorized_keys file has unusual permission flags: %s - setting to -rw-------", finfo.Mode().Perm().String()) if err = f.Chmod(0600); err != nil { diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 199b4f2c..d2c4d49c 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -10,6 +10,7 @@ import ( "os/exec" "path" "path/filepath" + "runtime" "strings" "time" @@ -98,12 +99,14 @@ var ( CustomPath string // Custom directory path. ProdMode bool RunUser string + IsWindows bool // I18n settings. Langs, Names []string ) func init() { + IsWindows = runtime.GOOS == "windows" log.NewLogger(0, "console", `{"level": 0}`) } -- cgit v1.2.3 From ed84adb679f3de70b2bffaead20a87711c38ee3a Mon Sep 17 00:00:00 2001 From: lunnyxiao Date: Wed, 17 Sep 2014 12:03:03 +0800 Subject: toutf8 improved & add max git diff lines --- conf/app.ini | 3 +++ models/git_diff.go | 34 ++++++++++++++++++++++------------ modules/base/template.go | 27 +++++++++++++++++++++++++++ modules/setting/setting.go | 3 +++ routers/repo/commit.go | 7 +++++-- routers/repo/view.go | 20 +------------------- templates/repo/diff.tmpl | 2 +- 7 files changed, 62 insertions(+), 34 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/conf/app.ini b/conf/app.ini index be49e064..cb907b22 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -255,3 +255,6 @@ CONN = [i18n] LANGS = en-US,zh-CN,de-DE NAMES = English,简体中文,Deutsch + +[git] +MAX_GITDIFF_LINES = 10000 \ No newline at end of file diff --git a/models/git_diff.go b/models/git_diff.go index bf7a9cd5..e093e7ab 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -70,7 +70,7 @@ func (diff *Diff) NumFiles() int { const DIFF_HEAD = "diff --git " -func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { +func ParsePatch(pid int64, maxlines int, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { scanner := bufio.NewScanner(reader) var ( curFile *DiffFile @@ -79,6 +79,7 @@ func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { } leftLine, rightLine int + isTooLong bool ) diff := &Diff{Files: make([]*DiffFile, 0)} @@ -90,16 +91,17 @@ func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { continue } + if line == "" { + continue + } + i = i + 1 - // Diff data too large. - if i == 5000 { + // Diff data too large, we only show the first about maxlines lines + if i == maxlines { + isTooLong = true log.Warn("Diff data too large") - return &Diff{}, nil - } - - if line == "" { - continue + //return &Diff{}, nil } switch { @@ -110,6 +112,10 @@ func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { curSection.Lines = append(curSection.Lines, diffLine) continue case line[0] == '@': + if isTooLong { + return diff, nil + } + curSection = &DiffSection{} curFile.Sections = append(curFile.Sections, curSection) ss := strings.Split(line, "@@") @@ -143,6 +149,10 @@ func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { // Get new file. if strings.HasPrefix(line, DIFF_HEAD) { + if isTooLong { + return diff, nil + } + fs := strings.Split(line[len(DIFF_HEAD):], " ") a := fs[0] @@ -174,7 +184,7 @@ func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { return diff, nil } -func GetDiffRange(repoPath, beforeCommitId string, afterCommitId string) (*Diff, error) { +func GetDiffRange(repoPath, beforeCommitId string, afterCommitId string, maxlines int) (*Diff, error) { repo, err := git.OpenRepository(repoPath) if err != nil { return nil, err @@ -228,9 +238,9 @@ func GetDiffRange(repoPath, beforeCommitId string, afterCommitId string) (*Diff, } }() - return ParsePatch(pid, cmd, rd) + return ParsePatch(pid, maxlines, cmd, rd) } -func GetDiffCommit(repoPath, commitId string) (*Diff, error) { - return GetDiffRange(repoPath, "", commitId) +func GetDiffCommit(repoPath, commitId string, maxlines int) (*Diff, error) { + return GetDiffRange(repoPath, "", commitId, maxlines) } diff --git a/modules/base/template.go b/modules/base/template.go index f2ae00b9..64195729 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -8,13 +8,16 @@ import ( "bytes" "container/list" "encoding/json" + "errors" "fmt" "html/template" "runtime" "strings" "time" + "code.google.com/p/mahonia" "github.com/gogits/gogs/modules/setting" + "github.com/saintfish/chardet" ) func Str2html(raw string) template.HTML { @@ -45,6 +48,29 @@ func ShortSha(sha1 string) string { return sha1 } +func ToUtf8WithErr(content []byte) (error, string) { + detector := chardet.NewTextDetector() + result, err := detector.DetectBest(content) + if err != nil { + return err, "" + } + + if result.Charset == "utf8" { + return nil, string(content) + } + + decoder := mahonia.NewDecoder(result.Charset) + if decoder != nil { + return nil, decoder.ConvertString(string(content)) + } + return errors.New("unknow char decoder"), string(content) +} + +func ToUtf8(content string) string { + _, res := ToUtf8WithErr([]byte(content)) + return res +} + var mailDomains = map[string]string{ "gmail.com": "gmail.com", } @@ -103,6 +129,7 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "ActionContent2Commits": ActionContent2Commits, "Oauth2Icon": Oauth2Icon, "Oauth2Name": Oauth2Name, + "ToUtf8": ToUtf8, } type Actioner interface { diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 199b4f2c..011c00c0 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -64,6 +64,7 @@ var ( // Picture settings. PictureService string DisableGravatar bool + MaxGitDiffLines int // Log settings. LogRootPath string @@ -241,6 +242,8 @@ func NewConfigContext() { []string{"server"}) DisableGravatar = Cfg.MustBool("picture", "DISABLE_GRAVATAR") + MaxGitDiffLines = Cfg.MustInt("git", "MAX_GITDIFF_LINES", 5000) + Langs = Cfg.MustValueArray("i18n", "LANGS", ",") Names = Cfg.MustValueArray("i18n", "NAMES", ",") } diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 54acc85b..f7feb4d9 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -12,6 +12,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -114,7 +115,8 @@ func Diff(ctx *middleware.Context) { commit := ctx.Repo.Commit - diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), commitId) + diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), + commitId, setting.MaxGitDiffLines) if err != nil { ctx.Handle(404, "GetDiffCommit", err) return @@ -176,7 +178,8 @@ func CompareDiff(ctx *middleware.Context) { return } - diff, err := models.GetDiffRange(models.RepoPath(userName, repoName), beforeCommitId, afterCommitId) + diff, err := models.GetDiffRange(models.RepoPath(userName, repoName), beforeCommitId, + afterCommitId, setting.MaxGitDiffLines) if err != nil { ctx.Handle(404, "GetDiffRange", err) return diff --git a/routers/repo/view.go b/routers/repo/view.go index f98eee03..e42894ae 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -11,12 +11,9 @@ import ( "path/filepath" "strings" - "github.com/saintfish/chardet" - "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/git" "github.com/gogits/gogs/modules/log" - "github.com/gogits/gogs/modules/mahonia" "github.com/gogits/gogs/modules/middleware" ) @@ -24,21 +21,6 @@ const ( HOME base.TplName = "repo/home" ) -func toUtf8(content []byte) (error, string) { - detector := chardet.NewTextDetector() - result, err := detector.DetectBest(content) - if err != nil { - return err, "" - } - - if result.Charset == "utf8" { - return nil, string(content) - } - - decoder := mahonia.NewDecoder(result.Charset) - return nil, decoder.ConvertString(string(content)) -} - func Home(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Repo.Repository.Name @@ -117,7 +99,7 @@ func Home(ctx *middleware.Context) { if readmeExist { ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, "")) } else { - if err, content := toUtf8(buf); err != nil { + if err, content := base.ToUtf8WithErr(buf); err != nil { if err != nil { log.Error(4, "Convert content encoding: %s", err) } diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 78733450..a2150f28 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -105,7 +105,7 @@ {{if .RightIdx}}{{.RightIdx}}{{end}} -
{{.Content}}
+
{{ToUtf8 .Content}}
{{end}} -- cgit v1.2.3 From 8a09256941ab0e2ca81e98ac35081f6dc04bb22a Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 17 Sep 2014 14:22:51 -0400 Subject: Mirror fix and fix #481 --- README.md | 2 +- README_ZH.md | 2 +- conf/app.ini | 8 ++++---- gogs.go | 2 +- models/repo.go | 2 +- modules/base/template.go | 2 +- modules/setting/setting.go | 12 +++++++----- templates/.VERSION | 2 +- 8 files changed, 17 insertions(+), 15 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/README.md b/README.md index 43d75c26..08eed134 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ The goal of this project is to make the easiest, fastest and most painless way t - Slack webhook integration - Supports MySQL, PostgreSQL and SQLite3 - Social account login(GitHub, Google, QQ, Weibo) -- Multi-language support(English, Chinese, Germany etc.) +- Multi-language support(English, Chinese, Germany, French etc.) ## System Requirements diff --git a/README_ZH.md b/README_ZH.md index bf6c1d03..4f59e001 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -35,7 +35,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - Slack Web 钩子集成 - 支持 MySQL、PostgreSQL 以及 SQLite3 数据库 - 社交帐号登录(GitHub、Google、QQ、微博) -- 多语言支持(英文、简体中文、德语等等) +- 多语言支持(英文、简体中文、德语、法语等等) ## 系统要求 diff --git a/conf/app.ini b/conf/app.ini index 099e8052..ba73a0e8 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -252,9 +252,9 @@ DRIVER = ; Based on xorm, e.g.: root:root@localhost/gogs?charset=utf8 CONN = +[git] +MAX_GITDIFF_LINES = 10000 + [i18n] LANGS = en-US,zh-CN,de-DE,fr-CA -NAMES = English,简体中文,Deutsch,Français - -[git] -MAX_GITDIFF_LINES = 10000 \ No newline at end of file +NAMES = English,简体中文,Deutsch,Français \ No newline at end of file diff --git a/gogs.go b/gogs.go index 8ae7449e..c5249b25 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.2.0916 Beta" +const APP_VER = "0.5.2.0917 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/repo.go b/models/repo.go index 2e162704..ccfaae2c 100644 --- a/models/repo.go +++ b/models/repo.go @@ -656,7 +656,7 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error { } // Check if new owner has repository with same name. - has, err := IsRepositoryExist(u, repo.Name) + has, err := IsRepositoryExist(newUser, repo.Name) if err != nil { return err } else if has { diff --git a/modules/base/template.go b/modules/base/template.go index 64195729..338fe677 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -14,8 +14,8 @@ import ( "runtime" "strings" "time" - "code.google.com/p/mahonia" + "github.com/gogits/gogs/modules/mahonia" "github.com/gogits/gogs/modules/setting" "github.com/saintfish/chardet" ) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index c56ad242..5fb1d52d 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -65,7 +65,6 @@ var ( // Picture settings. PictureService string DisableGravatar bool - MaxGitDiffLines int // Log settings. LogRootPath string @@ -94,6 +93,12 @@ var ( SessionProvider string SessionConfig *session.Config + // Git settings. + MaxGitDiffLines int + + // I18n settings. + Langs, Names []string + // Global setting objects. Cfg *goconfig.ConfigFile ConfRootPath string @@ -101,9 +106,6 @@ var ( ProdMode bool RunUser string IsWindows bool - - // I18n settings. - Langs, Names []string ) func init() { @@ -245,7 +247,7 @@ func NewConfigContext() { []string{"server"}) DisableGravatar = Cfg.MustBool("picture", "DISABLE_GRAVATAR") - MaxGitDiffLines = Cfg.MustInt("git", "MAX_GITDIFF_LINES", 5000) + MaxGitDiffLines = Cfg.MustInt("git", "MAX_GITDIFF_LINES", 10000) Langs = Cfg.MustValueArray("i18n", "LANGS", ",") Names = Cfg.MustValueArray("i18n", "NAMES", ",") diff --git a/templates/.VERSION b/templates/.VERSION index aada89d1..29de2fdf 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.2.0916 Beta \ No newline at end of file +0.5.2.0917 Beta \ No newline at end of file -- cgit v1.2.3 From 0055cbd3651ebde0f8b6cc70c9c44de56dc38830 Mon Sep 17 00:00:00 2001 From: Martin van Beurden Date: Sun, 14 Sep 2014 19:35:22 +0200 Subject: Allow Gogs to run from a suburl behind a reverse proxy. e.g. http://mydomain.com/gogs/ Conflicts: modules/setting/setting.go Conflicts: templates/repo/release/list.tmpl templates/user/dashboard/dashboard.tmpl Conflicts: routers/repo/setting.go --- conf/locale/locale_de-DE.ini | 8 ++++---- conf/locale/locale_en-US.ini | 8 ++++---- conf/locale/locale_zh-CN.ini | 8 ++++---- models/action.go | 2 +- models/user.go | 6 +++--- modules/base/markdown.go | 3 ++- modules/base/template.go | 31 ++++++++++++++++-------------- modules/middleware/auth.go | 8 ++++---- modules/middleware/context.go | 2 +- modules/middleware/org.go | 7 ++++--- modules/middleware/repo.go | 12 ++++++------ modules/setting/setting.go | 14 +++++++++++--- public/ng/js/gogs.js | 13 +++++++------ routers/admin/admin.go | 2 +- routers/admin/auths.go | 9 +++++---- routers/admin/users.go | 9 +++++---- routers/home.go | 2 +- routers/install.go | 2 +- routers/org/members.go | 3 ++- routers/org/org.go | 3 ++- routers/org/setting.go | 9 +++++---- routers/repo/commit.go | 4 ++-- routers/repo/issue.go | 6 +++--- routers/repo/repo.go | 5 +++-- routers/repo/setting.go | 16 +++++++-------- routers/user/auth.go | 12 ++++++------ routers/user/home.go | 7 ++++--- routers/user/setting.go | 19 +++++++++--------- routers/user/social.go | 4 ++-- templates/admin/auth/edit.tmpl | 2 +- templates/admin/auth/list.tmpl | 10 +++++----- templates/admin/auth/new.tmpl | 2 +- templates/admin/dashboard.tmpl | 4 ++-- templates/admin/nav.tmpl | 14 +++++++------- templates/admin/org/list.tmpl | 6 +++--- templates/admin/repo/list.tmpl | 8 ++++---- templates/admin/user/edit.tmpl | 2 +- templates/admin/user/list.tmpl | 10 +++++----- templates/admin/user/new.tmpl | 2 +- templates/base/head.tmpl | 26 ++++++++++++------------- templates/base/navbar.tmpl | 18 ++++++++--------- templates/explore/nav.tmpl | 2 +- templates/explore/repos.tmpl | 2 +- templates/home.tmpl | 4 ++-- templates/install.tmpl | 2 +- templates/ng/base/head.tmpl | 22 ++++++++++----------- templates/ng/base/header.tmpl | 26 ++++++++++++------------- templates/ng/base/social.tmpl | 8 ++++---- templates/org/base/header.tmpl | 2 +- templates/org/create.tmpl | 4 ++-- templates/org/home.tmpl | 16 +++++++-------- templates/org/member/members.tmpl | 2 +- templates/org/new.tmpl | 4 ++-- templates/org/settings/delete.tmpl | 2 +- templates/org/settings/nav.tmpl | 6 +++--- templates/org/settings/options.tmpl | 2 +- templates/org/team/members.tmpl | 2 +- templates/org/team/repositories.tmpl | 2 +- templates/org/team/teams.tmpl | 2 +- templates/repo/bare.tmpl | 2 +- templates/repo/commits_table.tmpl | 4 ++-- templates/repo/create.tmpl | 4 ++-- templates/repo/diff.tmpl | 2 +- templates/repo/header.tmpl | 2 +- templates/repo/issue/list.tmpl | 2 +- templates/repo/issue/view.tmpl | 26 ++++++++++++------------- templates/repo/migrate.tmpl | 4 ++-- templates/repo/nav.tmpl | 6 +++--- templates/repo/release/list.tmpl | 4 ++-- templates/repo/setting_nav.tmpl | 6 +++--- templates/repo/settings/collaboration.tmpl | 2 +- templates/repo/single.tmpl | 2 +- templates/repo/single_list.tmpl | 6 +++--- templates/repo/view_list.tmpl | 4 ++-- templates/status/404.tmpl | 2 +- templates/status/500.tmpl | 2 +- templates/user/auth/activate.tmpl | 2 +- templates/user/auth/forgot_passwd.tmpl | 2 +- templates/user/auth/reset_passwd.tmpl | 2 +- templates/user/auth/signin.tmpl | 6 +++--- templates/user/auth/signup.tmpl | 4 ++-- templates/user/dashboard/dashboard.tmpl | 24 +++++++++++------------ templates/user/dashboard/nav.tmpl | 6 +++--- templates/user/issues.tmpl | 24 +++++++++++------------ templates/user/profile.tmpl | 2 +- templates/user/settings/delete.tmpl | 2 +- templates/user/settings/nav.tmpl | 10 +++++----- templates/user/settings/password.tmpl | 2 +- templates/user/settings/profile.tmpl | 2 +- templates/user/settings/social.tmpl | 2 +- templates/user/settings/sshkeys.tmpl | 4 ++-- 91 files changed, 322 insertions(+), 300 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index d8060f0b..20f27e18 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -490,10 +490,10 @@ monitor.start = Startzeit monitor.execute_time = Ausführungszeit [action] -create_repo = Repository erstellen %s -commit_repo = pushed to %s at %s -create_issue = opened issue %s#%s -comment_issue = commented on issue %s#%s +create_repo = Repository erstellen %s +commit_repo = pushed to %s at %s +create_issue = opened issue %s#%s +comment_issue = commented on issue %s#%s [tool] ago = vor diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 75ea7fcc..50422bd2 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -541,10 +541,10 @@ monitor.start = Start Time monitor.execute_time = Execution Time [action] -create_repo = created repository %s -commit_repo = pushed to %s at %s -create_issue = opened issue %s#%s -comment_issue = commented on issue %s#%s +create_repo = created repository %s +commit_repo = pushed to %s at %s +create_issue = opened issue %s#%s +comment_issue = commented on issue %s#%s [tool] ago = ago diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 606e4c98..f26d46fc 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -539,10 +539,10 @@ monitor.start = 开始时间 monitor.execute_time = 已执行时间 [action] -create_repo = 创建了仓库 %s -commit_repo = 推送了 %s 分支的代码到 %s -create_issue = 创建了工单 %s#%s -comment_issue = 评论了工单 %s#%s +create_repo = 创建了仓库 %s +commit_repo = 推送了 %s 分支的代码到 %s +create_issue = 创建了工单 %s#%s +comment_issue = 评论了工单 %s#%s [tool] ago = 之前 diff --git a/models/action.go b/models/action.go index a6b22b16..596f51af 100644 --- a/models/action.go +++ b/models/action.go @@ -137,7 +137,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com return err } - url := fmt.Sprintf("/%s/%s/commit/%s", repoUserName, repoName, c.Sha1) + url := fmt.Sprintf("%s/%s/%s/commit/%s", setting.AppRootSubUrl, repoUserName, repoName, c.Sha1) message := fmt.Sprintf(`%s`, url, c.Message) if _, err = CreateComment(userId, issue.RepoId, issue.Id, 0, 0, COMMIT, message, nil); err != nil { diff --git a/models/user.go b/models/user.go index b3ea8161..1bed8109 100644 --- a/models/user.go +++ b/models/user.go @@ -82,14 +82,14 @@ type User struct { // DashboardLink returns the user dashboard page link. func (u *User) DashboardLink() string { if u.IsOrganization() { - return "/org/" + u.Name + "/dashboard/" + return setting.AppRootSubUrl + "/org/" + u.Name + "/dashboard/" } - return "/" + return setting.AppRootSubUrl + "/" } // HomeLink returns the user home page link. func (u *User) HomeLink() string { - return "/user/" + u.Name + return setting.AppRootSubUrl + "/user/" + u.Name } // AvatarLink returns user gravatar link. diff --git a/modules/base/markdown.go b/modules/base/markdown.go index b8bd33e1..2aa81005 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/gogits/gfm" + "github.com/gogits/gogs/modules/setting" ) func isletter(c byte) bool { @@ -112,7 +113,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { ms := MentionPattern.FindAll(line, -1) for _, m := range ms { line = bytes.Replace(line, m, - []byte(fmt.Sprintf(`%s`, m[1:], m)), -1) + []byte(fmt.Sprintf(`%s`, setting.AppRootSubUrl, m[1:], m)), -1) } } diff --git a/modules/base/template.go b/modules/base/template.go index 338fe677..dd883ea3 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -82,6 +82,9 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "AppName": func() string { return setting.AppName }, + "AppRootSubUrl": func() string { + return setting.AppRootSubUrl + }, "AppVer": func() string { return setting.AppVer }, @@ -163,14 +166,14 @@ func ActionIcon(opType int) string { // TODO: Legacy const ( - TPL_CREATE_REPO = `%s created repository %s` - TPL_COMMIT_REPO = `%s pushed to %s at %s%s` - TPL_COMMIT_REPO_LI = `
user-avatar %s %s
` - TPL_CREATE_ISSUE = `%s opened issue %s#%s + TPL_CREATE_REPO = `%s created repository %s` + TPL_COMMIT_REPO = `%s pushed to %s at %s%s` + TPL_COMMIT_REPO_LI = `
user-avatar %s %s
` + TPL_CREATE_ISSUE = `%s opened issue %s#%s
user-avatar %s
` - TPL_TRANSFER_REPO = `%s transfered repository %s to %s` - TPL_PUSH_TAG = `%s pushed tag %s at %s` - TPL_COMMENT_ISSUE = `%s commented on issue %s#%s + TPL_TRANSFER_REPO = `%s transfered repository %s to %s` + TPL_PUSH_TAG = `%s pushed tag %s at %s` + TPL_COMMENT_ISSUE = `%s commented on issue %s#%s
user-avatar %s
` ) @@ -207,7 +210,7 @@ func ActionDesc(act Actioner) string { content := act.GetContent() switch act.GetOpType() { case 1: // Create repository. - return fmt.Sprintf(TPL_CREATE_REPO, actUserName, actUserName, repoLink, repoName) + return fmt.Sprintf(TPL_CREATE_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, repoName) case 5: // Commit repository. var push *PushCommits if err := json.Unmarshal([]byte(content), &push); err != nil { @@ -218,22 +221,22 @@ func ActionDesc(act Actioner) string { buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n") } if push.Len > 3 { - buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len)) + buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len)) } - return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, + return fmt.Sprintf(TPL_COMMIT_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, buf.String()) case 6: // Create issue. infos := strings.SplitN(content, "|", 2) - return fmt.Sprintf(TPL_CREATE_ISSUE, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], + return fmt.Sprintf(TPL_CREATE_ISSUE, setting.AppRootSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], AvatarLink(email), infos[1]) case 8: // Transfer repository. newRepoLink := content + "/" + repoName - return fmt.Sprintf(TPL_TRANSFER_REPO, actUserName, actUserName, repoLink, newRepoLink, newRepoLink) + return fmt.Sprintf(TPL_TRANSFER_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, newRepoLink, newRepoLink) case 9: // Push tag. - return fmt.Sprintf(TPL_PUSH_TAG, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink) + return fmt.Sprintf(TPL_PUSH_TAG, setting.AppRootSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink) case 10: // Comment issue. infos := strings.SplitN(content, "|", 2) - return fmt.Sprintf(TPL_COMMENT_ISSUE, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], + return fmt.Sprintf(TPL_COMMENT_ISSUE, setting.AppRootSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], AvatarLink(email), infos[1]) default: return "invalid type" diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 51ce48c6..ccd8d031 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -25,13 +25,13 @@ func Toggle(options *ToggleOptions) macaron.Handler { return func(ctx *Context) { // Cannot view any page before installation. if !setting.InstallLock { - ctx.Redirect("/install") + ctx.Redirect(setting.AppRootSubUrl + "/install") return } // Redirect to dashboard if user tries to visit any non-login page. if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" { - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") return } @@ -48,8 +48,8 @@ func Toggle(options *ToggleOptions) macaron.Handler { if strings.HasSuffix(ctx.Req.RequestURI, "watch") { return } - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI)) - ctx.Redirect("/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) + ctx.Redirect(setting.AppRootSubUrl + "/user/login") return } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { ctx.Data["Title"] = ctx.Tr("auth.active_your_account") diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 3ef1b1d6..5c26f91f 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -187,7 +187,7 @@ func Contexter() macaron.Handler { Session: sess, } // Compute current URL for real-time change language. - link := ctx.Req.RequestURI + link := setting.AppRootSubUrl + ctx.Req.RequestURI i := strings.Index(link, "?") if i > -1 { link = link[:i] diff --git a/modules/middleware/org.go b/modules/middleware/org.go index 7bb24ab7..3a2cf7bc 100644 --- a/modules/middleware/org.go +++ b/modules/middleware/org.go @@ -9,6 +9,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/log" + "github.com/gogits/gogs/modules/setting" ) func OrgAssignment(redirect bool, args ...bool) macaron.Handler { @@ -37,7 +38,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetUserByName", err) } else if redirect { log.Error(4, "GetUserByName", err) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } else { ctx.Handle(500, "GetUserByName", err) } @@ -67,7 +68,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { } ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner - ctx.Org.OrgLink = "/org/" + org.Name + ctx.Org.OrgLink = setting.AppRootSubUrl + "/org/" + org.Name ctx.Data["OrgLink"] = ctx.Org.OrgLink // Team. @@ -79,7 +80,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetTeam", err) } else if redirect { log.Error(4, "GetTeam", err) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } else { ctx.Handle(500, "GetTeam", err) } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 82ef3c79..e7d7fb56 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -60,7 +60,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetUserByName", err) } else if redirect { log.Error(4, "GetUserByName", err) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } else { ctx.Handle(500, "GetUserByName", err) } @@ -72,7 +72,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { if u == nil { if redirect { - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") return } ctx.Handle(404, "RepoAssignment", errors.New("invliad user account for single repository")) @@ -92,7 +92,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetRepositoryByName", err) return } else if redirect { - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") return } ctx.Handle(500, "GetRepositoryByName", err) @@ -160,7 +160,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { return } ctx.Repo.GitRepo = gitRepo - ctx.Repo.RepoLink = "/" + u.Name + "/" + repo.Name + ctx.Repo.RepoLink = setting.AppRootSubUrl + "/" + u.Name + "/" + repo.Name ctx.Data["RepoLink"] = ctx.Repo.RepoLink tags, err := ctx.Repo.GitRepo.GetTags() @@ -298,8 +298,8 @@ func RequireTrueOwner() macaron.Handler { return func(ctx *Context) { if !ctx.Repo.IsTrueOwner && !ctx.Repo.IsAdmin { if !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI)) - ctx.Redirect("/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) + ctx.Redirect(setting.AppRootSubUrl + "/user/login") return } ctx.Handle(404, ctx.Req.RequestURI, nil) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 5fb1d52d..74427744 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -6,6 +6,7 @@ package setting import ( "fmt" + "net/url" "os" "os/exec" "path" @@ -31,9 +32,10 @@ const ( var ( // App settings. - AppVer string - AppName string - AppUrl string + AppVer string + AppName string + AppUrl string + AppRootSubUrl string // Server settings. Protocol Scheme @@ -165,6 +167,12 @@ func NewConfigContext() { AppUrl += "/" } + url, err := url.Parse(AppUrl) + if err != nil { + log.Fatal(4, "Invalid ROOT_URL %s: %s", AppUrl, err) + } + AppRootSubUrl = strings.TrimSuffix(url.Path, "/") + Protocol = HTTP if Cfg.MustValue("server", "PROTOCOL") == "https" { Protocol = HTTPS diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index 74bb6cc2..fcc470e9 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -202,7 +202,7 @@ var Gogs = {}; // Search users by keyword. Gogs.searchUsers = function (val, $target) { $.ajax({ - url: '/api/v1/users/search?q=' + val, + url: Gogs.AppRootSubUrl + '/api/v1/users/search?q=' + val, dataType: "json", success: function (json) { if (json.ok && json.data.length) { @@ -222,7 +222,7 @@ var Gogs = {}; // Search repositories by keyword. Gogs.searchRepos = function (val, $target, $param) { $.ajax({ - url: '/api/v1/repos/search?q=' + val + '&' + $param, + url: Gogs.AppRootSubUrl + '/api/v1/repos/search?q=' + val + '&' + $param, dataType: "json", success: function (json) { if (json.ok && json.data.length) { @@ -245,7 +245,7 @@ var Gogs = {}; return; } $(selector).zclip({ - path: "/js/ZeroClipboard.swf", + path: Gogs.AppRootSubUrl + "/js/ZeroClipboard.swf", copy: function () { var t = $(this).data("copy-val"); var to = $($(this).data("copy-from")); @@ -592,6 +592,7 @@ function initInstall() { } $(document).ready(function () { + Gogs.AppRootSubUrl = $('head').data('suburl'); initCore(); if ($('#user-profile-setting').length) { initUserSetting(); @@ -644,7 +645,7 @@ function homepage() { $('#promo-form').submit(function (e) { if ($('#username').val() === "") { e.preventDefault(); - window.location.href = '/user/login'; + window.location.href = Gogs.AppRootSubUrl + '/user/login'; return true } }); @@ -652,9 +653,9 @@ function homepage() { $('#register-button').click(function (e) { if ($('#username').val() === "") { e.preventDefault(); - window.location.href = '/user/sign_up'; + window.location.href = Gogs.AppRootSubUrl + '/user/sign_up'; return true } - $('#promo-form').attr('action', '/user/sign_up'); + $('#promo-form').attr('action', Gogs.AppRootSubUrl + '/user/sign_up'); }); } diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 756d76c0..1fee7adb 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -143,7 +143,7 @@ func Dashboard(ctx *middleware.Context) { } else { ctx.Flash.Success(success) } - ctx.Redirect("/admin") + ctx.Redirect(setting.AppRootSubUrl + "/admin") return } diff --git a/routers/admin/auths.go b/routers/admin/auths.go index 6fbeab35..9eaae489 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -14,6 +14,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -99,7 +100,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } log.Trace("Authentication created by admin(%s): %s", ctx.User.Name, form.AuthName) - ctx.Redirect("/admin/auths") + ctx.Redirect(setting.AppRootSubUrl + "/admin/auths") } func EditAuthSource(ctx *middleware.Context) { @@ -180,7 +181,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { log.Trace("Authentication changed by admin(%s): %s", ctx.User.Name, form.AuthName) ctx.Flash.Success(ctx.Tr("admin.auths.update_success")) - ctx.Redirect("/admin/auths/" + ctx.Params(":authid")) + ctx.Redirect(setting.AppRootSubUrl + "/admin/auths/" + ctx.Params(":authid")) } func DeleteAuthSource(ctx *middleware.Context) { @@ -200,12 +201,12 @@ func DeleteAuthSource(ctx *middleware.Context) { switch err { case models.ErrAuthenticationUserUsed: ctx.Flash.Error("form.still_own_user") - ctx.Redirect("/admin/auths/" + ctx.Params(":authid")) + ctx.Redirect(setting.AppRootSubUrl + "/admin/auths/" + ctx.Params(":authid")) default: ctx.Handle(500, "DelLoginSource", err) } return } log.Trace("Authentication deleted by admin(%s): %s", ctx.User.Name, a.Name) - ctx.Redirect("/admin/auths") + ctx.Redirect(setting.AppRootSubUrl + "/admin/auths") } diff --git a/routers/admin/users.go b/routers/admin/users.go index 3f14e48f..5cdb0f5c 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -14,6 +14,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -120,7 +121,7 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) { return } log.Trace("Account created by admin(%s): %s", ctx.User.Name, u.Name) - ctx.Redirect("/admin/users") + ctx.Redirect(setting.AppRootSubUrl + "/admin/users") } func EditUser(ctx *middleware.Context) { @@ -197,7 +198,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) { ctx.Data["User"] = u ctx.Flash.Success(ctx.Tr("admin.users.update_profile_success")) - ctx.Redirect("/admin/users/" + ctx.Params(":userid")) + ctx.Redirect(setting.AppRootSubUrl + "/admin/users/" + ctx.Params(":userid")) } func DeleteUser(ctx *middleware.Context) { @@ -217,12 +218,12 @@ func DeleteUser(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) - ctx.Redirect("/admin/users/" + ctx.Params(":userid")) + ctx.Redirect(setting.AppRootSubUrl + "/admin/users/" + ctx.Params(":userid")) default: ctx.Handle(500, "DeleteUser", err) } return } log.Trace("Account deleted by admin(%s): %s", ctx.User.Name, u.Name) - ctx.Redirect("/admin/users") + ctx.Redirect(setting.AppRootSubUrl + "/admin/users") } diff --git a/routers/home.go b/routers/home.go index 36a4f50f..8e973d16 100644 --- a/routers/home.go +++ b/routers/home.go @@ -33,7 +33,7 @@ func Home(ctx *middleware.Context) { // Check auto-login. uname := ctx.GetCookie(setting.CookieUserName) if len(uname) != 0 { - ctx.Redirect("/user/login") + ctx.Redirect(setting.AppRootSubUrl + "/user/login") return } diff --git a/routers/install.go b/routers/install.go index 26409814..54da4d4f 100644 --- a/routers/install.go +++ b/routers/install.go @@ -253,5 +253,5 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { log.Info("First-time run install finished!") ctx.Flash.Success(ctx.Tr("install.install_success")) - ctx.Redirect("/user/login") + ctx.Redirect(setting.AppRootSubUrl + "/user/login") } diff --git a/routers/org/members.go b/routers/org/members.go index 823daec9..d3bd51ea 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -11,6 +11,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -86,7 +87,7 @@ func MembersAction(ctx *middleware.Context) { if ctx.Params(":action") != "leave" { ctx.Redirect(ctx.Org.OrgLink + "/members") } else { - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } } diff --git a/routers/org/org.go b/routers/org/org.go index 27ccf02d..cea70823 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -10,6 +10,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -82,5 +83,5 @@ func CreatePost(ctx *middleware.Context, form auth.CreateOrgForm) { } log.Trace("Organization created: %s", org.Name) - ctx.Redirect("/org/" + form.OrgName + "/dashboard") + ctx.Redirect(setting.AppRootSubUrl + "/org/" + form.OrgName + "/dashboard") } diff --git a/routers/org/setting.go b/routers/org/setting.go index f853ef0e..3d397c0c 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -11,6 +11,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -48,7 +49,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { } else if err = models.ChangeUserName(org, form.OrgUserName); err != nil { if err == models.ErrUserNameIllegal { ctx.Flash.Error(ctx.Tr("form.illegal_username")) - ctx.Redirect("/org/" + org.LowerName + "/settings") + ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.LowerName + "/settings") return } else { ctx.Handle(500, "ChangeUserName", err) @@ -72,7 +73,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { } log.Trace("Organization setting updated: %s", org.Name) ctx.Flash.Success(ctx.Tr("org.settings.update_setting_success")) - ctx.Redirect("/org/" + org.Name + "/settings") + ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.Name + "/settings") } func SettingsDelete(ctx *middleware.Context) { @@ -86,13 +87,13 @@ func SettingsDelete(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("form.org_still_own_repo")) - ctx.Redirect("/org/" + org.LowerName + "/settings/delete") + ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.LowerName + "/settings/delete") default: ctx.Handle(500, "DeleteOrganization", err) } } else { log.Trace("Organization deleted: %s", ctx.User.Name) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } return } diff --git a/routers/repo/commit.go b/routers/repo/commit.go index f7feb4d9..e58b9e78 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -159,8 +159,8 @@ func Diff(ctx *middleware.Context) { ctx.Data["Diff"] = diff ctx.Data["Parents"] = parents ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 - ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId) - ctx.Data["RawPath"] = "/" + path.Join(userName, repoName, "raw", commitId) + ctx.Data["SourcePath"] = setting.AppRootSubUrl + "/" + path.Join(userName, repoName, "src", commitId) + ctx.Data["RawPath"] = setting.AppRootSubUrl + "/" + path.Join(userName, repoName, "raw", commitId) ctx.HTML(200, DIFF) } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 934cf3c9..8aba82ff 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -54,8 +54,8 @@ func Issues(ctx *middleware.Context) { isShowClosed := ctx.Query("state") == "closed" if viewType != "all" && !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI)) - ctx.Redirect("/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) + ctx.Redirect(setting.AppRootSubUrl + "/user/login") return } @@ -312,7 +312,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) { } log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id) - send(200, fmt.Sprintf("/%s/%s/issues/%d", ctx.Params(":username"), ctx.Params(":reponame"), issue.Index), nil) + send(200, fmt.Sprintf("%s/%s/%s/issues/%d", setting.AppRootSubUrl, ctx.Params(":username"), ctx.Params(":reponame"), issue.Index), nil) } func checkLabels(labels, allLabels []*models.Label) { diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 17f20a0a..3bd9aa7c 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -18,6 +18,7 @@ import ( "github.com/gogits/gogs/modules/git" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -95,7 +96,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { form.Gitignore, form.License, form.Private, false, form.InitReadme) if err == nil { log.Trace("Repository created: %s/%s", ctxUser.Name, form.RepoName) - ctx.Redirect("/" + ctxUser.Name + "/" + form.RepoName) + ctx.Redirect(setting.AppRootSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) return } else if err == models.ErrRepoAlreadyExist { ctx.Data["Err_RepoName"] = true @@ -179,7 +180,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { form.Mirror, url) if err == nil { log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName) - ctx.Redirect("/" + ctxUser.Name + "/" + form.RepoName) + ctx.Redirect(setting.AppRootSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) return } else if err == models.ErrRepoAlreadyExist { ctx.Data["Err_RepoName"] = true diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 62f2dbf5..926b5432 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -97,7 +97,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) - ctx.Redirect(fmt.Sprintf("/%s/%s/settings", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)) + ctx.Redirect(fmt.Sprintf("%s/%s/%s/settings", setting.AppRootSubUrl, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)) case "transfer": if ctx.Repo.Repository.Name != form.RepoName { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) @@ -122,7 +122,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } log.Trace("Repository transfered: %s/%s -> %s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newOwner) ctx.Flash.Success(ctx.Tr("repo.settings.transfer_succeed")) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") case "delete": if ctx.Repo.Repository.Name != form.RepoName { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) @@ -151,9 +151,9 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } log.Trace("Repository deleted: %s/%s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if ctx.Repo.Owner.IsOrganization() { - ctx.Redirect("/org/" + ctx.Repo.Owner.Name + "/dashboard") + ctx.Redirect(setting.AppRootSubUrl + "/org/" + ctx.Repo.Owner.Name + "/dashboard") } else { - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } } } @@ -167,7 +167,7 @@ func SettingsCollaboration(ctx *middleware.Context) { if ctx.Req.Method == "POST" { name := strings.ToLower(ctx.Query("collaborator")) if len(name) == 0 || ctx.Repo.Owner.LowerName == name { - ctx.Redirect(ctx.Req.URL.Path) + ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) return } has, err := models.HasAccess(name, repoLink, models.WRITABLE) @@ -175,7 +175,7 @@ func SettingsCollaboration(ctx *middleware.Context) { ctx.Handle(500, "HasAccess", err) return } else if has { - ctx.Redirect(ctx.Req.URL.Path) + ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) return } @@ -183,7 +183,7 @@ func SettingsCollaboration(ctx *middleware.Context) { if err != nil { if err == models.ErrUserNotExist { ctx.Flash.Error(ctx.Tr("form.user_not_exist")) - ctx.Redirect(ctx.Req.URL.Path) + ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) } else { ctx.Handle(500, "GetUserByName", err) } @@ -204,7 +204,7 @@ func SettingsCollaboration(ctx *middleware.Context) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_collaborator_success")) - ctx.Redirect(ctx.Req.URL.Path) + ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) return } diff --git a/routers/user/auth.go b/routers/user/auth.go index e3d13216..1dbc3300 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -82,7 +82,7 @@ func SignIn(ctx *middleware.Context) { return } - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } func SignInPost(ctx *middleware.Context, form auth.SignInForm) { @@ -140,7 +140,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) { return } - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } func SignOut(ctx *middleware.Context) { @@ -151,7 +151,7 @@ func SignOut(ctx *middleware.Context) { ctx.Session.Delete("socialEmail") ctx.SetCookie(setting.CookieUserName, "", -1) ctx.SetCookie(setting.CookieRememberName, "", -1) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } func oauthSignUp(ctx *middleware.Context, sid int64) { @@ -288,7 +288,7 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe return } - ctx.Redirect("/user/login") + ctx.Redirect(setting.AppRootSubUrl + "/user/login") } func Activate(ctx *middleware.Context) { @@ -335,7 +335,7 @@ func Activate(ctx *middleware.Context) { ctx.Session.Set("uid", user.Id) ctx.Session.Set("uname", user.Name) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") return } @@ -437,7 +437,7 @@ func ResetPasswdPost(ctx *middleware.Context) { } log.Trace("User password reset: %s", u.Name) - ctx.Redirect("/user/login") + ctx.Redirect(setting.AppRootSubUrl + "/user/login") return } diff --git a/routers/user/home.go b/routers/user/home.go index 372f111a..b411b8fc 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -13,6 +13,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -126,7 +127,7 @@ func Profile(ctx *middleware.Context) { uname := ctx.Params(":username") // Special handle for FireFox requests favicon.ico. if uname == "favicon.ico" { - ctx.Redirect("/img/favicon.png") + ctx.Redirect(setting.AppRootSubUrl + "/img/favicon.png") return } @@ -141,7 +142,7 @@ func Profile(ctx *middleware.Context) { } if u.IsOrganization() { - ctx.Redirect("/org/" + u.Name) + ctx.Redirect(setting.AppRootSubUrl + "/org/" + u.Name) return } @@ -181,7 +182,7 @@ func Email2User(ctx *middleware.Context) { } return } - ctx.Redirect("/user/" + u.Name) + ctx.Redirect(setting.AppRootSubUrl + "/user/" + u.Name) } const ( diff --git a/routers/user/setting.go b/routers/user/setting.go index 4e0e468f..a540f054 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -14,6 +14,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -55,7 +56,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { } else if err = models.ChangeUserName(ctx.User, form.UserName); err != nil { if err == models.ErrUserNameIllegal { ctx.Flash.Error(ctx.Tr("form.illegal_username")) - ctx.Redirect("/user/settings") + ctx.Redirect(setting.AppRootSubUrl + "/user/settings") return } else { ctx.Handle(500, "ChangeUserName", err) @@ -78,7 +79,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { } log.Trace("User setting updated: %s", ctx.User.Name) ctx.Flash.Success(ctx.Tr("settings.update_profile_success")) - ctx.Redirect("/user/settings") + ctx.Redirect(setting.AppRootSubUrl + "/user/settings") } func SettingsPassword(ctx *middleware.Context) { @@ -119,7 +120,7 @@ func SettingsPasswordPost(ctx *middleware.Context, form auth.ChangePasswordForm) ctx.Flash.Success(ctx.Tr("settings.change_password_success")) } - ctx.Redirect("/user/settings/password") + ctx.Redirect(setting.AppRootSubUrl + "/user/settings/password") } func SettingsSSHKeys(ctx *middleware.Context) { @@ -160,7 +161,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { ctx.Handle(500, "DeletePublicKey", err) } else { log.Trace("SSH key deleted: %s", ctx.User.Name) - ctx.Redirect("/user/settings/ssh") + ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") } return } @@ -177,7 +178,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { if ok, err := models.CheckPublicKeyString(cleanContent); !ok { ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error())) - ctx.Redirect("/user/settings/ssh") + ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") return } @@ -196,7 +197,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { } else { log.Trace("SSH key added: %s", ctx.User.Name) ctx.Flash.Success(ctx.Tr("settings.add_key_success")) - ctx.Redirect("/user/settings/ssh") + ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") return } } @@ -217,7 +218,7 @@ func SettingsSocial(ctx *middleware.Context) { return } ctx.Flash.Success(ctx.Tr("settings.unbind_success")) - ctx.Redirect("/user/settings/social") + ctx.Redirect(setting.AppRootSubUrl + "/user/settings/social") return } @@ -248,13 +249,13 @@ func SettingsDelete(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("form.still_own_repo")) - ctx.Redirect("/user/settings/delete") + ctx.Redirect(setting.AppRootSubUrl + "/user/settings/delete") default: ctx.Handle(500, "DeleteUser", err) } } else { log.Trace("Account deleted: %s", ctx.User.Name) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } return } diff --git a/routers/user/social.go b/routers/user/social.go index 07c6deed..fc2ea5fb 100644 --- a/routers/user/social.go +++ b/routers/user/social.go @@ -22,7 +22,7 @@ import ( func extractPath(next string) string { n, err := url.Parse(next) if err != nil { - return "/" + return setting.AppRootSubUrl + "/" } return n.Path } @@ -88,7 +88,7 @@ func SocialSignIn(ctx *middleware.Context) { return } case models.ErrOauth2NotAssociated: - next = "/user/sign_up" + next = setting.AppRootSubUrl + "/user/sign_up" default: ctx.Handle(500, "social.SocialSignIn(GetOauth2)", err) return diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 400a4ceb..4dead7f0 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -12,7 +12,7 @@
{{.i18n.Tr "admin.auths.edit"}}
-
+ {{.CsrfTokenHtml}} {{$type := .Source.Type}} diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index 591d2ed4..ba10e1d2 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -13,7 +13,7 @@ {{.i18n.Tr "admin.auths.auth_manage_panel"}}
- {{.i18n.Tr "admin.auths.new"}} + {{.i18n.Tr "admin.auths.new"}}
@@ -31,20 +31,20 @@ {{range .Sources}} - + - + {{end}}
{{.Id}}{{.Name}}{{.Name}} {{.TypeString}} {{DateFormat .Updated "M d, Y"}} {{DateFormat .Created "M d, Y"}}
{{if or .LastPageNum .NextPageNum}} {{end}}
diff --git a/templates/admin/auth/new.tmpl b/templates/admin/auth/new.tmpl index 8f9f5ccc..869eff32 100644 --- a/templates/admin/auth/new.tmpl +++ b/templates/admin/auth/new.tmpl @@ -12,7 +12,7 @@
{{.i18n.Tr "admin.auths.new"}}
- + {{.CsrfTokenHtml}}
diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index 09e10582..00696611 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -34,11 +34,11 @@ {{.i18n.Tr "admin.dashboard.clean_unbind_oauth"}} - {{.i18n.Tr "admin.dashboard.operation_run"}} + {{.i18n.Tr "admin.dashboard.operation_run"}} {{.i18n.Tr "admin.dashboard.delete_inactivate_accounts"}} - {{.i18n.Tr "admin.dashboard.operation_run"}} + {{.i18n.Tr "admin.dashboard.operation_run"}} diff --git a/templates/admin/nav.tmpl b/templates/admin/nav.tmpl index ccb250c2..ae44f4a8 100644 --- a/templates/admin/nav.tmpl +++ b/templates/admin/nav.tmpl @@ -2,13 +2,13 @@

{{.i18n.Tr "admin_panel"}}

\ No newline at end of file diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index ea9167c0..f42c2c53 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -30,7 +30,7 @@ {{range .Orgs}} {{.Id}} - {{.Name}} + {{.Name}} {{.Email}} {{.NumTeams}} {{.NumMembers}} @@ -42,8 +42,8 @@ {{if or .LastPageNum .NextPageNum}} {{end}}
diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index 3f357158..3e7442a6 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -31,8 +31,8 @@ {{range .Repos}} {{.Id}} - {{.Owner.Name}} - {{.Name}} + {{.Owner.Name}} + {{.Name}} {{.NumWatches}} {{.NumIssues}} @@ -44,8 +44,8 @@ {{if or .LastPageNum .NextPageNum}} {{end}} diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index e8812670..e9ed7836 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -12,7 +12,7 @@
{{.i18n.Tr "admin.users.edit_account"}}
- + {{.CsrfTokenHtml}}
diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index 51e6604f..f85bb6c0 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -13,7 +13,7 @@ {{.i18n.Tr "admin.users.user_manage_panel"}}
- {{.i18n.Tr "admin.users.new_account"}} + {{.i18n.Tr "admin.users.new_account"}}
@@ -32,21 +32,21 @@ {{range .Users}} - + - + {{end}}
{{.Id}}{{.Name}}{{.Name}} {{.Email}} {{.NumRepos}} {{DateFormat .Created "M d, Y"}}
{{if or .LastPageNum .NextPageNum}} {{end}}
diff --git a/templates/admin/user/new.tmpl b/templates/admin/user/new.tmpl index 0c4ad603..db842c68 100644 --- a/templates/admin/user/new.tmpl +++ b/templates/admin/user/new.tmpl @@ -12,7 +12,7 @@
{{.i18n.Tr "admin.users.new_account"}}
- + {{.CsrfTokenHtml}}
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index a58299f8..55dd4690 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,8 +1,8 @@ - + - + @@ -19,21 +19,21 @@ {{else}} - - + + - - + + {{end}} - - - - - + + + + + - - + + {{if .Title}}{{.Title}} - {{end}}{{AppName}} diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index 75096a4e..991e773d 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -1,8 +1,8 @@ diff --git a/templates/explore/nav.tmpl b/templates/explore/nav.tmpl index 1310bccf..a6c0acad 100644 --- a/templates/explore/nav.tmpl +++ b/templates/explore/nav.tmpl @@ -2,7 +2,7 @@

{{.i18n.Tr "explore"}}

\ No newline at end of file diff --git a/templates/explore/repos.tmpl b/templates/explore/repos.tmpl index a1e3d408..b8ae1791 100644 --- a/templates/explore/repos.tmpl +++ b/templates/explore/repos.tmpl @@ -12,7 +12,7 @@
  • {{.NumStars}}
  • {{.NumForks}}
  • -

    {{.Name}}

    +

    {{.Name}}

    {{.Description}}

    {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}

    diff --git a/templates/home.tmpl b/templates/home.tmpl index ba9cbe40..0fa70869 100644 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -3,12 +3,12 @@

    Gogs

    {{.i18n.Tr "app_desc"}}

    -
    + {{.CsrfTokenHtml}} diff --git a/templates/install.tmpl b/templates/install.tmpl index 7840f7ad..eb294082 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -8,7 +8,7 @@
    {{.i18n.Tr "install.title"}}
    - + {{.CsrfTokenHtml}}
    {{.i18n.Tr "install.requite_db_desc"}}
    diff --git a/templates/ng/base/head.tmpl b/templates/ng/base/head.tmpl index 40c3899e..222edb69 100644 --- a/templates/ng/base/head.tmpl +++ b/templates/ng/base/head.tmpl @@ -1,6 +1,6 @@ - + @@ -9,27 +9,27 @@ {{if .Repository.IsGoget}}{{end}} - + {{if CdnMode}} {{else}} - + - + {{end}} - - - - + + + + - - - + + + {{if .Title}}{{.Title}} - {{end}}{{AppName}} diff --git a/templates/ng/base/header.tmpl b/templates/ng/base/header.tmpl index 31533d27..af3bc02f 100644 --- a/templates/ng/base/header.tmpl +++ b/templates/ng/base/header.tmpl @@ -2,37 +2,37 @@ -

    {{.Name}}

    +

    {{.Name}}

    {{.Description}}

    {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}

    @@ -46,20 +46,20 @@
    {{if $isMember}} - {{.Org.NumMembers}} + {{.Org.NumMembers}} {{end}} {{.i18n.Tr "org.people"}}
    {{range .Members}} {{if or $isMember (.IsPublicMember $.Org.Id)}} - + {{end}} {{end}}
    {{if .IsOrganizationOwner}} {{end}}
    @@ -67,14 +67,14 @@
    - {{.Org.NumTeams}} + {{.Org.NumTeams}} {{.i18n.Tr "org.teams"}}
      {{range .Teams}}
    • - {{.Name}} + {{.Name}}

      {{.NumMembers}} {{$.i18n.Tr "org.lower_members"}} · {{.NumRepos}} {{$.i18n.Tr "org.lower_repositories"}}

    • {{end}} @@ -82,7 +82,7 @@
    {{if .IsOrganizationOwner}} {{end}}
    diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index 1c530982..eb4b9b7f 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -14,7 +14,7 @@ {{range .Members}}
    - {{.FullName}}({{.Name}}) + {{.FullName}}({{.Name}})
    • {{ $isPublic := .IsPublicMember $.Org.Id}} diff --git a/templates/org/new.tmpl b/templates/org/new.tmpl index 870f3982..eb5fd9a3 100644 --- a/templates/org/new.tmpl +++ b/templates/org/new.tmpl @@ -1,7 +1,7 @@ {{template "base/head" .}} {{template "base/navbar" .}}
      -
      + {{.CsrfTokenHtml}}

      Create New Organization

      {{template "base/alert" .}} @@ -24,7 +24,7 @@
      - Cancel + Cancel
      diff --git a/templates/org/settings/delete.tmpl b/templates/org/settings/delete.tmpl index ea9853d9..938fdd64 100644 --- a/templates/org/settings/delete.tmpl +++ b/templates/org/settings/delete.tmpl @@ -12,7 +12,7 @@

      {{.i18n.Tr "org.settings.delete_account"}}

      {{.i18n.Tr "org.settings.delete_prompt" | Str2html}} -
      + {{.CsrfTokenHtml}}

      diff --git a/templates/org/settings/nav.tmpl b/templates/org/settings/nav.tmpl index 954893c6..63cb6f08 100644 --- a/templates/org/settings/nav.tmpl +++ b/templates/org/settings/nav.tmpl @@ -4,9 +4,9 @@

      diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 14ea1b34..09492193 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -12,7 +12,7 @@
      {{.i18n.Tr "org.settings.options"}}
      - + {{.CsrfTokenHtml}}
      diff --git a/templates/org/team/members.tmpl b/templates/org/team/members.tmpl index d3176be1..ad9b30ed 100644 --- a/templates/org/team/members.tmpl +++ b/templates/org/team/members.tmpl @@ -30,7 +30,7 @@ {{if $.IsOrganizationOwner}} {{$.i18n.Tr "org.members.remove"}} {{end}} - + {{.Name}} {{.FullName}} ({{.Name}}) diff --git a/templates/org/team/repositories.tmpl b/templates/org/team/repositories.tmpl index 0a3f7710..f7ff97d8 100644 --- a/templates/org/team/repositories.tmpl +++ b/templates/org/team/repositories.tmpl @@ -30,7 +30,7 @@ {{if $canAddRemove}} {{$.i18n.Tr "org.teams.remove_repo"}} {{end}} - + {{$.Org.Name}}/{{.Name}} diff --git a/templates/org/team/teams.tmpl b/templates/org/team/teams.tmpl index 9c47cb5a..6440807f 100644 --- a/templates/org/team/teams.tmpl +++ b/templates/org/team/teams.tmpl @@ -25,7 +25,7 @@ {{if .NumMembers}}
      {{range .Members}} - + {{end}} diff --git a/templates/repo/bare.tmpl b/templates/repo/bare.tmpl index d53cd823..712e7013 100644 --- a/templates/repo/bare.tmpl +++ b/templates/repo/bare.tmpl @@ -5,7 +5,7 @@

      - {{.Repository.Owner.Name}} + {{.Repository.Owner.Name}} / {{.Repository.Name}}

      diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl index 4612398a..aa97925c 100644 --- a/templates/repo/commits_table.tmpl +++ b/templates/repo/commits_table.tmpl @@ -26,8 +26,8 @@ {{$r := List .Commits}} {{range $r}} - {{.Author.Name}} - {{SubStr .Id.String 0 10}} + {{.Author.Name}} + {{SubStr .Id.String 0 10}} {{.Summary}} {{TimeSince .Author.When $.Lang}} diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 6baa6d31..7b3c85ae 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - + {{.CsrfTokenHtml}}

      {{.i18n.Tr "new_repo"}}

      @@ -75,7 +75,7 @@
      - {{.i18n.Tr "cancel"}} + {{.i18n.Tr "cancel"}}
      diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index a2150f28..548c7a35 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -30,7 +30,7 @@

      - {{.Commit.Author.Name}} + {{.Commit.Author.Name}} {{TimeSince .Commit.Author.When $.Lang}}

      diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 42ae775a..dc271a75 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -2,7 +2,7 @@

      - {{.Owner.Name}} + {{.Owner.Name}} / {{.Repository.Name}} {{if .Repository.IsMirror}}{{.i18n.Tr "mirror"}}{{end}} diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 099e41b2..1849602b 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -85,7 +85,7 @@

      - {{.Poster.Name}} + {{.Poster.Name}} {{TimeSince .Created $.Lang}} {{.NumComments}}

      diff --git a/templates/repo/issue/view.tmpl b/templates/repo/issue/view.tmpl index ff68ce0c..dbbd1d92 100644 --- a/templates/repo/issue/view.tmpl +++ b/templates/repo/issue/view.tmpl @@ -8,7 +8,7 @@
      #{{.Issue.Index}}
      - +

      {{.Issue.Name}}

      @@ -17,7 +17,7 @@ {{end}} {{if .Issue.IsClosed}}Closed{{else}}Open{{end}} - {{.Issue.Poster.Name}} opened this issue + {{.Issue.Poster.Name}} opened this issue {{TimeSince .Issue.Created $.Lang}} · {{.Issue.NumComments}} comments

      @@ -63,10 +63,10 @@ {{/* 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE, 4 = COMMIT, 5 = PULL */}} {{if eq .Type 0}}
      - +
      - {{.Poster.Name}} commented {{TimeSince .Created $.Lang}} + {{.Poster.Name}} commented {{TimeSince .Created $.Lang}} Owner @@ -93,25 +93,25 @@
      {{else if eq .Type 1}}
      - +
      - {{.Poster.Name}} Reopened this issue {{TimeSince .Created $.Lang}} + {{.Poster.Name}} Reopened this issue {{TimeSince .Created $.Lang}}
      {{else if eq .Type 2}}
      - +
      - {{.Poster.Name}} Closed this issue {{TimeSince .Created $.Lang}} + {{.Poster.Name}} Closed this issue {{TimeSince .Created $.Lang}}
      {{else if eq .Type 4}}
      - +
      - {{.Poster.Name}} Referenced this issue {{TimeSince .Created $.Lang}} + {{.Poster.Name}} Referenced this issue {{TimeSince .Created $.Lang}}

      - + {{.ContentHtml}}

      @@ -120,7 +120,7 @@ {{end}}
      {{if .SignedUser}}
      - +
      {{.CsrfTokenHtml}}
      @@ -163,7 +163,7 @@
      -
      {{else}}
      Sign up for free to join this conversation. Already have an account? Sign in to comment
      {{end}} +
      {{else}}
      Sign up for free to join this conversation. Already have an account? Sign in to comment
      {{end}}
      diff --git a/templates/repo/migrate.tmpl b/templates/repo/migrate.tmpl index 7c983d76..f40124bf 100644 --- a/templates/repo/migrate.tmpl +++ b/templates/repo/migrate.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      -
      + {{.CsrfTokenHtml}}

      {{.i18n.Tr "new_migrate"}}

      @@ -74,7 +74,7 @@
      - {{.i18n.Tr "cancel"}} + {{.i18n.Tr "cancel"}}
      diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl index 69f60ba4..566e11a0 100644 --- a/templates/repo/nav.tmpl +++ b/templates/repo/nav.tmpl @@ -2,7 +2,7 @@
      -

      {{.Owner.Name}} / {{.Repository.Name}} {{if .Repository.IsPrivate}}Private{{else if .Repository.IsMirror}}Mirror{{end}}

      +

      {{.Owner.Name}} / {{.Repository.Name}} {{if .Repository.IsPrivate}}Private{{else if .Repository.IsMirror}}Mirror{{end}}

      {{.Repository.DescriptionHtml}}{{if .Repository.Website}} {{.Repository.Website}}{{end}}

      @@ -32,7 +32,7 @@
      {{if .IsSigned}} -
      +
      {{if .IsRepositoryWatching}} {{else}} @@ -59,7 +59,7 @@
      --> {{end}}
      diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index b9f46258..2bb5faa4 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -6,7 +6,7 @@

      Releases + Tags -->

        @@ -28,7 +28,7 @@

        {{.Title}} (edit)

           - {{.Publisher.Name}} + {{.Publisher.Name}} {{if .Created}}{{TimeSince .Created $.Lang}}{{end}} {{.NumCommitsBehind}} commits to {{.Target}} since this release

        diff --git a/templates/repo/setting_nav.tmpl b/templates/repo/setting_nav.tmpl index 489602b4..8cd1f2a2 100644 --- a/templates/repo/setting_nav.tmpl +++ b/templates/repo/setting_nav.tmpl @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/templates/repo/settings/collaboration.tmpl b/templates/repo/settings/collaboration.tmpl index fe4ec498..99561e27 100644 --- a/templates/repo/settings/collaboration.tmpl +++ b/templates/repo/settings/collaboration.tmpl @@ -18,7 +18,7 @@ {{range .Collaborators}}
      • {{if not (eq .Id $.Owner.Id)}}{{end}} - + {{.Name}} {{.FullName}} ({{.Name}}) diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl index 7ee6b0ca..9fbf2f55 100644 --- a/templates/repo/single.tmpl +++ b/templates/repo/single.tmpl @@ -12,7 +12,7 @@
      diff --git a/templates/repo/single_list.tmpl b/templates/repo/single_list.tmpl index 640f7f09..6728dd70 100644 --- a/templates/repo/single_list.tmpl +++ b/templates/repo/single_list.tmpl @@ -1,9 +1,9 @@
      - {{.LastCommit.Author.Name}} {{TimeSince .LastCommit.Author.When}} + {{.LastCommit.Author.Name}} {{TimeSince .LastCommit.Author.When}}
      @@ -36,7 +36,7 @@ diff --git a/templates/status/404.tmpl b/templates/status/404.tmpl index e024715e..5a57e954 100644 --- a/templates/status/404.tmpl +++ b/templates/status/404.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      -

      404

      +

      404



      Application Version: {{AppVer}}

      diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index b887532d..5bfdccc6 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      -

      500

      +

      500



      {{if .ErrorMsg}}

      An error has occurred : {{.ErrorMsg}}

      {{end}} diff --git a/templates/user/auth/activate.tmpl b/templates/user/auth/activate.tmpl index 6a9e0b0d..554e2b78 100644 --- a/templates/user/auth/activate.tmpl +++ b/templates/user/auth/activate.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      -
      + {{.CsrfTokenHtml}}

      {{.i18n.Tr "auth.active_your_account"}}

      diff --git a/templates/user/auth/forgot_passwd.tmpl b/templates/user/auth/forgot_passwd.tmpl index 3e9f76e9..a1a10093 100644 --- a/templates/user/auth/forgot_passwd.tmpl +++ b/templates/user/auth/forgot_passwd.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - + {{.CsrfTokenHtml}}

      {{.i18n.Tr "auth.forgot_password"}}

      diff --git a/templates/user/auth/reset_passwd.tmpl b/templates/user/auth/reset_passwd.tmpl index 3c9da96b..de2976d6 100644 --- a/templates/user/auth/reset_passwd.tmpl +++ b/templates/user/auth/reset_passwd.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - + {{.CsrfTokenHtml}}

      {{.i18n.Tr "auth.reset_password"}}

      diff --git a/templates/user/auth/signin.tmpl b/templates/user/auth/signin.tmpl index c2f6ef87..e9ec87cc 100644 --- a/templates/user/auth/signin.tmpl +++ b/templates/user/auth/signin.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - +

      {{if .IsSocialLogin}}{{.i18n.Tr "social_sign_in" | Str2html}}{{else}}{{.i18n.Tr "sign_in"}}{{end}}

      @@ -24,12 +24,12 @@
           - {{if not .IsSocialLogin}}{{.i18n.Tr "auth.forget_password"}}{{end}} + {{if not .IsSocialLogin}}{{.i18n.Tr "auth.forget_password"}}{{end}}
      {{if not .IsSocialLogin}} {{if .OauthEnabled}}
      diff --git a/templates/user/auth/signup.tmpl b/templates/user/auth/signup.tmpl index d116ad62..af4c250f 100644 --- a/templates/user/auth/signup.tmpl +++ b/templates/user/auth/signup.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - +

      {{if .IsSocialLogin}}{{.i18n.Tr "social_sign_in" | Str2html}}{{else}}{{.i18n.Tr "sign_up"}}{{end}}

      @@ -40,7 +40,7 @@
      {{end}}
      diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index a9326fa6..db838452 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -12,17 +12,17 @@

      - {{.GetActUserName}} + {{.GetActUserName}} {{if eq .GetOpType 1}} - {{$.i18n.Tr "action.create_repo" .GetRepoLink .GetRepoLink | Str2html}} + {{$.i18n.Tr "action.create_repo" AppRootSubUrl .GetRepoLink .GetRepoLink | Str2html}} {{else if eq .GetOpType 5}} - {{$.i18n.Tr "action.commit_repo" .GetRepoLink .GetBranch .GetBranch .GetRepoLink .GetRepoLink | Str2html}} + {{$.i18n.Tr "action.commit_repo" AppRootSubUrl .GetRepoLink .GetBranch .GetBranch AppRootSubUrl .GetRepoLink .GetRepoLink | Str2html}} {{else if eq .GetOpType 6}} {{ $index := index .GetIssueInfos 0}} - {{$.i18n.Tr "action.create_issue" .GetRepoLink $index .GetRepoLink $index | Str2html}} + {{$.i18n.Tr "action.create_issue" AppRootSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} {{else if eq .GetOpType 10}} {{ $index := index .GetIssueInfos 0}} - {{$.i18n.Tr "action.comment_issue" .GetRepoLink $index .GetRepoLink $index | Str2html}} + {{$.i18n.Tr "action.comment_issue" AppRootSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} {{end}}

      {{if eq .GetOpType 5}} @@ -31,7 +31,7 @@ {{ $push := ActionContent2Commits .}} {{ $repoLink := .GetRepoLink}} {{range $push.Commits}} -
    • {{ShortSha .Sha1}} {{.Message}}
    • +
    • {{ShortSha .Sha1}} {{.Message}}
    • {{end}}
      @@ -58,9 +58,9 @@ @@ -75,7 +75,7 @@
      diff --git a/templates/user/issues.tmpl b/templates/user/issues.tmpl index 93e798aa..19b0526c 100644 --- a/templates/user/issues.tmpl +++ b/templates/user/issues.tmpl @@ -3,10 +3,10 @@

      Your Issues

      @@ -17,30 +17,30 @@
      {{range .Issues}}{{if .}}
      #{{.Index}} -
      {{.Name}}
      +
      {{.Name}}

      - {{.Poster.Name}} + {{.Poster.Name}} {{TimeSince .Created $.Lang}} {{.NumComments}}

      diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index fe4e32f7..1b51a871 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -66,7 +66,7 @@
    • {{.NumForks}}

      - {{.Name}}{{if .IsPrivate}} Private{{end}} + {{.Name}}{{if .IsPrivate}} Private{{end}}

      {{.Description}}

      Last updated {{TimeSince .Updated $.Lang}}
      diff --git a/templates/user/settings/delete.tmpl b/templates/user/settings/delete.tmpl index 9bfc287d..78574ba1 100644 --- a/templates/user/settings/delete.tmpl +++ b/templates/user/settings/delete.tmpl @@ -11,7 +11,7 @@

      {{.i18n.Tr "settings.delete_account"}}

      {{.i18n.Tr "settings.delete_prompt" | Str2html}} - + {{.CsrfTokenHtml}}

      diff --git a/templates/user/settings/nav.tmpl b/templates/user/settings/nav.tmpl index d6d20dee..52fc83e1 100644 --- a/templates/user/settings/nav.tmpl +++ b/templates/user/settings/nav.tmpl @@ -2,11 +2,11 @@

      {{.i18n.Tr "settings"}}

      \ No newline at end of file diff --git a/templates/user/settings/password.tmpl b/templates/user/settings/password.tmpl index 44e087af..ccafd3ed 100644 --- a/templates/user/settings/password.tmpl +++ b/templates/user/settings/password.tmpl @@ -9,7 +9,7 @@

      {{.i18n.Tr "settings.change_password"}}

      - + {{.CsrfTokenHtml}}

      diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 663d8bdb..e344fb9a 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -11,7 +11,7 @@

      {{.i18n.Tr "settings.public_profile"}}
      - + {{.CsrfTokenHtml}}
      {{.i18n.Tr "settings.profile_desc"}}
      diff --git a/templates/user/settings/social.tmpl b/templates/user/settings/social.tmpl index bcbc1fc5..a2585922 100644 --- a/templates/user/settings/social.tmpl +++ b/templates/user/settings/social.tmpl @@ -20,7 +20,7 @@

      {{.Identity}}

      {{$.i18n.Tr "settings.add_on"}} {{DateFormat .Created "M d, Y"}} — {{$.i18n.Tr "settings.last_used"}} {{DateFormat .Updated "M d, Y"}}

      - {{$.i18n.Tr "settings.unbind"}} + {{$.i18n.Tr "settings.unbind"}}
    • {{end}} diff --git a/templates/user/settings/sshkeys.tmpl b/templates/user/settings/sshkeys.tmpl index 3db0f54b..2d186121 100644 --- a/templates/user/settings/sshkeys.tmpl +++ b/templates/user/settings/sshkeys.tmpl @@ -23,7 +23,7 @@

      {{.Fingerprint}}

      {{$.i18n.Tr "settings.add_on"}} {{DateFormat .Created "M d, Y"}} — {{if .HasUsed}}{{$.i18n.Tr "settings.last_used"}} {{DateFormat .Updated "M d, Y"}}{{else}}{{$.i18n.Tr "settings.no_activity"}}{{end}}

      - + {{$.CsrfTokenHtml}} @@ -35,7 +35,7 @@

      {{.i18n.Tr "settings.ssh_helper" | Str2html}}


      - + {{.CsrfTokenHtml}}

      {{.i18n.Tr "settings.add_new_key"}}

      -- cgit v1.2.3 From 7ba9257a7ff659417501baf7358216555cebcd86 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 19 Sep 2014 20:11:34 -0400 Subject: Add suburl support --- cmd/web.go | 7 +++++-- gogs.go | 2 +- models/action.go | 2 +- models/user.go | 6 +++--- modules/base/markdown.go | 2 +- modules/base/template.go | 16 ++++++++-------- modules/middleware/auth.go | 8 ++++---- modules/middleware/context.go | 2 +- modules/middleware/org.go | 6 +++--- modules/middleware/repo.go | 12 ++++++------ modules/setting/setting.go | 13 +++++++------ routers/admin/admin.go | 2 +- routers/admin/auths.go | 8 ++++---- routers/admin/users.go | 8 ++++---- routers/home.go | 2 +- routers/install.go | 2 +- routers/org/members.go | 2 +- routers/org/org.go | 2 +- routers/org/setting.go | 8 ++++---- routers/repo/commit.go | 4 ++-- routers/repo/issue.go | 6 +++--- routers/repo/repo.go | 4 ++-- routers/repo/setting.go | 16 ++++++++-------- routers/user/auth.go | 12 ++++++------ routers/user/home.go | 6 +++--- routers/user/setting.go | 18 +++++++++--------- routers/user/social.go | 4 ++-- templates/.VERSION | 2 +- templates/admin/auth/edit.tmpl | 2 +- templates/admin/auth/list.tmpl | 10 +++++----- templates/admin/auth/new.tmpl | 2 +- templates/admin/dashboard.tmpl | 4 ++-- templates/admin/nav.tmpl | 14 +++++++------- templates/admin/org/list.tmpl | 6 +++--- templates/admin/repo/list.tmpl | 8 ++++---- templates/admin/user/edit.tmpl | 2 +- templates/admin/user/list.tmpl | 10 +++++----- templates/admin/user/new.tmpl | 2 +- templates/base/head.tmpl | 26 +++++++++++++------------- templates/base/navbar.tmpl | 18 +++++++++--------- templates/explore/nav.tmpl | 2 +- templates/explore/repos.tmpl | 2 +- templates/home.tmpl | 4 ++-- templates/install.tmpl | 2 +- templates/ng/base/head.tmpl | 22 +++++++++++----------- templates/ng/base/header.tmpl | 26 +++++++++++++------------- templates/ng/base/social.tmpl | 8 ++++---- templates/org/base/header.tmpl | 2 +- templates/org/create.tmpl | 4 ++-- templates/org/home.tmpl | 16 ++++++++-------- templates/org/member/members.tmpl | 2 +- templates/org/new.tmpl | 4 ++-- templates/org/settings/delete.tmpl | 2 +- templates/org/settings/nav.tmpl | 6 +++--- templates/org/settings/options.tmpl | 2 +- templates/org/team/members.tmpl | 2 +- templates/org/team/repositories.tmpl | 2 +- templates/org/team/teams.tmpl | 2 +- templates/repo/bare.tmpl | 2 +- templates/repo/commits_table.tmpl | 4 ++-- templates/repo/create.tmpl | 4 ++-- templates/repo/diff.tmpl | 2 +- templates/repo/header.tmpl | 2 +- templates/repo/issue/list.tmpl | 2 +- templates/repo/issue/view.tmpl | 26 +++++++++++++------------- templates/repo/migrate.tmpl | 4 ++-- templates/repo/nav.tmpl | 6 +++--- templates/repo/release/list.tmpl | 4 ++-- templates/repo/setting_nav.tmpl | 6 +++--- templates/repo/settings/collaboration.tmpl | 2 +- templates/repo/single.tmpl | 2 +- templates/repo/single_list.tmpl | 6 +++--- templates/repo/view_list.tmpl | 4 ++-- templates/status/404.tmpl | 2 +- templates/status/500.tmpl | 2 +- templates/user/auth/activate.tmpl | 2 +- templates/user/auth/forgot_passwd.tmpl | 2 +- templates/user/auth/reset_passwd.tmpl | 2 +- templates/user/auth/signin.tmpl | 6 +++--- templates/user/auth/signup.tmpl | 4 ++-- templates/user/dashboard/dashboard.tmpl | 24 ++++++++++++------------ templates/user/dashboard/nav.tmpl | 6 +++--- templates/user/issues.tmpl | 24 ++++++++++++------------ templates/user/profile.tmpl | 2 +- templates/user/settings/delete.tmpl | 2 +- templates/user/settings/nav.tmpl | 10 +++++----- templates/user/settings/password.tmpl | 2 +- templates/user/settings/profile.tmpl | 2 +- templates/user/settings/social.tmpl | 2 +- templates/user/settings/sshkeys.tmpl | 4 ++-- 90 files changed, 287 insertions(+), 283 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/cmd/web.go b/cmd/web.go index f56ae826..45f35a35 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -79,6 +79,7 @@ func newMacaron() *macaron.Macaron { IndentJSON: macaron.Env != macaron.PROD, })) m.Use(i18n.I18n(i18n.Options{ + SubURL: setting.AppSubUrl, Langs: setting.Langs, Names: setting.Names, Redirect: true, @@ -88,7 +89,9 @@ func newMacaron() *macaron.Macaron { Interval: setting.CacheInternal, Conn: setting.CacheConn, })) - m.Use(captcha.Captchaer()) + m.Use(captcha.Captchaer(captcha.Options{ + SubURL: setting.AppSubUrl, + })) m.Use(session.Sessioner(session.Options{ Provider: setting.SessionProvider, Config: *setting.SessionConfig, @@ -365,7 +368,7 @@ func runWeb(*cli.Context) { var err error listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort) - log.Info("Listen: %v://%s", setting.Protocol, listenAddr) + log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubUrl) switch setting.Protocol { case setting.HTTP: err = http.ListenAndServe(listenAddr, m) diff --git a/gogs.go b/gogs.go index c5249b25..8f9bc767 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.2.0917 Beta" +const APP_VER = "0.5.3.0919 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/action.go b/models/action.go index 596f51af..b4457656 100644 --- a/models/action.go +++ b/models/action.go @@ -137,7 +137,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com return err } - url := fmt.Sprintf("%s/%s/%s/commit/%s", setting.AppRootSubUrl, repoUserName, repoName, c.Sha1) + url := fmt.Sprintf("%s/%s/%s/commit/%s", setting.AppSubUrl, repoUserName, repoName, c.Sha1) message := fmt.Sprintf(`%s`, url, c.Message) if _, err = CreateComment(userId, issue.RepoId, issue.Id, 0, 0, COMMIT, message, nil); err != nil { diff --git a/models/user.go b/models/user.go index 1bed8109..46e1b155 100644 --- a/models/user.go +++ b/models/user.go @@ -82,14 +82,14 @@ type User struct { // DashboardLink returns the user dashboard page link. func (u *User) DashboardLink() string { if u.IsOrganization() { - return setting.AppRootSubUrl + "/org/" + u.Name + "/dashboard/" + return setting.AppSubUrl + "/org/" + u.Name + "/dashboard/" } - return setting.AppRootSubUrl + "/" + return setting.AppSubUrl + "/" } // HomeLink returns the user home page link. func (u *User) HomeLink() string { - return setting.AppRootSubUrl + "/user/" + u.Name + return setting.AppSubUrl + "/user/" + u.Name } // AvatarLink returns user gravatar link. diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 2aa81005..a3db15df 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -113,7 +113,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { ms := MentionPattern.FindAll(line, -1) for _, m := range ms { line = bytes.Replace(line, m, - []byte(fmt.Sprintf(`%s`, setting.AppRootSubUrl, m[1:], m)), -1) + []byte(fmt.Sprintf(`%s`, setting.AppSubUrl, m[1:], m)), -1) } } diff --git a/modules/base/template.go b/modules/base/template.go index dd883ea3..ec419149 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -82,8 +82,8 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "AppName": func() string { return setting.AppName }, - "AppRootSubUrl": func() string { - return setting.AppRootSubUrl + "AppSubUrl": func() string { + return setting.AppSubUrl }, "AppVer": func() string { return setting.AppVer @@ -210,7 +210,7 @@ func ActionDesc(act Actioner) string { content := act.GetContent() switch act.GetOpType() { case 1: // Create repository. - return fmt.Sprintf(TPL_CREATE_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, repoName) + return fmt.Sprintf(TPL_CREATE_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, repoName) case 5: // Commit repository. var push *PushCommits if err := json.Unmarshal([]byte(content), &push); err != nil { @@ -223,20 +223,20 @@ func ActionDesc(act Actioner) string { if push.Len > 3 { buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len)) } - return fmt.Sprintf(TPL_COMMIT_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, + return fmt.Sprintf(TPL_COMMIT_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, buf.String()) case 6: // Create issue. infos := strings.SplitN(content, "|", 2) - return fmt.Sprintf(TPL_CREATE_ISSUE, setting.AppRootSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], + return fmt.Sprintf(TPL_CREATE_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], AvatarLink(email), infos[1]) case 8: // Transfer repository. newRepoLink := content + "/" + repoName - return fmt.Sprintf(TPL_TRANSFER_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, newRepoLink, newRepoLink) + return fmt.Sprintf(TPL_TRANSFER_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, newRepoLink, newRepoLink) case 9: // Push tag. - return fmt.Sprintf(TPL_PUSH_TAG, setting.AppRootSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink) + return fmt.Sprintf(TPL_PUSH_TAG, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink) case 10: // Comment issue. infos := strings.SplitN(content, "|", 2) - return fmt.Sprintf(TPL_COMMENT_ISSUE, setting.AppRootSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], + return fmt.Sprintf(TPL_COMMENT_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], AvatarLink(email), infos[1]) default: return "invalid type" diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index ccd8d031..8fae5d1e 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -25,13 +25,13 @@ func Toggle(options *ToggleOptions) macaron.Handler { return func(ctx *Context) { // Cannot view any page before installation. if !setting.InstallLock { - ctx.Redirect(setting.AppRootSubUrl + "/install") + ctx.Redirect(setting.AppSubUrl + "/install") return } // Redirect to dashboard if user tries to visit any non-login page. if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") return } @@ -48,8 +48,8 @@ func Toggle(options *ToggleOptions) macaron.Handler { if strings.HasSuffix(ctx.Req.RequestURI, "watch") { return } - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.Redirect(setting.AppSubUrl + "/user/login") return } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { ctx.Data["Title"] = ctx.Tr("auth.active_your_account") diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 5c26f91f..9145038f 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -187,7 +187,7 @@ func Contexter() macaron.Handler { Session: sess, } // Compute current URL for real-time change language. - link := setting.AppRootSubUrl + ctx.Req.RequestURI + link := setting.AppSubUrl + ctx.Req.RequestURI i := strings.Index(link, "?") if i > -1 { link = link[:i] diff --git a/modules/middleware/org.go b/modules/middleware/org.go index 3a2cf7bc..be102989 100644 --- a/modules/middleware/org.go +++ b/modules/middleware/org.go @@ -38,7 +38,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetUserByName", err) } else if redirect { log.Error(4, "GetUserByName", err) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } else { ctx.Handle(500, "GetUserByName", err) } @@ -68,7 +68,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { } ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner - ctx.Org.OrgLink = setting.AppRootSubUrl + "/org/" + org.Name + ctx.Org.OrgLink = setting.AppSubUrl + "/org/" + org.Name ctx.Data["OrgLink"] = ctx.Org.OrgLink // Team. @@ -80,7 +80,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetTeam", err) } else if redirect { log.Error(4, "GetTeam", err) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } else { ctx.Handle(500, "GetTeam", err) } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index e7d7fb56..79b01133 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -60,7 +60,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetUserByName", err) } else if redirect { log.Error(4, "GetUserByName", err) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } else { ctx.Handle(500, "GetUserByName", err) } @@ -72,7 +72,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { if u == nil { if redirect { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") return } ctx.Handle(404, "RepoAssignment", errors.New("invliad user account for single repository")) @@ -92,7 +92,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetRepositoryByName", err) return } else if redirect { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") return } ctx.Handle(500, "GetRepositoryByName", err) @@ -160,7 +160,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { return } ctx.Repo.GitRepo = gitRepo - ctx.Repo.RepoLink = setting.AppRootSubUrl + "/" + u.Name + "/" + repo.Name + ctx.Repo.RepoLink = setting.AppSubUrl + "/" + u.Name + "/" + repo.Name ctx.Data["RepoLink"] = ctx.Repo.RepoLink tags, err := ctx.Repo.GitRepo.GetTags() @@ -298,8 +298,8 @@ func RequireTrueOwner() macaron.Handler { return func(ctx *Context) { if !ctx.Repo.IsTrueOwner && !ctx.Repo.IsAdmin { if !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.Redirect(setting.AppSubUrl + "/user/login") return } ctx.Handle(404, ctx.Req.RequestURI, nil) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 74427744..321282df 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -32,10 +32,10 @@ const ( var ( // App settings. - AppVer string - AppName string - AppUrl string - AppRootSubUrl string + AppVer string + AppName string + AppUrl string + AppSubUrl string // Server settings. Protocol Scheme @@ -167,11 +167,12 @@ func NewConfigContext() { AppUrl += "/" } + // Check if has app suburl. url, err := url.Parse(AppUrl) if err != nil { - log.Fatal(4, "Invalid ROOT_URL %s: %s", AppUrl, err) + log.Fatal(4, "Invalid ROOT_URL(%s): %s", AppUrl, err) } - AppRootSubUrl = strings.TrimSuffix(url.Path, "/") + AppSubUrl = strings.TrimSuffix(url.Path, "/") Protocol = HTTP if Cfg.MustValue("server", "PROTOCOL") == "https" { diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 1fee7adb..6f2966bc 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -143,7 +143,7 @@ func Dashboard(ctx *middleware.Context) { } else { ctx.Flash.Success(success) } - ctx.Redirect(setting.AppRootSubUrl + "/admin") + ctx.Redirect(setting.AppSubUrl + "/admin") return } diff --git a/routers/admin/auths.go b/routers/admin/auths.go index 9eaae489..e537572b 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -100,7 +100,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } log.Trace("Authentication created by admin(%s): %s", ctx.User.Name, form.AuthName) - ctx.Redirect(setting.AppRootSubUrl + "/admin/auths") + ctx.Redirect(setting.AppSubUrl + "/admin/auths") } func EditAuthSource(ctx *middleware.Context) { @@ -181,7 +181,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { log.Trace("Authentication changed by admin(%s): %s", ctx.User.Name, form.AuthName) ctx.Flash.Success(ctx.Tr("admin.auths.update_success")) - ctx.Redirect(setting.AppRootSubUrl + "/admin/auths/" + ctx.Params(":authid")) + ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid")) } func DeleteAuthSource(ctx *middleware.Context) { @@ -201,12 +201,12 @@ func DeleteAuthSource(ctx *middleware.Context) { switch err { case models.ErrAuthenticationUserUsed: ctx.Flash.Error("form.still_own_user") - ctx.Redirect(setting.AppRootSubUrl + "/admin/auths/" + ctx.Params(":authid")) + ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid")) default: ctx.Handle(500, "DelLoginSource", err) } return } log.Trace("Authentication deleted by admin(%s): %s", ctx.User.Name, a.Name) - ctx.Redirect(setting.AppRootSubUrl + "/admin/auths") + ctx.Redirect(setting.AppSubUrl + "/admin/auths") } diff --git a/routers/admin/users.go b/routers/admin/users.go index 5cdb0f5c..fc3b0cbc 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -121,7 +121,7 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) { return } log.Trace("Account created by admin(%s): %s", ctx.User.Name, u.Name) - ctx.Redirect(setting.AppRootSubUrl + "/admin/users") + ctx.Redirect(setting.AppSubUrl + "/admin/users") } func EditUser(ctx *middleware.Context) { @@ -198,7 +198,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) { ctx.Data["User"] = u ctx.Flash.Success(ctx.Tr("admin.users.update_profile_success")) - ctx.Redirect(setting.AppRootSubUrl + "/admin/users/" + ctx.Params(":userid")) + ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) } func DeleteUser(ctx *middleware.Context) { @@ -218,12 +218,12 @@ func DeleteUser(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) - ctx.Redirect(setting.AppRootSubUrl + "/admin/users/" + ctx.Params(":userid")) + ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) default: ctx.Handle(500, "DeleteUser", err) } return } log.Trace("Account deleted by admin(%s): %s", ctx.User.Name, u.Name) - ctx.Redirect(setting.AppRootSubUrl + "/admin/users") + ctx.Redirect(setting.AppSubUrl + "/admin/users") } diff --git a/routers/home.go b/routers/home.go index 8e973d16..dd604ec7 100644 --- a/routers/home.go +++ b/routers/home.go @@ -33,7 +33,7 @@ func Home(ctx *middleware.Context) { // Check auto-login. uname := ctx.GetCookie(setting.CookieUserName) if len(uname) != 0 { - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.Redirect(setting.AppSubUrl + "/user/login") return } diff --git a/routers/install.go b/routers/install.go index 54da4d4f..07af613c 100644 --- a/routers/install.go +++ b/routers/install.go @@ -253,5 +253,5 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { log.Info("First-time run install finished!") ctx.Flash.Success(ctx.Tr("install.install_success")) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.Redirect(setting.AppSubUrl + "/user/login") } diff --git a/routers/org/members.go b/routers/org/members.go index d3bd51ea..f571e334 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -87,7 +87,7 @@ func MembersAction(ctx *middleware.Context) { if ctx.Params(":action") != "leave" { ctx.Redirect(ctx.Org.OrgLink + "/members") } else { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } } diff --git a/routers/org/org.go b/routers/org/org.go index cea70823..ab589832 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -83,5 +83,5 @@ func CreatePost(ctx *middleware.Context, form auth.CreateOrgForm) { } log.Trace("Organization created: %s", org.Name) - ctx.Redirect(setting.AppRootSubUrl + "/org/" + form.OrgName + "/dashboard") + ctx.Redirect(setting.AppSubUrl + "/org/" + form.OrgName + "/dashboard") } diff --git a/routers/org/setting.go b/routers/org/setting.go index 3d397c0c..0522f998 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -49,7 +49,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { } else if err = models.ChangeUserName(org, form.OrgUserName); err != nil { if err == models.ErrUserNameIllegal { ctx.Flash.Error(ctx.Tr("form.illegal_username")) - ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.LowerName + "/settings") + ctx.Redirect(setting.AppSubUrl + "/org/" + org.LowerName + "/settings") return } else { ctx.Handle(500, "ChangeUserName", err) @@ -73,7 +73,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { } log.Trace("Organization setting updated: %s", org.Name) ctx.Flash.Success(ctx.Tr("org.settings.update_setting_success")) - ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.Name + "/settings") + ctx.Redirect(setting.AppSubUrl + "/org/" + org.Name + "/settings") } func SettingsDelete(ctx *middleware.Context) { @@ -87,13 +87,13 @@ func SettingsDelete(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("form.org_still_own_repo")) - ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.LowerName + "/settings/delete") + ctx.Redirect(setting.AppSubUrl + "/org/" + org.LowerName + "/settings/delete") default: ctx.Handle(500, "DeleteOrganization", err) } } else { log.Trace("Organization deleted: %s", ctx.User.Name) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } return } diff --git a/routers/repo/commit.go b/routers/repo/commit.go index e58b9e78..218cae7b 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -159,8 +159,8 @@ func Diff(ctx *middleware.Context) { ctx.Data["Diff"] = diff ctx.Data["Parents"] = parents ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 - ctx.Data["SourcePath"] = setting.AppRootSubUrl + "/" + path.Join(userName, repoName, "src", commitId) - ctx.Data["RawPath"] = setting.AppRootSubUrl + "/" + path.Join(userName, repoName, "raw", commitId) + ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitId) + ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitId) ctx.HTML(200, DIFF) } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 8aba82ff..3a028e58 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -54,8 +54,8 @@ func Issues(ctx *middleware.Context) { isShowClosed := ctx.Query("state") == "closed" if viewType != "all" && !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.Redirect(setting.AppSubUrl + "/user/login") return } @@ -312,7 +312,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) { } log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id) - send(200, fmt.Sprintf("%s/%s/%s/issues/%d", setting.AppRootSubUrl, ctx.Params(":username"), ctx.Params(":reponame"), issue.Index), nil) + send(200, fmt.Sprintf("%s/%s/%s/issues/%d", setting.AppSubUrl, ctx.Params(":username"), ctx.Params(":reponame"), issue.Index), nil) } func checkLabels(labels, allLabels []*models.Label) { diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 3bd9aa7c..ae599f9f 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -96,7 +96,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { form.Gitignore, form.License, form.Private, false, form.InitReadme) if err == nil { log.Trace("Repository created: %s/%s", ctxUser.Name, form.RepoName) - ctx.Redirect(setting.AppRootSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) + ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) return } else if err == models.ErrRepoAlreadyExist { ctx.Data["Err_RepoName"] = true @@ -180,7 +180,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { form.Mirror, url) if err == nil { log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName) - ctx.Redirect(setting.AppRootSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) + ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) return } else if err == models.ErrRepoAlreadyExist { ctx.Data["Err_RepoName"] = true diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 926b5432..137d104f 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -97,7 +97,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) - ctx.Redirect(fmt.Sprintf("%s/%s/%s/settings", setting.AppRootSubUrl, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)) + ctx.Redirect(fmt.Sprintf("%s/%s/%s/settings", setting.AppSubUrl, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)) case "transfer": if ctx.Repo.Repository.Name != form.RepoName { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) @@ -122,7 +122,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } log.Trace("Repository transfered: %s/%s -> %s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newOwner) ctx.Flash.Success(ctx.Tr("repo.settings.transfer_succeed")) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") case "delete": if ctx.Repo.Repository.Name != form.RepoName { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) @@ -151,9 +151,9 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } log.Trace("Repository deleted: %s/%s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if ctx.Repo.Owner.IsOrganization() { - ctx.Redirect(setting.AppRootSubUrl + "/org/" + ctx.Repo.Owner.Name + "/dashboard") + ctx.Redirect(setting.AppSubUrl + "/org/" + ctx.Repo.Owner.Name + "/dashboard") } else { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } } } @@ -167,7 +167,7 @@ func SettingsCollaboration(ctx *middleware.Context) { if ctx.Req.Method == "POST" { name := strings.ToLower(ctx.Query("collaborator")) if len(name) == 0 || ctx.Repo.Owner.LowerName == name { - ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) return } has, err := models.HasAccess(name, repoLink, models.WRITABLE) @@ -175,7 +175,7 @@ func SettingsCollaboration(ctx *middleware.Context) { ctx.Handle(500, "HasAccess", err) return } else if has { - ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) return } @@ -183,7 +183,7 @@ func SettingsCollaboration(ctx *middleware.Context) { if err != nil { if err == models.ErrUserNotExist { ctx.Flash.Error(ctx.Tr("form.user_not_exist")) - ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) } else { ctx.Handle(500, "GetUserByName", err) } @@ -204,7 +204,7 @@ func SettingsCollaboration(ctx *middleware.Context) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_collaborator_success")) - ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) return } diff --git a/routers/user/auth.go b/routers/user/auth.go index 1dbc3300..71622e55 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -82,7 +82,7 @@ func SignIn(ctx *middleware.Context) { return } - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } func SignInPost(ctx *middleware.Context, form auth.SignInForm) { @@ -140,7 +140,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) { return } - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } func SignOut(ctx *middleware.Context) { @@ -151,7 +151,7 @@ func SignOut(ctx *middleware.Context) { ctx.Session.Delete("socialEmail") ctx.SetCookie(setting.CookieUserName, "", -1) ctx.SetCookie(setting.CookieRememberName, "", -1) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } func oauthSignUp(ctx *middleware.Context, sid int64) { @@ -288,7 +288,7 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe return } - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.Redirect(setting.AppSubUrl + "/user/login") } func Activate(ctx *middleware.Context) { @@ -335,7 +335,7 @@ func Activate(ctx *middleware.Context) { ctx.Session.Set("uid", user.Id) ctx.Session.Set("uname", user.Name) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") return } @@ -437,7 +437,7 @@ func ResetPasswdPost(ctx *middleware.Context) { } log.Trace("User password reset: %s", u.Name) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.Redirect(setting.AppSubUrl + "/user/login") return } diff --git a/routers/user/home.go b/routers/user/home.go index b411b8fc..031872fc 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -127,7 +127,7 @@ func Profile(ctx *middleware.Context) { uname := ctx.Params(":username") // Special handle for FireFox requests favicon.ico. if uname == "favicon.ico" { - ctx.Redirect(setting.AppRootSubUrl + "/img/favicon.png") + ctx.Redirect(setting.AppSubUrl + "/img/favicon.png") return } @@ -142,7 +142,7 @@ func Profile(ctx *middleware.Context) { } if u.IsOrganization() { - ctx.Redirect(setting.AppRootSubUrl + "/org/" + u.Name) + ctx.Redirect(setting.AppSubUrl + "/org/" + u.Name) return } @@ -182,7 +182,7 @@ func Email2User(ctx *middleware.Context) { } return } - ctx.Redirect(setting.AppRootSubUrl + "/user/" + u.Name) + ctx.Redirect(setting.AppSubUrl + "/user/" + u.Name) } const ( diff --git a/routers/user/setting.go b/routers/user/setting.go index a540f054..8f778acd 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -56,7 +56,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { } else if err = models.ChangeUserName(ctx.User, form.UserName); err != nil { if err == models.ErrUserNameIllegal { ctx.Flash.Error(ctx.Tr("form.illegal_username")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubUrl + "/user/settings") return } else { ctx.Handle(500, "ChangeUserName", err) @@ -79,7 +79,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { } log.Trace("User setting updated: %s", ctx.User.Name) ctx.Flash.Success(ctx.Tr("settings.update_profile_success")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubUrl + "/user/settings") } func SettingsPassword(ctx *middleware.Context) { @@ -120,7 +120,7 @@ func SettingsPasswordPost(ctx *middleware.Context, form auth.ChangePasswordForm) ctx.Flash.Success(ctx.Tr("settings.change_password_success")) } - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/password") + ctx.Redirect(setting.AppSubUrl + "/user/settings/password") } func SettingsSSHKeys(ctx *middleware.Context) { @@ -161,7 +161,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { ctx.Handle(500, "DeletePublicKey", err) } else { log.Trace("SSH key deleted: %s", ctx.User.Name) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") + ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") } return } @@ -178,7 +178,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { if ok, err := models.CheckPublicKeyString(cleanContent); !ok { ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error())) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") + ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") return } @@ -197,7 +197,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { } else { log.Trace("SSH key added: %s", ctx.User.Name) ctx.Flash.Success(ctx.Tr("settings.add_key_success")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") + ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") return } } @@ -218,7 +218,7 @@ func SettingsSocial(ctx *middleware.Context) { return } ctx.Flash.Success(ctx.Tr("settings.unbind_success")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/social") + ctx.Redirect(setting.AppSubUrl + "/user/settings/social") return } @@ -249,13 +249,13 @@ func SettingsDelete(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("form.still_own_repo")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/delete") + ctx.Redirect(setting.AppSubUrl + "/user/settings/delete") default: ctx.Handle(500, "DeleteUser", err) } } else { log.Trace("Account deleted: %s", ctx.User.Name) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } return } diff --git a/routers/user/social.go b/routers/user/social.go index fc2ea5fb..0bc1fa59 100644 --- a/routers/user/social.go +++ b/routers/user/social.go @@ -22,7 +22,7 @@ import ( func extractPath(next string) string { n, err := url.Parse(next) if err != nil { - return setting.AppRootSubUrl + "/" + return setting.AppSubUrl + "/" } return n.Path } @@ -88,7 +88,7 @@ func SocialSignIn(ctx *middleware.Context) { return } case models.ErrOauth2NotAssociated: - next = setting.AppRootSubUrl + "/user/sign_up" + next = setting.AppSubUrl + "/user/sign_up" default: ctx.Handle(500, "social.SocialSignIn(GetOauth2)", err) return diff --git a/templates/.VERSION b/templates/.VERSION index 29de2fdf..9df945b7 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.2.0917 Beta \ No newline at end of file +0.5.3.0919 Beta \ No newline at end of file diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 4dead7f0..9697b773 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -12,7 +12,7 @@
      {{.i18n.Tr "admin.auths.edit"}}
      - + {{.CsrfTokenHtml}} {{$type := .Source.Type}} diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index ba10e1d2..01b586fb 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -13,7 +13,7 @@ {{.i18n.Tr "admin.auths.auth_manage_panel"}}
      @@ -31,20 +31,20 @@ {{range .Sources}} - + - + {{end}}
      {{.Id}}{{.Name}}{{.Name}} {{.TypeString}} {{DateFormat .Updated "M d, Y"}} {{DateFormat .Created "M d, Y"}}
      {{if or .LastPageNum .NextPageNum}} {{end}}
      diff --git a/templates/admin/auth/new.tmpl b/templates/admin/auth/new.tmpl index 869eff32..daae60e0 100644 --- a/templates/admin/auth/new.tmpl +++ b/templates/admin/auth/new.tmpl @@ -12,7 +12,7 @@
      {{.i18n.Tr "admin.auths.new"}}
      - + {{.CsrfTokenHtml}}
      diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index 00696611..80c02828 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -34,11 +34,11 @@ {{.i18n.Tr "admin.dashboard.clean_unbind_oauth"}} - {{.i18n.Tr "admin.dashboard.operation_run"}} + {{.i18n.Tr "admin.dashboard.operation_run"}} {{.i18n.Tr "admin.dashboard.delete_inactivate_accounts"}} - {{.i18n.Tr "admin.dashboard.operation_run"}} + {{.i18n.Tr "admin.dashboard.operation_run"}} diff --git a/templates/admin/nav.tmpl b/templates/admin/nav.tmpl index ae44f4a8..e294cd92 100644 --- a/templates/admin/nav.tmpl +++ b/templates/admin/nav.tmpl @@ -2,13 +2,13 @@

      {{.i18n.Tr "admin_panel"}}

      \ No newline at end of file diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index f42c2c53..f901c696 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -30,7 +30,7 @@ {{range .Orgs}} {{.Id}} - {{.Name}} + {{.Name}} {{.Email}} {{.NumTeams}} {{.NumMembers}} @@ -42,8 +42,8 @@ {{if or .LastPageNum .NextPageNum}} {{end}}
      diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index 3e7442a6..cb333aeb 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -31,8 +31,8 @@ {{range .Repos}} {{.Id}} - {{.Owner.Name}} - {{.Name}} + {{.Owner.Name}} + {{.Name}} {{.NumWatches}} {{.NumIssues}} @@ -44,8 +44,8 @@ {{if or .LastPageNum .NextPageNum}} {{end}}
      diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index e9ed7836..3924afec 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -12,7 +12,7 @@
      {{.i18n.Tr "admin.users.edit_account"}}
      - + {{.CsrfTokenHtml}}
      diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index f85bb6c0..1092539e 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -13,7 +13,7 @@ {{.i18n.Tr "admin.users.user_manage_panel"}}
      - {{.i18n.Tr "admin.users.new_account"}} + {{.i18n.Tr "admin.users.new_account"}}
      @@ -32,21 +32,21 @@ {{range .Users}} - + - + {{end}}
      {{.Id}}{{.Name}}{{.Name}} {{.Email}} {{.NumRepos}} {{DateFormat .Created "M d, Y"}}
      {{if or .LastPageNum .NextPageNum}} {{end}}
      diff --git a/templates/admin/user/new.tmpl b/templates/admin/user/new.tmpl index db842c68..38acbf8f 100644 --- a/templates/admin/user/new.tmpl +++ b/templates/admin/user/new.tmpl @@ -12,7 +12,7 @@
      {{.i18n.Tr "admin.users.new_account"}}
      - + {{.CsrfTokenHtml}}
      diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 55dd4690..7775933c 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,8 +1,8 @@ - + - + @@ -19,21 +19,21 @@ {{else}} - - + + - - + + {{end}} - - - - - + + + + + - - + + {{if .Title}}{{.Title}} - {{end}}{{AppName}} diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index 991e773d..b69e9dc4 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -1,8 +1,8 @@ diff --git a/templates/explore/nav.tmpl b/templates/explore/nav.tmpl index a6c0acad..556627b0 100644 --- a/templates/explore/nav.tmpl +++ b/templates/explore/nav.tmpl @@ -2,7 +2,7 @@

      {{.i18n.Tr "explore"}}

      \ No newline at end of file diff --git a/templates/explore/repos.tmpl b/templates/explore/repos.tmpl index b8ae1791..954d0b06 100644 --- a/templates/explore/repos.tmpl +++ b/templates/explore/repos.tmpl @@ -12,7 +12,7 @@
    • {{.NumStars}}
    • {{.NumForks}}
    -

    {{.Name}}

    +

    {{.Name}}

    {{.Description}}

    {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}

    diff --git a/templates/home.tmpl b/templates/home.tmpl index 0fa70869..da73025d 100644 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -3,12 +3,12 @@

    Gogs

    {{.i18n.Tr "app_desc"}}

    -
    + {{.CsrfTokenHtml}} diff --git a/templates/install.tmpl b/templates/install.tmpl index eb294082..f1c28031 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -8,7 +8,7 @@
    {{.i18n.Tr "install.title"}}
    - + {{.CsrfTokenHtml}}
    {{.i18n.Tr "install.requite_db_desc"}}
    diff --git a/templates/ng/base/head.tmpl b/templates/ng/base/head.tmpl index 222edb69..efdc9653 100644 --- a/templates/ng/base/head.tmpl +++ b/templates/ng/base/head.tmpl @@ -1,6 +1,6 @@ - + @@ -9,27 +9,27 @@ {{if .Repository.IsGoget}}{{end}} - + {{if CdnMode}} {{else}} - + - + {{end}} - - - - + + + + - - - + + + {{if .Title}}{{.Title}} - {{end}}{{AppName}} diff --git a/templates/ng/base/header.tmpl b/templates/ng/base/header.tmpl index af3bc02f..aec4e2ef 100644 --- a/templates/ng/base/header.tmpl +++ b/templates/ng/base/header.tmpl @@ -2,37 +2,37 @@ -

    {{.Name}}

    +

    {{.Name}}

    {{.Description}}

    {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}

    @@ -46,20 +46,20 @@
    {{if $isMember}} - {{.Org.NumMembers}} + {{.Org.NumMembers}} {{end}} {{.i18n.Tr "org.people"}}
    {{range .Members}} {{if or $isMember (.IsPublicMember $.Org.Id)}} - + {{end}} {{end}}
    {{if .IsOrganizationOwner}} {{end}}
    @@ -67,14 +67,14 @@
    - {{.Org.NumTeams}} + {{.Org.NumTeams}} {{.i18n.Tr "org.teams"}}
      {{range .Teams}}
    • - {{.Name}} + {{.Name}}

      {{.NumMembers}} {{$.i18n.Tr "org.lower_members"}} · {{.NumRepos}} {{$.i18n.Tr "org.lower_repositories"}}

    • {{end}} @@ -82,7 +82,7 @@
    {{if .IsOrganizationOwner}} {{end}}
    diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index eb4b9b7f..0e7453ac 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -14,7 +14,7 @@ {{range .Members}}
    - {{.FullName}}({{.Name}}) + {{.FullName}}({{.Name}})
    • {{ $isPublic := .IsPublicMember $.Org.Id}} diff --git a/templates/org/new.tmpl b/templates/org/new.tmpl index eb5fd9a3..4e42775a 100644 --- a/templates/org/new.tmpl +++ b/templates/org/new.tmpl @@ -1,7 +1,7 @@ {{template "base/head" .}} {{template "base/navbar" .}}
      -
      + {{.CsrfTokenHtml}}

      Create New Organization

      {{template "base/alert" .}} @@ -24,7 +24,7 @@
      - Cancel + Cancel
      diff --git a/templates/org/settings/delete.tmpl b/templates/org/settings/delete.tmpl index 938fdd64..8b698e0d 100644 --- a/templates/org/settings/delete.tmpl +++ b/templates/org/settings/delete.tmpl @@ -12,7 +12,7 @@

      {{.i18n.Tr "org.settings.delete_account"}}

      {{.i18n.Tr "org.settings.delete_prompt" | Str2html}} -
      + {{.CsrfTokenHtml}}

      diff --git a/templates/org/settings/nav.tmpl b/templates/org/settings/nav.tmpl index 63cb6f08..11d32d7f 100644 --- a/templates/org/settings/nav.tmpl +++ b/templates/org/settings/nav.tmpl @@ -4,9 +4,9 @@

      diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 09492193..793b9c29 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -12,7 +12,7 @@
      {{.i18n.Tr "org.settings.options"}}
      - + {{.CsrfTokenHtml}}
      diff --git a/templates/org/team/members.tmpl b/templates/org/team/members.tmpl index ad9b30ed..66f496eb 100644 --- a/templates/org/team/members.tmpl +++ b/templates/org/team/members.tmpl @@ -30,7 +30,7 @@ {{if $.IsOrganizationOwner}} {{$.i18n.Tr "org.members.remove"}} {{end}} - + {{.Name}} {{.FullName}} ({{.Name}}) diff --git a/templates/org/team/repositories.tmpl b/templates/org/team/repositories.tmpl index f7ff97d8..31b6477c 100644 --- a/templates/org/team/repositories.tmpl +++ b/templates/org/team/repositories.tmpl @@ -30,7 +30,7 @@ {{if $canAddRemove}} {{$.i18n.Tr "org.teams.remove_repo"}} {{end}} - + {{$.Org.Name}}/{{.Name}} diff --git a/templates/org/team/teams.tmpl b/templates/org/team/teams.tmpl index 6440807f..30df3e40 100644 --- a/templates/org/team/teams.tmpl +++ b/templates/org/team/teams.tmpl @@ -25,7 +25,7 @@ {{if .NumMembers}}
      {{range .Members}} - + {{end}} diff --git a/templates/repo/bare.tmpl b/templates/repo/bare.tmpl index 712e7013..2a1409a6 100644 --- a/templates/repo/bare.tmpl +++ b/templates/repo/bare.tmpl @@ -5,7 +5,7 @@

      - {{.Repository.Owner.Name}} + {{.Repository.Owner.Name}} / {{.Repository.Name}}

      diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl index aa97925c..cb2ed5d0 100644 --- a/templates/repo/commits_table.tmpl +++ b/templates/repo/commits_table.tmpl @@ -26,8 +26,8 @@ {{$r := List .Commits}} {{range $r}} - {{.Author.Name}} - {{SubStr .Id.String 0 10}} + {{.Author.Name}} + {{SubStr .Id.String 0 10}} {{.Summary}} {{TimeSince .Author.When $.Lang}} diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 7b3c85ae..5d0c9b0f 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - + {{.CsrfTokenHtml}}

      {{.i18n.Tr "new_repo"}}

      @@ -75,7 +75,7 @@
      - {{.i18n.Tr "cancel"}} + {{.i18n.Tr "cancel"}}
      diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 548c7a35..8e5efd14 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -30,7 +30,7 @@

      - {{.Commit.Author.Name}} + {{.Commit.Author.Name}} {{TimeSince .Commit.Author.When $.Lang}}

      diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index dc271a75..524bfd11 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -2,7 +2,7 @@

      - {{.Owner.Name}} + {{.Owner.Name}} / {{.Repository.Name}} {{if .Repository.IsMirror}}{{.i18n.Tr "mirror"}}{{end}} diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 1849602b..0f9daae9 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -85,7 +85,7 @@

      - {{.Poster.Name}} + {{.Poster.Name}} {{TimeSince .Created $.Lang}} {{.NumComments}}

      diff --git a/templates/repo/issue/view.tmpl b/templates/repo/issue/view.tmpl index dbbd1d92..49aa982a 100644 --- a/templates/repo/issue/view.tmpl +++ b/templates/repo/issue/view.tmpl @@ -8,7 +8,7 @@
      #{{.Issue.Index}}
      - +

      {{.Issue.Name}}

      @@ -17,7 +17,7 @@ {{end}} {{if .Issue.IsClosed}}Closed{{else}}Open{{end}} - {{.Issue.Poster.Name}} opened this issue + {{.Issue.Poster.Name}} opened this issue {{TimeSince .Issue.Created $.Lang}} · {{.Issue.NumComments}} comments

      @@ -63,10 +63,10 @@ {{/* 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE, 4 = COMMIT, 5 = PULL */}} {{if eq .Type 0}}
      - +
      - {{.Poster.Name}} commented {{TimeSince .Created $.Lang}} + {{.Poster.Name}} commented {{TimeSince .Created $.Lang}} Owner @@ -93,25 +93,25 @@
      {{else if eq .Type 1}}
      - +
      - {{.Poster.Name}} Reopened this issue {{TimeSince .Created $.Lang}} + {{.Poster.Name}} Reopened this issue {{TimeSince .Created $.Lang}}
      {{else if eq .Type 2}}
      - +
      - {{.Poster.Name}} Closed this issue {{TimeSince .Created $.Lang}} + {{.Poster.Name}} Closed this issue {{TimeSince .Created $.Lang}}
      {{else if eq .Type 4}}
      - +
      - {{.Poster.Name}} Referenced this issue {{TimeSince .Created $.Lang}} + {{.Poster.Name}} Referenced this issue {{TimeSince .Created $.Lang}}

      - + {{.ContentHtml}}

      @@ -120,7 +120,7 @@ {{end}}
      {{if .SignedUser}}
      - +
      {{.CsrfTokenHtml}}
      @@ -163,7 +163,7 @@
      -
      {{else}}
      Sign up for free to join this conversation. Already have an account? Sign in to comment
      {{end}} +
      {{else}}
      Sign up for free to join this conversation. Already have an account? Sign in to comment
      {{end}}
      diff --git a/templates/repo/migrate.tmpl b/templates/repo/migrate.tmpl index f40124bf..b28d0647 100644 --- a/templates/repo/migrate.tmpl +++ b/templates/repo/migrate.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      -
      + {{.CsrfTokenHtml}}

      {{.i18n.Tr "new_migrate"}}

      @@ -74,7 +74,7 @@
      - {{.i18n.Tr "cancel"}} + {{.i18n.Tr "cancel"}}
      diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl index 566e11a0..dfcfd745 100644 --- a/templates/repo/nav.tmpl +++ b/templates/repo/nav.tmpl @@ -2,7 +2,7 @@
      -

      {{.Owner.Name}} / {{.Repository.Name}} {{if .Repository.IsPrivate}}Private{{else if .Repository.IsMirror}}Mirror{{end}}

      +

      {{.Owner.Name}} / {{.Repository.Name}} {{if .Repository.IsPrivate}}Private{{else if .Repository.IsMirror}}Mirror{{end}}

      {{.Repository.DescriptionHtml}}{{if .Repository.Website}} {{.Repository.Website}}{{end}}

      @@ -32,7 +32,7 @@
      {{if .IsSigned}} -
      +
      {{if .IsRepositoryWatching}} {{else}} @@ -59,7 +59,7 @@
      --> {{end}}
      diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index 2bb5faa4..58a050ab 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -6,7 +6,7 @@

      Releases + Tags -->

        @@ -28,7 +28,7 @@

        {{.Title}} (edit)

           - {{.Publisher.Name}} + {{.Publisher.Name}} {{if .Created}}{{TimeSince .Created $.Lang}}{{end}} {{.NumCommitsBehind}} commits to {{.Target}} since this release

        diff --git a/templates/repo/setting_nav.tmpl b/templates/repo/setting_nav.tmpl index 8cd1f2a2..5aa77f0b 100644 --- a/templates/repo/setting_nav.tmpl +++ b/templates/repo/setting_nav.tmpl @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/templates/repo/settings/collaboration.tmpl b/templates/repo/settings/collaboration.tmpl index 99561e27..98091c35 100644 --- a/templates/repo/settings/collaboration.tmpl +++ b/templates/repo/settings/collaboration.tmpl @@ -18,7 +18,7 @@ {{range .Collaborators}}
      • {{if not (eq .Id $.Owner.Id)}}{{end}} - + {{.Name}} {{.FullName}} ({{.Name}}) diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl index 9fbf2f55..d640fb00 100644 --- a/templates/repo/single.tmpl +++ b/templates/repo/single.tmpl @@ -12,7 +12,7 @@
      diff --git a/templates/repo/single_list.tmpl b/templates/repo/single_list.tmpl index 6728dd70..03511a80 100644 --- a/templates/repo/single_list.tmpl +++ b/templates/repo/single_list.tmpl @@ -1,9 +1,9 @@
      - {{.LastCommit.Author.Name}} {{TimeSince .LastCommit.Author.When}} + {{.LastCommit.Author.Name}} {{TimeSince .LastCommit.Author.When}}
      @@ -36,7 +36,7 @@ diff --git a/templates/status/404.tmpl b/templates/status/404.tmpl index 5a57e954..fe6739b9 100644 --- a/templates/status/404.tmpl +++ b/templates/status/404.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      -

      404

      +

      404



      Application Version: {{AppVer}}

      diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index 5bfdccc6..21116fa3 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      -

      500

      +

      500



      {{if .ErrorMsg}}

      An error has occurred : {{.ErrorMsg}}

      {{end}} diff --git a/templates/user/auth/activate.tmpl b/templates/user/auth/activate.tmpl index 554e2b78..b4dbb2e2 100644 --- a/templates/user/auth/activate.tmpl +++ b/templates/user/auth/activate.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      -
      + {{.CsrfTokenHtml}}

      {{.i18n.Tr "auth.active_your_account"}}

      diff --git a/templates/user/auth/forgot_passwd.tmpl b/templates/user/auth/forgot_passwd.tmpl index a1a10093..6122dfce 100644 --- a/templates/user/auth/forgot_passwd.tmpl +++ b/templates/user/auth/forgot_passwd.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - + {{.CsrfTokenHtml}}

      {{.i18n.Tr "auth.forgot_password"}}

      diff --git a/templates/user/auth/reset_passwd.tmpl b/templates/user/auth/reset_passwd.tmpl index de2976d6..d63d7a0f 100644 --- a/templates/user/auth/reset_passwd.tmpl +++ b/templates/user/auth/reset_passwd.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - + {{.CsrfTokenHtml}}

      {{.i18n.Tr "auth.reset_password"}}

      diff --git a/templates/user/auth/signin.tmpl b/templates/user/auth/signin.tmpl index e9ec87cc..54748077 100644 --- a/templates/user/auth/signin.tmpl +++ b/templates/user/auth/signin.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - +

      {{if .IsSocialLogin}}{{.i18n.Tr "social_sign_in" | Str2html}}{{else}}{{.i18n.Tr "sign_in"}}{{end}}

      @@ -24,12 +24,12 @@
           - {{if not .IsSocialLogin}}{{.i18n.Tr "auth.forget_password"}}{{end}} + {{if not .IsSocialLogin}}{{.i18n.Tr "auth.forget_password"}}{{end}}
      {{if not .IsSocialLogin}} {{if .OauthEnabled}}
      diff --git a/templates/user/auth/signup.tmpl b/templates/user/auth/signup.tmpl index af4c250f..b68c7963 100644 --- a/templates/user/auth/signup.tmpl +++ b/templates/user/auth/signup.tmpl @@ -1,7 +1,7 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}}
      - +

      {{if .IsSocialLogin}}{{.i18n.Tr "social_sign_in" | Str2html}}{{else}}{{.i18n.Tr "sign_up"}}{{end}}

      @@ -40,7 +40,7 @@
      {{end}}
      diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index db838452..0d728ef4 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -12,17 +12,17 @@

      - {{.GetActUserName}} + {{.GetActUserName}} {{if eq .GetOpType 1}} - {{$.i18n.Tr "action.create_repo" AppRootSubUrl .GetRepoLink .GetRepoLink | Str2html}} + {{$.i18n.Tr "action.create_repo" AppSubUrl .GetRepoLink .GetRepoLink | Str2html}} {{else if eq .GetOpType 5}} - {{$.i18n.Tr "action.commit_repo" AppRootSubUrl .GetRepoLink .GetBranch .GetBranch AppRootSubUrl .GetRepoLink .GetRepoLink | Str2html}} + {{$.i18n.Tr "action.commit_repo" AppSubUrl .GetRepoLink .GetBranch .GetBranch AppSubUrl .GetRepoLink .GetRepoLink | Str2html}} {{else if eq .GetOpType 6}} {{ $index := index .GetIssueInfos 0}} - {{$.i18n.Tr "action.create_issue" AppRootSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} + {{$.i18n.Tr "action.create_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} {{else if eq .GetOpType 10}} {{ $index := index .GetIssueInfos 0}} - {{$.i18n.Tr "action.comment_issue" AppRootSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} + {{$.i18n.Tr "action.comment_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} {{end}}

      {{if eq .GetOpType 5}} @@ -31,7 +31,7 @@ {{ $push := ActionContent2Commits .}} {{ $repoLink := .GetRepoLink}} {{range $push.Commits}} -
    • {{ShortSha .Sha1}} {{.Message}}
    • +
    • {{ShortSha .Sha1}} {{.Message}}
    • {{end}}
      @@ -58,9 +58,9 @@ @@ -75,7 +75,7 @@
      diff --git a/templates/user/issues.tmpl b/templates/user/issues.tmpl index 19b0526c..45492039 100644 --- a/templates/user/issues.tmpl +++ b/templates/user/issues.tmpl @@ -3,10 +3,10 @@

      Your Issues

      @@ -17,30 +17,30 @@
      {{range .Issues}}{{if .}}
      #{{.Index}} -
      {{.Name}}
      +
      {{.Name}}

      - {{.Poster.Name}} + {{.Poster.Name}} {{TimeSince .Created $.Lang}} {{.NumComments}}

      diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 1b51a871..4e3b32b5 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -66,7 +66,7 @@
    • {{.NumForks}}

      - {{.Name}}{{if .IsPrivate}} Private{{end}} + {{.Name}}{{if .IsPrivate}} Private{{end}}

      {{.Description}}

      Last updated {{TimeSince .Updated $.Lang}}
      diff --git a/templates/user/settings/delete.tmpl b/templates/user/settings/delete.tmpl index 78574ba1..cc6bf273 100644 --- a/templates/user/settings/delete.tmpl +++ b/templates/user/settings/delete.tmpl @@ -11,7 +11,7 @@

      {{.i18n.Tr "settings.delete_account"}}

      {{.i18n.Tr "settings.delete_prompt" | Str2html}} - + {{.CsrfTokenHtml}}

      diff --git a/templates/user/settings/nav.tmpl b/templates/user/settings/nav.tmpl index 52fc83e1..fd60cb53 100644 --- a/templates/user/settings/nav.tmpl +++ b/templates/user/settings/nav.tmpl @@ -2,11 +2,11 @@

      {{.i18n.Tr "settings"}}

      \ No newline at end of file diff --git a/templates/user/settings/password.tmpl b/templates/user/settings/password.tmpl index ccafd3ed..4f2f63e4 100644 --- a/templates/user/settings/password.tmpl +++ b/templates/user/settings/password.tmpl @@ -9,7 +9,7 @@

      {{.i18n.Tr "settings.change_password"}}

      - + {{.CsrfTokenHtml}}

      diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index e344fb9a..577b6ee2 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -11,7 +11,7 @@

      {{.i18n.Tr "settings.public_profile"}}
      - + {{.CsrfTokenHtml}}
      {{.i18n.Tr "settings.profile_desc"}}
      diff --git a/templates/user/settings/social.tmpl b/templates/user/settings/social.tmpl index a2585922..7514b232 100644 --- a/templates/user/settings/social.tmpl +++ b/templates/user/settings/social.tmpl @@ -20,7 +20,7 @@

      {{.Identity}}

      {{$.i18n.Tr "settings.add_on"}} {{DateFormat .Created "M d, Y"}} — {{$.i18n.Tr "settings.last_used"}} {{DateFormat .Updated "M d, Y"}}

      - {{$.i18n.Tr "settings.unbind"}} + {{$.i18n.Tr "settings.unbind"}}
    • {{end}} diff --git a/templates/user/settings/sshkeys.tmpl b/templates/user/settings/sshkeys.tmpl index 2d186121..188f078a 100644 --- a/templates/user/settings/sshkeys.tmpl +++ b/templates/user/settings/sshkeys.tmpl @@ -23,7 +23,7 @@

      {{.Fingerprint}}

      {{$.i18n.Tr "settings.add_on"}} {{DateFormat .Created "M d, Y"}} — {{if .HasUsed}}{{$.i18n.Tr "settings.last_used"}} {{DateFormat .Updated "M d, Y"}}{{else}}{{$.i18n.Tr "settings.no_activity"}}{{end}}

      - + {{$.CsrfTokenHtml}} @@ -35,7 +35,7 @@

      {{.i18n.Tr "settings.ssh_helper" | Str2html}}


      - + {{.CsrfTokenHtml}}

      {{.i18n.Tr "settings.add_new_key"}}

      -- cgit v1.2.3 From 976f1486e01548bfb420a7c809ede6fc273e4a26 Mon Sep 17 00:00:00 2001 From: Martin van Beurden Date: Sun, 21 Sep 2014 14:07:00 +0200 Subject: Set cookiepath to AppSubUrl --- cmd/web.go | 7 ++++--- modules/middleware/auth.go | 2 +- modules/middleware/repo.go | 2 +- modules/setting/setting.go | 1 + routers/repo/issue.go | 2 +- routers/user/auth.go | 16 ++++++++-------- 6 files changed, 16 insertions(+), 14 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/cmd/web.go b/cmd/web.go index 45f35a35..83dfca4e 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -97,9 +97,10 @@ func newMacaron() *macaron.Macaron { Config: *setting.SessionConfig, })) m.Use(csrf.Generate(csrf.Options{ - Secret: setting.SecretKey, - SetCookie: true, - Header: "X-Csrf-Token", + Secret: setting.SecretKey, + SetCookie: true, + Header: "X-Csrf-Token", + CookiePath: setting.AppSubUrl, })) m.Use(toolbox.Toolboxer(m, toolbox.Options{ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{ diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 8fae5d1e..2bc05697 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -48,7 +48,7 @@ func Toggle(options *ToggleOptions) macaron.Handler { if strings.HasSuffix(ctx.Req.RequestURI, "watch") { return } - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl) ctx.Redirect(setting.AppSubUrl + "/user/login") return } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 79b01133..f17018dd 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -298,7 +298,7 @@ func RequireTrueOwner() macaron.Handler { return func(ctx *Context) { if !ctx.Repo.IsTrueOwner && !ctx.Repo.IsAdmin { if !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl) ctx.Redirect(setting.AppSubUrl + "/user/login") return } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 321282df..a1ab43d0 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -380,6 +380,7 @@ func newSessionService() { SessionConfig = new(session.Config) SessionConfig.ProviderConfig = strings.Trim(Cfg.MustValue("session", "PROVIDER_CONFIG"), "\" ") SessionConfig.CookieName = Cfg.MustValue("session", "COOKIE_NAME", "i_like_gogits") + SessionConfig.CookiePath = AppSubUrl SessionConfig.Secure = Cfg.MustBool("session", "COOKIE_SECURE") SessionConfig.EnableSetCookie = Cfg.MustBool("session", "ENABLE_SET_COOKIE", true) SessionConfig.Gclifetime = Cfg.MustInt64("session", "GC_INTERVAL_TIME", 86400) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 3a028e58..f854a22b 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -54,7 +54,7 @@ func Issues(ctx *middleware.Context) { isShowClosed := ctx.Query("state") == "closed" if viewType != "all" && !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl) ctx.Redirect(setting.AppSubUrl + "/user/login") return } diff --git a/routers/user/auth.go b/routers/user/auth.go index 71622e55..c695f929 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -52,8 +52,8 @@ func SignIn(ctx *middleware.Context) { defer func() { if !isSucceed { log.Trace("auto-login cookie cleared: %s", uname) - ctx.SetCookie(setting.CookieUserName, "", -1) - ctx.SetCookie(setting.CookieRememberName, "", -1) + ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl) + ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl) return } }() @@ -77,7 +77,7 @@ func SignIn(ctx *middleware.Context) { ctx.Session.Set("uid", u.Id) ctx.Session.Set("uname", u.Name) if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 { - ctx.SetCookie("redirect_to", "", -1) + ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl) ctx.Redirect(redirectTo) return } @@ -113,9 +113,9 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) { if form.Remember { days := 86400 * setting.LogInRememberDays - ctx.SetCookie(setting.CookieUserName, u.Name, days) + ctx.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubUrl) ctx.SetSuperSecureCookie(base.EncodeMd5(u.Rands+u.Passwd), - setting.CookieRememberName, u.Name, days) + setting.CookieRememberName, u.Name, days, setting.AppSubUrl) } // Bind with social account. @@ -135,7 +135,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) { ctx.Session.Set("uid", u.Id) ctx.Session.Set("uname", u.Name) if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 { - ctx.SetCookie("redirect_to", "", -1) + ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl) ctx.Redirect(redirectTo) return } @@ -149,8 +149,8 @@ func SignOut(ctx *middleware.Context) { ctx.Session.Delete("socialId") ctx.Session.Delete("socialName") ctx.Session.Delete("socialEmail") - ctx.SetCookie(setting.CookieUserName, "", -1) - ctx.SetCookie(setting.CookieRememberName, "", -1) + ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl) + ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl) ctx.Redirect(setting.AppSubUrl + "/") } -- cgit v1.2.3 From 4a01bb8fa40e770433b6858a97e336393cb8e9b2 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 21 Sep 2014 12:19:50 -0400 Subject: Mirror bug fix --- .travis.yml | 3 +-- README.md | 2 +- README_ZH.md | 2 +- cmd/web.go | 7 +++---- gogs.go | 2 +- modules/setting/setting.go | 1 - templates/.VERSION | 2 +- 7 files changed, 8 insertions(+), 11 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/.travis.yml b/.travis.yml index 2600693b..eb5732ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,4 @@ language: go go: - 1.2 - - 1.3 - - tip \ No newline at end of file + - 1.3 \ No newline at end of file diff --git a/README.md b/README.md index 08eed134..232aa92a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) is a painless self-hosted Git Service written in Go. ![Demo](https://gowalker.org/public/gogs_demo.gif) -##### Current version: 0.5.2 Beta +##### Current version: 0.5.3 Beta ### NOTICES diff --git a/README_ZH.md b/README_ZH.md index 4f59e001..fcc8b496 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个基于 Go 语言的自助 Git 服务。 ![Demo](https://gowalker.org/public/gogs_demo.gif) -##### 当前版本:0.5.2 Beta +##### 当前版本:0.5.3 Beta ## 开发目的 diff --git a/cmd/web.go b/cmd/web.go index 83dfca4e..45f35a35 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -97,10 +97,9 @@ func newMacaron() *macaron.Macaron { Config: *setting.SessionConfig, })) m.Use(csrf.Generate(csrf.Options{ - Secret: setting.SecretKey, - SetCookie: true, - Header: "X-Csrf-Token", - CookiePath: setting.AppSubUrl, + Secret: setting.SecretKey, + SetCookie: true, + Header: "X-Csrf-Token", })) m.Use(toolbox.Toolboxer(m, toolbox.Options{ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{ diff --git a/gogs.go b/gogs.go index 8f9bc767..645e4e33 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.3.0919 Beta" +const APP_VER = "0.5.3.0921 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index a1ab43d0..321282df 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -380,7 +380,6 @@ func newSessionService() { SessionConfig = new(session.Config) SessionConfig.ProviderConfig = strings.Trim(Cfg.MustValue("session", "PROVIDER_CONFIG"), "\" ") SessionConfig.CookieName = Cfg.MustValue("session", "COOKIE_NAME", "i_like_gogits") - SessionConfig.CookiePath = AppSubUrl SessionConfig.Secure = Cfg.MustBool("session", "COOKIE_SECURE") SessionConfig.EnableSetCookie = Cfg.MustBool("session", "ENABLE_SET_COOKIE", true) SessionConfig.Gclifetime = Cfg.MustInt64("session", "GC_INTERVAL_TIME", 86400) diff --git a/templates/.VERSION b/templates/.VERSION index 9df945b7..4e0c5d61 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.3.0919 Beta \ No newline at end of file +0.5.3.0921 Beta \ No newline at end of file -- cgit v1.2.3 From b72d7c201ab34bd4de9582be891c3d4b76c3fd70 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 21 Sep 2014 12:22:50 -0400 Subject: Mirror bug fix --- cmd/web.go | 7 ++++--- modules/setting/setting.go | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'modules/setting/setting.go') diff --git a/cmd/web.go b/cmd/web.go index 45f35a35..83dfca4e 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -97,9 +97,10 @@ func newMacaron() *macaron.Macaron { Config: *setting.SessionConfig, })) m.Use(csrf.Generate(csrf.Options{ - Secret: setting.SecretKey, - SetCookie: true, - Header: "X-Csrf-Token", + Secret: setting.SecretKey, + SetCookie: true, + Header: "X-Csrf-Token", + CookiePath: setting.AppSubUrl, })) m.Use(toolbox.Toolboxer(m, toolbox.Options{ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{ diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 321282df..a1ab43d0 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -380,6 +380,7 @@ func newSessionService() { SessionConfig = new(session.Config) SessionConfig.ProviderConfig = strings.Trim(Cfg.MustValue("session", "PROVIDER_CONFIG"), "\" ") SessionConfig.CookieName = Cfg.MustValue("session", "COOKIE_NAME", "i_like_gogits") + SessionConfig.CookiePath = AppSubUrl SessionConfig.Secure = Cfg.MustBool("session", "COOKIE_SECURE") SessionConfig.EnableSetCookie = Cfg.MustBool("session", "ENABLE_SET_COOKIE", true) SessionConfig.Gclifetime = Cfg.MustInt64("session", "GC_INTERVAL_TIME", 86400) -- cgit v1.2.3 From 1273b3d3a985e0aeb88c632e27d0e8dbc8dd2e19 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 21 Sep 2014 19:39:10 -0400 Subject: Support custom robots.txt --- cmd/web.go | 9 +++++++++ modules/setting/setting.go | 3 +++ 2 files changed, 12 insertions(+) (limited to 'modules/setting/setting.go') diff --git a/cmd/web.go b/cmd/web.go index 83dfca4e..a5ebf259 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -364,6 +364,15 @@ func runWeb(*cli.Context) { r.Any("/:reponame/*", ignSignInAndCsrf, repo.Http) }) + // robots.txt + m.Get("/robots.txt", func(ctx *middleware.Context) { + if setting.HasRobotsTxt { + ctx.ServeFile(path.Join(setting.CustomPath, "robots.txt")) + } else { + ctx.Error(404) + } + }) + // Not found handler. m.NotFound(routers.NotFound) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index a1ab43d0..67e48108 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -108,6 +108,7 @@ var ( ProdMode bool RunUser string IsWindows bool + HasRobotsTxt bool ) func init() { @@ -260,6 +261,8 @@ func NewConfigContext() { Langs = Cfg.MustValueArray("i18n", "LANGS", ",") Names = Cfg.MustValueArray("i18n", "NAMES", ",") + + HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt")) } var Service struct { -- cgit v1.2.3