package App::WRT; # From semver.org: # # Given a version number MAJOR.MINOR.PATCH, increment the: # # MAJOR version when you make incompatible API changes, # MINOR version when you add functionality in a backwards-compatible # manner, and # PATCH version when you make backwards-compatible bug fixes. # # Additional labels for pre-release and build metadata are available as # extensions to the MAJOR.MINOR.PATCH format. # # Honestly I have always found it just about impossible to follow semver # without overthinking a bunch of hair-splitting decisions and categories, # but whatever. I'll try to follow it, roughly. use version; our $VERSION = version->declare("v8.1.0"); use strict; use warnings; no warnings 'uninitialized'; use 5.14.0; use utf8; use open qw(:std :utf8); use Carp; use Cwd qw(getcwd abs_path); use Encode qw(decode encode); use File::Spec; use HTML::Entities; use JSON; use JSON::Feed; use Mojo::DOM; use XML::Atom::SimpleFeed; use App::WRT::Date qw(iso_date rfc_3339_date get_mtime month_name); use App::WRT::EntryStore; use App::WRT::FileIO; use App::WRT::Filters; use App::WRT::HTML qw(:all); use App::WRT::Image qw(image_size); use App::WRT::Markup qw(line_parse image_markup eval_perl); use App::WRT::Util qw(dir_list file_get_contents); =pod =head1 NAME App::WRT - WRiting Tool, a static site/blog generator and related utilities =head1 SYNOPSIS Using the commandline tools: $ mkdir project $ cd project $ wrt init # set up some defaults $ wrt config # dump configuration values $ wrt ls # list entries $ wrt display new # print HTML for new entries to stdout $ wrt render-all # publish HTML to project/public/ Using App::WRT in library form: #!/usr/bin/env perl use App::WRT; my $w = App::WRT->new( entry_dir => 'archives', url_root => '/', # etc. ); print $w->display(@ARGV); =head1 INSTALLING It's possible this would run on a Perl as old as 5.14.0. In practice, I know that it works under 5.26.2. It should be fine on any reasonably modern Linux distribution, and might work on BSD of your choosing. Maybe even MacOS. It's possible that it would run under the Windows Subsystem for Linux, but it would definitely fail under vanilla Windows; it currently makes too many assumptions about things like directory path separators and filesystem semantics. (Although I would like the code to be more robust across platforms, this is not a problem I feel much urgency about solving at the moment, since I'm pretty sure I am the only user of this software. Please let me know if I'm mistaken.) To install the latest development version from the main repo: $ git clone https://code.p1k3.com/gitea/brennen/wrt.git $ cd wrt $ perl Build.PL $ ./Build installdeps $ ./Build test $ ./Build install To install the latest version released on CPAN: $ cpanm App::WRT Or: $ cpan -i App::WRT You will likely need to use C or C to get a systemwide install. =head1 DESCRIPTION This started life somewhere around 2001 as C, a CGI script to concatenate fragments of handwritten HTML by date. It has since accumulated several of the usual weblog features (lightweight markup, feed generation, embedded Perl, poetry tools, image galleries, and ill-advised dependencies), but the basic idea hasn't changed that much. The C utility now generates static HTML files, instead of expecting to run as a CGI script. This is a better idea, for the most part. By default, entries are stored in a simple directory tree under C. Like: archives/2001/1/1 archives/2001/1/2/index archives/2001/1/2/sub_entry Which will publish files like so: public/index.html public/all/index.html public/2001/index.html public/2001/1/index.html public/2001/1/1/index.html public/2001/1/2/index.html public/2001/1/2/sub_entry/index.html Contents will be generated for each year and for the entire collection of dated entries. Month indices will consist of all entries for that month. A top-level index file will consist of the most recent month's entries. An entry may be either a plain UTF-8 text file, or a directory containing several such files. If it's a directory, a file named "index" will be treated as the text of the entry, and all other lower-case filenames without extensions will be treated as sub-entries or documents within that entry, and displayed accordingly. Links to certain other filetypes will be displayed as well. Directories may be nested to an arbitrary depth, although it's probably not a good idea to go very deep with the current display logic. A PNG or JPEG file with a name like 2001/1/1.icon.png 2001/1/1/index.icon.png 2001/1/1/whatever.icon.png 2001/1/1/whatever/index.icon.png will be treated as an icon for the corresponding entry file. =head2 MARKUP Entries may consist of hand-written HTML (to be passed along without further mangling), a supported form of lightweight markup, or some combination thereof. Header tags (

,

, etc.) will be used to display titles in feeds, navigation, and other places. Other special markup is indicated by a variety of HTML-like container tags. B - evaluated and replaced by whatever value you return (evaluated in a scalar context): my $dog = "Ralph."; return $dog; This code is evaluated before any other processing is done, so you can return any other markup understood by the script and have it handled appropriately. B - actually keys to the hash underlying the App::WRT object, for the moment: $self->{title} = "About Ralph, My Dog"; return '';

The title is ${title}.

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