NAME

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

VERSION

version 1.113

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

  -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.

PERL VERSION

This module should work on any version of perl still receiving updates from the Perl 5 Porters. This means it should work on any version of perl released in the last two to three years. (That is, if the most recently released version is v5.40, then this module should work on both v5.40 and v5.38.)

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

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.

AUTHOR

Ricardo SIGNES <cpan@semiotic.systems>

CONTRIBUTORS

  • Len Jaffe <lenjaffe@jaffesystems.com>

  • Ricardo Signes <rjbs@semiotic.systems>

  • Shoichi Kaji <skaji@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 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.