ikiwiki-calendar: New command automates creation of archive pages using the calendar plugin.
parent
5cddd8a0a3
commit
e1939185d2
|
@ -1,3 +1,10 @@
|
|||
ikiwiki (3.20091010) UNRELEASED; urgency=low
|
||||
|
||||
* ikiwiki-calendar: New command automates creation of archive pages
|
||||
using the calendar plugin.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Sun, 11 Oct 2009 15:54:45 -0400
|
||||
|
||||
ikiwiki (3.20091009) unstable; urgency=low
|
||||
|
||||
* parentlinks: Add has_parentlinks template parameter to allow styling
|
||||
|
|
|
@ -23,3 +23,7 @@ Some additional configuration you might want to do:
|
|||
enable comments to posts to the blog:
|
||||
|
||||
comments_pagespec => 'blog/posts/* and !*/Discussion',
|
||||
|
||||
* Enable the [[calendar|plugins/calendar]] plugin and run the
|
||||
[[ikiwiki-calendar]] command from cron daily to get an interlinked
|
||||
set of calendar archives.
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
# NAME
|
||||
|
||||
ikiwiki-calendar - create calendar archive pages
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
ikiwiki-calendar [-f] your.setup [pagespec] [year]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
`ikiwiki-calendar` creates pages that use the [[ikiwiki/directive/calendar]]
|
||||
directive, allowing the archives to be browsed one month
|
||||
at a time, with calendar-based navigation.
|
||||
|
||||
You must specify the setup file for your wiki. The pages will
|
||||
be created inside its `srcdir`, beneath the `archivebase`
|
||||
directory used by the calendar plugin (default "archives").
|
||||
|
||||
You will probably want to specify a [[ikiwiki/PageSpec]]
|
||||
to control which pages are included on the calendars. The
|
||||
default is all pages. To limit it to only posts in a blog,
|
||||
use something like "posts/* and !*/Discussion".
|
||||
|
||||
It defaults to creating calendar pages for the current
|
||||
year, as well as the previous year, and the next year.
|
||||
If you specify a year, it will create pages for that year.
|
||||
|
||||
Existing pages will not be overwritten by this command by default.
|
||||
Use the `-f` switch to force it to overwrite any existing pages.
|
||||
|
||||
## CRONTAB
|
||||
|
||||
While this command only needs to be run once a year to update
|
||||
the archive pages for each new year, you are recommended to set up
|
||||
a cron job to run it daily, at midnight. Then it will also update
|
||||
the calendars to highlight the current day.
|
||||
|
||||
An example crontab:
|
||||
|
||||
0 0 * * * ikiwiki-calendar ~/ikiwiki.setup "posts/* and !*/Discussion"
|
||||
|
||||
# TEMPLATES
|
||||
|
||||
This command uses two [[template|wikitemplates]] to generate
|
||||
the pages, `calendarmonth.tmpl` and `calendaryear.tmpl`.
|
||||
|
||||
# AUTHOR
|
||||
|
||||
Joey Hess <joey@ikiwiki.info>
|
||||
|
||||
Warning: this page is automatically made into ikiwiki-calendar's man page, edit with care
|
|
@ -1,5 +1,4 @@
|
|||
The `calendar` directive is supplied by the [[!iki plugins/calendar desc=calendar]] plugin.
|
||||
This plugin requires extra setup. See the plugin documentation for details.
|
||||
|
||||
This directive displays a calendar, similar to the typical calendars shown on
|
||||
some blogs.
|
||||
|
@ -12,16 +11,28 @@ some blogs.
|
|||
|
||||
\[[!calendar type="year" year="2005" pages="blog/* and !*/Discussion"]]
|
||||
|
||||
## setup
|
||||
|
||||
The calendar is essentially a fancy front end to archives of previous
|
||||
pages, usually used for blogs. It can produce a calendar for a given month,
|
||||
or a list of months for a given year.
|
||||
or a list of months for a given year. The month format calendar simply
|
||||
links to any page posted on each day of the month. The year format calendar
|
||||
links to archive pages, with names like `archives/2007` (for all of 2007)
|
||||
and `archives/2007/01` (for January, 2007).
|
||||
|
||||
The month format calendar simply links to any page posted on each
|
||||
day of the month. The year format calendar links to archive pages, with
|
||||
names like `archives/2007` (for all of 2007) and `archives/2007/01`
|
||||
(for January, 2007). For this to work, you'll need to create these archive
|
||||
pages. They typically use [[inline]] to display or list pages created in
|
||||
the given time frame.
|
||||
While you can insert calendar directives anywhere on your wiki, including
|
||||
in the sidebar, you'll also need to create these archive pages. They
|
||||
typically use this directive to display a calendar, and also use [[inline]]
|
||||
to display or list pages created in the given time frame.
|
||||
|
||||
The `ikiwiki-calendar` command can be used to automatically generate the
|
||||
archive pages. It also refreshes the wiki, updating the calendars to
|
||||
highlight the current day. This command is typically run at midnight from
|
||||
cron. An example crontab:
|
||||
|
||||
An example crontab:
|
||||
|
||||
0 0 * * * ikiwiki-calendar ~/ikiwiki.setup "posts/* and !*/Discussion"
|
||||
|
||||
## usage
|
||||
|
||||
|
|
|
@ -3,13 +3,9 @@
|
|||
|
||||
This plugin provides a [[ikiwiki/directive/calendar]] [[ikiwiki/directive]].
|
||||
The directive displays a calendar, similar to the typical calendars shown on
|
||||
some blogs.
|
||||
some blogs.
|
||||
|
||||
Since ikiwiki is a wiki compiler, to keep the calendar up-to-date,
|
||||
wikis that include it need to be periodically refreshed, typically by cron
|
||||
at midnight. Example crontab:
|
||||
|
||||
0 0 * * * ikiwiki -setup ~/ikiwiki.setup -refresh
|
||||
The [[ikiwiki-calendar]] command is used to keep the calendar up-to-date.
|
||||
|
||||
## CSS
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
use IkiWiki;
|
||||
use IkiWiki::Setup;
|
||||
use Getopt::Long;
|
||||
|
||||
sub usage () {
|
||||
die gettext("usage: ikiwiki-calendar [-f] your.setup [pagespec] [year]"), "\n";
|
||||
}
|
||||
|
||||
my $force=0;
|
||||
GetOptions(
|
||||
"force" => \$force,
|
||||
) || usage();
|
||||
my $setup=shift || usage();
|
||||
my $pagespec=shift || "*";
|
||||
my $year=shift || 1900+(localtime(time))[5];
|
||||
|
||||
%config=IkiWiki::defaultconfig();
|
||||
IkiWiki::Setup::load($setup);
|
||||
IkiWiki::loadplugins();
|
||||
IkiWiki::checkconfig();
|
||||
|
||||
my $archivebase = 'archives';
|
||||
$archivebase = $config{archivebase} if defined $config{archivebase};
|
||||
|
||||
sub writearchive ($$;$) {
|
||||
my $template=template(shift);
|
||||
my $year=shift;
|
||||
my $month=shift;
|
||||
|
||||
my $page=defined $month ? "$year/$month" : $year;
|
||||
|
||||
my $pagefile=newpagefile("$archivebase/$page", $config{default_pageext});
|
||||
$template->param(pagespec => $pagespec);
|
||||
$template->param(year => $year);
|
||||
$template->param(month => $month) if defined $month;
|
||||
|
||||
if ($force || ! -e "$config{srcdir}/$pagefile") {
|
||||
writefile($pagefile, $config{srcdir}, $template->output);
|
||||
IkiWiki::rcs_add($pagefile) if $config{rcs};
|
||||
}
|
||||
}
|
||||
|
||||
IkiWiki::lockwiki();
|
||||
|
||||
foreach my $y ($year-1, $year, $year+1) {
|
||||
writearchive("calendaryear.tmpl", $y);
|
||||
foreach my $m (qw{01 02 03 04 05 06 07 08 09 10 11 12}) {
|
||||
writearchive("calendarmonth.tmpl", $y, $m);
|
||||
}
|
||||
}
|
||||
|
||||
IkiWiki::rcs_commit_staged(gettext("calendar update"), undef, undef)
|
||||
if $config{rcs};
|
||||
IkiWiki::unlockwiki();
|
||||
|
||||
system("ikiwiki", "-setup", $setup, "-refresh");
|
|
@ -0,0 +1,3 @@
|
|||
[[!calendar type=month month=<TMPL_VAR MONTH> year=<TMPL_VAR YEAR> pages="<TMPL_VAR PAGESPEC>"]]
|
||||
|
||||
[[!inline pages="creation_month(<TMPL_VAR MONTH>) and creation_year(<TMPL_VAR YEAR>) and <TMPL_VAR PAGESPEC>" show=0 feeds=no reverse=yes]]
|
|
@ -0,0 +1 @@
|
|||
[[!calendar type=year year=<TMPL_VAR YEAR> pages="<TMPL_VAR PAGESPEC>"]]
|
Loading…
Reference in New Issue