@@ -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
+ tplUncycloStart base.TplName = "repo/wiki/start"
23
+ tplUncycloView base.TplName = "repo/wiki/view"
24
+ tplUncycloNew base.TplName = "repo/wiki/new"
25
+ tplUncycloPages base.TplName = "repo/wiki/pages"
26
26
)
27
27
28
+ // MustEnableUncyclo check if wiki is enabled, if external then redirect
28
29
func MustEnableUncyclo (ctx * context.Context ) {
29
30
if ! ctx .Repo .Repository .EnableUncyclo {
30
31
ctx .Handle (404 , "MustEnableUncyclo" , nil )
@@ -37,6 +38,7 @@ func MustEnableUncyclo(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 renderUncycloPage(ctx *context.Context, isViewPage bool) (*git.Repository, str
115
117
return wikiRepo , pageName
116
118
}
117
119
120
+ // Uncyclo render wiki page
118
121
func Uncyclo (ctx * context.Context ) {
119
122
ctx .Data ["PageIsUncyclo" ] = true
120
123
121
124
if ! ctx .Repo .Repository .HasUncyclo () {
122
125
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki" )
123
- ctx .HTML (200 , WIKI_START )
126
+ ctx .HTML (200 , tplUncycloStart )
124
127
return
125
128
}
126
129
@@ -137,9 +140,10 @@ func Uncyclo(ctx *context.Context) {
137
140
}
138
141
ctx .Data ["Author" ] = lastCommit .Author
139
142
140
- ctx .HTML (200 , WIKI_VIEW )
143
+ ctx .HTML (200 , tplUncycloView )
141
144
}
142
145
146
+ // UncycloPages render wiki pages list page
143
147
func UncycloPages (ctx * context.Context ) {
144
148
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.pages" )
145
149
ctx .Data ["PageIsUncyclo" ] = true
@@ -183,9 +187,10 @@ func UncycloPages(ctx *context.Context) {
183
187
}
184
188
ctx .Data ["Pages" ] = pages
185
189
186
- ctx .HTML (200 , WIKI_PAGES )
190
+ ctx .HTML (200 , tplUncycloPages )
187
191
}
188
192
193
+ // NewUncyclo render wiki create page
189
194
func NewUncyclo (ctx * context.Context ) {
190
195
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.new_page" )
191
196
ctx .Data ["PageIsUncyclo" ] = true
@@ -195,23 +200,24 @@ func NewUncyclo(ctx *context.Context) {
195
200
ctx .Data ["title" ] = "Home"
196
201
}
197
202
198
- ctx .HTML (200 , WIKI_NEW )
203
+ ctx .HTML (200 , tplUncycloNew )
199
204
}
200
205
206
+ // NewUncycloPost response fro wiki create request
201
207
func NewUncycloPost (ctx * context.Context , form auth.NewUncycloForm ) {
202
208
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.new_page" )
203
209
ctx .Data ["PageIsUncyclo" ] = true
204
210
ctx .Data ["RequireSimpleMDE" ] = true
205
211
206
212
if ctx .HasError () {
207
- ctx .HTML (200 , WIKI_NEW )
213
+ ctx .HTML (200 , tplUncycloNew )
208
214
return
209
215
}
210
216
211
217
if err := ctx .Repo .Repository .AddUncycloPage (ctx .User , form .Title , form .Content , form .Message ); err != nil {
212
218
if models .IsErrUncycloAlreadyExist (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" ), tplUncycloNew , & form )
215
221
} else {
216
222
ctx .Handle (500 , "AddUncycloPage" , err )
217
223
}
@@ -221,6 +227,7 @@ func NewUncycloPost(ctx *context.Context, form auth.NewUncycloForm) {
221
227
ctx .Redirect (ctx .Repo .RepoLink + "/wiki/" + models .ToUncycloPageURL (form .Title ))
222
228
}
223
229
230
+ // EditUncyclo render wiki modify page
224
231
func EditUncyclo (ctx * context.Context ) {
225
232
ctx .Data ["PageIsUncyclo" ] = true
226
233
ctx .Data ["PageIsUncycloEdit" ] = true
@@ -236,16 +243,17 @@ func EditUncyclo(ctx *context.Context) {
236
243
return
237
244
}
238
245
239
- ctx .HTML (200 , WIKI_NEW )
246
+ ctx .HTML (200 , tplUncycloNew )
240
247
}
241
248
249
+ // EditUncycloPost response fro wiki modify request
242
250
func EditUncycloPost (ctx * context.Context , form auth.NewUncycloForm ) {
243
251
ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.new_page" )
244
252
ctx .Data ["PageIsUncyclo" ] = true
245
253
ctx .Data ["RequireSimpleMDE" ] = true
246
254
247
255
if ctx .HasError () {
248
- ctx .HTML (200 , WIKI_NEW )
256
+ ctx .HTML (200 , tplUncycloNew )
249
257
return
250
258
}
251
259
@@ -257,6 +265,7 @@ func EditUncycloPost(ctx *context.Context, form auth.NewUncycloForm) {
257
265
ctx .Redirect (ctx .Repo .RepoLink + "/wiki/" + models .ToUncycloPageURL (form .Title ))
258
266
}
259
267
268
+ // DeleteUncycloPagePost delete wiki page
260
269
func DeleteUncycloPagePost (ctx * context.Context ) {
261
270
pageURL := ctx .Params (":page" )
262
271
if len (pageURL ) == 0 {
0 commit comments