App::Dapper - A publishing tool for static websites.
Version 0.15
Dapper allows you to transform simple text files into static websites. By installing the App::Dapper Perl module, an executable named dapper will be available to you in your terminal window. You can use this executable in a number of ways:
dapper
# Initialize the current directory with a fresh skeleton of a site $ dapper [-solc] init # Build the site $ dapper [-solc] build # Serve the site locally at http://localhost:8000 $ dapper [-solc] serve # Rebuild the site if anything (source, layout dirs; config file) changes $ dapper [-solc] watch # Get help on usage and switches $ dapper -h # Print the version $ dapper -v
Additionally, Dapper may be used as a perl module directly from a script. Examples:
use App::Dapper; # Create a Dapper object my $d = App::Dapper->new(); # Initialize a new website in the current directory $d->init(); # Build the site $d->build(); # Serve the site locally at http://localhost:8000 $d->serve();
Dapper helps you build static websites. To get you started, you can use the dapper init command to initialize a directory. After running this command, the following directory structure will be created:
dapper init
_config.yml _layout/ index.html _source/ index.md
In that same directory, you may then build the site using the dapper build command, which will combine the source files and the layout files and place the results in the output directory (default: _output). After you build the default site, you'll then have the following directory structure:
dapper build
_output
_config.yml _layout/ index.html _source/ index.md _output/ index.html
To see what your website looks like, run the dapper serve command which will spin up a development webserver and serve the static files located in the output directory (default: _output) at http://localhost:8000.
dapper serve
Now, let's walk through each file:
The configuration file is a YAML file that specifies key configuration elements for your static website. The default configuration file is as follows:
--- name : My Site
If you want to use a separate source, layout, or output directory, you may specify it in this file. For instance:
--- name : My Site source : _source layout : _layout output : _output
All of the configurations in this file are available in layout templates, based on the Liquid template system. For instance, name in the configuration file may be used in a template as follows:
name
{{ site.name }}
A sample markdown file is available in the _source directory. Contents:
--- layout: index title: Welcome --- Hello world.
There are a few things to note about this file:
index
_layout/index.html
title
<!-- Example use of "name" in a layout file --> <h1>{{ page.name }}</h1>
Layout files are processed using the Liquid template system. The initial layout file that is given after you run the dapper init command, is this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>{{ page.title }}</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <body> {{ page.content }} </body> </html>
The main content of the text file that is being rendered with this template is available using {{ page.content }}.
{{ page.content }}
Definitions specified in the _config.yml file can be referenced under the "site" namespace (e.g. {{ site.name }}. Definitions specified in the YAML portion of text files can be referenced under the "page" namespace (e.g. {{ page.title }}.
_config.yml
The output file that is created is a mix of the input file and the layout that is specified by the input file. For the default site, the following output file is created:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Welcome</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <body> <p>Hello world.</p> </body> </html>
Dapper provides a number of optional command line switches:
Specify the directory containing source files to process. If this command line option is not present, it defaults to "_source".
Specify the directory to place the output files in. If this command line option is not present, it defaults to "_output".
Specify the directory containing source files to process. If this command line option is not present, it defaults to "_layout".
Get help on available commands and options.
Print the version and exit.
Dapper may be used directly from a script as well. The following methods are available:
Create a new Dapper object. Example:
my $d = App::Dapper->new();
Alternatively, the source dir, output dir, layout dir, and configuration file may be specified. Example:
my $d = App::Dapper->new("_source", "_output", "_layout", "_config.yml");
After creating a Dapper object, the followin hash elements may be accessed:
use App::Dapper; my $d = App::Dapper->new(); print "Source directory: $d->{source}\n"; print "Output directory: $d->{output}\n"; print "Layout directory: $d->{layout}\n"; print "Config file: $d->{config}\n"; print "Object instantiation time: $d->{site}->{time}\n";
Initializes a new skeleton project in the current directory (of the calling script, and uses the defined source dir, output dir, layout dir, and config file. Example usage:
use App::Dapper; my $d = App::Dapper->new(); $d->init();
Build the site. Example:
use App::Dapper; my $d = App::Dapper->new(); $d->build();
When the site is built, it is done in three steps:
1. Parse. In this step, the configuration file is read. In addition, all the source files in the source directory as well as the layout files in the layout directory are reach and stored in the site hash.
2. Transform. Combine source and layout files.
3. Render. Save output files to the output directory.
Mark Benson, <markbenson at vanilladraft.com>
<markbenson at vanilladraft.com>
Please report any bugs or feature requests to bug-text-dapper at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Dapper. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-text-dapper at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc App::Dapper
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Dapper
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/App-Dapper
CPAN Ratings
http://cpanratings.perl.org/d/App-Dapper
Search CPAN
http://search.cpan.org/dist/App-Dapper/
The MIT License (MIT)
Copyright (c) 2002-2014 Mark Benson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
To install App::Dapper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Dapper
CPAN shell
perl -MCPAN -e shell install App::Dapper
For more information on module installation, please visit the detailed CPAN module installation guide.