App-WRT
view release on metacpan or search on metacpan
lib/App/WRT.pm view on Meta::CPAN
<p>The title is <em>${title}</em>.</p>
This is likely to change at some point, so don't build anything too elaborate
on it.
Embedded code and variables are intended only for use in the F<template> file,
where it's handy to drop in titles or conditionalize aspects of a layout. You
want to be careful with this sort of thing - it's useful in small doses, but
it's also a maintainability nightmare waiting to happen.
B<Includes> - replaced by the contents of the enclosed file path, from the
root of the current wrt project:
<include>path/to/file</include>
This is a bit constraining, since it doesn't currently allow for files outside
of the current project, but is useful for including HTML generated by some
external script in a page.
B<Several forms of lightweight markup>:
<markdown>John Gruber's Markdown, by way of
Text::Markdown::Discount</markdown>
<textile>Dean Allen's Textile, via Brad Choate's
Text::Textile.</textile>
<freeverse>An easy way to
get properly broken lines
plus -- em dashes --
for poetry and such.</freeverse>
B<And a couple of shortcuts>:
<image>filename.ext
alt text, if any</image>
<list>
one list item
another list item
</list>
As it stands, freeverse, image, and list are not particularly robust. In
practice, image and list have not proven all that useful, and may be deprecated
in a future release.
=head2 TEMPLATES
A single template, specified by the C<template_dir> and C<template> config
values, is used to render all pages. See F<example/templates/basic> for an
example, or run C<wrt init> in an empty directory and look at
F<templates/default>.
Here's a short example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${title_prefix} - ${title}</title>
</head>
<body>
${content}
</body>
</html>
Within templates, C<${foo}> will be replaced with the corresponding
configuration value. C<${content}> will always be set to the content of the
current entry.
=head2 CONFIGURATION
Configuration is read from a F<wrt.json> in the directory where the C<wrt>
utility is invoked, or can (usually) be specified with the C<--config> option.
See F<example/wrt.json> for a sample configuration.
Under the hood, configuration is done by combining a hash called C<%default>
with values pulled out of the JSON file. Most defaults can be overwritten
from the config file, but changing some would require writing Perl, since
they contain things like subroutine references.
=cut
=over
=item %default
Here's a verbatim copy of C<%default>, with some commentary about values.
my %default = (
root_dir => '.', # dir for wrt repository
entry_dir => 'archives', # dir for entry files
filter_dir => 'filters', # dir to contain filter scripts
publish_dir => 'public', # dir to publish site to
url_root => "/", # root URL for building links
image_url_root => '', # same for images
template_dir => 'templates', # dir for template files
template => 'default', # template to use
title => '', # current title (used in template)
title_prefix => '', # a string to slap in front of titles
stylesheet_url => undef, # path to a CSS file (used in template)
favicon_url => undef, # path to a favicon (used in template)
feed_alias => 'feed', # what entry path should correspond to feed?
feed_length => 30, # how many entries should there be in the feed?
author => undef, # author name (used in template, feed)
description => undef, # site description (used in template)
content => undef, # place to stash content for templates
default_entry => 'new', # what to display if no entry specified
cache_includes => 0, # should included files be cached in memory?
# A license string for site content:
license => 'public domain',
# A string value to replace all pages with (useful for occasional
# situations where every page of a site should serve some other
# content in-place, like Net Neutrality protest blackouts):
( run in 2.947 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )