@@ -58,10 +58,10 @@ func NewWikiPage(ctx *context.APIContext) {
58
58
return
59
59
}
60
60
61
- wikiName := wiki_service .NormalizeWikiName ( form .Title )
61
+ wikiName := wiki_service .UserTitleToWebPath ( "" , form .Title )
62
62
63
63
if len (form .Message ) == 0 {
64
- form .Message = fmt .Sprintf ("Add '%s' " , form .Title )
64
+ form .Message = fmt .Sprintf ("Add %q " , form .Title )
65
65
}
66
66
67
67
content , err := base64 .StdEncoding .DecodeString (form .ContentBase64 )
@@ -85,7 +85,7 @@ func NewWikiPage(ctx *context.APIContext) {
85
85
wikiPage := getWikiPage (ctx , wikiName )
86
86
87
87
if ! ctx .Written () {
88
- notification .NotifyNewWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , wikiName , form .Message )
88
+ notification .NotifyNewWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , string ( wikiName ) , form .Message )
89
89
ctx .JSON (http .StatusCreated , wikiPage )
90
90
}
91
91
}
@@ -127,15 +127,15 @@ func EditWikiPage(ctx *context.APIContext) {
127
127
128
128
form := web .GetForm (ctx ).(* api.CreateWikiPageOptions )
129
129
130
- oldWikiName := wiki_service .NormalizeWikiName (ctx .Params (":pageName" ))
131
- newWikiName := wiki_service .NormalizeWikiName ( form .Title )
130
+ oldWikiName := wiki_service .WebPathFromRequest (ctx .Params (":pageName" ))
131
+ newWikiName := wiki_service .UserTitleToWebPath ( "" , form .Title )
132
132
133
133
if len (newWikiName ) == 0 {
134
134
newWikiName = oldWikiName
135
135
}
136
136
137
137
if len (form .Message ) == 0 {
138
- form .Message = fmt .Sprintf ("Update '%s' " , newWikiName )
138
+ form .Message = fmt .Sprintf ("Update %q " , newWikiName )
139
139
}
140
140
141
141
content , err := base64 .StdEncoding .DecodeString (form .ContentBase64 )
@@ -153,14 +153,12 @@ func EditWikiPage(ctx *context.APIContext) {
153
153
wikiPage := getWikiPage (ctx , newWikiName )
154
154
155
155
if ! ctx .Written () {
156
- notification .NotifyEditWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , newWikiName , form .Message )
156
+ notification .NotifyEditWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , string ( newWikiName ) , form .Message )
157
157
ctx .JSON (http .StatusOK , wikiPage )
158
158
}
159
159
}
160
160
161
- func getWikiPage (ctx * context.APIContext , title string ) * api.WikiPage {
162
- title = wiki_service .NormalizeWikiName (title )
163
-
161
+ func getWikiPage (ctx * context.APIContext , wikiName wiki_service.WebPath ) * api.WikiPage {
164
162
wikiRepo , commit := findWikiRepoCommit (ctx )
165
163
if wikiRepo != nil {
166
164
defer wikiRepo .Close ()
@@ -170,7 +168,7 @@ func getWikiPage(ctx *context.APIContext, title string) *api.WikiPage {
170
168
}
171
169
172
170
// lookup filename in wiki - get filecontent, real filename
173
- content , pageFilename := wikiContentsByName (ctx , commit , title , false )
171
+ content , pageFilename := wikiContentsByName (ctx , commit , wikiName , false )
174
172
if ctx .Written () {
175
173
return nil
176
174
}
@@ -196,7 +194,7 @@ func getWikiPage(ctx *context.APIContext, title string) *api.WikiPage {
196
194
}
197
195
198
196
return & api.WikiPage {
199
- WikiPageMetaData : convert .ToWikiPageMetaData (title , lastCommit , ctx .Repo .Repository ),
197
+ WikiPageMetaData : convert .ToWikiPageMetaData (wikiName , lastCommit , ctx .Repo .Repository ),
200
198
ContentBase64 : content ,
201
199
CommitCount : commitsCount ,
202
200
Sidebar : sidebarContent ,
@@ -233,7 +231,7 @@ func DeleteWikiPage(ctx *context.APIContext) {
233
231
// "404":
234
232
// "$ref": "#/responses/notFound"
235
233
236
- wikiName := wiki_service .NormalizeWikiName (ctx .Params (":pageName" ))
234
+ wikiName := wiki_service .WebPathFromRequest (ctx .Params (":pageName" ))
237
235
238
236
if err := wiki_service .DeleteWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , wikiName ); err != nil {
239
237
if err .Error () == "file does not exist" {
@@ -244,7 +242,7 @@ func DeleteWikiPage(ctx *context.APIContext) {
244
242
return
245
243
}
246
244
247
- notification .NotifyDeleteWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , wikiName )
245
+ notification .NotifyDeleteWikiPage (ctx , ctx .Doer , ctx .Repo .Repository , string ( wikiName ) )
248
246
249
247
ctx .Status (http .StatusNoContent )
250
248
}
@@ -316,7 +314,7 @@ func ListWikiPages(ctx *context.APIContext) {
316
314
ctx .Error (http .StatusInternalServerError , "GetCommit" , err )
317
315
return
318
316
}
319
- wikiName , err := wiki_service .FilenameToName (entry .Name ())
317
+ wikiName , err := wiki_service .GitPathToWebPath (entry .Name ())
320
318
if err != nil {
321
319
if repo_model .IsErrWikiInvalidFileName (err ) {
322
320
continue
@@ -361,7 +359,7 @@ func GetWikiPage(ctx *context.APIContext) {
361
359
// "$ref": "#/responses/notFound"
362
360
363
361
// get requested pagename
364
- pageName := wiki_service .NormalizeWikiName (ctx .Params (":pageName" ))
362
+ pageName := wiki_service .WebPathFromRequest (ctx .Params (":pageName" ))
365
363
366
364
wikiPage := getWikiPage (ctx , pageName )
367
365
if ! ctx .Written () {
@@ -411,7 +409,7 @@ func ListPageRevisions(ctx *context.APIContext) {
411
409
}
412
410
413
411
// get requested pagename
414
- pageName := wiki_service .NormalizeWikiName (ctx .Params (":pageName" ))
412
+ pageName := wiki_service .WebPathFromRequest (ctx .Params (":pageName" ))
415
413
if len (pageName ) == 0 {
416
414
pageName = "Home"
417
415
}
@@ -502,9 +500,9 @@ func wikiContentsByEntry(ctx *context.APIContext, entry *git.TreeEntry) string {
502
500
503
501
// wikiContentsByName returns the contents of a wiki page, along with a boolean
504
502
// indicating whether the page exists. Writes to ctx if an error occurs.
505
- func wikiContentsByName (ctx * context.APIContext , commit * git.Commit , wikiName string , isSidebarOrFooter bool ) (string , string ) {
506
- pageFilename := wiki_service .NameToFilename (wikiName )
507
- entry , err := findEntryForFile (commit , pageFilename )
503
+ func wikiContentsByName (ctx * context.APIContext , commit * git.Commit , wikiName wiki_service. WebPath , isSidebarOrFooter bool ) (string , string ) {
504
+ gitFilename := wiki_service .WebPathToGitPath (wikiName )
505
+ entry , err := findEntryForFile (commit , gitFilename )
508
506
if err != nil {
509
507
if git .IsErrNotExist (err ) {
510
508
if ! isSidebarOrFooter {
@@ -515,5 +513,5 @@ func wikiContentsByName(ctx *context.APIContext, commit *git.Commit, wikiName st
515
513
}
516
514
return "" , ""
517
515
}
518
- return wikiContentsByEntry (ctx , entry ), pageFilename
516
+ return wikiContentsByEntry (ctx , entry ), gitFilename
519
517
}
0 commit comments