NAME

App::DocKnot::Spin - Static site builder supporting thread macro language

SYNOPSIS

use App::DocKnot::Spin;

my $spin = App::DocKnot::Spin->new({ delete => 1 });
$spin->spin('/path/to/input', '/path/to/output');

REQUIREMENTS

Perl 5.24 or later and the modules Git::Repository, Image::Size, List::SomeUtils, Path::Iterator::Rule, Path::Tiny, Pod::Thread, Sort::Versions, Template (part of Template Toolkit), and YAML::XS, all of which are available from CPAN. Also expects to find faq2html, cvs2xhtml, and cl2xhtml on the user's PATH to convert certain types of files.

DESCRIPTION

App::DocKnot::Spin is a static site builder that takes an input tree of files and generates an output HTML site. It is built around the macro language thread, which is designed for writing simple HTML pages using somewhat nicer syntax, catering to my personal taste, and supporting variables and macros to make writing pages less tedious.

Each file in the input tree is examined recursively and either copied verbatim to the same relative path in the output tree (the default action), used as instructions to an external program, or converted to HTML. When converted to HTML, the output file will be named the same as the input file except the extension will be replaced with .html. Missing directories are created.

If the timestamp of the output file is the same as or newer than the timestamp of the input file, it will be assumed to be up-to-date and will not be regenerated. This optimization makes updating an existing static site much quicker.

Most files in the input tree will normally be thread files ending in .th. These are processed into HTML using App::DocKnot::Spin::Thread. See that module's documentation for the details of the thread macro language.

Files that end in .spin are pointers to external files that should be converted to HTML and then written to the output tree. These pointers are interpreted by App::DocKnot::Spin::Pointer. See that module's documentation for their format and effects.

Files that end in various other extensions are taken to be instructions to run an external converter on a file. The first line of such a pointer file should be the path to the source file, the second line any arguments to the converter, and the third line the style sheet to use if not the default. Which converter to run is based on the extension of the file as follows:

.changelog  cl2xhtml
.faq        faq2html
.log        cvs log <file> | cvs2xhtml
.rpod       Pod::Thread

All other files not beginning with a period are copied as-is, except that files or directories named CVS, Makefile, or RCS are ignored. As an exception, .htaccess files are also copied. This list of exclusions can be added to with the exclude constructor argument.

If there is a file named .sitemap at the top of the input tree, it will be parsed with App::DocKnot::Spin::Sitemap and used for inter-page links and the \sitemap thread command. See that module's documentation for the format of this file.

If there is a file named .versions at the top of the input tree, it will be parsed with App::DocKnot::Spin::Versions and used to determine when to regenerate certain pages and for the \release and \version thread commands. See that module's documentation for the format of this file.

If there is a file named .rss in any directory of the input tree, it will be processed with App::DocKnot::Spin::RSS to generate RSS and possibly other files. This is done before processing the files in that directory so that the generated files will then be processed as normal.

If there is a directory named .git at the top of the input tree, App::DocKnot::Spin will assume that the input tree is a Git repository and will try to use git log to determine the last modification date of files.

CLASS METHODS

new(ARGS)

Create a new App::DocKnot::Spin object. ARGS should be a hash reference with one or more of the following keys:

delete

If set to a true value, after populating the output tree with the results of converting or copying all the files in the source tree, delete all files and directories in the output tree that do not have a corresponding file in the source tree.

exclude

A list of strings, interpreted as regular expressions, which match files to exclude from processing. These patterns will be added to a built-in list of exclude patterns.

style-url

The base URL for style sheets. A style sheet specified in a \heading command will be considered to be relative to this URL and this URL will be prepended to it. If this option is not given, the name of the style sheet will be used verbatim as its URL, except with .css appended.

INSTANCE METHODS

spin(INPUT, OUTPUT)

Build the source tree rooted at INPUT into an HTML static site, storing it in the directory OUTPUT. If OUTPUT does not exist, it will be created.

AUTHOR

Russ Allbery <rra@cpan.org>

COPYRIGHT AND LICENSE

Copyright 1999-2011, 2013, 2021-2023 Russ Allbery <rra@cpan.org>

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.

SEE ALSO

cl2xhtml(1), cvs2xhtml(1), docknot(1), faq2html(1), App::DocKnot::Spin::Pointer, App::DocKnot::Spin::RSS, App::DocKnot::Spin::Sitemap, App::DocKnot::Spin::Thread, App::DocKnot::Spin::Versions, Pod::Thread

This module is part of the App-DocKnot distribution. The current version of DocKnot is available from CPAN, or directly from its web site at https://www.eyrie.org/~eagle/software/docknot/.