mirror of
https://github.com/go-gitea/gitea.git
synced 2025-12-13 14:42:06 +01:00
Integrate DefaultWikiFormat to wiki settings
This commit is contained in:
parent
a4ccf65011
commit
884a1ed5ee
@ -524,9 +524,6 @@ func handleSettingsPostAdvanced(ctx *context.Context) {
|
||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeCode)
|
||||
}
|
||||
|
||||
if form.EnableWiki && form.DefaultWikiFormat {
|
||||
}
|
||||
|
||||
if form.EnableWiki && form.EnableExternalWiki && !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
|
||||
if !validation.IsValidExternalURL(form.ExternalWikiURL) {
|
||||
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))
|
||||
@ -557,6 +554,18 @@ func handleSettingsPostAdvanced(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// Update DefaultWikiFormat if wiki is enabled
|
||||
if form.EnableWiki && !form.EnableExternalWiki {
|
||||
defaultWikiFormat := form.DefaultWikiFormat
|
||||
if defaultWikiFormat == "" {
|
||||
defaultWikiFormat = setting.Repository.DefaultWikiFormat
|
||||
}
|
||||
if repo.DefaultWikiFormat != defaultWikiFormat {
|
||||
repo.DefaultWikiFormat = defaultWikiFormat
|
||||
repoChanged = true
|
||||
}
|
||||
}
|
||||
|
||||
if form.EnableIssues && form.EnableExternalTracker && !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
|
||||
if !validation.IsValidExternalURL(form.ExternalTrackerURL) {
|
||||
ctx.Flash.Error(ctx.Tr("repo.settings.external_tracker_url_error"))
|
||||
|
||||
@ -215,12 +215,31 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
|
||||
ctx.ServerError("ListEntries", err)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Get default wiki format from repository, using global setting as fallback
|
||||
defaultWikiFormat := ctx.Repo.Repository.DefaultWikiFormat
|
||||
if defaultWikiFormat == "" {
|
||||
defaultWikiFormat = setting.Repository.DefaultWikiFormat
|
||||
}
|
||||
|
||||
pages := make([]PageMeta, 0, len(entries))
|
||||
for _, entry := range entries {
|
||||
if !entry.IsRegular() {
|
||||
continue
|
||||
}
|
||||
wikiName, err := wiki_service.GitPathToWebPath(entry.Name())
|
||||
entryName := entry.Name()
|
||||
|
||||
// Filter by DefaultWikiFormat
|
||||
hasMdSuffix := strings.HasSuffix(entryName, ".md")
|
||||
hasOrgSuffix := strings.HasSuffix(entryName, ".org")
|
||||
if defaultWikiFormat == "markdown" && hasOrgSuffix {
|
||||
continue
|
||||
}
|
||||
if defaultWikiFormat == "org" && hasMdSuffix {
|
||||
continue
|
||||
}
|
||||
|
||||
wikiName, err := wiki_service.GitPathToWebPath(entryName)
|
||||
if err != nil {
|
||||
if repo_model.IsErrWikiInvalidFileName(err) {
|
||||
continue
|
||||
@ -234,7 +253,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
|
||||
pages = append(pages, PageMeta{
|
||||
Name: displayName,
|
||||
SubURL: wiki_service.WebPathToURLPath(wikiName),
|
||||
GitEntryName: entry.Name(),
|
||||
GitEntryName: entryName,
|
||||
})
|
||||
}
|
||||
ctx.Data["Pages"] = pages
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user