summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-01-21 20:50:51 +0800
committerGitHub <noreply@github.com>2017-01-21 20:50:51 +0800
commitf8c2903484f0db71b9d2ca29f67a38cb7d738699 (patch)
tree6d70f965eb150fc60b78c2c5d0ee3c01f56cc19a /models
parent369972b1164be38abd6769b79ecc5ad9c73d1b17 (diff)
downloadgitea-f8c2903484f0db71b9d2ca29f67a38cb7d738699.tar.gz
gitea-f8c2903484f0db71b9d2ca29f67a38cb7d738699.zip
fixed bugs on Wiki and resolved #667 (#674)
Diffstat (limited to 'models')
-rw-r--r--models/wiki.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/models/wiki.go b/models/wiki.go
index 1a7ad0e489..43ebc535f3 100644
--- a/models/wiki.go
+++ b/models/wiki.go
@@ -89,7 +89,7 @@ func discardLocalWikiChanges(localPath string) error {
}
// updateWikiPage adds new page to repository wiki.
-func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, message string, isNew bool) (err error) {
+func (repo *Repository) updateWikiPage(doer *User, oldWikiPath, wikiPath, content, message string, isNew bool) (err error) {
wikiWorkingPool.CheckIn(com.ToStr(repo.ID))
defer wikiWorkingPool.CheckOut(com.ToStr(repo.ID))
@@ -104,8 +104,8 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
return fmt.Errorf("UpdateLocalWiki: %v", err)
}
- title = ToWikiPageName(title)
- filename := path.Join(localPath, title+".md")
+ title := ToWikiPageName(wikiPath)
+ filename := path.Join(localPath, wikiPath+".md")
// If not a new file, show perform update not create.
if isNew {
@@ -113,7 +113,7 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
return ErrWikiAlreadyExist{filename}
}
} else {
- file := path.Join(localPath, oldTitle+".md")
+ file := path.Join(localPath, oldWikiPath+".md")
if err := os.Remove(file); err != nil {
return fmt.Errorf("Fail to remove %s: %v", file, err)
@@ -149,19 +149,19 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
return nil
}
-// AddWikiPage adds a new wiki page with a given title.
-func (repo *Repository) AddWikiPage(doer *User, title, content, message string) error {
- return repo.updateWikiPage(doer, "", title, content, message, true)
+// AddWikiPage adds a new wiki page with a given wikiPath.
+func (repo *Repository) AddWikiPage(doer *User, wikiPath, content, message string) error {
+ return repo.updateWikiPage(doer, "", wikiPath, content, message, true)
}
-// EditWikiPage updates a wiki page identified by its title,
-// optionally also changing title.
-func (repo *Repository) EditWikiPage(doer *User, oldTitle, title, content, message string) error {
- return repo.updateWikiPage(doer, oldTitle, title, content, message, false)
+// EditWikiPage updates a wiki page identified by its wikiPath,
+// optionally also changing wikiPath.
+func (repo *Repository) EditWikiPage(doer *User, oldWikiPath, wikiPath, content, message string) error {
+ return repo.updateWikiPage(doer, oldWikiPath, wikiPath, content, message, false)
}
-// DeleteWikiPage deletes a wiki page identified by its title.
-func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error) {
+// DeleteWikiPage deletes a wiki page identified by its wikiPath.
+func (repo *Repository) DeleteWikiPage(doer *User, wikiPath string) (err error) {
wikiWorkingPool.CheckIn(com.ToStr(repo.ID))
defer wikiWorkingPool.CheckOut(com.ToStr(repo.ID))
@@ -172,13 +172,13 @@ func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error) {
return fmt.Errorf("UpdateLocalWiki: %v", err)
}
- title = ToWikiPageName(title)
- filename := path.Join(localPath, title+".md")
+ filename := path.Join(localPath, wikiPath+".md")
if err := os.Remove(filename); err != nil {
return fmt.Errorf("Fail to remove %s: %v", filename, err)
}
+ title := ToWikiPageName(wikiPath)
message := "Delete page '" + title + "'"
if err = git.AddChanges(localPath, true); err != nil {