X-Git-Url: https://scripts.mit.edu/gitweb/www/ikiwiki.git/blobdiff_plain/a223f4540fee2d0c49523343a422315377bc0025..df2ccc34b35d99c97293ae406e8f1916ad723683:/ikiwiki
diff --git a/ikiwiki b/ikiwiki
index 3540f8667..235a72102 100755
--- a/ikiwiki
+++ b/ikiwiki
@@ -8,7 +8,8 @@ use File::Spec;
use HTML::Template;
use lib '.'; # For use without installation, removed by Makefile.
-use vars qw{%config %links %oldlinks %oldpagemtime %renderedfiles %pagesources};
+use vars qw{%config %links %oldlinks %oldpagemtime %pagectime
+ %renderedfiles %pagesources %inlinepages};
sub usage () { #{{{
die "usage: ikiwiki [options] source dest\n";
@@ -19,7 +20,8 @@ sub getconfig () { #{{{
%config=(
wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
wiki_link_regexp => qr/\[\[([^\s\]]+)\]\]/,
- wiki_file_regexp => qr/(^[-A-Za-z0-9_.\&;:\/+]+$)/,
+ wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]+)\]\]/,
+ wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
verbose => 0,
wikiname => "wiki",
default_pageext => ".mdwn",
@@ -30,6 +32,7 @@ sub getconfig () { #{{{
historyurl => '',
diffurl => '',
anonok => 0,
+ rss => 0,
rebuild => 0,
wrapper => undef,
wrappermode => undef,
@@ -49,6 +52,7 @@ sub getconfig () { #{{{
"wrappermode=i" => \$config{wrappermode},
"svn!" => \$config{svn},
"anonok!" => \$config{anonok},
+ "rss!" => \$config{rss},
"cgi!" => \$config{cgi},
"url=s" => \$config{url},
"cgiurl=s" => \$config{cgiurl},
@@ -85,7 +89,10 @@ sub getconfig () { #{{{
sub checkconfig () { #{{{
if ($config{cgi} && ! length $config{url}) {
- error("Must specify url to wiki with --url when using --cgi");
+ error("Must specify url to wiki with --url when using --cgi\n");
+ }
+ if ($config{rss} && ! length $config{url}) {
+ error("Must specify url to wiki with --url when using --rss\n");
}
$config{wikistatedir}="$config{srcdir}/.ikiwiki"
@@ -255,7 +262,7 @@ sub htmllink ($$;$$) { #{{{
$bestlink="$page/".lc($link);
}
- my $linktext=pagetitle($link);
+ my $linktext=pagetitle(basename($link));
return $linktext if length $bestlink && $page eq $bestlink;
@@ -267,7 +274,7 @@ sub htmllink ($$;$$) { #{{{
$bestlink=htmlpage($bestlink);
}
if (! grep { $_ eq $bestlink } values %renderedfiles) {
- return "?$linktext"
+ return "?$linktext"
}
$bestlink=File::Spec->abs2rel($bestlink, dirname($page));
@@ -311,13 +318,26 @@ sub loadindex () { #{{{
while () {
$_=possibly_foolish_untaint($_);
chomp;
- my ($mtime, $file, $rendered, @links)=split(' ', $_);
- my $page=pagename($file);
- $pagesources{$page}=$file;
- $oldpagemtime{$page}=$mtime;
- $oldlinks{$page}=[@links];
- $links{$page}=[@links];
- $renderedfiles{$page}=$rendered;
+ my %items;
+ $items{link}=[];
+ foreach my $i (split(/ /, $_)) {
+ my ($item, $val)=split(/=/, $i, 2);
+ push @{$items{$item}}, $val;
+ }
+
+ next unless exists $items{src}; # skip bad lines for now
+
+ my $page=pagename($items{src}[0]);
+ if (! $config{rebuild}) {
+ $pagesources{$page}=$items{src}[0];
+ $oldpagemtime{$page}=$items{mtime}[0];
+ $oldlinks{$page}=[@{$items{link}}];
+ $links{$page}=[@{$items{link}}];
+ $inlinepages{$page}=join(" ", @{$items{inlinepage}})
+ if exists $items{inlinepage};
+ $renderedfiles{$page}=$items{dest}[0];
+ }
+ $pagectime{$page}=$items{ctime}[0];
}
close IN;
} #}}}
@@ -329,9 +349,16 @@ sub saveindex () { #{{{
open (OUT, ">$config{wikistatedir}/index") ||
error("cannot write to $config{wikistatedir}/index: $!");
foreach my $page (keys %oldpagemtime) {
- print OUT "$oldpagemtime{$page} $pagesources{$page} $renderedfiles{$page} ".
- join(" ", @{$links{$page}})."\n"
- if $oldpagemtime{$page};
+ next unless $oldpagemtime{$page};
+ my $line="mtime=$oldpagemtime{$page} ".
+ "ctime=$pagectime{$page} ".
+ "src=$pagesources{$page} ".
+ "dest=$renderedfiles{$page}";
+ $line.=" link=$_" foreach @{$links{$page}};
+ if (exists $inlinepages{$page}) {
+ $line.=" inlinepage=$_" foreach split " ", $inlinepages{$page};
+ }
+ print OUT $line."\n";
}
close OUT;
} #}}}
@@ -439,7 +466,13 @@ sub globlist_match ($$) { #{{{
sub main () { #{{{
getconfig();
- if ($config{setup}) {
+ if ($config{cgi}) {
+ lockwiki();
+ loadindex();
+ require IkiWiki::CGI;
+ cgi();
+ }
+ elsif ($config{setup}) {
require IkiWiki::Setup;
setup();
}
@@ -448,14 +481,9 @@ sub main () { #{{{
require IkiWiki::Wrapper;
gen_wrapper();
}
- elsif ($config{cgi}) {
- lockwiki();
- require IkiWiki::CGI;
- cgi();
- }
else {
lockwiki();
- loadindex() unless $config{rebuild};
+ loadindex();
require IkiWiki::Render;
rcs_update();
refresh();