Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to have wiki pages in sub-folder? #16456

Closed
Tony2 opened this issue Jul 16, 2021 · 2 comments
Closed

Is it possible to have wiki pages in sub-folder? #16456

Tony2 opened this issue Jul 16, 2021 · 2 comments
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@Tony2
Copy link

Tony2 commented Jul 16, 2021

Hi,

I put wiki pages in a folder hierarchy, but gitea wiki doesn't seem to show them, I can see only the pages at the same level as the Home page. Is it possible at all?

@noerw noerw added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label Jul 16, 2021
@noerw
Copy link
Member

noerw commented Jul 16, 2021

Hi! No, this is currently not supported.

The following badly tested patch enables listing and viewing files in subdirs. But it's a hacky solution and a good implementation would clean up the tree-entry code paths for the wiki entirely. Feel free to further work on this :)

diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go
index 5271fe9b4..539f43619 100644
--- a/routers/web/repo/wiki.go
+++ b/routers/web/repo/wiki.go
@@ -142,7 +142,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
 	}
 
 	// Get page list.
-	entries, err := commit.ListEntries()
+	entries, err := commit.ListEntriesRecursive()
 	if err != nil {
 		if wikiRepo != nil {
 			wikiRepo.Close()
@@ -151,6 +151,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
 		return nil, nil
 	}
 	pages := make([]PageMeta, 0, len(entries))
+	var wikiEntry *git.TreeEntry
 	for _, entry := range entries {
 		if !entry.IsRegular() {
 			continue
@@ -168,6 +169,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
 		} else if wikiName == "_Sidebar" || wikiName == "_Footer" {
 			continue
 		}
+		wikiEntry = entry
 		pages = append(pages, PageMeta{
 			Name:   wikiName,
 			SubURL: wiki_service.NameToSubURL(wikiName),
@@ -188,6 +190,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
 
 	//lookup filename in wiki - get filecontent, gitTree entry , real filename
 	data, entry, pageFilename, noEntry := wikiContentsByName(ctx, commit, pageName)
+	entry = wikiEntry // HACK: the entry returned by wikiContentsByName does not include the full path to the file, but the wikiEntry we got above does. ideally don't do a duplicate entry look up in the first place!
 	if noEntry {
 		ctx.Redirect(ctx.Repo.RepoLink + "/wiki/_pages")
 	}
@@ -473,7 +476,7 @@ func WikiPages(ctx *context.Context) {
 		return
 	}
 
-	entries, err := commit.ListEntries()
+	entries, err := commit.ListEntriesRecursive()
 	if err != nil {
 		if wikiRepo != nil {
 			wikiRepo.Close()

@a1012112796
Copy link
Member

see #7390

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

No branches or pull requests

4 participants