@@ -19,12 +19,13 @@ import (
19
19
)
20
20
21
21
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"
26
26
)
27
27
28
+ // MustEnableWiki check if wiki is enabled, if external then redirect
28
29
func MustEnableWiki (ctx * context.Context ) {
29
30
if ! ctx .Repo .Repository .EnableWiki {
30
31
ctx .Handle (404 , "MustEnableWiki" , nil )
@@ -37,6 +38,7 @@ func MustEnableWiki(ctx *context.Context) {
37
38
}
38
39
}
39
40
41
+ // PageMeta wiki page meat information
40
42
type PageMeta struct {
41
43
Name string
42
44
URL string
@@ -115,12 +117,13 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, str
115
117
return wikiRepo , pageName
116
118
}
117
119
120
+ // Wiki render wiki page
118
121
func Wiki (ctx * context.Context ) {
119
122
ctx .Data ["PageIsWiki" ] = true
120
123
121
124
if ! ctx .Repo .Repository .HasWiki () {
122
125
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki" )
123
- ctx .HTML (200 , WIKI_START )
126
+ ctx .HTML (200 , tplWikiStart )
124
127
return
125
128
}
126
129
@@ -137,9 +140,10 @@ func Wiki(ctx *context.Context) {
137
140
}
138
141
ctx .Data ["Author" ] = lastCommit .Author
139
142
140
- ctx .HTML (200 , WIKI_VIEW )
143
+ ctx .HTML (200 , tplWikiView )
141
144
}
142
145
146
+ // WikiPages render wiki pages list page
143
147
func WikiPages (ctx * context.Context ) {
144
148
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.pages" )
145
149
ctx .Data ["PageIsWiki" ] = true
@@ -183,9 +187,10 @@ func WikiPages(ctx *context.Context) {
183
187
}
184
188
ctx .Data ["Pages" ] = pages
185
189
186
- ctx .HTML (200 , WIKI_PAGES )
190
+ ctx .HTML (200 , tplWikiPages )
187
191
}
188
192
193
+ // NewWiki render wiki create page
189
194
func NewWiki (ctx * context.Context ) {
190
195
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.new_page" )
191
196
ctx .Data ["PageIsWiki" ] = true
@@ -195,23 +200,24 @@ func NewWiki(ctx *context.Context) {
195
200
ctx .Data ["title" ] = "Home"
196
201
}
197
202
198
- ctx .HTML (200 , WIKI_NEW )
203
+ ctx .HTML (200 , tplWikiNew )
199
204
}
200
205
206
+ // NewWikiPost response fro wiki create request
201
207
func NewWikiPost (ctx * context.Context , form auth.NewWikiForm ) {
202
208
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.new_page" )
203
209
ctx .Data ["PageIsWiki" ] = true
204
210
ctx .Data ["RequireSimpleMDE" ] = true
205
211
206
212
if ctx .HasError () {
207
- ctx .HTML (200 , WIKI_NEW )
213
+ ctx .HTML (200 , tplWikiNew )
208
214
return
209
215
}
210
216
211
217
if err := ctx .Repo .Repository .AddWikiPage (ctx .User , form .Title , form .Content , form .Message ); err != nil {
212
218
if models .IsErrWikiAlreadyExist (err ) {
213
219
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 )
215
221
} else {
216
222
ctx .Handle (500 , "AddWikiPage" , err )
217
223
}
@@ -221,6 +227,7 @@ func NewWikiPost(ctx *context.Context, form auth.NewWikiForm) {
221
227
ctx .Redirect (ctx .Repo .RepoLink + "/wiki/" + models .ToWikiPageURL (form .Title ))
222
228
}
223
229
230
+ // EditWiki render wiki modify page
224
231
func EditWiki (ctx * context.Context ) {
225
232
ctx .Data ["PageIsWiki" ] = true
226
233
ctx .Data ["PageIsWikiEdit" ] = true
@@ -236,16 +243,17 @@ func EditWiki(ctx *context.Context) {
236
243
return
237
244
}
238
245
239
- ctx .HTML (200 , WIKI_NEW )
246
+ ctx .HTML (200 , tplWikiNew )
240
247
}
241
248
249
+ // EditWikiPost response fro wiki modify request
242
250
func EditWikiPost (ctx * context.Context , form auth.NewWikiForm ) {
243
251
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.new_page" )
244
252
ctx .Data ["PageIsWiki" ] = true
245
253
ctx .Data ["RequireSimpleMDE" ] = true
246
254
247
255
if ctx .HasError () {
248
- ctx .HTML (200 , WIKI_NEW )
256
+ ctx .HTML (200 , tplWikiNew )
249
257
return
250
258
}
251
259
@@ -257,6 +265,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
257
265
ctx .Redirect (ctx .Repo .RepoLink + "/wiki/" + models .ToWikiPageURL (form .Title ))
258
266
}
259
267
268
+ // DeleteWikiPagePost delete wiki page
260
269
func DeleteWikiPagePost (ctx * context.Context ) {
261
270
pageURL := ctx .Params (":page" )
262
271
if len (pageURL ) == 0 {
0 commit comments