@@ -177,6 +177,10 @@ func findWikiRepoCommit(ctx *context.Context) (*git.Repository, *git.Commit, err
177
177
// ctx.Handle(500, "OpenRepository", err)
178
178
return nil , nil , err
179
179
}
180
+ if ! wikiRepo .IsBranchExist ("master" ) {
181
+ return wikiRepo , nil , nil
182
+ }
183
+
180
184
commit , err := wikiRepo .GetBranchCommit ("master" )
181
185
if err != nil {
182
186
ctx .Handle (500 , "GetBranchCommit" , err )
@@ -190,6 +194,9 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, *gi
190
194
if err != nil {
191
195
return nil , nil
192
196
}
197
+ if commit == nil {
198
+ return wikiRepo , nil
199
+ }
193
200
194
201
// Get page list.
195
202
if isViewPage {
@@ -210,7 +217,7 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, *gi
210
217
}
211
218
pages = append (pages , PageMeta {
212
219
Name : models .ToWikiPageName (name ),
213
- URL : models . ToWikiPageURL ( name ) ,
220
+ URL : name ,
214
221
})
215
222
}
216
223
}
@@ -308,6 +315,11 @@ func Wiki(ctx *context.Context) {
308
315
if ctx .Written () {
309
316
return
310
317
}
318
+ if entry == nil {
319
+ ctx .Data ["Title" ] = ctx .Tr ("repo.wiki" )
320
+ ctx .HTML (200 , tplWikiStart )
321
+ return
322
+ }
311
323
312
324
ename := entry .Name ()
313
325
if ! markdown .IsMarkdownFile (ename ) {
@@ -362,7 +374,7 @@ func WikiPages(ctx *context.Context) {
362
374
}
363
375
pages = append (pages , PageMeta {
364
376
Name : models .ToWikiPageName (name ),
365
- URL : models . ToWikiPageURL ( name ) ,
377
+ URL : name ,
366
378
Updated : c .Author .When ,
367
379
})
368
380
}
@@ -480,7 +492,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
480
492
return
481
493
}
482
494
483
- oldWikiPath := ctx .Params (":page" )
495
+ oldWikiPath := models . ToWikiPageURL ( ctx .Params (":page" ) )
484
496
newWikiPath := models .ToWikiPageURL (form .Title )
485
497
486
498
if err := ctx .Repo .Repository .EditWikiPage (ctx .User , oldWikiPath , newWikiPath , form .Content , form .Message ); err != nil {
@@ -493,7 +505,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
493
505
494
506
// DeleteWikiPagePost delete wiki page
495
507
func DeleteWikiPagePost (ctx * context.Context ) {
496
- pageURL := ctx .Params (":page" )
508
+ pageURL := models . ToWikiPageURL ( ctx .Params (":page" ) )
497
509
if len (pageURL ) == 0 {
498
510
pageURL = "Home"
499
511
}
0 commit comments