static-ish - plain-text content & blogging engine for PHP

API

Page

Page::load($path)
Loads a page from $path, returning the page object
$page->__get($key)
Returns page metadata item (as defined by the YAML preamable) identified by $key
$page->__set($key, $val)
Sets page metadata item identified by $key to $value
$page->block_html($options = array())
Returns HTML representation of page's blocks, concatenated into a single string
foreach ($page as $block)
Iterates over each page block

Blog

static-ish's Blog class is a wrapper around a directory structure arranged according to a simple convention, permitting content to be accessed and queried as a blog.

Example static-ish blog directory structure:
BLOG_ROOT
  |
  |- index.page # Blog metadata contained in YAML preamble
  |
  |- 2008
  |  |- 01
  |  |  |- 12-this-is-a-post.page
  |  |  |- another-post.page
  |  |
  |  |- 05
  |  |- 10
  |  |- 23
  |
  |- 2009
     |- 05
     |- 07
        |- 15-last-post.page

Note: leading zeroes for months are required.

At the very least, index.page should define base_url, the URL prefix for all blog posts (a post's full URL can be retrieved using $post->url). Additionally, if present, the keys title, description, language and copyright will be inserted into the RSS feed.

new Blog($blog_root, $host = '')
Creates a new Blog instance, with content root $blog_root and (optional) hostname $host. $host will be prepended to all URLs generated by the blog engine, before base_url as defined in the blog's index.page.
$blog->get_info()
Returns a Page containing the blog's metadata.
$blog->get_post($path)
Returns a specified post from the blog. Format of $path should resemble 2009/01/foo-bar-baz, or more formally, match the regex |^\d{4}/\d{2}/[a-z0-9\._-]+$|i. When searching for a matching file, the engine will ignore any numeric prefix on the page's name. For example, post path 2009/01/foo would match both 2009/01/foo.page and 2009/01/20-foo.page. This allows you to organise monthly folders chronologically without causing the day numbers to appear in URLs.
$blog->get_page($page, $rpp)
Returns the $pageth page of posts based on $rpp posts per page.
$blog->get_monthly_archive_counts()
Returns an array mapping month (expressed as Unix timestamp) => number of posts.
$blog->get_post_count()
Returns the total number of posts in the blog.
$blog->get_page_count($rpp)
Returns the total number of pages in the blog, based on $rpp posts per page.
$blog->get_monthly_archive($unix_timestamp)
Returns an array of posts for the given month, expressed as a Unix timestamp.
$blog->get_monthly_archive($year, $month)
Returns an array of posts for the given year and month.
$blog->get_feed($count)
Returns a DOMDocument representing an RSS feed of the latest $count posts.