From 2bce24068dc3c64ee5e501c48b7f080c48383970 Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Sun, 24 Aug 2014 08:59:47 -0400 Subject: add Slack API webhook support --- cmd/web.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index e0ef3a76..275d3fb9 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -284,9 +284,11 @@ func runWeb(*cli.Context) { r.Route("/collaboration", "GET,POST", repo.SettingsCollaboration) r.Get("/hooks", repo.Webhooks) r.Get("/hooks/new", repo.WebHooksNew) - r.Post("/hooks/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost) + r.Post("/hooks/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost) + r.Post("/hooks/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost) r.Get("/hooks/:id", repo.WebHooksEdit) - r.Post("/hooks/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost) + r.Post("/hooks/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost) + r.Post("/hooks/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost) }) }, reqSignIn, middleware.RepoAssignment(true), reqTrueOwner) -- cgit v1.2.3 From 00a864e693434bce687f3f5145d8369583197b78 Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Tue, 26 Aug 2014 08:20:18 -0400 Subject: add commit compare functionality --- cmd/web.go | 1 + models/action.go | 6 +++- models/git_diff.go | 25 ++++++++++----- models/slack.go | 14 ++++++--- models/update.go | 4 +-- models/webhook.go | 13 +++++--- public/css/gogs.css | 7 +++++ routers/repo/commit.go | 65 +++++++++++++++++++++++++++++++++++++-- templates/repo/commits.tmpl | 43 +------------------------- templates/repo/commits_table.tmpl | 42 +++++++++++++++++++++++++ templates/repo/diff.tmpl | 15 +++++++-- 11 files changed, 169 insertions(+), 66 deletions(-) create mode 100644 templates/repo/commits_table.tmpl (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index 275d3fb9..2199d4ca 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -342,6 +342,7 @@ func runWeb(*cli.Context) { r.Get("/commit/:branchname/*", repo.Diff) r.Get("/releases", repo.Releases) r.Get("/archive/*.*", repo.Download) + r.Get("/compare/:before([a-z0-9]+)...:after([a-z0-9]+)", repo.CompareDiff) }, ignSignIn, middleware.RepoAssignment(true, true)) m.Group("/:username", func(r *macaron.Router) { diff --git a/models/action.go b/models/action.go index d536c84d..5a8c3169 100644 --- a/models/action.go +++ b/models/action.go @@ -172,7 +172,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com // CommitRepoAction adds new action for committing repository. func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, - repoId int64, repoUserName, repoName string, refFullName string, commit *base.PushCommits) error { + repoId int64, repoUserName, repoName string, refFullName string, commit *base.PushCommits, oldCommitId string, newCommitId string) error { opType := COMMIT_REPO // Check it's tag push or branch. @@ -226,6 +226,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, } repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName) + compareUrl := fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId) commits := make([]*PayloadCommit, len(commit.Commits)) for i, cmt := range commit.Commits { commits[i] = &PayloadCommit{ @@ -258,6 +259,9 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, Name: repo.Owner.LowerName, Email: repo.Owner.Email, }, + Before: oldCommitId, + After: newCommitId, + CompareUrl: compareUrl, } for _, w := range ws { diff --git a/models/git_diff.go b/models/git_diff.go index 4b4d1234..21a624de 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -175,25 +175,30 @@ func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { return diff, nil } -func GetDiff(repoPath, commitid string) (*Diff, error) { +func GetDiffRange(repoPath, beforeCommitId string, afterCommitId string) (*Diff, error) { repo, err := git.OpenRepository(repoPath) if err != nil { return nil, err } - commit, err := repo.GetCommit(commitid) + commit, err := repo.GetCommit(afterCommitId) if err != nil { return nil, err } rd, wr := io.Pipe() var cmd *exec.Cmd - // First commit of repository. - if commit.ParentCount() == 0 { - cmd = exec.Command("git", "show", commitid) + // if "after" commit given + if beforeCommitId == "" { + // First commit of repository. + if commit.ParentCount() == 0 { + cmd = exec.Command("git", "show", afterCommitId) + } else { + c, _ := commit.Parent(0) + cmd = exec.Command("git", "diff", c.Id.String(), afterCommitId) + } } else { - c, _ := commit.Parent(0) - cmd = exec.Command("git", "diff", c.Id.String(), commitid) + cmd = exec.Command("git", "diff", beforeCommitId, afterCommitId) } cmd.Dir = repoPath cmd.Stdout = wr @@ -208,7 +213,7 @@ func GetDiff(repoPath, commitid string) (*Diff, error) { }() defer rd.Close() - desc := fmt.Sprintf("GetDiff(%s)", repoPath) + desc := fmt.Sprintf("GetDiffRange(%s)", repoPath) pid := process.Add(desc, cmd) go func() { // In case process became zombie. @@ -226,3 +231,7 @@ func GetDiff(repoPath, commitid string) (*Diff, error) { return ParsePatch(pid, cmd, rd) } + +func GetDiffCommit(repoPath, commitId string) (*Diff, error) { + return GetDiffRange(repoPath, "", commitId) +} diff --git a/models/slack.go b/models/slack.go index 0a557409..714b2f6c 100644 --- a/models/slack.go +++ b/models/slack.go @@ -70,19 +70,21 @@ func getSlackPushPayload(p *Payload, slack *Slack) (*SlackPayload, error) { branchName := refSplit[len(refSplit)-1] var commitString string - // TODO: add commit compare before/after link when gogs adds it if len(p.Commits) == 1 { commitString = "1 new commit" } else { commitString = fmt.Sprintf("%d new commits", len(p.Commits)) + commitString = SlackLinkFormatter(p.CompareUrl, commitString) } - text := fmt.Sprintf("[%s:%s] %s pushed by %s", p.Repo.Name, branchName, commitString, p.Pusher.Name) + repoLink := SlackLinkFormatter(p.Repo.Url, p.Repo.Name) + branchLink := SlackLinkFormatter(p.Repo.Url+"/src/"+branchName, branchName) + text := fmt.Sprintf("[%s:%s] %s pushed by %s", repoLink, branchLink, commitString, p.Pusher.Name) var attachmentText string // for each commit, generate attachment text for i, commit := range p.Commits { - attachmentText += fmt.Sprintf("<%s|%s>: %s - %s", commit.Url, commit.Id[:7], SlackFormatter(commit.Message), commit.Author.Name) + attachmentText += fmt.Sprintf("%s: %s - %s", SlackLinkFormatter(commit.Url, commit.Id[:7]), SlackTextFormatter(commit.Message), SlackTextFormatter(commit.Author.Name)) // add linebreak to each commit but the last if i < len(p.Commits)-1 { attachmentText += "\n" @@ -103,7 +105,7 @@ func getSlackPushPayload(p *Payload, slack *Slack) (*SlackPayload, error) { } // see: https://api.slack.com/docs/formatting -func SlackFormatter(s string) string { +func SlackTextFormatter(s string) string { // take only first line of commit first := strings.Split(s, "\n")[0] // replace & < > @@ -112,3 +114,7 @@ func SlackFormatter(s string) string { first = strings.Replace(first, ">", ">", -1) return first } + +func SlackLinkFormatter(url string, text string) string { + return fmt.Sprintf("<%s|%s>", url, SlackTextFormatter(text)) +} diff --git a/models/update.go b/models/update.go index 68a92ada..ec6a9790 100644 --- a/models/update.go +++ b/models/update.go @@ -101,7 +101,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName commit := &base.PushCommits{} if err = CommitRepoAction(userId, ru.Id, userName, actEmail, - repos.Id, repoUserName, repoName, refName, commit); err != nil { + repos.Id, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil { log.GitLogger.Fatal(4, "runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) } return err @@ -152,7 +152,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName //commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()}) if err = CommitRepoAction(userId, ru.Id, userName, actEmail, - repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}); err != nil { + repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}, oldCommitId, newCommitId); err != nil { return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) } return nil diff --git a/models/webhook.go b/models/webhook.go index 55ed4844..0b7b3a99 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -169,11 +169,14 @@ type BasePayload interface { // Payload represents a payload information of hook. type Payload struct { - Secret string `json:"secret"` - Ref string `json:"ref"` - Commits []*PayloadCommit `json:"commits"` - Repo *PayloadRepo `json:"repository"` - Pusher *PayloadAuthor `json:"pusher"` + Secret string `json:"secret"` + Ref string `json:"ref"` + Commits []*PayloadCommit `json:"commits"` + Repo *PayloadRepo `json:"repository"` + Pusher *PayloadAuthor `json:"pusher"` + Before string `json:"before"` + After string `json:"after"` + CompareUrl string `json:"compare_url"` } func (p Payload) GetJSONPayload() ([]byte, error) { diff --git a/public/css/gogs.css b/public/css/gogs.css index 2d30d062..0af09a3e 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -968,6 +968,13 @@ body { .guide-box .zclip { left: auto !important; } +div.compare div#commits { + margin-top: 5px; +} +div.compare div#commits h4 { + margin: 10px 0; + line-height: 1.1; +} .diff-head-box h4 { margin-top: 0; margin-bottom: 0; diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 6320123b..54acc85b 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -114,9 +114,9 @@ func Diff(ctx *middleware.Context) { commit := ctx.Repo.Commit - diff, err := models.GetDiff(models.RepoPath(userName, repoName), commitId) + diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), commitId) if err != nil { - ctx.Handle(404, "GetDiff", err) + ctx.Handle(404, "GetDiffCommit", err) return } @@ -162,6 +162,67 @@ func Diff(ctx *middleware.Context) { ctx.HTML(200, DIFF) } +func CompareDiff(ctx *middleware.Context) { + ctx.Data["IsRepoToolbarCommits"] = true + ctx.Data["IsDiffCompare"] = true + userName := ctx.Repo.Owner.Name + repoName := ctx.Repo.Repository.Name + beforeCommitId := ctx.Params(":before") + afterCommitId := ctx.Params(":after") + + commit, err := ctx.Repo.GitRepo.GetCommit(afterCommitId) + if err != nil { + ctx.Handle(404, "GetCommit", err) + return + } + + diff, err := models.GetDiffRange(models.RepoPath(userName, repoName), beforeCommitId, afterCommitId) + if err != nil { + ctx.Handle(404, "GetDiffRange", err) + return + } + + isImageFile := func(name string) bool { + blob, err := commit.GetBlobByPath(name) + if err != nil { + return false + } + + dataRc, err := blob.Data() + if err != nil { + return false + } + buf := make([]byte, 1024) + n, _ := dataRc.Read(buf) + if n > 0 { + buf = buf[:n] + } + _, isImage := base.IsImageFile(buf) + return isImage + } + + commits, err := commit.CommitsBeforeUntil(beforeCommitId) + if err != nil { + ctx.Handle(500, "CommitsBeforeUntil", err) + return + } + + ctx.Data["Commits"] = commits + ctx.Data["CommitCount"] = commits.Len() + ctx.Data["BeforeCommitId"] = beforeCommitId + ctx.Data["AfterCommitId"] = afterCommitId + ctx.Data["Username"] = userName + ctx.Data["Reponame"] = repoName + ctx.Data["IsImageFile"] = isImageFile + ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitId) + "..." + base.ShortSha(afterCommitId) + " · " + userName + "/" + repoName + ctx.Data["Commit"] = commit + ctx.Data["Diff"] = diff + ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 + ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", afterCommitId) + ctx.Data["RawPath"] = "/" + path.Join(userName, repoName, "raw", afterCommitId) + ctx.HTML(200, DIFF) +} + func FileHistory(ctx *middleware.Context) { ctx.Data["IsRepoToolbarCommits"] = true diff --git a/templates/repo/commits.tmpl b/templates/repo/commits.tmpl index 420e973a..e7518e98 100644 --- a/templates/repo/commits.tmpl +++ b/templates/repo/commits.tmpl @@ -3,47 +3,6 @@ {{template "repo/nav" .}} {{template "repo/toolbar" .}}
-
-
-
- -

{{.CommitCount}} Commits

-
- - - - - - - - - - - {{ $username := .Username}} - {{ $reponame := .Reponame}} - {{$r := List .Commits}} - {{range $r}} - - - - - - - {{end}} - - -
- {{if not .IsSearchPage}}{{end}} -
+ {{template "repo/commits_table" .}}
{{template "base/footer" .}} diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl new file mode 100644 index 00000000..4612398a --- /dev/null +++ b/templates/repo/commits_table.tmpl @@ -0,0 +1,42 @@ +
+
+
+ +

{{.CommitCount}} Commits

+
+ + + + + + + + + + + {{ $username := .Username}} + {{ $reponame := .Reponame}} + {{$r := List .Commits}} + {{range $r}} + + + + + + + {{end}} + + +
+ {{if not .IsSearchPage}}{{end}} +
diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 6adea045..78733450 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -3,7 +3,18 @@ {{template "repo/nav" .}}
+ {{if .IsDiffCompare }}
+ +
+ {{template "repo/commits_table" .}} +
+
+ {{else}} +
Browse Source

{{.Commit.Message}}

@@ -22,9 +33,9 @@ {{.Commit.Author.Name}} {{TimeSince .Commit.Author.When $.Lang}}

-
+
- + {{end}} {{if .DiffNotAvailable}}

Diff Data Not Available.

{{else}} -- cgit v1.2.3 From 9476e58de941624912a3ceb89d52d36e79c03358 Mon Sep 17 00:00:00 2001 From: Vyacheslav Bakhmutov Date: Tue, 2 Sep 2014 22:48:40 +0700 Subject: Set headers in js and go files to X-Csrf-Token --- cmd/web.go | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index 2199d4ca..57164683 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -95,6 +95,7 @@ func newMacaron() *macaron.Macaron { m.Use(csrf.Generate(csrf.Options{ Secret: setting.SecretKey, SetCookie: true, + Header: "X-Csrf-Token", })) m.Use(toolbox.Toolboxer(m, toolbox.Options{ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{ -- cgit v1.2.3 From 85c35a6b8bb7430568d375d1e792e1417bbd7f4b Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Thu, 4 Sep 2014 07:17:00 -0400 Subject: add organization-level webhooks --- cmd/web.go | 7 +++++ conf/locale/locale_en-US.ini | 1 + models/action.go | 16 ++++++++-- models/webhook.go | 13 ++++++++ public/ng/js/gogs.js | 29 ++++++++++------- routers/org/setting.go | 28 +++++++++++++++++ routers/repo/setting.go | 56 ++++++++++++++++++++++++++++----- templates/org/settings/hook_new.tmpl | 37 ++++++++++++++++++++++ templates/org/settings/hooks.tmpl | 38 ++++++++++++++++++++++ templates/org/settings/nav.tmpl | 3 +- templates/repo/settings/hook_gogs.tmpl | 2 +- templates/repo/settings/hook_slack.tmpl | 2 +- 12 files changed, 208 insertions(+), 24 deletions(-) create mode 100644 templates/org/settings/hook_new.tmpl create mode 100644 templates/org/settings/hooks.tmpl (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index 57164683..f7b8d921 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -260,6 +260,13 @@ func runWeb(*cli.Context) { m.Group("/settings", func(r *macaron.Router) { r.Get("", org.Settings) r.Post("", bindIgnErr(auth.UpdateOrgSettingForm{}), org.SettingsPost) + r.Get("/hooks", org.SettingsHooks) + r.Get("/hooks/new", repo.WebHooksNew) + r.Post("/hooks/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost) + r.Post("/hooks/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost) + r.Get("/hooks/:id", repo.WebHooksEdit) + r.Post("/hooks/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost) + r.Post("/hooks/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost) r.Route("/delete", "GET,POST", org.SettingsDelete) }) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 4f1acdcd..3969074e 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -270,6 +270,7 @@ settings.delete = Delete Organization settings.delete_account = Delete This Organization settings.delete_prompt = The operation will delete this organization permanently, and CANNOT be undone! settings.confirm_delete_account = Confirm Deletion +settings.hooks_desc = Add webhooks that will be triggered for all repositories under this organization. members.public = Public members.public_helper = make private diff --git a/models/action.go b/models/action.go index f739fc35..c0992dba 100644 --- a/models/action.go +++ b/models/action.go @@ -220,8 +220,20 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, ws, err := GetActiveWebhooksByRepoId(repoId) if err != nil { - return errors.New("action.CommitRepoAction(GetWebhooksByRepoId): " + err.Error()) - } else if len(ws) == 0 { + return errors.New("action.CommitRepoAction(GetActiveWebhooksByRepoId): " + err.Error()) + } + + // check if repo belongs to org and append additional webhooks + if repo.Owner.IsOrganization() { + // get hooks for org + orgws, err := GetActiveWebhooksByOrgId(repo.OwnerId) + if err != nil { + return errors.New("action.CommitRepoAction(GetActiveWebhooksByOrgId): " + err.Error()) + } + ws = append(ws, orgws...) + } + + if len(ws) == 0 { return nil } diff --git a/models/webhook.go b/models/webhook.go index 0b7b3a99..5acc83f5 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -45,6 +45,7 @@ type Webhook struct { IsActive bool HookTaskType HookTaskType Meta string `xorm:"TEXT"` // store hook-specific attributes + OrgId int64 } // GetEvent handles conversion from Events to HookEvent. @@ -120,6 +121,18 @@ func DeleteWebhook(hookId int64) error { return err } +// GetWebhooksByOrgId returns all webhooks for an organization. +func GetWebhooksByOrgId(orgId int64) (ws []*Webhook, err error) { + err = x.Find(&ws, &Webhook{OrgId: orgId}) + return ws, err +} + +// GetActiveWebhooksByOrgId returns all active webhooks for an organization. +func GetActiveWebhooksByOrgId(orgId int64) (ws []*Webhook, err error) { + err = x.Find(&ws, &Webhook{OrgId: orgId, IsActive: true}) + return ws, err +} + // ___ ___ __ ___________ __ // / | \ ____ ____ | | _\__ ___/____ _____| | __ // / ~ \/ _ \ / _ \| |/ / | | \__ \ / ___/ |/ / diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index c08a887a..c60a5cf6 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -349,17 +349,8 @@ function initRepo() { }) } -function initRepoSetting() { - // Options. - // Confirmation of changing repository name. - $('#repo-setting-form').submit(function (e) { - var $reponame = $('#repo_name'); - if (($reponame.data('repo-name') != $reponame.val()) && !confirm('Repository name has been changed, do you want to continue?')) { - e.preventDefault(); - return true; - } - }); - +// when user changes hook type, hide/show proper divs +function initHookTypeChange() { // web hook type change $('select#hook-type').on("change", function () { hookTypes = ['Gogs','Slack']; @@ -374,6 +365,20 @@ function initRepoSetting() { } }); }); +} + +function initRepoSetting() { + // Options. + // Confirmation of changing repository name. + $('#repo-setting-form').submit(function (e) { + var $reponame = $('#repo_name'); + if (($reponame.data('repo-name') != $reponame.val()) && !confirm('Repository name has been changed, do you want to continue?')) { + e.preventDefault(); + return true; + } + }); + + initHookTypeChange(); $('#transfer-button').click(function () { $('#transfer-form').show(); @@ -421,6 +426,8 @@ function initOrgSetting() { return true; } }); + + initHookTypeChange(); } function initInvite() { diff --git a/routers/org/setting.go b/routers/org/setting.go index 0ddf0065..f853ef0e 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -5,6 +5,7 @@ package org import ( + "github.com/Unknwon/com" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" @@ -15,6 +16,7 @@ import ( const ( SETTINGS_OPTIONS base.TplName = "org/settings/options" SETTINGS_DELETE base.TplName = "org/settings/delete" + SETTINGS_HOOKS base.TplName = "org/settings/hooks" ) func Settings(ctx *middleware.Context) { @@ -97,3 +99,29 @@ func SettingsDelete(ctx *middleware.Context) { ctx.HTML(200, SETTINGS_DELETE) } + +func SettingsHooks(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("org.settings") + ctx.Data["PageIsSettingsHooks"] = true + + // Delete web hook. + remove := com.StrTo(ctx.Query("remove")).MustInt64() + if remove > 0 { + if err := models.DeleteWebhook(remove); err != nil { + ctx.Handle(500, "DeleteWebhook", err) + return + } + ctx.Flash.Success(ctx.Tr("repo.settings.remove_hook_success")) + ctx.Redirect(ctx.Org.OrgLink + "/settings/hooks") + return + } + + ws, err := models.GetWebhooksByOrgId(ctx.Org.Organization.Id) + if err != nil { + ctx.Handle(500, "GetWebhooksByOrgId", err) + return + } + + ctx.Data["Webhooks"] = ws + ctx.HTML(200, SETTINGS_HOOKS) +} diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 74567812..81747d43 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -6,6 +6,7 @@ package repo import ( "encoding/json" + "errors" "fmt" "strings" "time" @@ -26,6 +27,7 @@ const ( COLLABORATION base.TplName = "repo/settings/collaboration" HOOKS base.TplName = "repo/settings/hooks" HOOK_NEW base.TplName = "repo/settings/hook_new" + ORG_HOOK_NEW base.TplName = "org/settings/hook_new" ) func Settings(ctx *middleware.Context) { @@ -284,7 +286,14 @@ func WebHooksNew(ctx *middleware.Context) { ctx.Data["PageIsSettingsHooksNew"] = true ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}} renderHookTypes(ctx) - ctx.HTML(200, HOOK_NEW) + orgId, repoId, _ := getOrgRepoCtx(ctx) + if repoId > 0 { + ctx.HTML(200, HOOK_NEW) + } else if orgId > 0 { + ctx.HTML(200, ORG_HOOK_NEW) + } else { + ctx.Handle(500, "WebHooksEdit(DetermineContext)", errors.New("Can't determine hook context")) + } } func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { @@ -293,6 +302,8 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { ctx.Data["PageIsSettingsHooksNew"] = true ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}} + orgId, repoId, link := getOrgRepoCtx(ctx) + if ctx.HasError() { ctx.HTML(200, HOOK_NEW) return @@ -304,7 +315,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { } w := &models.Webhook{ - RepoId: ctx.Repo.Repository.Id, + RepoId: repoId, Url: form.PayloadUrl, ContentType: ct, Secret: form.Secret, @@ -314,6 +325,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { IsActive: form.Active, HookTaskType: models.GOGS, Meta: "", + OrgId: orgId, } if err := w.UpdateEvent(); err != nil { @@ -325,7 +337,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_hook_success")) - ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks") + ctx.Redirect(link + "/settings/hooks") } func WebHooksEdit(ctx *middleware.Context) { @@ -363,7 +375,14 @@ func WebHooksEdit(ctx *middleware.Context) { } w.GetEvent() ctx.Data["Webhook"] = w - ctx.HTML(200, HOOK_NEW) + orgId, repoId, _ := getOrgRepoCtx(ctx) + if repoId > 0 { + ctx.HTML(200, HOOK_NEW) + } else if orgId > 0 { + ctx.HTML(200, ORG_HOOK_NEW) + } else { + ctx.Handle(500, "WebHooksEdit(DetermineContext)", errors.New("Can't determine hook context")) + } } func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) { @@ -413,9 +432,10 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) { ctx.Handle(500, "WebHooksEditPost", err) return } + _, _, link := getOrgRepoCtx(ctx) ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success")) - ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", ctx.Repo.RepoLink, hookId)) + ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", link, hookId)) } func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { @@ -428,6 +448,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.HTML(200, HOOK_NEW) return } + orgId, repoId, link := getOrgRepoCtx(ctx) meta, err := json.Marshal(&models.Slack{ Domain: form.Domain, @@ -440,7 +461,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { } w := &models.Webhook{ - RepoId: ctx.Repo.Repository.Id, + RepoId: repoId, Url: models.GetSlackURL(form.Domain, form.Token), ContentType: models.JSON, Secret: "", @@ -450,6 +471,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { IsActive: form.Active, HookTaskType: models.SLACK, Meta: string(meta), + OrgId: orgId, } if err := w.UpdateEvent(); err != nil { ctx.Handle(500, "UpdateEvent", err) @@ -460,7 +482,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_hook_success")) - ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks") + ctx.Redirect(link + "/settings/hooks") } func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { @@ -514,7 +536,25 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.Handle(500, "SlackHooksEditPost", err) return } + _, _, link := getOrgRepoCtx(ctx) ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success")) - ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", ctx.Repo.RepoLink, hookId)) + ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", link, hookId)) +} + +func getOrgRepoCtx(ctx *middleware.Context) (int64, int64, string) { + orgId := int64(0) + repoId := int64(0) + link := "" + if _, ok := ctx.Data["RepoLink"]; ok { + repoId = ctx.Repo.Repository.Id + link = ctx.Repo.RepoLink + } + + if _, ok := ctx.Data["OrgLink"]; ok { + orgId = ctx.Org.Organization.Id + link = ctx.Org.OrgLink + } + + return orgId, repoId, link } diff --git a/templates/org/settings/hook_new.tmpl b/templates/org/settings/hook_new.tmpl new file mode 100644 index 00000000..6e7ee536 --- /dev/null +++ b/templates/org/settings/hook_new.tmpl @@ -0,0 +1,37 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +{{template "org/base/header" .}} +
+
+ {{template "org/settings/nav" .}} +
+
+ {{template "ng/base/alert" .}} +
+
+
+ {{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}} +
+ {{template "repo/settings/hook_types" .}} + {{template "repo/settings/hook_gogs" .}} + {{template "repo/settings/hook_slack" .}} +
+
+ {{if .PageIsSettingsHooksEdit}} +
+
+
+
+ {{.i18n.Tr "repo.settings.recent_deliveries"}} +
+
    +
  • Coming soon!
  • +
+
+
+ {{end}} +
+
+
+
+{{template "ng/base/footer" .}} diff --git a/templates/org/settings/hooks.tmpl b/templates/org/settings/hooks.tmpl new file mode 100644 index 00000000..713cfeb4 --- /dev/null +++ b/templates/org/settings/hooks.tmpl @@ -0,0 +1,38 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +{{template "org/base/header" .}} +
+
+ {{template "org/settings/nav" .}} +
+
+ {{template "ng/base/alert" .}} +
+
+
+ {{.i18n.Tr "repo.settings.add_webhook"}} + {{.i18n.Tr "repo.settings.hooks"}} +
+
    +
  • {{.i18n.Tr "org.settings.hooks_desc" | Str2html}}
  • + {{range .Webhooks}} +
  • + {{if .IsActive}} + + {{else}} + + {{end}} + {{.Url}} + + +
  • + {{end}} +
+
+
+
+
+
+
+
+{{template "ng/base/footer" .}} diff --git a/templates/org/settings/nav.tmpl b/templates/org/settings/nav.tmpl index 950569d6..954893c6 100644 --- a/templates/org/settings/nav.tmpl +++ b/templates/org/settings/nav.tmpl @@ -5,7 +5,8 @@ - \ No newline at end of file + diff --git a/templates/repo/settings/hook_gogs.tmpl b/templates/repo/settings/hook_gogs.tmpl index 35b58995..31a04ce0 100644 --- a/templates/repo/settings/hook_gogs.tmpl +++ b/templates/repo/settings/hook_gogs.tmpl @@ -1,5 +1,5 @@
-
+ {{.CsrfTokenHtml}}
{{.i18n.Tr "repo.settings.add_webhook_desc" | Str2html}}
diff --git a/templates/repo/settings/hook_slack.tmpl b/templates/repo/settings/hook_slack.tmpl index 50d28e2f..ed7a42e6 100644 --- a/templates/repo/settings/hook_slack.tmpl +++ b/templates/repo/settings/hook_slack.tmpl @@ -1,5 +1,5 @@
- + {{.CsrfTokenHtml}}
{{.i18n.Tr "repo.settings.add_slack_hook_desc" | Str2html}}
-- cgit v1.2.3 From ab7206d6b787645956b0279f729bd7b22cbed690 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 5 Sep 2014 17:28:09 -0400 Subject: Fix #348 --- README.md | 3 +- README_ZH.md | 3 +- cmd/web.go | 1 + conf/locale/locale_en-US.ini | 3 ++ conf/locale/locale_zh-CN.ini | 3 ++ gogs.go | 2 +- models/repo.go | 4 +- routers/home.go | 26 +++++++++- templates/.VERSION | 2 +- templates/explore/nav.tmpl | 8 ++++ templates/explore/repos.tmpl | 25 ++++++++++ templates/org/settings/options.tmpl | 96 ++++++++++++++++++------------------- templates/status/404.tmpl | 4 +- 13 files changed, 121 insertions(+), 59 deletions(-) create mode 100644 templates/explore/nav.tmpl create mode 100644 templates/explore/repos.tmpl (limited to 'cmd/web.go') diff --git a/README.md b/README.md index ddb8367e..689b0df4 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ There are 5 ways to install Gogs: - [Install from binary](http://gogs.io/docs/installation/install_from_binary.md): **STRONGLY RECOMMENDED** - [Install from source](http://gogs.io/docs/installation/install_from_source.md) - [Install from packages](http://gogs.io/docs/installation/install_from_packages.md) -- [Ship with Docker](https://github.com/gogits/gogs/tree/master/dockerfiles) +- [Ship with Docker](https://github.com/gogits/gogs/tree/master/docker) - [Install with Vagrant](https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs) ## Acknowledgments @@ -70,7 +70,6 @@ There are 5 ways to install Gogs: - Usage and modification from [beego](http://beego.me) modules. - Thanks [lavachen](http://www.lavachen.cn/) and [Rocker](http://weibo.com/rocker1989) for designing Logo. - Thanks [gobuild.io](http://gobuild.io) for providing binary compile and download service. -- Thanks [Docker China](http://www.dockboard.org/) for providing [dockerfiles](https://github.com/gogits/gogs/tree/master/dockerfiles). ## Contributors diff --git a/README_ZH.md b/README_ZH.md index de982baf..401c8186 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -50,7 +50,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - [二进制安装](http://gogs.io/docs/installation/install_from_binary.md): **强烈推荐** - [源码安装](http://gogs.io/docs/installation/install_from_source.md) - [包管理安装](http://gogs.io/docs/installation/install_from_packages.md) -- [采用 Docker 部署](https://github.com/gogits/gogs/tree/master/dockerfiles) +- [采用 Docker 部署](https://github.com/gogits/gogs/tree/master/docker) - [通过 Vagrant 安装](https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs) ## 特别鸣谢 @@ -61,7 +61,6 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - [martini](http://martini.codegangsta.io/) 的路由与中间件机制。 - 感谢 [gobuild.io](http://gobuild.io) 提供二进制编译与下载服务。 - 感谢 [lavachen](http://www.lavachen.cn/) 和 [Rocker](http://weibo.com/rocker1989) 设计的 Logo。 -- 感谢 [Docker 中文社区](http://www.dockboard.org/) 提供的 [dockerfiles](https://github.com/gogits/gogs/tree/master/dockerfiles)。 ## 贡献成员 diff --git a/cmd/web.go b/cmd/web.go index 57164683..cad1db33 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -124,6 +124,7 @@ func runWeb(*cli.Context) { // Routers. m.Get("/", ignSignIn, routers.Home) + m.Get("/explore", routers.Explore) m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install) m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost) m.Group("", func(r *macaron.Router) { diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 946d5604..e8329933 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -47,6 +47,9 @@ collaborative_repos = Collaborative Repositories my_orgs = My Organizations my_mirrors = My Mirrors +[explore] +repos = Repositories + [auth] create_new_account = Create New Account register_hepler_msg = Already have an account? Sign in now! diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 55d22f23..a61a54ce 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -47,6 +47,9 @@ collaborative_repos = 参与协作的仓库 my_orgs = 我的组织 my_mirrors = 我的镜像 +[explore] +repos = 探索仓库 + [auth] create_new_account = 创建帐户 register_hepler_msg = 已经注册?立即登录! diff --git a/gogs.go b/gogs.go index a1160190..1c012d40 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.4.9.0902 Beta" +const APP_VER = "0.4.9.0905 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/repo.go b/models/repo.go index 23d44a6b..341e7e47 100644 --- a/models/repo.go +++ b/models/repo.go @@ -972,8 +972,8 @@ func GetRepositories(uid int64, private bool) ([]*Repository, error) { } // GetRecentUpdatedRepositories returns the list of repositories that are recently updated. -func GetRecentUpdatedRepositories() (repos []*Repository, err error) { - err = x.Where("is_private=?", false).Limit(5).Desc("updated").Find(&repos) +func GetRecentUpdatedRepositories(num int) (repos []*Repository, err error) { + err = x.Where("is_private=?", false).Limit(num).Desc("updated").Find(&repos) return repos, err } diff --git a/routers/home.go b/routers/home.go index 5ea3e2a0..36a4f50f 100644 --- a/routers/home.go +++ b/routers/home.go @@ -5,6 +5,9 @@ package routers import ( + "fmt" + + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/setting" @@ -12,7 +15,8 @@ import ( ) const ( - HOME base.TplName = "home" + HOME base.TplName = "home" + EXPLORE_REPOS base.TplName = "explore/repos" ) func Home(ctx *middleware.Context) { @@ -42,6 +46,26 @@ func Home(ctx *middleware.Context) { ctx.HTML(200, HOME) } +func Explore(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("explore") + ctx.Data["PageIsExploreRepositories"] = true + + repos, err := models.GetRecentUpdatedRepositories(20) + if err != nil { + ctx.Handle(500, "GetRecentUpdatedRepositories", err) + return + } + for _, repo := range repos { + if err = repo.GetOwner(); err != nil { + ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.Id, err)) + return + } + } + ctx.Data["Repos"] = repos + + ctx.HTML(200, EXPLORE_REPOS) +} + func NotFound(ctx *middleware.Context) { ctx.Data["Title"] = "Page Not Found" ctx.Handle(404, "home.NotFound", nil) diff --git a/templates/.VERSION b/templates/.VERSION index 5f3c5181..6e361299 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.4.9.0902 Beta \ No newline at end of file +0.4.9.0905 Beta \ No newline at end of file diff --git a/templates/explore/nav.tmpl b/templates/explore/nav.tmpl new file mode 100644 index 00000000..1310bccf --- /dev/null +++ b/templates/explore/nav.tmpl @@ -0,0 +1,8 @@ +
+

{{.i18n.Tr "explore"}}

+ +
\ No newline at end of file diff --git a/templates/explore/repos.tmpl b/templates/explore/repos.tmpl new file mode 100644 index 00000000..a1e3d408 --- /dev/null +++ b/templates/explore/repos.tmpl @@ -0,0 +1,25 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +
+
+ {{template "explore/nav" .}} +
+
+
+ {{range .Repos}} +
+
    +
  • {{.NumStars}}
  • +
  • {{.NumForks}}
  • +
+

{{.Name}}

+

{{.Description}}

+

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

+
+ {{end}} +
+
+
+
+
+{{template "ng/base/footer" .}} \ No newline at end of file diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index ae225a9c..14ea1b34 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -3,54 +3,54 @@ {{template "org/base/header" .}}
- {{template "org/settings/nav" .}} -
-
- {{template "ng/base/alert" .}} -
-
-
- {{.i18n.Tr "org.settings.options"}} -
- - {{.CsrfTokenHtml}} - -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
+ {{template "org/settings/nav" .}} +
+
+ {{template "ng/base/alert" .}} +
+
+
+ {{.i18n.Tr "org.settings.options"}} +
+
+ {{.CsrfTokenHtml}} + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
diff --git a/templates/status/404.tmpl b/templates/status/404.tmpl index 2d04b559..e024715e 100644 --- a/templates/status/404.tmpl +++ b/templates/status/404.tmpl @@ -1,11 +1,11 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}} -
+

404



Application Version: {{AppVer}}

If you think this is an error, please open an issue on GitHub.

-

We're currently working on 0.5 beta version, many pages may be missing at this time. Sorry for confusion!

+
{{template "ng/base/footer" .}} -- cgit v1.2.3 From f8977f4847b8df9feec1bb5913f75401d79db876 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 7 Sep 2014 19:39:26 -0400 Subject: Organization level webhooks --- README.md | 5 +++-- README_ZH.md | 5 +++-- cmd/dump.go | 8 +++++--- cmd/web.go | 6 +++--- conf/app.ini | 2 +- templates/org/settings/hooks.tmpl | 20 ++++++++++---------- 6 files changed, 25 insertions(+), 21 deletions(-) (limited to 'cmd/web.go') diff --git a/README.md b/README.md index 689b0df4..3115d3fc 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](http://gowalker.org/public/gogs_demo.gif) -##### Current version: 0.4.9 Beta +##### Current version: 0.5.0 Beta ### NOTICES @@ -35,7 +35,8 @@ The goal of this project is to make the easiest, fastest and most painless way t - Register/delete/rename account - Create/manage/delete organization with team management - Create/migrate/mirror/delete/watch/rename/transfer public/private repository -- Repository viewer/release/issue tracker/webhooks +- Repository viewer/release/issue tracker +- Repository and Organization level webhooks - Add/remove repository collaborators - Gravatar and cache support - Mail service(register, issue) diff --git a/README_ZH.md b/README_ZH.md index 401c8186..ef154d0e 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个基于 Go 语言的自助 Git 服务。 ![Demo](http://gowalker.org/public/gogs_demo.gif) -##### 当前版本:0.4.9 Beta +##### 当前版本:0.5.0 Beta ## 开发目的 @@ -26,7 +26,8 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - 注册/删除/重命名 用户 - 创建/管理/删除 组织以及团队管理功能 - 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库 -- 仓库 浏览/发布/工单管理/Web 钩子 +- 仓库 浏览/发布/工单管理 +- 仓库和组织级别 Web 钩子 - 添加/删除 仓库协作者 - Gravatar 以及缓存支持 - 邮件服务(注册、Issue) diff --git a/cmd/dump.go b/cmd/dump.go index 2a54db1a..41491224 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -24,16 +24,18 @@ var CmdDump = cli.Command{ Description: `Dump compresses all related files and database into zip file. It can be used for backup and capture Gogs server image to send to maintainer`, Action: runDump, - Flags: []cli.Flag{}, + Flags: []cli.Flag{ + cli.BoolFlag{"verbose, v", "show process details", ""}, + }, } -func runDump(*cli.Context) { +func runDump(ctx *cli.Context) { setting.NewConfigContext() models.LoadModelsConfig() models.SetEngine() log.Printf("Dumping local repositories...%s", setting.RepoRootPath) - zip.Verbose = false + zip.Verbose = ctx.Bool("verbose") defer os.Remove("gogs-repo.zip") if err := zip.PackTo(setting.RepoRootPath, "gogs-repo.zip", true); err != nil { log.Fatalf("Fail to dump local repositories: %v", err) diff --git a/cmd/web.go b/cmd/web.go index 8182d7b5..e7038076 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -69,9 +69,9 @@ func newMacaron() *macaron.Macaron { SkipLogging: !setting.DisableRouterLog, }, )) - if setting.EnableGzip { - m.Use(macaron.Gzip()) - } + // if setting.EnableGzip { + // m.Use(macaron.Gzip()) + // } m.Use(macaron.Renderer(macaron.RenderOptions{ Directory: path.Join(setting.StaticRootPath, "templates"), Funcs: []template.FuncMap{base.TemplateFuncs}, diff --git a/conf/app.ini b/conf/app.ini index c646160e..3e7e191c 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -29,7 +29,7 @@ KEY_FILE = custom/https/key.pem ; default is the path where Gogs is executed STATIC_ROOT_PATH = ; Application level GZIP support -ENABLE_GZIP = false +#ENABLE_GZIP = false [database] ; Either "mysql", "postgres" or "sqlite3", it's your choice diff --git a/templates/org/settings/hooks.tmpl b/templates/org/settings/hooks.tmpl index 713cfeb4..2f6ba630 100644 --- a/templates/org/settings/hooks.tmpl +++ b/templates/org/settings/hooks.tmpl @@ -16,16 +16,16 @@
  • {{.i18n.Tr "org.settings.hooks_desc" | Str2html}}
  • {{range .Webhooks}} -
  • - {{if .IsActive}} - - {{else}} - - {{end}} - {{.Url}} - - -
  • +
  • + {{if .IsActive}} + + {{else}} + + {{end}} + {{.Url}} + + +
  • {{end}}
-- cgit v1.2.3 From 0f037b430a99a10cc9cff6f04dd1cf197ecc04ba Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 15 Sep 2014 10:09:17 -0400 Subject: Fix #464 --- cmd/web.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index e7038076..a9ff9dbc 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -124,7 +124,7 @@ func runWeb(*cli.Context) { // Routers. m.Get("/", ignSignIn, routers.Home) - m.Get("/explore", routers.Explore) + m.Get("/explore", ignSignIn, routers.Explore) m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install) m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost) m.Group("", func(r *macaron.Router) { @@ -355,11 +355,9 @@ func runWeb(*cli.Context) { }, ignSignIn, middleware.RepoAssignment(true, true)) m.Group("/:username", func(r *macaron.Router) { - r.Get("/:reponame", middleware.RepoAssignment(true, true, true), repo.Home) - m.Group("/:reponame", func(r *macaron.Router) { - r.Any("/*", repo.Http) - }) - }, ignSignInAndCsrf) + r.Get("/:reponame", ignSignIn, middleware.RepoAssignment(true, true, true), repo.Home) + r.Any("/:reponame/*", ignSignInAndCsrf, repo.Http) + }) // Not found handler. m.NotFound(routers.NotFound) -- cgit v1.2.3 From ea309acdb23f2058478f7e7753e359a6c6256c81 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 15 Sep 2014 17:23:58 -0400 Subject: Fix #468 --- README.md | 6 +++--- README_ZH.md | 4 ++-- cmd/web.go | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'cmd/web.go') diff --git a/README.md b/README.md index 05771144..3c319896 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ Gogs(Go Git Service) is a painless self-hosted Git Service written in Go. ### NOTICES -- Due to testing purpose, data of [try.gogits.org](http://try.gogits.org) has been reset in **June 21, 2014** and will reset multiple times after. Please do **NOT** put your important data on the site. -- Demo site [try.gogits.org](http://try.gogits.org) is running under `dev` branch. +- Due to testing purpose, data of [try.gogs.io](https://try.gogs.io) has been reset in **June 21, 2014** and will reset multiple times after. Please do **NOT** put your important data on the site. +- Demo site [try.gogs.io](https://try.gogs.io) is running under `dev` branch. #### Other language version @@ -24,7 +24,7 @@ The goal of this project is to make the easiest, fastest and most painless way t - Please see [Documentation](http://gogs.io/docs/intro/) for project design, known issues, and change log. - See [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team. -- Try it before anything? Do it [online](http://try.gogits.org/Unknown/gogs) or go down to **Installation -> Install from binary** section! +- Try it before anything? Do it [online](https://try.gogs.io/Unknown/gogs) or go down to **Installation -> Install from binary** section! - Having troubles? Get help from [Troubleshooting](http://gogs.io/docs/intro/troubleshooting.md). ## Features diff --git a/README_ZH.md b/README_ZH.md index 2fa82e7d..7faeee2b 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.0 Beta +##### 当前版本:0.5.1 Beta ## 开发目的 @@ -15,7 +15,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - 有关项目设计、已知问题和变更日志,请通过 [使用手册](http://gogs.io/docs/intro/) 查看。 - 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。 -- 想要先睹为快?通过 [在线体验](http://try.gogits.org/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。 +- 想要先睹为快?通过 [在线体验](https://try.gogs.io/Unknown/gogs) 或查看 **安装部署 -> 二进制安装** 小节。 - 使用过程中遇到问题?尝试从 [故障排查](http://gogs.io/docs/intro/troubleshooting.md) 页面获取帮助。 ## 功能特性 diff --git a/cmd/web.go b/cmd/web.go index a9ff9dbc..f56ae826 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -64,7 +64,8 @@ func newMacaron() *macaron.Macaron { m := macaron.New() m.Use(macaron.Logger()) m.Use(macaron.Recovery()) - m.Use(macaron.Static("public", + m.Use(macaron.Static( + path.Join(setting.StaticRootPath, "public"), macaron.StaticOptions{ SkipLogging: !setting.DisableRouterLog, }, -- 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 'cmd/web.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"}}
- {{.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 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 'cmd/web.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 'cmd/web.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 'cmd/web.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 'cmd/web.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 From ebb05475ed15fffc37145799ce7c72b65ccdbfc5 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 23 Sep 2014 13:06:25 -0400 Subject: Fix #495 and cannot view repository by tag --- cmd/web.go | 2 +- gogs.go | 2 +- modules/git/repo_tag.go | 1 + modules/middleware/repo.go | 8 ++++++-- public/ng/css/ui.css | 3 ++- public/ng/less/ui/reset.less | 6 ++---- templates/.VERSION | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index a5ebf259..e2c929c1 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -355,7 +355,7 @@ func runWeb(*cli.Context) { r.Get("/commit/:branchname", repo.Diff) r.Get("/commit/:branchname/*", repo.Diff) r.Get("/releases", repo.Releases) - r.Get("/archive/*.*", repo.Download) + r.Get("/archive/:branchname/*.*", repo.Download) r.Get("/compare/:before([a-z0-9]+)...:after([a-z0-9]+)", repo.CompareDiff) }, ignSignIn, middleware.RepoAssignment(true, true)) diff --git a/gogs.go b/gogs.go index 84733042..0821dbc2 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.4.0922 Beta" +const APP_VER = "0.5.4.0923 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/git/repo_tag.go b/modules/git/repo_tag.go index 21818f3e..dd31e441 100644 --- a/modules/git/repo_tag.go +++ b/modules/git/repo_tag.go @@ -77,6 +77,7 @@ func (repo *Repository) getTag(id sha1) (*Tag, error) { } tag.Id = id + tag.Object = id tag.repo = repo repo.tagCache[id] = tag diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index f17018dd..7227e05d 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -213,7 +213,11 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "RepoAssignment invalid tag", nil) return } - ctx.Repo.Commit, _ = ctx.Repo.Tag.Commit() + ctx.Repo.Commit, err = ctx.Repo.Tag.Commit() + if err != nil { + ctx.Handle(500, "RepoAssignment", fmt.Errorf("fail to get tag commit(%s): %v", refName, err)) + return + } ctx.Repo.CommitId = ctx.Repo.Commit.Id.String() } else if len(refName) == 40 { ctx.Repo.IsCommit = true @@ -226,7 +230,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { return } } else { - ctx.Handle(404, "RepoAssignment invalid repo", errors.New("branch or tag not exist")) + ctx.Handle(404, "RepoAssignment invalid repo", fmt.Errorf("branch or tag not exist: %s", refName)) return } diff --git a/public/ng/css/ui.css b/public/ng/css/ui.css index f3f6eded..5dc3cc04 100644 --- a/public/ng/css/ui.css +++ b/public/ng/css/ui.css @@ -151,7 +151,8 @@ code, kbd, pre, samp { - font: 14px Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-family: monospace, monospace; + font-size: 1em; } .text-left { text-align: left; diff --git a/public/ng/less/ui/reset.less b/public/ng/less/ui/reset.less index 8ff45d69..0e7a50e4 100644 --- a/public/ng/less/ui/reset.less +++ b/public/ng/less/ui/reset.less @@ -193,21 +193,19 @@ code, kbd, pre, samp { - font: 14px Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-family: monospace, monospace; + font-size: 1em; } .text-left { text-align: left; } - .text-right { text-align: right; } - .text-center { text-align: center; } - .list-no-style { list-style: none; } diff --git a/templates/.VERSION b/templates/.VERSION index 8a713df0..23f5f0fe 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.4.0922 Beta \ No newline at end of file +0.5.4.0923 Beta \ No newline at end of file -- cgit v1.2.3 From 612fdb98df0ff84c81603a5c8d66a5f2f4395bd5 Mon Sep 17 00:00:00 2001 From: lunnyxiao Date: Wed, 24 Sep 2014 21:05:09 +0800 Subject: bug fixed for download 404 from repo's home page --- cmd/web.go | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index e2c929c1..0d472cd7 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -356,6 +356,7 @@ func runWeb(*cli.Context) { r.Get("/commit/:branchname/*", repo.Diff) r.Get("/releases", repo.Releases) r.Get("/archive/:branchname/*.*", repo.Download) + r.Get("/archive/*.*", repo.Download) r.Get("/compare/:before([a-z0-9]+)...:after([a-z0-9]+)", repo.CompareDiff) }, ignSignIn, middleware.RepoAssignment(true, true)) -- cgit v1.2.3 From 25268577a53bd326b21866c792d7ec390a6e4d94 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 24 Sep 2014 17:43:33 -0400 Subject: Fix download archive issue --- cmd/web.go | 3 +-- gogs.go | 2 +- modules/middleware/repo.go | 11 +++------ routers/repo/repo.go | 52 +++++++++++++++++++++++++++++++++------- templates/.VERSION | 2 +- templates/repo/release/list.tmpl | 8 +++---- 6 files changed, 54 insertions(+), 24 deletions(-) (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index 0d472cd7..2376fd21 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -343,6 +343,7 @@ func runWeb(*cli.Context) { r.Get("/issues/:index", repo.ViewIssue) r.Get("/pulls", repo.Pulls) r.Get("/branches", repo.Branches) + r.Get("/archive/*", repo.Download) }, ignSignIn, middleware.RepoAssignment(true)) m.Group("/:username/:reponame", func(r *macaron.Router) { @@ -355,8 +356,6 @@ func runWeb(*cli.Context) { r.Get("/commit/:branchname", repo.Diff) r.Get("/commit/:branchname/*", repo.Diff) r.Get("/releases", repo.Releases) - r.Get("/archive/:branchname/*.*", repo.Download) - r.Get("/archive/*.*", repo.Download) r.Get("/compare/:before([a-z0-9]+)...:after([a-z0-9]+)", repo.CompareDiff) }, ignSignIn, middleware.RepoAssignment(true, true)) diff --git a/gogs.go b/gogs.go index 0821dbc2..6956b9f5 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.4.0923 Beta" +const APP_VER = "0.5.4.0924 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index e447ee3a..c0290b2e 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -200,7 +200,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Repo.Commit, err = gitRepo.GetCommitOfBranch(refName) if err != nil { - ctx.Handle(404, "RepoAssignment invalid branch", nil) + ctx.Handle(500, "RepoAssignment invalid branch", err) return } ctx.Repo.CommitId = ctx.Repo.Commit.Id.String() @@ -209,14 +209,9 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Repo.IsTag = true ctx.Repo.BranchName = refName - ctx.Repo.Tag, err = gitRepo.GetTag(refName) + ctx.Repo.Commit, err = gitRepo.GetCommitOfTag(refName) if err != nil { - ctx.Handle(404, "RepoAssignment invalid tag", nil) - return - } - ctx.Repo.Commit, err = ctx.Repo.Tag.Commit() - if err != nil { - ctx.Handle(500, "RepoAssignment", fmt.Errorf("fail to get tag commit(%s): %v", refName, err)) + ctx.Handle(500, "RepoAssignment invalid tag", err) return } ctx.Repo.CommitId = ctx.Repo.Commit.Id.String() diff --git a/routers/repo/repo.go b/routers/repo/repo.go index ae599f9f..5562a840 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -244,18 +244,25 @@ func Action(ctx *middleware.Context) { } func Download(ctx *middleware.Context) { - ext := "." + ctx.Params(":ext") - - var archivePath string - switch ext { - case ".zip": + var ( + uri = ctx.Params("*") + refName string + ext string + archivePath string + ) + + switch { + case strings.HasSuffix(uri, ".zip"): + ext = ".zip" archivePath = path.Join(ctx.Repo.GitRepo.Path, "archives/zip") - case ".tar.gz": + case strings.HasSuffix(uri, ".tar.gz"): + ext = ".tar.gz" archivePath = path.Join(ctx.Repo.GitRepo.Path, "archives/targz") default: ctx.Error(404) return } + refName = strings.TrimSuffix(uri, ext) if !com.IsDir(archivePath) { if err := os.MkdirAll(archivePath, os.ModePerm); err != nil { @@ -264,13 +271,42 @@ func Download(ctx *middleware.Context) { } } + // Get corresponding commit. + var ( + commit *git.Commit + err error + ) + gitRepo := ctx.Repo.GitRepo + if gitRepo.IsBranchExist(refName) { + commit, err = gitRepo.GetCommitOfBranch(refName) + if err != nil { + ctx.Handle(500, "Download", err) + return + } + } else if gitRepo.IsTagExist(refName) { + commit, err = gitRepo.GetCommitOfTag(refName) + if err != nil { + ctx.Handle(500, "Download", err) + return + } + } else if len(refName) == 40 { + commit, err = gitRepo.GetCommit(refName) + if err != nil { + ctx.Handle(404, "Download", nil) + return + } + } else { + ctx.Error(404) + return + } + archivePath = path.Join(archivePath, ctx.Repo.CommitId+ext) if !com.IsFile(archivePath) { - if err := ctx.Repo.Commit.CreateArchive(archivePath, git.ZIP); err != nil { + if err := commit.CreateArchive(archivePath, git.ZIP); err != nil { ctx.Handle(500, "Download -> CreateArchive "+archivePath, err) return } } - ctx.ServeFile(archivePath, ctx.Repo.Repository.Name+"-"+base.ShortSha(ctx.Repo.CommitId)+ext) + ctx.ServeFile(archivePath, ctx.Repo.Repository.Name+"-"+base.ShortSha(commit.Id.String())+ext) } diff --git a/templates/.VERSION b/templates/.VERSION index 23f5f0fe..49d86b40 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.4.0923 Beta \ No newline at end of file +0.5.4.0924 Beta \ No newline at end of file diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index 58a050ab..1eb11fc5 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -36,8 +36,8 @@ {{str2html .Note}}

      - Source Code (ZIP) - Source Code (TAR.GZ) + Source Code (ZIP) + Source Code (TAR.GZ)

       
      @@ -48,8 +48,8 @@ -- cgit v1.2.3 From f69761563b7a4fe9ace2a1643391cbcf9b92b372 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 25 Sep 2014 16:36:19 -0400 Subject: Fix bug on transfer repo --- .gitignore | 3 +++ cmd/web.go | 3 ++- conf/locale/locale_en-US.ini | 1 + conf/locale/locale_zh-CN.ini | 1 + gogs.go | 2 +- models/action.go | 4 ++-- models/repo.go | 40 ++++++++++++++++++++++++--------- modules/base/template.go | 8 +++---- templates/.VERSION | 2 +- templates/user/dashboard/dashboard.tmpl | 2 ++ 10 files changed, 45 insertions(+), 21 deletions(-) (limited to 'cmd/web.go') diff --git a/.gitignore b/.gitignore index 57d1493b..3f7608d7 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ __pycache__ output* config.codekit .brackets.json +docker/fig.yml +docker/docker/Dockerfile +docker/docker/init_gogs.sh diff --git a/cmd/web.go b/cmd/web.go index 2376fd21..8a87f86b 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -190,7 +190,8 @@ func runWeb(*cli.Context) { r.Get("/logout", user.SignOut) }) - m.Get("/user/:username", ignSignIn, user.Profile) // TODO: Legacy + // FIXME: Legacy + m.Get("/user/:username", ignSignIn, user.Profile) // Gravatar service. avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg") diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 15d8028c..13be2fbd 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -565,6 +565,7 @@ 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 +transfer_repo = transfered repository %s to %s [tool] ago = ago diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index e479f5cd..7d65abd3 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -563,6 +563,7 @@ create_repo = 创建了仓库 %s commit_repo = 推送了 %s 分支的代码到 %s create_issue = 创建了工单 %s#%s comment_issue = 评论了工单 %s#%s +transfer_repo = 将仓库 %s 转移至 %s [tool] ago = 之前 diff --git a/gogs.go b/gogs.go index 6956b9f5..2f5b2417 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.4.0924 Beta" +const APP_VER = "0.5.4.0925 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/action.go b/models/action.go index 18c956bd..46500a92 100644 --- a/models/action.go +++ b/models/action.go @@ -351,8 +351,8 @@ func NewRepoAction(u *User, repo *Repository) (err error) { // TransferRepoAction adds new action for transfering repository. func TransferRepoAction(u, newUser *User, repo *Repository) (err error) { if err = NotifyWatchers(&Action{ActUserId: u.Id, ActUserName: u.Name, ActEmail: u.Email, - OpType: TRANSFER_REPO, RepoId: repo.Id, RepoUserName: repo.Owner.Name, - RepoName: repo.Name, Content: newUser.Name, + OpType: TRANSFER_REPO, RepoId: repo.Id, RepoUserName: newUser.Name, + RepoName: repo.Name, IsPrivate: repo.IsPrivate}); err != nil { log.Error(4, "NotifyWatchers: %d/%s", u.Id, repo.Name) return err diff --git a/models/repo.go b/models/repo.go index c0a581b9..093e3b7f 100644 --- a/models/repo.go +++ b/models/repo.go @@ -669,15 +669,23 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error { return err } - if _, err = sess.Where("repo_name = ?", u.LowerName+"/"+repo.LowerName). - And("user_name = ?", u.LowerName).Update(&Access{UserName: newUser.LowerName}); err != nil { - sess.Rollback() - return err + curRepoLink := path.Join(u.LowerName, repo.LowerName) + // Delete all access first if current owner is an organization. + if u.IsOrganization() { + if _, err = sess.Where("repo_name=?", curRepoLink).Delete(new(Access)); err != nil { + sess.Rollback() + return fmt.Errorf("fail to delete current accesses: %v", err) + } + } else { + if _, err = sess.Where("repo_name=?", curRepoLink).And("user_name=?", u.LowerName). + Update(&Access{UserName: newUser.LowerName}); err != nil { + sess.Rollback() + return err + } } - if _, err = sess.Where("repo_name = ?", u.LowerName+"/"+repo.LowerName).Update(&Access{ - RepoName: newUser.LowerName + "/" + repo.LowerName, - }); err != nil { + if _, err = sess.Where("repo_name=?", curRepoLink). + Update(&Access{RepoName: path.Join(newUser.LowerName, repo.LowerName)}); err != nil { sess.Rollback() return err } @@ -700,12 +708,12 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error { return err } + mode := WRITABLE + if repo.IsMirror { + mode = READABLE + } // New owner is organization. if newUser.IsOrganization() { - mode := WRITABLE - if repo.IsMirror { - mode = READABLE - } access := &Access{ RepoName: path.Join(newUser.LowerName, repo.LowerName), Mode: mode, @@ -737,6 +745,16 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error { sess.Rollback() return err } + } else { + access := &Access{ + RepoName: path.Join(newUser.LowerName, repo.LowerName), + UserName: newUser.LowerName, + Mode: mode, + } + if _, err = sess.Insert(access); err != nil { + sess.Rollback() + return err + } } // Change repository directory name. diff --git a/modules/base/template.go b/modules/base/template.go index ec419149..b1c8c161 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -149,14 +149,12 @@ type Actioner interface { // and returns a icon class name. func ActionIcon(opType int) string { switch opType { - case 1: // Create repository. + case 1, 8: // Create, transfer repository. return "repo" case 5, 9: // Commit repository. return "git-commit" case 6: // Create issue. return "issue-opened" - case 8: // Transfer repository. - return "share" case 10: // Comment issue. return "comment" default: @@ -164,7 +162,7 @@ func ActionIcon(opType int) string { } } -// TODO: Legacy +// FIXME: Legacy const ( TPL_CREATE_REPO = `%s created repository %s` TPL_COMMIT_REPO = `%s pushed to %s at %s%s` @@ -197,7 +195,7 @@ func ActionContent2Commits(act Actioner) *PushCommits { return push } -// TODO: Legacy +// FIXME: Legacy // ActionDesc accepts int that represents action operation type // and returns the description. func ActionDesc(act Actioner) string { diff --git a/templates/.VERSION b/templates/.VERSION index 49d86b40..87b06b81 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.4.0924 Beta \ No newline at end of file +0.5.4.0925 Beta \ No newline at end of file diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index 0d728ef4..370173e4 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -20,6 +20,8 @@ {{else if eq .GetOpType 6}} {{ $index := index .GetIssueInfos 0}} {{$.i18n.Tr "action.create_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} + {{else if eq .GetOpType 8}} + {{$.i18n.Tr "action.transfer_repo" .GetRepoName AppSubUrl .GetRepoLink .GetRepoLink | Str2html}} {{else if eq .GetOpType 10}} {{ $index := index .GetIssueInfos 0}} {{$.i18n.Tr "action.comment_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}} -- cgit v1.2.3 From 7d48f811f16d3565f161a44e4e98c451cf6c857e Mon Sep 17 00:00:00 2001 From: fuxiaohei Date: Sat, 27 Sep 2014 19:03:07 +0800 Subject: add issue router for new issue page ui preview --- cmd/web.go | 1 + routers/repo/issue.go | 6 ++++++ templates/repo/issue2/list.tmpl | 6 ++++++ 3 files changed, 13 insertions(+) create mode 100644 templates/repo/issue2/list.tmpl (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index 8a87f86b..fc417618 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -345,6 +345,7 @@ func runWeb(*cli.Context) { r.Get("/pulls", repo.Pulls) r.Get("/branches", repo.Branches) r.Get("/archive/*", repo.Download) + r.Get("/issues2/",repo.Issues2) }, ignSignIn, middleware.RepoAssignment(true)) m.Group("/:username/:reponame", func(r *macaron.Router) { diff --git a/routers/repo/issue.go b/routers/repo/issue.go index f854a22b..e611032e 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -1119,3 +1119,9 @@ func IssueGetAttachment(ctx *middleware.Context) { // We must put the name in " manually. ctx.ServeFile(attachment.Path, "\""+attachment.Name+"\"") } + +// testing route handler for new issue ui page +// todo : move to Issue() function +func Issues2(ctx *middleware.Context){ + ctx.HTML(200,"repo/issue2/list") +} diff --git a/templates/repo/issue2/list.tmpl b/templates/repo/issue2/list.tmpl new file mode 100644 index 00000000..9616199e --- /dev/null +++ b/templates/repo/issue2/list.tmpl @@ -0,0 +1,6 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +
      + {{template "repo/header" .}} +
      +{{template "ng/base/footer" .}} \ No newline at end of file -- cgit v1.2.3 From 49193bebd283322bb997b7aed09fc7818a881af9 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 28 Sep 2014 01:38:25 -0400 Subject: UI: Confirmation box --- cmd/web.go | 6 ++ conf/locale/locale_en-US.ini | 13 ++++ conf/locale/locale_zh-CN.ini | 15 ++++ gogs.go | 3 +- modules/middleware/context.go | 18 ----- public/ng/css/gogs.css | 4 + public/ng/js/gogs.js | 146 +++++++++++++++++++++++------------ public/ng/js/min/gogs-min.js | 10 +-- public/ng/less/gogs/repository.less | 4 + templates/.VERSION | 2 +- templates/admin/auth/edit.tmpl | 9 ++- templates/admin/user/edit.tmpl | 11 ++- templates/org/settings/delete.tmpl | 11 ++- templates/org/settings/options.tmpl | 9 ++- templates/org/team/new.tmpl | 9 ++- templates/repo/home.tmpl | 2 +- templates/repo/settings/options.tmpl | 9 ++- templates/user/settings/delete.tmpl | 11 ++- templates/user/settings/profile.tmpl | 4 +- 19 files changed, 210 insertions(+), 86 deletions(-) (limited to 'cmd/web.go') diff --git a/cmd/web.go b/cmd/web.go index 8a87f86b..f226e76e 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -50,6 +50,7 @@ and it takes care of all the other things for you`, // checkVersion checks if binary matches the version of templates files. func checkVersion() { + // Templates. data, err := ioutil.ReadFile(path.Join(setting.StaticRootPath, "templates/.VERSION")) if err != nil { log.Fatal(4, "Fail to read 'templates/.VERSION': %v", err) @@ -57,6 +58,11 @@ func checkVersion() { if string(data) != setting.AppVer { log.Fatal(4, "Binary and template file version does not match, did you forget to recompile?") } + + // Macaron. + if macaron.Version() != "0.1.8.0927" { + log.Fatal(4, "Macaron version does not match, did you forget to update?(github.com/Unknwon/macaron)") + } } // newMacaron initializes Macaron instance. diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index f0e0877f..3990ea87 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -223,6 +223,8 @@ unbind_success = Social account has been unbound. delete_account = Delete Your Account delete_prompt = The operation will delete your account permanently, and CANNOT be undone! confirm_delete_account = Confirm Deletion +delete_account_title = Account Deletion +delete_account_desc = This account is going to be deleted permanently, do you want to continue? [repo] owner = Owner @@ -257,6 +259,7 @@ unstar = Unstar star = Star fork = Fork +no_desc = No Description quick_guide = Quick Guide clone_this_repo = Clone this repository create_new_repo_command = Create a new repository on the command line @@ -289,6 +292,8 @@ settings.basic_settings = Basic Settings settings.danger_zone = Danger Zone settings.site = Official Site settings.update_settings = Update Settings +settings.change_reponame = Repository Name Changed +settings.change_reponame_desc = Repository name has been changed, do you want to continue? This will affect all links relate to this repository. settings.transfer = Transfer Ownership settings.transfer_desc = Transfer this repo to another user or to an organization where you have admin rights. settings.new_owner_has_same_repo = New owner already has a repository with same name. @@ -349,11 +354,15 @@ settings.full_name = Full Name settings.website = Website settings.location = Location settings.update_settings = Update Settings +settings.change_orgname = Organization Name Changed +settings.change_orgname_desc = Organization name has been changed, do you want to continue? This will affect all links relate to this organization. settings.update_setting_success = Organization setting has been successfully updated. settings.delete = Delete Organization settings.delete_account = Delete This Organization settings.delete_prompt = The operation will delete this organization permanently, and CANNOT be undone! settings.confirm_delete_account = Confirm Deletion +settings.delete_org_title = Organization Deletion +settings.delete_org_desc = This organization is going to be deleted permanently, do you want to continue? settings.hooks_desc = Add webhooks that will be triggered for all repositories under this organization. members.public = Public @@ -383,6 +392,8 @@ teams.members = Team Members teams.update_settings = Update Settings teams.delete_team = Delete This Team teams.add_team_member = Add Team Member +teams.delete_team_title = Team Deletion +teams.delete_team_desc = This team is going to be deleted, do you want to continue? Members of this team may lose access to some repositories. teams.delete_team_success = Given team has been successfully deleted. teams.read_permission_desc = This team grants Read access: members can view and clone the team's repositories. teams.write_permission_desc = This team grants Write access: members can read from and push to the team's repositories. @@ -499,6 +510,8 @@ auths.activated = This authentication has activated auths.update_success = Authorization setting has been successfully updated. auths.update = Update Authorization Setting auths.delete = Delete This Authorization +auths.delete_auth_title = Authorization Deletion +auths.delete_auth_desc = This authorization is going to be deleted, do you want to continue? config.server_config = Server Configuration config.app_name = Application Name diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 4d80327e..6ecd529d 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -223,6 +223,8 @@ unbind_success = 社交帐号解除绑定成功! delete_account = 删除当前帐户 delete_prompt = 删除操作会永久清除您的帐户信息,并且 不可恢复! confirm_delete_account = 确认删除帐户 +delete_account_title = 帐户删除操作 +delete_account_desc = 该帐户将被永久性删除,您确定要继续操作吗? [repo] owner = 拥有者 @@ -257,6 +259,7 @@ unstar = 取消点赞 star = 点赞 fork = 派生 +no_desc = 暂无描述 quick_guide = 快速帮助 clone_this_repo = 克隆当前仓库 create_new_repo_command = 从命令行创建一个新的仓库 @@ -289,6 +292,8 @@ settings.basic_settings = 基本设置 settings.danger_zone = 危险操作区 settings.site = 官方网站 settings.update_settings = 更新仓库设置 +settings.change_reponame = 仓库名称将被修改 +settings.change_reponame_desc = 仓库名称被修改,您确定要继续操作吗?这将会影响到所有与该仓库有关的链接。 settings.transfer = 转移仓库所有权 settings.transfer_desc = 您可以将仓库转移至您拥有管理员权限的帐户或组织。 settings.new_owner_has_same_repo = 新的仓库拥有者已经存在同名仓库! @@ -349,11 +354,16 @@ settings.full_name = 组织全名 settings.website = 官方网站 settings.location = 所在地区 settings.update_settings = 更新组织设置 +settings.change_orgname = 组织名称将被修改 +settings.change_orgname_desc = 组织名称被修改,您确定要继续操作吗?这将会影响到所有与该组织有关的链接。 settings.update_setting_success = 组织设置更新成功! settings.delete = 删除组织 settings.delete_account = 删除当前组织 settings.delete_prompt = 删除操作会永久清除该组织的信息,并且 不可恢复! settings.confirm_delete_account = 确认删除组织 +settings.delete_org_title = 组织删除操作 +settings.delete_org_desc = 该组织将被永久性删除,您确定要继续操作吗? +settings.hooks_desc = 在此处添加的 Web 钩子将会应用到该组织下的 所有仓库。 members.public = 公开成员 members.public_helper = 设为私有 @@ -382,6 +392,8 @@ teams.members = 团队成员 teams.update_settings = 更新团队设置 teams.delete_team = 删除当前团队 teams.add_team_member = 添加团队成员 +teams.delete_team_title = 团队删除操作 +teams.delete_team_desc = 删除操作会永久清除有关该团队的信息,您确定要继续操作吗?团队成员可能会失去对某些仓库的操作权限。 teams.delete_team_success = 指定团队删除成功! teams.read_permission_desc = 该团队拥有对所属仓库的 读取 权限,团队成员可以进行查看和克隆等只读操作。 teams.write_permission_desc = 该团队拥有对所属仓库的 读取写入 的权限。 @@ -457,6 +469,7 @@ users.is_activated = 该用户已被激活 users.is_admin = 该用户具有管理员权限 users.update_profile = 更新用户信息 users.delete_account = 删除该用户 +users.still_own_repo = 该帐户仍然是某些仓库的拥有者,您必须先转移或删除它们才能执行删除帐户操作! orgs.org_manage_panel = 组织管理面板 orgs.name = 组织名称 @@ -497,6 +510,8 @@ auths.activated = 该授权认证已经启用 auths.update_success = 授权认证设置更新成功! auths.update = 更新授权认证信息 auths.delete = 删除该授权认证 +auths.delete_auth_title = 授权认证删除操作 +auths.delete_auth_desc = 该授权认证将被删除,您确定要继续吗? config.server_config = 服务器配置 config.app_name = 应用名称 diff --git a/gogs.go b/gogs.go index 28b0fecc..a5d9a49f 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.4.0926 Beta" +const APP_VER = "0.5.4.0927 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) @@ -38,5 +38,6 @@ func main() { cmd.CmdCert, } app.Flags = append(app.Flags, []cli.Flag{}...) + println(runtime.Version()) app.Run(os.Args) } diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 9145038f..90716d2c 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -9,7 +9,6 @@ import ( "html/template" "io" "net/http" - "path" "strings" "time" @@ -140,23 +139,6 @@ func (ctx *Context) Handle(status int, title string, err error) { ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status))) } -func (ctx *Context) ServeFile(file string, names ...string) { - var name string - if len(names) > 0 { - name = names[0] - } else { - name = path.Base(file) - } - ctx.Resp.Header().Set("Content-Description", "File Transfer") - ctx.Resp.Header().Set("Content-Type", "application/octet-stream") - ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+name) - ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary") - ctx.Resp.Header().Set("Expires", "0") - ctx.Resp.Header().Set("Cache-Control", "must-revalidate") - ctx.Resp.Header().Set("Pragma", "public") - http.ServeFile(ctx.Resp, ctx.Req, file) -} - func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) { modtime := time.Now() for _, p := range params { diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index dbaa3db1..a0be4ee4 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -1472,6 +1472,10 @@ The register and sign-in page style font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace; font-size: 14px; } +.no-desc { + color: #888; + font-style: italic; +} #admin-wrapper, #setting-wrapper { padding-bottom: 100px; diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index fcad5cbc..9a861004 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -293,39 +293,38 @@ function initCore() { } e.preventDefault(); }); + + // Popup. + $(document).on('click', '.popup-modal-dismiss', function (e) { + e.preventDefault(); + $.magnificPopup.close(); + }); } function initUserSetting() { // Confirmation of change username in user profile page. var $username = $('#username'); - var $form = $('#user-profile-form'); - var confimed = false; - $('.popup-modal').magnificPopup({ + var $profile_form = $('#user-profile-form'); + $('#change-username-btn').magnificPopup({ modal: true, callbacks: { open: function () { if (($username.data('uname') == $username.val())) { $.magnificPopup.close(); - $form.submit(); + $profile_form.submit(); } } } - }); - $(document).on('click', '.popup-modal-dismiss', function (e) { - e.preventDefault(); - $.magnificPopup.close(); - }); - $('#modal-submit').click(function(){ - $.magnificPopup.close(); - confimed = true; - $form.submit(); - }); - $form.submit(function (e) { - if (($username.data('uname') != $username.val()) && !confimed) { + }).click(function () { + if (($username.data('uname') != $username.val())) { e.preventDefault(); return true; } }); + $('#change-username-submit').click(function () { + $.magnificPopup.close(); + $profile_form.submit(); + }); // Show add SSH key panel. $('#ssh-add').click(function () { @@ -333,11 +332,15 @@ function initUserSetting() { }); // Confirmation of delete account. - $('#delete-account-button').click(function (e) { - if (!confirm('This account is going to be deleted, do you want to continue?')) { - e.preventDefault(); - return true; - } + $('#delete-account-btn').magnificPopup({ + modal: true + }).click(function (e) { + e.preventDefault(); + return true; + }); + $('#delete-account-submit').click(function () { + $.magnificPopup.close(); + $('#delete-account-form').submit(); }); } @@ -409,13 +412,28 @@ function initHookTypeChange() { function initRepoSetting() { // Options. // Confirmation of changing repository name. - $('#repo-setting-form').submit(function (e) { - var $reponame = $('#repo_name'); - if (($reponame.data('repo-name') != $reponame.val()) && !confirm('Repository name has been changed, do you want to continue?')) { + var $reponame = $('#repo_name'); + var $setting_form = $('#repo-setting-form'); + $('#change-reponame-btn').magnificPopup({ + modal: true, + callbacks: { + open: function () { + if (($reponame.data('repo-name') == $reponame.val())) { + $.magnificPopup.close(); + $setting_form.submit(); + } + } + } + }).click(function () { + if (($reponame.data('repo-name') != $reponame.val())) { e.preventDefault(); return true; } }); + $('#change-reponame-submit').click(function () { + $.magnificPopup.close(); + $setting_form.submit(); + }); initHookTypeChange(); @@ -451,19 +469,39 @@ function initRepoSetting() { function initOrgSetting() { // Options. // Confirmation of changing organization name. - $('#org-setting-form').submit(function (e) { - var $orgname = $('#orgname'); - if (($orgname.data('orgname') != $orgname.val()) && !confirm('Organization name has been changed, do you want to continue?')) { + var $orgname = $('#orgname'); + var $setting_form = $('#org-setting-form'); + $('#change-orgname-btn').magnificPopup({ + modal: true, + callbacks: { + open: function () { + if (($orgname.data('orgname') == $orgname.val())) { + $.magnificPopup.close(); + $setting_form.submit(); + } + } + } + }).click(function () { + if (($orgname.data('orgname') != $orgname.val())) { e.preventDefault(); return true; } }); + $('#change-orgname-submit').click(function () { + $.magnificPopup.close(); + $setting_form.submit(); + }); + // Confirmation of delete organization. - $('#delete-org-button').click(function (e) { - if (!confirm('This organization is going to be deleted, do you want to continue?')) { - e.preventDefault(); - return true; - } + $('#delete-org-btn').magnificPopup({ + modal: true + }).click(function (e) { + e.preventDefault(); + return true; + }); + $('#delete-org-submit').click(function () { + $.magnificPopup.close(); + $('#delete-org-form').submit(); }); initHookTypeChange(); @@ -493,11 +531,14 @@ function initInvite() { function initOrgTeamCreate() { // Delete team. - $('#org-team-delete').click(function (e) { - if (!confirm('This team is going to be deleted, do you want to continue?')) { - e.preventDefault(); - return true; - } + $('#org-team-delete').magnificPopup({ + modal: true + }).click(function (e) { + e.preventDefault(); + return true; + }); + $('#delete-team-submit').click(function () { + $.magnificPopup.close(); var $form = $('#team-create-form'); $form.attr('action', $form.data('delete-url')); }); @@ -561,15 +602,20 @@ function initAdmin() { $('.auth-name').toggleShow(); } }); + // Delete account. - $('#user-delete').click(function (e) { - if (!confirm('This account is going to be deleted, do you want to continue?')) { - e.preventDefault(); - return true; - } + $('#delete-account-btn').magnificPopup({ + modal: true + }).click(function (e) { + e.preventDefault(); + return true; + }); + $('#delete-account-submit').click(function () { + $.magnificPopup.close(); var $form = $('#user-profile-form'); $form.attr('action', $form.data('delete-url')); }); + // Create authorization. $('#auth-type').on("change", function () { var v = $(this).val(); @@ -582,13 +628,17 @@ function initAdmin() { $('.ldap').toggleHide(); } }); + // Delete authorization. - $('#auth-delete').click(function (e) { - if (!confirm('This authorization is going to be deleted, do you want to continue?')) { - e.preventDefault(); - return true; - } - var $form = $('auth-setting-form'); + $('#delete-auth-btn').magnificPopup({ + modal: true + }).click(function (e) { + e.preventDefault(); + return true; + }); + $('#delete-auth-submit').click(function () { + $.magnificPopup.close(); + var $form = $('#auth-setting-form'); $form.attr('action', $form.data('delete-url')); }); } diff --git a/public/ng/js/min/gogs-min.js b/public/ng/js/min/gogs-min.js index d27e0a8b..5bb6daa7 100644 --- a/public/ng/js/min/gogs-min.js +++ b/public/ng/js/min/gogs-min.js @@ -1,5 +1,5 @@ -function Tabs(e){function t(e){console.log("hide",e),e.removeClass("js-tab-nav-show"),$(e.data("tab-target")).removeClass("js-tab-show").hide()}function n(e){console.log("show",e),e.addClass("js-tab-nav-show"),$(e.data("tab-target")).addClass("js-tab-show").show()}var r=$(e);if(r.length){var i=r.find(".js-tab-nav-show");i.length&&$(i.data("tab-target")).addClass("js-tab-show"),r.on("click",".js-tab-nav",function(e){e.preventDefault();var o=$(this);o.hasClass("js-tab-nav-show")||(i=r.find(".js-tab-nav-show").eq(0),t(i),n(o))}),console.log("init tabs @",e)}}function Preview(e,t){function n(e){return e.find(".js-preview-input").eq(0)}function r(e){return e.hasClass("js-preview-container")?e:e.find(".js-preview-container").eq(0)}var i=$(e),o=$(t),a=n(o);if(!a.length)return void console.log("[preview]: no preview input");var s=r(o);return s.length?(i.on("click",function(){$.post("/api/v1/markdown",{text:a.val()},function(e){s.html(e)})}),void console.log("[preview]: init preview @",e,"&",t)):void console.log("[preview]: no preview container")}function initCore(){Gogs.renderMarkdown(),Gogs.renderCodeView(),$(".js-tab-nav").click(function(e){$(this).hasClass("js-tab-nav-show")||($(this).parent().find(".js-tab-nav-show").each(function(){$(this).removeClass("js-tab-nav-show"),$($(this).data("tab-target")).hide()}),$(this).addClass("js-tab-nav-show"),$($(this).data("tab-target")).show()),e.preventDefault()})}function initUserSetting(){var e=$("#username"),t=$("#user-profile-form"),n=!1;$(".popup-modal").magnificPopup({modal:!0,callbacks:{open:function(){e.data("uname")==e.val()&&($.magnificPopup.close(),t.submit())}}}),$(document).on("click",".popup-modal-dismiss",function(e){e.preventDefault(),$.magnificPopup.close()}),$("#modal-submit").click(function(){$.magnificPopup.close(),n=!0,t.submit()}),t.submit(function(t){return e.data("uname")==e.val()||n?void 0:(t.preventDefault(),!0)}),$("#ssh-add").click(function(){$("#user-ssh-add-form").removeClass("hide")}),$("#delete-account-button").click(function(e){return confirm("This account is going to be deleted, do you want to continue?")?void 0:(e.preventDefault(),!0)})}function initRepoCreate(){$("#repo-create-owner-list").on("click","li",function(){if(!$(this).hasClass("checked")){var e=$(this).data("uid");$("#repo-owner-id").val(e),$("#repo-owner-avatar").attr("src",$(this).find("img").attr("src")),$("#repo-owner-name").text($(this).text().trim()),$(this).parent().find(".checked").removeClass("checked"),$(this).addClass("checked"),console.log("set repo owner to uid :",e,$(this).text().trim())}}),$("#auth-button").click(function(e){$("#repo-migrate-auth").slideToggle("fast"),e.preventDefault()}),console.log("initRepoCreate")}function initRepo(){$("#repo-clone-ssh").click(function(){$(this).removeClass("btn-gray").addClass("btn-blue"),$("#repo-clone-https").removeClass("btn-blue").addClass("btn-gray"),$("#repo-clone-url").val($(this).data("link")),$(".clone-url").text($(this).data("link"))}),$("#repo-clone-https").click(function(){$(this).removeClass("btn-gray").addClass("btn-blue"),$("#repo-clone-ssh").removeClass("btn-blue").addClass("btn-gray"),$("#repo-clone-url").val($(this).data("link")),$(".clone-url").text($(this).data("link"))});var e=$("#repo-clone-copy");e.hover(function(){Gogs.bindCopy($(this))}),e.tipsy({fade:!0})}function initHookTypeChange(){$("select#hook-type").on("change",function(){hookTypes=["Gogs","Slack"];var e=$(this).val();hookTypes.forEach(function(t){e===t?$("div#"+t.toLowerCase()).toggleShow():$("div#"+t.toLowerCase()).toggleHide()})})}function initRepoSetting(){$("#repo-setting-form").submit(function(e){var t=$("#repo_name");return t.data("repo-name")==t.val()||confirm("Repository name has been changed, do you want to continue?")?void 0:(e.preventDefault(),!0)}),initHookTypeChange(),$("#transfer-button").click(function(){$("#transfer-form").show()}),$("#delete-button").click(function(){$("#delete-form").show()}),$("#repo-collab-list hr:last-child").remove();var e=$("#repo-collaborator").next().next().find("ul");$("#repo-collaborator").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchUsers(t.val(),e):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#repo-collaborator").val($(this).text()),e.toggleHide()})}function initOrgSetting(){$("#org-setting-form").submit(function(e){var t=$("#orgname");return t.data("orgname")==t.val()||confirm("Organization name has been changed, do you want to continue?")?void 0:(e.preventDefault(),!0)}),$("#delete-org-button").click(function(e){return confirm("This organization is going to be deleted, do you want to continue?")?void 0:(e.preventDefault(),!0)}),initHookTypeChange()}function initInvite(){var e=$("#org-member-invite-list");$("#org-member-invite").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchUsers(t.val(),e):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-member-invite").val($(this).text()),e.toggleHide()})}function initOrgTeamCreate(){$("#org-team-delete").click(function(e){if(!confirm("This team is going to be deleted, do you want to continue?"))return e.preventDefault(),!0;var t=$("#team-create-form");t.attr("action",t.data("delete-url"))})}function initTeamMembersList(){var e=$("#org-team-members-list");$("#org-team-members-add").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchUsers(t.val(),e):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-team-members-add").val($(this).text()),e.toggleHide()})}function initTeamRepositoriesList(){var e=$("#org-team-repositories-list");$("#org-team-repositories-add").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchRepos(t.val(),e,"uid="+t.data("uid")):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-team-repositories-add").val($(this).text()),e.toggleHide()})}function initAdmin(){$("#login-type").on("change",function(){var e=$(this).val();e.indexOf("0-")+1?($(".auth-name").toggleHide(),$(".pwd").find("input").attr("required","required").end().toggleShow()):($(".pwd").find("input").removeAttr("required").end().toggleHide(),$(".auth-name").toggleShow())}),$("#user-delete").click(function(e){if(!confirm("This account is going to be deleted, do you want to continue?"))return e.preventDefault(),!0;var t=$("#user-profile-form");t.attr("action",t.data("delete-url"))}),$("#auth-type").on("change",function(){var e=$(this).val();2==e&&($(".ldap").toggleShow(),$(".smtp").toggleHide()),3==e&&($(".smtp").toggleShow(),$(".ldap").toggleHide())}),$("#auth-delete").click(function(e){if(!confirm("This authorization is going to be deleted, do you want to continue?"))return e.preventDefault(),!0;var t=$("auth-setting-form");t.attr("action",t.data("delete-url"))})}function initInstall(){!function(){var e="127.0.0.1:3306",t="127.0.0.1:5432";$("#install-database").on("change",function(){var n=$(this).val();"SQLite3"!=n?($(".server-sql").show(),$(".sqlite-setting").addClass("hide"),"PostgreSQL"==n?($(".pgsql-setting").removeClass("hide"),$("#database-host").val()==e&&$("#database-host").val(t)):"MySQL"==n?($(".pgsql-setting").addClass("hide"),$("#database-host").val()==t&&$("#database-host").val(e)):$(".pgsql-setting").addClass("hide")):($(".server-sql").hide(),$(".pgsql-setting").hide(),$(".sqlite-setting").removeClass("hide"))})}()}function initProfile(){$("#profile-avatar").tipsy({fade:!0})}function homepage(){$("#promo-form").submit(function(e){return""===$("#username").val()?(e.preventDefault(),window.location.href=Gogs.AppSubUrl+"/user/login",!0):void 0}),$("#register-button").click(function(e){return""===$("#username").val()?(e.preventDefault(),window.location.href=Gogs.AppSubUrl+"/user/sign_up",!0):void $("#promo-form").attr("action",Gogs.AppSubUrl+"/user/sign_up")})}!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=e.length,n=ot.type(e);return"function"===n||ot.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function r(e,t,n){if(ot.isFunction(t))return ot.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return ot.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(pt.test(t))return ot.filter(t,e,n);t=ot.filter(t,e)}return ot.grep(e,function(e){return ot.inArray(e,t)>=0!==n})}function i(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function o(e){var t=wt[e]={};return ot.each(e.match(xt)||[],function(e,n){t[n]=!0}),t}function a(){mt.addEventListener?(mt.removeEventListener("DOMContentLoaded",s,!1),e.removeEventListener("load",s,!1)):(mt.detachEvent("onreadystatechange",s),e.detachEvent("onload",s))}function s(){(mt.addEventListener||"load"===event.type||"complete"===mt.readyState)&&(a(),ot.ready())}function l(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace($t,"-$1").toLowerCase();if(n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:kt.test(n)?ot.parseJSON(n):n}catch(i){}ot.data(e,t,n)}else n=void 0}return n}function u(e){var t;for(t in e)if(("data"!==t||!ot.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function c(e,t,n,r){if(ot.acceptData(e)){var i,o,a=ot.expando,s=e.nodeType,l=s?ot.cache:e,u=s?e[a]:e[a]&&a;if(u&&l[u]&&(r||l[u].data)||void 0!==n||"string"!=typeof t)return u||(u=s?e[a]=V.pop()||ot.guid++:a),l[u]||(l[u]=s?{}:{toJSON:ot.noop}),("object"==typeof t||"function"==typeof t)&&(r?l[u]=ot.extend(l[u],t):l[u].data=ot.extend(l[u].data,t)),o=l[u],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[ot.camelCase(t)]=n),"string"==typeof t?(i=o[t],null==i&&(i=o[ot.camelCase(t)])):i=o,i}}function d(e,t,n){if(ot.acceptData(e)){var r,i,o=e.nodeType,a=o?ot.cache:e,s=o?e[ot.expando]:ot.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){ot.isArray(t)?t=t.concat(ot.map(t,ot.camelCase)):t in r?t=[t]:(t=ot.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;for(;i--;)delete r[t[i]];if(n?!u(r):!ot.isEmptyObject(r))return}(n||(delete a[s].data,u(a[s])))&&(o?ot.cleanData([e],!0):rt.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}function f(){return!0}function p(){return!1}function h(){try{return mt.activeElement}catch(e){}}function m(e){var t=Pt.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function g(e,t){var n,r,i=0,o=typeof e.getElementsByTagName!==St?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==St?e.querySelectorAll(t||"*"):void 0;if(!o)for(o=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||ot.nodeName(r,t)?o.push(r):ot.merge(o,g(r,t));return void 0===t||t&&ot.nodeName(e,t)?ot.merge([e],o):o}function v(e){jt.test(e.type)&&(e.defaultChecked=e.checked)}function y(e,t){return ot.nodeName(e,"table")&&ot.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function b(e){return e.type=(null!==ot.find.attr(e,"type"))+"/"+e.type,e}function x(e){var t=Zt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function w(e,t){for(var n,r=0;null!=(n=e[r]);r++)ot._data(n,"globalEval",!t||ot._data(t[r],"globalEval"))}function C(e,t){if(1===t.nodeType&&ot.hasData(e)){var n,r,i,o=ot._data(e),a=ot._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)ot.event.add(t,n,s[n][r])}a.data&&(a.data=ot.extend({},a.data))}}function S(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!rt.noCloneEvent&&t[ot.expando]){i=ot._data(t);for(r in i.events)ot.removeEvent(t,r,i.handle);t.removeAttribute(ot.expando)}"script"===n&&t.text!==e.text?(b(t).text=e.text,x(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),rt.html5Clone&&e.innerHTML&&!ot.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&jt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function T(t,n){var r,i=ot(n.createElement(t)).appendTo(n.body),o=e.getDefaultComputedStyle&&(r=e.getDefaultComputedStyle(i[0]))?r.display:ot.css(i[0],"display");return i.detach(),o}function k(e){var t=mt,n=Jt[e];return n||(n=T(e,t),"none"!==n&&n||(Kt=(Kt||ot("