aboutsummaryrefslogtreecommitdiff
path: root/ikiwiki-calendar.in
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2010-03-26 13:11:02 -0400
committerJoey Hess <joey@gnu.kitenet.net>2010-03-26 13:11:02 -0400
commit1273f1de52998cf54afb3445fd8c616bce53e698 (patch)
tree11ebd7f2521112fa67faa5fefe1690c8daa2768f /ikiwiki-calendar.in
parentb10c6dd631496df972177d8673d40d77bb441644 (diff)
downloadikiwiki-1273f1de52998cf54afb3445fd8c616bce53e698.tar
ikiwiki-1273f1de52998cf54afb3445fd8c616bce53e698.tar.gz
Add preprocessed 'use lib' line to ikiwiki-transition and ikiwiki-calendar if necessary for unusual install.
Diffstat (limited to 'ikiwiki-calendar.in')
-rwxr-xr-xikiwiki-calendar.in58
1 files changed, 58 insertions, 0 deletions
diff --git a/ikiwiki-calendar.in b/ikiwiki-calendar.in
new file mode 100755
index 000000000..9738ea5f7
--- /dev/null
+++ b/ikiwiki-calendar.in
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use lib '.'; # For use in nonstandard directory, munged by Makefile.
+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 $startyear=shift || 1900+(localtime(time))[5];
+my $endyear=shift || $startyear;
+
+%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};
+ }
+}
+
+foreach my $y ($startyear..$endyear) {
+ 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};
+
+system("ikiwiki", "-setup", $setup, "-refresh");