App-WRT
view release on metacpan or search on metacpan
lib/App/WRT.pm view on Meta::CPAN
Or:
$ cpan -i App::WRT
You will likely need to use C<sudo> or C<su> to get a systemwide install.
=head1 DESCRIPTION
This started life somewhere around 2001 as C<display.pl>, 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<wrt> 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<entry_dir>.
Like:
lib/App/WRT.pm view on Meta::CPAN
=item datestamp($entry)
Returns a nice html datestamp / breadcrumbs for a given entry.
=cut
sub datestamp {
my $self = shift;
my ($entry) = @_;
my @fragment_stack;
my @fragment_stamps = (
a({ href => $self->{url_root} }, $self->{title_prefix}),
);
# Chop up by directory separator:
my @pieces = split '/', $entry;
foreach my $fragment (@pieces) {
push @fragment_stack, $fragment;
push @fragment_stamps,
a({ href => $self->{url_root} . (join '/', @fragment_stack) . '/',
title => $fragment }, $fragment);
}
my $stamp = p({class => 'datestamp'}, join(" /\n", @fragment_stamps));
my $tag_list = $self->entry_tag_list($entry);
if ($tag_list) {
$stamp = "\n" . p({class => 'tags'}, $tag_list) . $stamp;
}
return "\n$stamp\n";
}
=item root_locations($file)
lib/App/WRT/Markup.pm view on Meta::CPAN
# TODO: Possibly this should be fatal.
"UNDEFINED: $1";
}
}gex;
return $text;
}
=item line_parse
Performs substitutions on lines called by fragment_slurp, at least. Calls
include_process(), image_markup(), textile_process(), markdown_process(),
eval_perl().
Applies before-parsing and after-parsing filters.
Returns string.
Parses some special markup. Specifically:
<perl>print "hello world";</perl>
my $w = App::WRT::new_from_file('wrt.json'),
"got WRT object."
);
# individual subroutine tests
my $datestamp = $w->datestamp('2014/1/1/test_entry');
like(
$datestamp,
qr{test_entry},
'datestamp for a fragment references that fragment'
) or diag($datestamp);
# icon rendering
my $with_icon = $w->display('icon_test');
like(
$with_icon,
qr/img src/,
'icon_test has an image in it'
t/wrt_sort.t view on Meta::CPAN
'2014/3/1/a',
'2014/3/1/frobnicate',
'2014/3/1/b',
'1999/12/1',
'a/index',
'a/ind',
'a',
'2019/6/11',
'2019/6/1',
'b',
'supercalifragilisticexpialidociousceteradisestamblishmentarianism'
);
my $sorted = [
'1999/12/1',
'2012/1/2',
'2014/3/1/a',
'2014/3/1/b',
'2014/3/1/frobnicate',
'2019/6/1',
'2019/6/2',
t/wrt_sort.t view on Meta::CPAN
'2019/6/21',
'a',
'abc',
'a/ind',
'a/index',
'b',
'c',
'c/frobnicate',
'chapbook',
'frobnicate',
'supercalifragilisticexpialidociousceteradisestamblishmentarianism'
];
my (@result) = sort_entries(@unsorted);
unless (is_deeply($sorted, \@result, "sort_entries() works, more or less")) {
for (@result) {
diag($_);
}
}
( run in 0.938 second using v1.01-cache-2.11-cpan-b16cb0d3907 )