]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - ikiwiki-calendar.in
Add ikistrap plugin for ikistrap theme.
[git.ikiwiki.info.git] / ikiwiki-calendar.in
index 9738ea5f7195cef46bf6480fc5c515fd89438cbe..d3e31b6db0ea204a58f62440316163dbaf515ac1 100755 (executable)
@@ -1,13 +1,14 @@
 #!/usr/bin/perl
+no lib '.';
 use warnings;
 use strict;
-use lib '.'; # For use in nonstandard directory, munged by Makefile.
+use FindBin; use lib $FindBin::Bin; # 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";
+       die gettext("usage: ikiwiki-calendar [-f] your.setup [pagespec] [startyear [endyear]]"), "\n";
 }
 
 my $force=0;
@@ -15,7 +16,10 @@ GetOptions(
        "force" => \$force,
 ) || usage();
 my $setup=shift                || usage();
-my $pagespec=shift     || "*";
+my $pagespec;
+if (@ARGV && $ARGV[0] !~ /^\d+$/) {
+       $pagespec=shift;
+}
 my $startyear=shift    || 1900+(localtime(time))[5];
 my $endyear=shift      || $startyear;
 
@@ -27,6 +31,10 @@ IkiWiki::checkconfig();
 my $archivebase = 'archives';
 $archivebase = $config{archivebase} if defined $config{archivebase};
 
+if (! defined $pagespec) {
+       $pagespec=$config{archive_pagespec} || "*";
+}
+
 sub writearchive ($$;$) {
        my $template=template(shift);
        my $year=shift;
@@ -52,7 +60,8 @@ foreach my $y ($startyear..$endyear) {
        }
 }
 
-IkiWiki::rcs_commit_staged(gettext("calendar update"), undef, undef)
+IkiWiki::rcs_commit_staged(message => gettext("calendar update"))
        if $config{rcs};
 
-system("ikiwiki", "-setup", $setup, "-refresh");
+exec("ikiwiki", "--setup", $setup, "--refresh");
+die "failed to run ikiwiki --setup $setup --refresh\n";