Skip to content

edvanbeinum/snowshoe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snowshoe

A static site generator written in PHP

Installation

Get the source files from our friends over at Github

$ git clone [email protected]:edvanbeinum/snowshoe.git

You'll also need grab the submodules too, as we make sue of a few third party libraries:

$ cd snowshoe
$ git submodules init
$ git submodules update

There you go. To generate the site, from the snowshoe directory

$ php bin/snowshoe

Then have a look in public/ folder to see this site in all its glorious HTML.

Folders

The pertinent folders you need to know about are

  • /assets/content - raw Markdown files that are the main content for the site. Filenames and folders will be replicated in the published site.
  • /assets/layout - the layout file, using the templating engine (Twig by default) basically the second step in the two-step view process
  • /public where to final site is saved to

Configuration

Currently the application config is done through Snowshoe/Config/App.php class. That will probably be moved out into a JSON/YAML config file later. For now, these are the parameters

is_production_mode
In production mode, URLs will have the publish_location value prepended to them. Otherwise they will have the public_directory. You can switch to production mode by using the -p flag on the command line
site_name
The name of the site - used for page title. It will appear after the page title in the browser window e.g: About | Site Name
formatter
Name of the Format type that the content is written in. Ships with Markdown or Textile
formatter_file_extension
File extension of the content files
template_engine
Name of the Template Engine. Ships with Twig or Mustache
public_file_extension
This is the file extension that wil be used on the public site
content_directory
Path, relative to Snowshoe's root folder, where the content files live
template_path
Path, relative to Snowshoe's root folder, where the template layout file lives
public_directory
Path, relative to Snowshoe's root folder, where the finished files will be written to
publish_location
The URL of the live site where the files in the publish directory will be available at. This can be an absolute filepath too. This location will be prepended to links in the navigation and will only be used with -p flag
navigation_sort_criteria
What criteria should the navigation be sorted on? date | alpha
navigation_sort_direction
What direction should the navigation be sorted on? asc | desc

Production Mode

You the '-p' flag to run Snowshoe in production mode

$ php bin/snowshoe -p

That will make the URLs on the navigation use the 'publish_location' path rather than the local path. The site is then ready for publishing.

Extending Snowshoe

You can add your own text formatter or template engine. Snowshoe makes use of the Adapter pattern so if you want to use, let's say Mustache as the templating engine, copy the Mustache PHP library into the Vendor folder. Then create a class called Mustache in the TemplateEngine/Adapter folder and make sure it extends the AAdapter bse class. This will give you an execute method that you can then implement. In the case of mustache, you would include the PHP lib, instantiate the Mustache class and call render() on it, passing though the template string and the variables. I would suggest it would look something like this:

namespace Snowshoe\TemplateEngine\Adapter;

/**
 * Mustache TemplateEngine Adapter. This class knows how to interact with the Mustache library
 *
 * @package Snowshoe
 * @author Ed van Beinum <[email protected]>
 */
class Mustache extends \Snowshoe\TemplateEngine\AAdapter
{

    public function __construct()
    {
        require_once APPLICATION_PATH . 'Snowshoe/Vendor/TemplateEngines/Mustache/Mustache.php';
        $this->_templateEngine = new \Mustache;
    }

    /**
     * Takes a templated string and the variables to be injected and returns the result
     *
     * @param string $templateString
     * @param array $templateVars
     * @return string
     */
    public function execute($templateString, array $templateVars = array())
    {
        return $this->_templateEngine->render($templateString, $templateVars);
    }
}

Then to tell Snowshoe to use the Mustache Adapter, in Snowshoe\Config\App set the 'template_engine' => 'Mustache'

About

A (nother) static site generator in PHP

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages