Skip to content

Commit b2cce12

Browse files
authored
golint fixed for routers/repo/wiki.go (#203)
1 parent f0df8e8 commit b2cce12

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

routers/repo/wiki.go

+21-12
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ import (
1919
)
2020

2121
const (
22-
WIKI_START base.TplName = "repo/wiki/start"
23-
WIKI_VIEW base.TplName = "repo/wiki/view"
24-
WIKI_NEW base.TplName = "repo/wiki/new"
25-
WIKI_PAGES base.TplName = "repo/wiki/pages"
22+
tplWikiStart base.TplName = "repo/wiki/start"
23+
tplWikiView base.TplName = "repo/wiki/view"
24+
tplWikiNew base.TplName = "repo/wiki/new"
25+
tplWikiPages base.TplName = "repo/wiki/pages"
2626
)
2727

28+
// MustEnableWiki check if wiki is enabled, if external then redirect
2829
func MustEnableWiki(ctx *context.Context) {
2930
if !ctx.Repo.Repository.EnableWiki {
3031
ctx.Handle(404, "MustEnableWiki", nil)
@@ -37,6 +38,7 @@ func MustEnableWiki(ctx *context.Context) {
3738
}
3839
}
3940

41+
// PageMeta wiki page meat information
4042
type PageMeta struct {
4143
Name string
4244
URL string
@@ -115,12 +117,13 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, str
115117
return wikiRepo, pageName
116118
}
117119

120+
// Wiki render wiki page
118121
func Wiki(ctx *context.Context) {
119122
ctx.Data["PageIsWiki"] = true
120123

121124
if !ctx.Repo.Repository.HasWiki() {
122125
ctx.Data["Title"] = ctx.Tr("repo.wiki")
123-
ctx.HTML(200, WIKI_START)
126+
ctx.HTML(200, tplWikiStart)
124127
return
125128
}
126129

@@ -137,9 +140,10 @@ func Wiki(ctx *context.Context) {
137140
}
138141
ctx.Data["Author"] = lastCommit.Author
139142

140-
ctx.HTML(200, WIKI_VIEW)
143+
ctx.HTML(200, tplWikiView)
141144
}
142145

146+
// WikiPages render wiki pages list page
143147
func WikiPages(ctx *context.Context) {
144148
ctx.Data["Title"] = ctx.Tr("repo.wiki.pages")
145149
ctx.Data["PageIsWiki"] = true
@@ -183,9 +187,10 @@ func WikiPages(ctx *context.Context) {
183187
}
184188
ctx.Data["Pages"] = pages
185189

186-
ctx.HTML(200, WIKI_PAGES)
190+
ctx.HTML(200, tplWikiPages)
187191
}
188192

193+
// NewWiki render wiki create page
189194
func NewWiki(ctx *context.Context) {
190195
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
191196
ctx.Data["PageIsWiki"] = true
@@ -195,23 +200,24 @@ func NewWiki(ctx *context.Context) {
195200
ctx.Data["title"] = "Home"
196201
}
197202

198-
ctx.HTML(200, WIKI_NEW)
203+
ctx.HTML(200, tplWikiNew)
199204
}
200205

206+
// NewWikiPost response fro wiki create request
201207
func NewWikiPost(ctx *context.Context, form auth.NewWikiForm) {
202208
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
203209
ctx.Data["PageIsWiki"] = true
204210
ctx.Data["RequireSimpleMDE"] = true
205211

206212
if ctx.HasError() {
207-
ctx.HTML(200, WIKI_NEW)
213+
ctx.HTML(200, tplWikiNew)
208214
return
209215
}
210216

211217
if err := ctx.Repo.Repository.AddWikiPage(ctx.User, form.Title, form.Content, form.Message); err != nil {
212218
if models.IsErrWikiAlreadyExist(err) {
213219
ctx.Data["Err_Title"] = true
214-
ctx.RenderWithErr(ctx.Tr("repo.wiki.page_already_exists"), WIKI_NEW, &form)
220+
ctx.RenderWithErr(ctx.Tr("repo.wiki.page_already_exists"), tplWikiNew, &form)
215221
} else {
216222
ctx.Handle(500, "AddWikiPage", err)
217223
}
@@ -221,6 +227,7 @@ func NewWikiPost(ctx *context.Context, form auth.NewWikiForm) {
221227
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.ToWikiPageURL(form.Title))
222228
}
223229

230+
// EditWiki render wiki modify page
224231
func EditWiki(ctx *context.Context) {
225232
ctx.Data["PageIsWiki"] = true
226233
ctx.Data["PageIsWikiEdit"] = true
@@ -236,16 +243,17 @@ func EditWiki(ctx *context.Context) {
236243
return
237244
}
238245

239-
ctx.HTML(200, WIKI_NEW)
246+
ctx.HTML(200, tplWikiNew)
240247
}
241248

249+
// EditWikiPost response fro wiki modify request
242250
func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
243251
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
244252
ctx.Data["PageIsWiki"] = true
245253
ctx.Data["RequireSimpleMDE"] = true
246254

247255
if ctx.HasError() {
248-
ctx.HTML(200, WIKI_NEW)
256+
ctx.HTML(200, tplWikiNew)
249257
return
250258
}
251259

@@ -257,6 +265,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
257265
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.ToWikiPageURL(form.Title))
258266
}
259267

268+
// DeleteWikiPagePost delete wiki page
260269
func DeleteWikiPagePost(ctx *context.Context) {
261270
pageURL := ctx.Params(":page")
262271
if len(pageURL) == 0 {

0 commit comments

Comments
 (0)