1. David Chambers
  2. Mango

Wiki

Clone wiki

Mango / Conventions

Conventions

In trade-offs between simplicity and flexibility, Mango tends to favour the latter at the expense of the former. Mango was conceived by a developer keen to exchange one-size-pretty-much-fits-all-with-a-bit-of-hackery WordPress for something simpler. Blogging, after all, should be about writing posts, not dealing with the complexities of a CMS.

File naming

Mango enforces several conventions. The most important is that of file naming. File names are used by Mango as slugs. Take this posts directory, for example:

  • my-first-post.text
  • my-second-post.text
  • my-third-post.text

Three URLs will be "active" in this case:

This simple mapping between file names and URLs ensures that a database table is not required.

Note that files in the posts directory do not require a particular extension – in fact, they don't require an extension at all.

Short URLs

Mango accommodates short URLs thanks to a simple naming convention: (alias)=>(slug).text

For example:

  • 1=>my-first-post.text
  • 2=>my-second-post.text
  • 3=>my-third-post.text

Six URLs will be "active" in this case:

(For those with an interest in SEO, 302 redirects are used to redirect the browser from the short URLs to the full equivalents.)

There's no requirement that a post's alias must be a numeric index; any text will do. This means that it's possible to do the following:

alias=>my-really-really-really-long-url.text

http://mysite.com/my-really-really-really-long-url/
http://mysite.com/alias/ => http://mysite.com/my-really-really-really-long-url/

Zero padding

Mango accommodates zero padding of aliases (for those running operating systems that think that 10 comes before 2). For example:

  • 01=>my-first-post.text
  • 02=>my-second-post.text
  • 03=>my-third-post.text

Crucially, /1/ will map to /my-first-post/ but /01/ will not.

There's no limit on the number of zeroes that may precede an alias: 000001=>my-first-post.text will still be accessible via /my-first-post/ and /1/ only.

Word of caution

When using aliases be aware that there's nothing in place to ensure the uniqueness of either the alias or the slug: files named 1=>apples.text and 1=>oranges.text may both reside happily in the same directory. Mango handles such conflicts gracefully by displaying the content of the first file matched.

Updated