Skip to content

feat: lay out pulled pages as namespace and subpage folders - #14

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/namespace-folders
Oct 23, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/namespace-folders

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

What

Pulled pages are laid out like the wiki: a folder per namespace, subfolders for
subpages, main-namespace pages at the root.

Page Before Now
User:CameronBrooks11/wikisync User%3ACameronBrooks11%2Fwikisync.wiki User/CameronBrooks11/wikisync.wiki
User talk:X User_talk%3AX.wiki User_talk/X.wiki
Welcome to Appropedia Welcome_to_Appropedia.wiki unchanged
  • The namespace comes from the ns number the API returns with each page, so a
    colon 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 single
    folder, smw%2Fschema/.
  • Titles come from the wiki, so they are checked. A title with an empty,
    . or .. segment falls back to one flat name with its slashes encoded
    (../../etc/passwd → ..%2F..%2Fetc%2Fpasswd.wiki). No title can produce a
    path outside the working tree.
  • Nothing moves under existing users. A page already in the manifest keeps
    its recorded path when re-pulled.
  • Two pages that map to the same file (User:foo and a main-namespace page
    User/foo) are refused by the existing collision check; the first is not
    overwritten.

Verification

  • TestPagePath (main, namespaced, subpage, talk, colon handling, slash in a
    namespace name, %) and TestPagePathStaysInsideTheTree (traversal, .,
    .., empty and leading/trailing segments, a namespace named ..; each output
    asserted filepath.IsLocal).
  • Pull tests for nested writes plus status, keeping a recorded path on
    re-pull, and refusing a layout collision.
  • Breaking each part: dropping the segment check, ignoring the namespace,
    ignoring the recorded path, and skipping folder creation each fail their
    target test. A filepath.IsLocal fallback I first added could never trigger
    after the segment check, so it is not in this PR.
  • Live, read-only against Appropedia with a built binary: pulled
    User:CameronBrooks11/wikisync, User:CameronBrooks11/sandbox and
    Welcome to Appropedia; files landed at User/CameronBrooks11/{wikisync,sandbox}.wiki
    and Welcome_to_Appropedia.wiki; status, diff and push preview
    worked on the nested path.

On Windows, reserved device names (CON, NUL, …) as titles still can't be
written. That was true of the flat layout too.

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.
@CameronBrooks11
CameronBrooks11 merged commit 00554d0 into main Oct 23, 2026
6 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/namespace-folders branch October 23, 2026 13:59
@CameronBrooks11 CameronBrooks11 mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant