Repository navigation
feat: lay out pulled pages as namespace and subpage folders - #14
Merged
Merged
Conversation
Namespaced pages were pulled to flat percent-encoded names such as User%3ACameronBrooks11%2Fwikisync.wiki, which are hard to find and type in an editor. Pages now go to a folder per namespace, with subpages as subfolders: User/CameronBrooks11/wikisync.wiki; main-namespace pages stay at the root. The namespace comes from the ns number the API returns, so a colon in a main-namespace title is not mistaken for one. Titles come from the wiki, so a title with an empty, '.' or '..' segment falls back to a single flat name with its slashes encoded, and no title can yield a path outside the working tree. A page already in the manifest keeps its recorded path. Two pages mapping to the same file are refused by the existing collision check.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Pulled pages are laid out like the wiki: a folder per namespace, subfolders for
subpages, main-namespace pages at the root.
User:CameronBrooks11/wikisyncUser%3ACameronBrooks11%2Fwikisync.wikiUser/CameronBrooks11/wikisync.wikiUser talk:XUser_talk%3AX.wikiUser_talk/X.wikiWelcome to AppropediaWelcome_to_Appropedia.wikinsnumber the API returns with each page, so acolon in a main-namespace title (
Notes: draft) stays part of the name.Appropedia has 34 namespaces, subpages are enabled in the main namespace, and
one namespace name contains a slash (
smw/schema); that becomes a singlefolder,
smw%2Fschema/..or..segment falls back to one flat name with its slashes encoded(
../../etc/passwd→..%2F..%2Fetc%2Fpasswd.wiki). No title can produce apath outside the working tree.
its recorded path when re-pulled.
User:fooand a main-namespace pageUser/foo) are refused by the existing collision check; the first is notoverwritten.
Verification
TestPagePath(main, namespaced, subpage, talk, colon handling, slash in anamespace name,
%) andTestPagePathStaysInsideTheTree(traversal,.,.., empty and leading/trailing segments, a namespace named..; each outputasserted
filepath.IsLocal).status, keeping a recorded path onre-pull, and refusing a layout collision.
ignoring the recorded path, and skipping folder creation each fail their
target test. A
filepath.IsLocalfallback I first added could never triggerafter the segment check, so it is not in this PR.
User:CameronBrooks11/wikisync,User:CameronBrooks11/sandboxandWelcome to Appropedia; files landed atUser/CameronBrooks11/{wikisync,sandbox}.wikiand
Welcome_to_Appropedia.wiki;status,diffandpushpreviewworked on the nested path.
On Windows, reserved device names (
CON,NUL, …) as titles still can't bewritten. That was true of the flat layout too.