aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-04 21:30:33 -0500
committerUnknwon <u@gogs.io>2015-12-04 21:30:33 -0500
commite538ff27704cddb1a99efc1a6be19e134f97355f (patch)
tree88f93b17d47aeb3ac4dd0692f5c5b613ee38b28b /routers/repo
parent76d4b9288b60ed6c037257415a570225764ff0a0 (diff)
downloadgitea-e538ff27704cddb1a99efc1a6be19e134f97355f.tar.gz
gitea-e538ff27704cddb1a99efc1a6be19e134f97355f.zip
fix #1829 and fix #890
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/issue.go33
-rw-r--r--routers/repo/release.go4
-rw-r--r--routers/repo/setting.go21
-rw-r--r--routers/repo/view.go4
-rw-r--r--routers/repo/wiki.go8
5 files changed, 58 insertions, 12 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 975fa239a0..ed9454440a 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -41,6 +41,18 @@ var (
ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
)
+func MustEnableIssues(ctx *middleware.Context) {
+ if !ctx.Repo.Repository.EnableIssues {
+ ctx.Handle(404, "MustEnableIssues", nil)
+ }
+}
+
+func MustEnablePulls(ctx *middleware.Context) {
+ if !ctx.Repo.Repository.EnablePulls {
+ ctx.Handle(404, "MustEnablePulls", nil)
+ }
+}
+
func RetrieveLabels(ctx *middleware.Context) {
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID)
if err != nil {
@@ -60,7 +72,12 @@ func Issues(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.pulls")
ctx.Data["PageIsPullList"] = true
ctx.Data["HasForkedRepo"] = ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)
+
} else {
+ MustEnableIssues(ctx)
+ if ctx.Written() {
+ return
+ }
ctx.Data["Title"] = ctx.Tr("repo.issues")
ctx.Data["PageIsIssueList"] = true
}
@@ -496,6 +513,10 @@ func ViewIssue(ctx *middleware.Context) {
ctx.Data["PageIsPullConversation"] = true
ctx.Data["HasForkedRepo"] = ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)
} else {
+ MustEnableIssues(ctx)
+ if ctx.Written() {
+ return
+ }
ctx.Data["PageIsIssueList"] = true
}
@@ -503,7 +524,8 @@ func ViewIssue(ctx *middleware.Context) {
ctx.Handle(500, "GetPoster", err)
return
}
- issue.RenderedContent = string(base.RenderMarkdown([]byte(issue.Content), ctx.Repo.RepoLink))
+ issue.RenderedContent = string(base.RenderMarkdown([]byte(issue.Content), ctx.Repo.RepoLink,
+ ctx.Repo.Repository.ComposeMetas()))
repo := ctx.Repo.Repository
@@ -570,7 +592,8 @@ func ViewIssue(ctx *middleware.Context) {
// Render comments.
for _, comment = range issue.Comments {
if comment.Type == models.COMMENT_TYPE_COMMENT {
- comment.RenderedContent = string(base.RenderMarkdown([]byte(comment.Content), ctx.Repo.RepoLink))
+ comment.RenderedContent = string(base.RenderMarkdown([]byte(comment.Content), ctx.Repo.RepoLink,
+ ctx.Repo.Repository.ComposeMetas()))
// Check tag.
tag, ok = marked[comment.PosterID]
@@ -656,7 +679,7 @@ func UpdateIssueContent(ctx *middleware.Context) {
}
ctx.JSON(200, map[string]interface{}{
- "content": string(base.RenderMarkdown([]byte(issue.Content), ctx.Query("context"))),
+ "content": string(base.RenderMarkdown([]byte(issue.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
})
}
@@ -893,7 +916,7 @@ func UpdateCommentContent(ctx *middleware.Context) {
}
ctx.JSON(200, map[string]interface{}{
- "content": string(base.RenderMarkdown([]byte(comment.Content), ctx.Query("context"))),
+ "content": string(base.RenderMarkdown([]byte(comment.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
})
}
@@ -991,7 +1014,7 @@ func Milestones(ctx *middleware.Context) {
return
}
for _, m := range miles {
- m.RenderedContent = string(base.RenderMarkdown([]byte(m.Content), ctx.Repo.RepoLink))
+ m.RenderedContent = string(base.RenderMarkdown([]byte(m.Content), ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()))
m.CalOpenIssues()
}
ctx.Data["Milestones"] = miles
diff --git a/routers/repo/release.go b/routers/repo/release.go
index 8fc1cb7d37..a3b9887ea1 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -69,7 +69,7 @@ func Releases(ctx *middleware.Context) {
rel.NumCommitsBehind = ctx.Repo.CommitsCount - rel.NumCommits
}
- rel.Note = base.RenderMarkdownString(rel.Note, ctx.Repo.RepoLink)
+ rel.Note = base.RenderMarkdownString(rel.Note, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas())
tags[i] = rel
rels[j] = nil // Mark as used.
break
@@ -129,7 +129,7 @@ func Releases(ctx *middleware.Context) {
rel.NumCommitsBehind = ctx.Repo.CommitsCount - rel.NumCommits
}
- rel.Note = base.RenderMarkdownString(rel.Note, ctx.Repo.RepoLink)
+ rel.Note = base.RenderMarkdownString(rel.Note, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas())
tags = append(tags, rel)
}
models.SortReleases(tags)
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 24ab91eec0..0a219c73bf 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -104,7 +104,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
ctx.Handle(500, "UpdateRepository", err)
return
}
- log.Trace("Repository updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
+ log.Trace("Repository basic settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
if isNameChanged {
if err := models.RenameRepoAction(ctx.User, oldRepoName, repo); err != nil {
@@ -123,7 +123,24 @@ 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.AppSubUrl, ctx.Repo.Owner.Name, repo.Name))
+ ctx.Redirect(ctx.Repo.RepoLink + "/settings")
+
+ case "advanced":
+ repo.EnableWiki = form.EnableWiki
+ repo.EnableIssues = form.EnableIssues
+ repo.EnableExternalTracker = form.EnableExternalTracker
+ repo.ExternalTrackerFormat = form.TrackerURLFormat
+ repo.EnablePulls = form.EnablePulls
+
+ if err := models.UpdateRepository(repo, false); err != nil {
+ ctx.Handle(500, "UpdateRepository", err)
+ return
+ }
+ log.Trace("Repository advanced settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
+
+ ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
+ ctx.Redirect(ctx.Repo.RepoLink + "/settings")
+
case "transfer":
if repo.Name != form.RepoName {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil)
diff --git a/routers/repo/view.go b/routers/repo/view.go
index 877ff4cba0..98b44f42e3 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -108,7 +108,7 @@ func Home(ctx *middleware.Context) {
readmeExist := base.IsMarkdownFile(blob.Name()) || base.IsReadmeFile(blob.Name())
ctx.Data["ReadmeExist"] = readmeExist
if readmeExist {
- ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, path.Dir(treeLink)))
+ ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
} else {
if err, content := template.ToUtf8WithErr(buf); err != nil {
if err != nil {
@@ -201,7 +201,7 @@ func Home(ctx *middleware.Context) {
buf = append(buf, d...)
switch {
case base.IsMarkdownFile(readmeFile.Name()):
- buf = base.RenderMarkdown(buf, treeLink)
+ buf = base.RenderMarkdown(buf, treeLink, ctx.Repo.Repository.ComposeMetas())
default:
buf = bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1)
}
diff --git a/routers/repo/wiki.go b/routers/repo/wiki.go
index 0fdd76d784..5e160518a0 100644
--- a/routers/repo/wiki.go
+++ b/routers/repo/wiki.go
@@ -24,6 +24,12 @@ const (
WIKI_PAGES base.TplName = "repo/wiki/pages"
)
+func MustEnableWiki(ctx *middleware.Context) {
+ if !ctx.Repo.Repository.EnableWiki {
+ ctx.Handle(404, "MustEnableWiki", nil)
+ }
+}
+
type PageMeta struct {
Name string
URL string
@@ -94,7 +100,7 @@ func renderWikiPage(ctx *middleware.Context, isViewPage bool) (*git.Repository,
return nil, ""
}
if isViewPage {
- ctx.Data["content"] = string(base.RenderMarkdown(data, ctx.Repo.RepoLink))
+ ctx.Data["content"] = string(base.RenderMarkdown(data, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()))
} else {
ctx.Data["content"] = string(data)
}