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
$keyto$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_rootand (optional) hostname$host.$hostwill be prepended to all URLs generated by the blog engine, beforebase_urlas defined in the blog'sindex.page. - $blog->get_info()
-
Returns a
Pagecontaining the blog's metadata. - $blog->get_post($path)
-
Returns a specified post from the blog. Format of
$pathshould resemble2009/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 path2009/01/foowould match both2009/01/foo.pageand2009/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$rppposts 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
$rppposts 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
DOMDocumentrepresenting an RSS feed of the latest$countposts.