Almost-minimal filesystem based blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
516 B

cache rendered html; extract titles; all as utf-8 This stashes the HTML version of every entry in memory and uses Mojo::DOM to extract headers from the markup for use as titles. Titles are displayed in $self->{page_navigation}, now available inside templates as ${page_navigation}. In order to keep Mojo::DOM from choking on other input, it uses the open pragma to open everything as UTF-8 by default, which also eliminates a whole class of character encoding bugs and removes some fiddling with Encode::decode() from feed_print(). This is all obviously a more memory-intensive, but caching the markup turns out to have the side effect of making it much faster to render even a large site, probably as much as anything because the HTML in question is only getting generated once per entry instead of (potentially) 2-3 times. This commit isn't very atomic. In the process of roughing it out and testing it, I made a small pile of minor but potentially breaking changes: - Removed entry_map from settings and hardcoded handling of various types of entry as some if-statements instead. - Removed embedded_perl flag in settings - was always turned on in practice, and wasn't very coherent since templating would have broken without it. - bin/wrt-display - now handles the "feed" alias correctly - EntryStore: now supports retrieving values for properties with prop_value() - this isn't currently used, but it seems like a reasonable extension of the property idea. - Added `wrt ls --with-titles`. - Added dependency versions to Build.PL. - Refactored Markup's line_parse() a little. - Refactored some tests to give cleaner / more useful output. - Renamed default template file to "default".
4 years ago
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use 5.10.0;
  5. use lib 'lib';
  6. use Data::Dumper;
  7. use Test::More tests => 1;
  8. use App::WRT;
  9. use App::WRT::Mock::FileIO;
  10. use App::WRT::Renderer;
  11. chdir 'example/blog';
  12. my $config_file = 'wrt.json';
  13. my $wrt = App::WRT::new_from_file($config_file);
  14. my $log_string = '';
  15. my $renderer = App::WRT::Renderer->new(
  16. $wrt,
  17. sub { $log_string .= join '', @_; },
  18. App::WRT::Mock::FileIO->new(),
  19. );
  20. ok(
  21. $renderer->render(),
  22. 'successful mock render'
  23. );
  24. # diag($log_string);