X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/3479809f96fa9c7a5d9f86c18c581f9a343a3aef..d420e032cc4f8418e210a3d7920b2e512f5ad0ce:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index db16a0854..68047b9b9 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -87,6 +87,7 @@ sub defaultconfig () { #{{{ numbacklinks => 10, account_creation_password => "", prefix_directives => 0, + hardlink => 0, } #}}} sub checkconfig () { #{{{ @@ -323,12 +324,9 @@ sub readfile ($;$$) { #{{{ return $ret; } #}}} -sub writefile ($$$;$$) { #{{{ - my $file=shift; # can include subdirs - my $destdir=shift; # directory to put file in - my $content=shift; - my $binary=shift; - my $writer=shift; +sub prep_writefile ($$) { + my $file=shift; + my $destdir=shift; my $test=$file; while (length $test) { @@ -337,12 +335,8 @@ sub writefile ($$$;$$) { #{{{ } $test=dirname($test); } - my $newfile="$destdir/$file.ikiwiki-new"; - if (-l $newfile) { - error("cannot write to a symlink ($newfile)"); - } - my $dir=dirname($newfile); + my $dir=dirname("$destdir/$file"); if (! -d $dir) { my $d=""; foreach my $s (split(m!/+!, $dir)) { @@ -353,6 +347,23 @@ sub writefile ($$$;$$) { #{{{ } } + return 1; +} + +sub writefile ($$$;$$) { #{{{ + my $file=shift; # can include subdirs + my $destdir=shift; # directory to put file in + my $content=shift; + my $binary=shift; + my $writer=shift; + + prep_writefile($file, $destdir); + + my $newfile="$destdir/$file.ikiwiki-new"; + if (-l $newfile) { + error("cannot write to a symlink ($newfile)"); + } + my $cleanup = sub { unlink($newfile) }; open (my $out, '>', $newfile) || error("failed to write $newfile: $!", $cleanup); binmode($out) if ($binary); @@ -610,6 +621,9 @@ sub userlink ($) { #{{{ return "$oiduser"; } else { + eval q{use CGI 'escapeHTML'}; + error($@) if $@; + return htmllink("", "", escapeHTML( length $config{userdir} ? $config{userdir}."/".$user : $user ), noimageinline => 1); @@ -902,7 +916,7 @@ sub loadindex () { #{{{ my $in; if (! open ($in, "<", "$config{wikistatedir}/indexdb")) { if (-e "$config{wikistatedir}/index") { - system("ikiwiki-transition", "indexdb", $config{wikistatedir}); + system("ikiwiki-transition", "indexdb", $config{srcdir}); open ($in, "<", "$config{wikistatedir}/indexdb") || return; } else { @@ -914,12 +928,13 @@ sub loadindex () { #{{{ return 0; } my %index=%$ret; - foreach my $page (keys %index) { - my %d=%{$index{$page}}; + foreach my $src (keys %index) { + my %d=%{$index{$src}}; + my $page=pagename($src); $pagectime{$page}=$d{ctime}; if (! $config{rebuild}) { + $pagesources{$page}=$src; $pagemtime{$page}=$d{mtime}; - $pagesources{$page}=$d{src}; $renderedfiles{$page}=$d{dest}; if (exists $d{links} && ref $d{links}) { $links{$page}=$d{links}; @@ -961,23 +976,23 @@ sub saveindex () { #{{{ my %index; foreach my $page (keys %pagemtime) { next unless $pagemtime{$page}; + my $src=$pagesources{$page}; - $index{$page}={ + $index{$src}={ ctime => $pagectime{$page}, mtime => $pagemtime{$page}, - src => $pagesources{$page}, dest => $renderedfiles{$page}, links => $links{$page}, }; if (exists $depends{$page}) { - $index{$page}{depends} = $depends{$page}; + $index{$src}{depends} = $depends{$page}; } if (exists $pagestate{$page}) { foreach my $id (@hookids) { foreach my $key (keys %{$pagestate{$page}{$id}}) { - $index{$page}{state}{$id}{$key}=$pagestate{$page}{$id}{$key}; + $index{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key}; } } }