The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::AdventCalendar - a calendar for a month of articles (on the web)

VERSION

version 1.111

DESCRIPTION

This is a library for producing Advent calendar websites. In other words, it makes four things:

  • a page saying "first door opens in X days" the calendar starts

  • a calendar page on and after the calendar starts

  • a page for each day in the month with an article

  • an Atom feed

This library was originally written just for RJBS's Perl Advent Calendar, so it assumed you'd always be publishing from Dec 1 to Dec 24 or so. It has recently been retooled to work across arbitrary ranges, as long as they're within one month. This feature isn't well tested. Neither is the rest of the code, to be perfectly honest, though...

OVERVIEW

To build an Advent calendar:

  1. create an advent.ini configuration file

  2. write articles and put them in a directory

  3. schedule advcal to run nightly

advent.ini is easy to produce. Here's the one used for the original RJBS Advent Calendar:

  title  = RJBS Advent Calendar
  year   = 2009
  uri    = http://advent.rjbs.manxome.org/
  editor = Ricardo Signes
  category = Perl
  category = RJBS

  article_dir = rjbs/articles
  share_dir   = share

These should all be self-explanatory. Only category can be provided more than once, and is used for the category listing in the Atom feed.

These settings all correspond to "ATTRIBUTES" in calendar attributes described below. A few settings below are not given above.

Articles are easy, too. They're just files in the article_dir. They begin with an email-like set of headers, followed by a body written in Pod. For example, here's the beginning of the first article in the original calendar:

  Title:  Built in Our Workshop, Delivered in Your Package
  Topic: Sub::Exporter

  =head1 Exporting

  In Perl, we organize our subroutines (and other stuff) into namespaces called
  packages.  This makes it easy to avoid having to think of unique names for

The two headers seen above, title and topic, are the only headers required, and correspond to those attributes in the WWW::AdventCalendar::Article object created from the article file.

Finally, running advcal is easy, too. Here is its usage:

  advcal [-aot] [long options...]
    -c --config       the ini file to read for configuration
    -a --article-dir  the root of articles
    --share-dir       the root of shared files
    -o --output-dir   output directory
    --today           the day we treat as "today"; default to today

    -t --tracker      include Google Analytics; -t TRACKER-ID
    -y --year-links   place year links at the bottom of the page

Options given on the command line override those loaded form configuration. By running this program every day, we cause the calendar to be rebuilt, adding any new articles that have become available.

METHODS

build

  $calendar->build;

This method does all the work: it reads in the articles, decides how many to show, writes out the rendered pages, the index, and the atom feed.

read_articles

  my $article = $calendar->read_articles;

This method reads in all the articles for the calendar and returns a hashref. The keys are dates (in the format YYYY-MM-DD) and the values are WWW::AdventCalendar::Article objects.

ATTRIBUTES

title

The title of the calendar, to be used in headers, the feed, and so on.

tagline

A tagline for the calendar, used in some templates. Optional.

uri

The base URI of the calendar, including trailing slash.

editor

The name of the calendar's editor, used in the feed.

default_author

The name of the calendar's default author, used for articles that provide none.

year

The calendar year. Optional, if you provide start_date and end_date.

start_date

The start of the article-containing period. Defaults to Dec 1 of the year.

end_date

The end of the article-containing period. Defaults to Dec 24 of the year.

categories

An arrayref of category names for use in the feed.

article_dir

The directory in which articles can be found, with names like YYYY-MM-DD.html.

share_dir

The directory for templates, stylesheets, and other static content.

output_dir

The directory into which output files will be written.

today

The date to treat as "today" when deciding how much of the calendar to publish.

tracker_id

A Google Analytics tracker id. If given, each page will include analytics.

AUTHOR

Ricardo SIGNES <rjbs@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Ricardo SIGNES.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.