summaryrefslogtreecommitdiffstats
path: root/routers/repo/issue.go
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/issue.go
parent76d4b9288b60ed6c037257415a570225764ff0a0 (diff)
downloadgitea-e538ff27704cddb1a99efc1a6be19e134f97355f.tar.gz
gitea-e538ff27704cddb1a99efc1a6be19e134f97355f.zip
fix #1829 and fix #890
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r--routers/repo/issue.go33
1 files changed, 28 insertions, 5 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