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.

66 lines
1.5 KiB

  1. #!/usr/bin/env perl
  2. =pod
  3. =head1 NAME
  4. wrt-render-all - utility for rendering static HTML files from entries
  5. =head1 USAGE
  6. wrt render-all
  7. wrt render-all --config ./wrt.json ...
  8. wrt render-all --help
  9. =head1 DESCRIPTION
  10. Renders all entries in the current wrt archive to the C<publish_dir> specified
  11. in the configuration file (normally F<wrt.json>). By default, this is
  12. F<./public>.
  13. Detailed documentation can be found in the L<App::WRT> man page or at
  14. L<https://github.com/brennen/wrt>.
  15. =head1 LICENSE
  16. wrt is free software; you can redistribute it and/or modify
  17. it under the terms of the GNU General Public License as published by
  18. the Free Software Foundation; either version 2 of the License, or
  19. (at your option) any later version.
  20. =head1 AUTHOR
  21. Brennen Bearnes
  22. =cut
  23. use 5.10.0;
  24. use strict;
  25. use warnings;
  26. no warnings 'uninitialized';
  27. use Getopt::Long;
  28. use Pod::Usage;
  29. use App::WRT;
  30. # Handle options, including help generated from the POD above. See:
  31. # - http://perldoc.perl.org/Getopt/Long.html#User-defined-subroutines-to-handle-options
  32. # - https://metacpan.org/pod/Pod::Usage
  33. # - http://michael.thegrebs.com/2014/06/08/Pod-Usage/
  34. my $config_file = 'wrt.json';
  35. GetOptions(
  36. 'config=s' => \$config_file,
  37. help => sub { pod2usage(0) },
  38. ) or pod2usage(2);
  39. unless (-e $config_file) {
  40. die "No wrt config file found. Tried: $config_file";
  41. }
  42. my $w = App::WRT::new_from_file($config_file);
  43. # This expects a callback to handle logging output:
  44. $w->render(sub { say $_[0]; });
  45. exit(0);