App-Aphra
view release on metacpan or search on metacpan
defined extensions, so it is processed by the Template Toolkit.
=item *
As part of this processing, the Template Toolkit needs to process
C<index_text.md>. This template is found in the fragments directory, but
its extension, C<.md>, means that it is pre-processed by C<pandoc> (converting
Markdown to HTML) before it is processed by the Template Toolkit.
=item *
The output from processing C<src/index.html.tt> is written to
C<docs/index.html>. The C<.tt> extension is removed.
=item *
C<src/style.css> is found. As its extension is not one of the defined ones,
it is simply copied to C<docs/style.css>.
=item *
C<src/about/index.html.tt> is found. It is processed in a very similar way
to C<src/index.html> (including the processing of C<fragments/about_text.md>
and the output is written to C<docs/about/index.html>.
=back
After the processing is complete, we have the following in the C<docs>
directory:
docs/index.html
docs/style.css
docs/about/index.html
=head1 SITE CONFIGURATION FILE - site.yml
You can store site-wide configuration and data in a file called C<site.yml>,
which should be in the same directory as the various directories discussed
above.
The file is in YAML format. Any variables defined inside this file will be
available inside your templates within the `site` variable. For example, your
`site.yml` could contain the following definition:
name: My Cool Site
And you could access that text inside your templates with markup like this:
<h1><% site.name %></h1>
=head2 Special variables in site.yml
There are a few special variables that you can define in your `site.yml` file
which will be used by the program.
=over 4
=item uri, protocol, host, port
These are used to construct the base URL for the site. If you don't define
these, then the program will try to guess them. It will use the value of the
`uri` variable if it is defined. If not, it will use the values of the
`protocol`, `host` and `port` variables. If any of these aren't defined, it
will use the values "https", the result of calling `hostname` and no port
(which is, effectively, port 80) respectively.
=item redirects
This is a list of URLs that should be redirected to other URLs. Each entry in
the list should be a hash containing the keys `from` and `to`. For example:
redirects:
- from: /old/page
to: /new/page
The value of "from" should be the path part of the URL that you want to
redirect and the value of "to" can be either a full URL or a path part of a
URL. If it is a path part, then the base URL of the site will be prepended to
it.
Aphra implements these redirects by creating stub HTML files in the output
directory which contain a meta refresh tag that redirects the browser to the
new URL. Redirects are created before other files are processed, so any files
that have the same URL as a redirect will overwrite the redirect stub HTML
file.
=back
=head1 FRONT MATTER IN INDIVIDUAL PAGES
At the start of the template for a page, you can add a data section which
contains variable definitions. This section is preceded and followed by lines
consisting of three dashes. The variables are defined using YAML format. The
variables defined in this section are available within templates by using the
`page` variable. For example, your template could start with this definition:
---
title: Important Page
---
And you could access that text inside your templates with markdown like this:
## <% page.title %>
=head2 Special values in front matter
If your front matter includes a variable called C<layout>, then that will
override the default layout for this single page. You should ensure there
is a file of the correct name in the C<layouts> directory.
=cut
use strict;
use warnings;
use 5.014;
use App::Aphra;
App::Aphra->new->run;
=head1 AUTHOR
( run in 1.555 second using v1.01-cache-2.11-cpan-99c4e6809bf )