I'm building riki, my partial ikiwiki clone, from the bottom up. My previous two attempt have been more top down. I'm now thining that for this project at least it makes sense to first build the fundamental building blocks that I know I'll be needing, and do the higher level logic on top of that later.

The first building block is a way to represent page names, and to resolve references from one page to another, within a site. I'm trying to mimick what ikiwiki does, since I'm aiming to be compatible with it.

  • A page is the unit of a site. A site consits of one or more pages.
    • note that I consider "blobs" such as images to each be pages, but they're not parsed as wiki text, and merely get copied to the output directory as-is
  • A "page path name" is the file system pathname to the source file of a page, relative to root of the site source directory.
  • A "page name" is the path from the root of site to a page. It refers to the logial page, not the source file or the generated file.
  • A "link" is a path from one logical page to another.

Examples:

  • a file index.mdwn (page path name) at the root of source tree becomes page / and output file index.html
  • file foo/bar.mdwn becomes page foo/bar and output file foo/bar/index.html
  • if file foo/bar.mdwn links to (refers to) page /bar, it refers to page bar at the root of the site, which corresponds to file bar.mdwn in the source and bar/index.html in the source tree

I like the ikiwiki default of using a directory for each page in the output. In other words, source file foo.mdwn becomes foo/index.html in the output, to represent page foo.

I'm not fond of the .mdwn suffix for markdown files, which ikiwiki has been using for a very long time. I will make riki support it, but will later also support the .md suffix. Initially, I'll stick with the longer suffix only.

I've implemented a Rust type PageName to represent a page name, and RelativePath to represent the path from one page to another. I like to use Rust types to help me keep track of what's what and to help me avoid silly mistakes. These two types are basically slighly camouflaged strings.

More interestingly, I've also implemented a type Pages that represents the complete set of pages in a site. This exists only to allow me to implement the method resolve:

fn resolve(&self, source: &PageName, link: &str) -> Result<PageName, PageNameError>

This returns the name of the page that the link refers to. ikiwiki has a somewhat intricate set of linking rules which this method implements. This will be used in many places: everywhere a page refers to another page on the site. Thus, this is truly a fundamental building block that has to be correct.

The source code module implemetning all of the above is in Git if you want all the dirty details. I expect it to change, but I wanted to at least get the logic for linking rules done and that was easier if it's all in one module.