mirror of
https://github.com/gogs/gogs.git
synced 2025-12-22 16:20:14 +01:00
api: EditWiki implementation (#5860)
Co-authored-by: Joe Chen <jc@unknwon.io>
This commit is contained in:
@@ -89,7 +89,7 @@ func dumpTable(db *gorm.DB, table interface{}, w io.Writer) error {
|
|||||||
return errors.Wrap(err, "encode JSON")
|
return errors.Wrap(err, "encode JSON")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpLegacyTables(dirPath string, verbose bool) error {
|
func dumpLegacyTables(dirPath string, verbose bool) error {
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||||||
}, reqRepoWriter())
|
}, reqRepoWriter())
|
||||||
|
|
||||||
m.Patch("/issue-tracker", reqRepoWriter(), bind(api.EditIssueTrackerOption{}), repo.IssueTracker)
|
m.Patch("/issue-tracker", reqRepoWriter(), bind(api.EditIssueTrackerOption{}), repo.IssueTracker)
|
||||||
|
m.Patch("/wiki", reqRepoWriter(), bind(api.EditWikiOption{}), repo.Wiki)
|
||||||
m.Post("/mirror-sync", reqRepoWriter(), repo.MirrorSync)
|
m.Post("/mirror-sync", reqRepoWriter(), repo.MirrorSync)
|
||||||
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
|
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
|
||||||
}, repoAssignment())
|
}, repoAssignment())
|
||||||
|
|||||||
@@ -390,6 +390,32 @@ func IssueTracker(c *context.APIContext, form api.EditIssueTrackerOption) {
|
|||||||
c.NoContent()
|
c.NoContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Wiki(c *context.APIContext, form api.EditWikiOption) {
|
||||||
|
_, repo := parseOwnerAndRepo(c)
|
||||||
|
if c.Written() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if form.AllowPublicWiki != nil {
|
||||||
|
repo.AllowPublicWiki = *form.AllowPublicWiki
|
||||||
|
}
|
||||||
|
if form.EnableExternalWiki != nil {
|
||||||
|
repo.EnableExternalWiki = *form.EnableExternalWiki
|
||||||
|
}
|
||||||
|
if form.EnableWiki != nil {
|
||||||
|
repo.EnableWiki = *form.EnableWiki
|
||||||
|
}
|
||||||
|
if form.ExternalWikiURL != nil {
|
||||||
|
repo.ExternalWikiURL = *form.ExternalWikiURL
|
||||||
|
}
|
||||||
|
if err := db.UpdateRepository(repo, false); err != nil {
|
||||||
|
c.Error(err, "update repository")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.NoContent()
|
||||||
|
}
|
||||||
|
|
||||||
func MirrorSync(c *context.APIContext) {
|
func MirrorSync(c *context.APIContext) {
|
||||||
_, repo := parseOwnerAndRepo(c)
|
_, repo := parseOwnerAndRepo(c)
|
||||||
if c.Written() {
|
if c.Written() {
|
||||||
|
|||||||
Reference in New Issue
Block a user