Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement .org file rendering in Wiki#36018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
LinlyBoi wants to merge19 commits intogo-gitea:main
base:main
Choose a base branch
Loading
fromLinlyBoi:main
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
19 commits
Select commitHold shift + click to select a range
30254b9
Detect markup rendering from filename
Nov 24, 2025
cb93344
Detect .org files if .md isn't found in wiki
Nov 24, 2025
cb38c04
Handle .org files in Sidebar and footer of wiki
Nov 24, 2025
51b7680
Detect markup type instead of defaulting to .md
Nov 24, 2025
3931b8f
Add .org file detection to WikiRaw function
Nov 24, 2025
36c23b8
Add .org condition to escapeSegToWeb
Nov 24, 2025
3ae4823
Add org file path resolution for Web and Git paths
Nov 24, 2025
676a785
add .org to WebPathToUserTitle
Nov 24, 2025
83353a8
Add .org to Git path preparation
Nov 24, 2025
e2812ca
Resolve linting issues
Nov 24, 2025
3268f6f
Merge branch 'go-gitea:main' into main
LinlyBoiNov 25, 2025
997ce9f
Add default wiki format setting value to struct
Nov 26, 2025
f0c005b
Add DefaultWikiFormat var and its checks
Nov 26, 2025
a4ccf65
use config option for default wiki format paths
Nov 26, 2025
884a1ed
Integrate DefaultWikiFormat to wiki settings
Nov 27, 2025
535a377
check wiki entry names based on DefaultWikiFormat
Nov 27, 2025
914926f
Add wiki format setting to option tmpl and locales
Nov 27, 2025
4778511
Include defaultWikiFormat in WebPathToGitPath
Nov 27, 2025
1707118
Merge container registry fix to fork
Nov 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
check wiki entry names based on DefaultWikiFormat
  • Loading branch information
Aly Sewelam committedNov 27, 2025
commit535a3772d862b35bf0744e424972f7ccf753244a
2 changes: 0 additions & 2 deletionsrouters/api/v1/repo/wiki.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,8 +8,6 @@ import (
"fmt"
"net/http"
"net/url"
"strings"

repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"
Expand Down
115 changes: 88 additions & 27 deletionsrouters/web/repo/wiki.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,26 +153,50 @@ func wikiEntryByName(ctx *context.Context, commit *git.Commit, wikiName wiki_ser
return nil, "", false, false
}
if entry == nil {
// If .md file not found, try .org file
if base, ok := strings.CutSuffix(gitFilename, ".md"); ok {
orgFilename := base + ".org"
entry, err = findEntryForFile(commit, orgFilename)
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("findEntryForFile", err)
return nil, "", false, false
// Get default wiki format from repository, using global setting as fallback
defaultWikiFormat := ctx.Repo.Repository.DefaultWikiFormat
if defaultWikiFormat == "" {
defaultWikiFormat = setting.Repository.DefaultWikiFormat
}

// Check if gitFilename already has .md or .org extension and extract base filename
baseFilename, hasMdSuffix := strings.CutSuffix(gitFilename, ".md")
var hasOrgSuffix bool
if !hasMdSuffix {
baseFilename, hasOrgSuffix = strings.CutSuffix(gitFilename, ".org")
if !hasOrgSuffix {
baseFilename = gitFilename
}
if entry != nil {
gitFilename = orgFilename
}

// Try alternative formats based on DefaultWikiFormat setting
if defaultWikiFormat == "markdown" || defaultWikiFormat == "both" {
if !hasMdSuffix && !hasOrgSuffix {
entry, err = findEntryForFile(commit, baseFilename+".md")
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("findEntryForFile", err)
return nil, "", false, false
}
if entry != nil {
gitFilename = baseFilename + ".md"
}
}
}
// If still not found, check if the file without extension exists (for raw files)
if entry == nil {
baseFilename := gitFilename
if base, ok := strings.CutSuffix(baseFilename, ".md"); ok {
baseFilename = base
} else if base, ok := strings.CutSuffix(baseFilename, ".org"); ok {
baseFilename = base

if entry == nil && (defaultWikiFormat == "org" || defaultWikiFormat == "both") {
if !hasMdSuffix && !hasOrgSuffix {
entry, err = findEntryForFile(commit, baseFilename+".org")
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("findEntryForFile", err)
return nil, "", false, false
}
if entry != nil {
gitFilename = baseFilename + ".org"
}
}
}

if entry == nil {
entry, err = findEntryForFile(commit, baseFilename)
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("findEntryForFile", err)
Expand DownExpand Up@@ -638,12 +662,30 @@ func WikiPages(ctx *context.Context) {
return
}

// 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.Entry.IsRegular() {
continue
}
wikiName, err := wiki_service.GitPathToWebPath(entry.Entry.Name())
entryName := entry.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
Expand All@@ -655,7 +697,7 @@ func WikiPages(ctx *context.Context) {
pages = append(pages, PageMeta{
Name: displayName,
SubURL: wiki_service.WebPathToURLPath(wikiName),
GitEntryName:entry.Entry.Name(),
GitEntryName:entryName,
UpdatedUnix: timeutil.TimeStamp(entry.Commit.Author.When.Unix()),
})
}
Expand DownExpand Up@@ -688,17 +730,36 @@ func WikiRaw(ctx *context.Context) {
}

if entry == nil {
// Try to find a wiki page with that name (check both .md and .org)
providedGitPath := strings.TrimSuffix(providedGitPath, ".md")
// Try .org version
orgPath := providedGitPath + ".org"
entry, err = findEntryForFile(commit, orgPath)
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("findFile", err)
return
// Get default wiki format from repository, using global setting as fallback
defaultWikiFormat := ctx.Repo.Repository.DefaultWikiFormat
if defaultWikiFormat == "" {
defaultWikiFormat = setting.Repository.DefaultWikiFormat
}

// Try to find a wiki page with that name based on DefaultWikiFormat
basePath, _ := strings.CutSuffix(providedGitPath, ".md")
if basePath == providedGitPath {
basePath, _ = strings.CutSuffix(providedGitPath, ".org")
}

if defaultWikiFormat == "markdown" || defaultWikiFormat == "both" {
entry, err = findEntryForFile(commit, basePath+".md")
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("findFile", err)
return
}
}

if entry == nil && (defaultWikiFormat == "org" || defaultWikiFormat == "both") {
entry, err = findEntryForFile(commit, basePath+".org")
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("findFile", err)
return
}
}

if entry == nil {
entry, err = findEntryForFile(commit,providedGitPath)
entry, err = findEntryForFile(commit,basePath)
if err != nil && !git.IsErrNotExist(err) {
ctx.ServerError("findFile", err)
return
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp