source file, to allow tracking of extra rendered files like rss feeds.
* Note that plugins that accessed this variable will need to be updated!
The plugin interface has been increased to version 1.01 for this change.
* Add will_render function to the plugin interface, used to register that a
page renders a destination file, and do some security checks.
* Use will_render in the inline and linkmap plugins.
* Previously but no longer rendered files will be cleaned up.
* You will need to rebuild your wiki on upgrade to this version.
use open qw{:utf8 :std};
use vars qw{%config %links %oldlinks %oldpagemtime %pagectime %pagecase
- %renderedfiles %pagesources %depends %hooks %forcerebuild};
+ %renderedfiles %oldrenderedfiles %pagesources %depends %hooks
+ %forcerebuild};
use Exporter q{import};
our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
bestlink htmllink readfile writefile pagetype srcfile pagename
displaytime
%config %links %renderedfiles %pagesources);
-our $VERSION = 1.00;
+our $VERSION = 1.01;
# Optimisation.
use Memoize;
close OUT;
} #}}}
+sub will_render ($$;$) { #{{{
+ my $page=shift;
+ my $dest=shift;
+ my $clear=shift;
+
+ # Important security check.
+ if (-e "$config{destdir}/$dest" && ! $config{rebuild} &&
+ ! grep { $_ eq $dest } (@{$renderedfiles{$page}}, @{$oldrenderedfiles{$page}})) {
+ error("$config{destdir}/$dest independently created, not overwriting with version from $page");
+ }
+
+ if (! $clear) {
+ $renderedfiles{$page}=[$dest, grep { $_ ne $dest } @{$renderedfiles{$page}}];
+ }
+ else {
+ $renderedfiles{$page}=[$dest];
+ }
+} #}}}
+
sub bestlink ($$) { #{{{
my $page=shift;
my $link=shift;
# TODO BUG: %renderedfiles may not have it, if the linked to page
# was also added and isn't yet rendered! Note that this bug is
# masked by the bug that makes all new files be rendered twice.
- if (! grep { $_ eq $bestlink } values %renderedfiles) {
+ if (! grep { $_ eq $bestlink } map { @{$_} } values %renderedfiles) {
$bestlink=htmlpage($bestlink);
}
- if (! grep { $_ eq $bestlink } values %renderedfiles) {
+ if (! grep { $_ eq $bestlink } map { @{$_} } values %renderedfiles) {
return "<span><a href=\"".
cgiurl(do => "create", page => lc($link), from => $page).
"\">?</a>$linktext</span>"
chomp;
my %items;
$items{link}=[];
+ $items{dest}=[];
foreach my $i (split(/ /, $_)) {
my ($item, $val)=split(/=/, $i, 2);
push @{$items{$item}}, decode_entities($val);
$oldlinks{$page}=[@{$items{link}}];
$links{$page}=[@{$items{link}}];
$depends{$page}=$items{depends}[0] if exists $items{depends};
- $renderedfiles{$page}=$items{dest}[0];
+ $renderedfiles{$page}=[@{$items{dest}}];
+ $oldrenderedfiles{$page}=[@{$items{dest}}];
$pagecase{lc $page}=$page;
}
$pagectime{$page}=$items{ctime}[0];
next unless $oldpagemtime{$page};
my $line="mtime=$oldpagemtime{$page} ".
"ctime=$pagectime{$page} ".
- "src=$pagesources{$page} ".
- "dest=$renderedfiles{$page}";
+ "src=$pagesources{$page}";
+ $line.=" dest=$_" foreach @{$renderedfiles{$page}};
$line.=" link=$_" foreach @{$links{$page}};
if (exists $depends{$page}) {
$line.=" depends=".encode_entities($depends{$page}, " \t\n");
use warnings;
use strict;
-use IkiWiki;
+use IkiWiki 1.00;
use IkiWiki::Render; # for displaytime
use URI;
}
}
- # TODO: should really add this to renderedfiles and call
- # check_overwrite, but currently renderedfiles
- # only supports listing one file per page.
if ($config{rss} && $rss) {
+ will_render($params{page}, rsspage($params{page}));
writefile(rsspage($params{page}), $config{destdir},
genrss($desc, $params{page}, @list));
$toping{$params{page}}=1 unless $config{rebuild};
my $itemtemplate=template("rssitem.tmpl", blind_cache => 1);
my $content="";
foreach my $p (@pages) {
- next unless exists $renderedfiles{$p};
-
- my $u=URI->new(encode_utf8("$config{url}/$renderedfiles{$p}"));
+ my $u=URI->new(encode_utf8($config{url}."/".htmlpage($p)));
$itemtemplate->param(
title => pagetitle(basename($p)),
# Use ikiwiki's function to create the file, this makes sure needed
# subdirs are there and does some sanity checking.
- writefile("$params{page}.png", $config{destdir}, "");
+ will_render($params{page}, $params{page}.".png");
+ writefile($params{page}.".png", $config{destdir}, "");
# Run dot to create the graphic and get the map data.
- # TODO: should really add the png to renderedfiles and call
- # check_overwrite, but currently renderedfiles
- # only supports listing one file per page.
my $pid;
my $sigpipe=0;;
$SIG{PIPE}=sub { $sigpipe=1 };
debug("updating hyperestraier search index");
estcmd("gather -cm -bc -cl -sd",
map {
- Encode::encode_utf8($config{destdir}."/".$renderedfiles{pagename($_)})
+ Encode::encode_utf8($config{destdir}."/".$_)
+ foreach @{$renderedfiles{pagename($_)}};
} @_
);
estcfg();
return $content;
} #}}}
-sub check_overwrite ($$) { #{{{
- # Important security check. Make sure to call this before saving
- # any files to the source directory.
- my $dest=shift;
- my $src=shift;
-
- if (! exists $renderedfiles{$src} && -e $dest && ! $config{rebuild}) {
- error("$dest already exists and was not rendered from $src before");
- }
-} #}}}
-
sub mtime ($) { #{{{
my $file=shift;
my $content=readfile($srcfile);
my $page=pagename($file);
delete $depends{$page};
+ will_render($page, htmlpage($page), 1);
$content=filter($page, $content);
$content=linkify($page, $page, $content);
$content=htmlize($page, $type, $content);
- check_overwrite("$config{destdir}/".htmlpage($page), $page);
writefile(htmlpage($page), $config{destdir},
genpage($page, $content, mtime($srcfile)));
$oldpagemtime{$page}=time;
- $renderedfiles{$page}=htmlpage($page);
}
else {
my $content=readfile($srcfile, 1);
$links{$file}=[];
delete $depends{$file};
- check_overwrite("$config{destdir}/$file", $file);
+ will_render($file, $file, 1);
writefile($file, $config{destdir}, $content, 1);
$oldpagemtime{$file}=time;
- $renderedfiles{$file}=$file;
}
} #}}}
if (! $exists{$page}) {
debug("removing old page $page");
push @del, $pagesources{$page};
- prune($config{destdir}."/".$renderedfiles{$page});
- delete $renderedfiles{$page};
+ $renderedfiles{$page}=[];
$oldpagemtime{$page}=0;
+ prune($config{destdir}."/".$_)
+ foreach @{$oldrenderedfiles{$page}};
delete $pagesources{$page};
}
}
}
}
+ # Remove no longer rendered files.
+ foreach my $src (keys %rendered) {
+ my $page=pagename($src);
+ foreach my $file (@{$oldrenderedfiles{$page}}) {
+ if (! grep { $_ eq $file } @{$renderedfiles{$page}}) {
+ debug("removing $file, no longer rendered by $page");
+ prune($config{destdir}."/".$file);
+ }
+ }
+ }
+
if (@del) {
run_hooks(delete => sub { shift->(@del) });
}
+ikiwiki (1.29) unstable; urgency=low
+
+ Wikis need to be rebuilt on upgrade to this version. If you listed your wiki
+ in /etc/ikiwiki/wikilist this will be done automatically when the Debian
+ package is upgraded. Or use ikiwiki-mass-rebuild to force a rebuild.
+
+ There is a change to the plugin interface in this version. Plugins that use
+ %renderedfiles will need to be updated, as the hash's values are now arrays
+ of rendered files. Plugins that cause a page to render additional files
+ should use the new will_render function to register the files.
+
+ -- Joey Hess <joeyh@debian.org> Sun, 8 Oct 2006 17:27:56 -0400
+
ikiwiki (1.22) unstable; urgency=low
Due to some changes in the CSS, wikis should be rebuilt on upgrade to this
version. If you listed your wiki in /etc/ikiwiki/wikilist this will be done
- automatically when the Debian package is upgraded. Or use ikiiki-mass-rebuild
+ automatically when the Debian package is upgraded. Or use ikiwiki-mass-rebuild
to force a rebuild.
If you have modified versions of ikiwiki's html templates, you will need
using HTTP Authentication instead of ikiwiki's built in authentication.
Useful for eg, large sites with their own previously existing user auth
setup. Closes: #384534
-
- -- Joey Hess <joeyh@debian.org> Mon, 2 Oct 2006 18:50:29 -0400
+ * Change %renderedfiles to store an array of files rendered from a given
+ source file, to allow tracking of extra rendered files like rss feeds.
+ * Note that plugins that accessed this variable will need to be updated!
+ The plugin interface has been increased to version 1.01 for this change.
+ * Add will_render function to the plugin interface, used to register that a
+ page renders a destination file, and do some security checks.
+ * Use will_render in the inline and linkmap plugins.
+ * Previously but no longer rendered files will be cleaned up.
+ * You will need to rebuild your wiki on upgrade to this version.
+
+ -- Joey Hess <joeyh@debian.org> Sun, 8 Oct 2006 16:53:17 -0400
ikiwiki (1.28) unstable; urgency=low
# Change this when some incompatible change is made that requires
# rebuilding all wikis.
-firstcompat=1.22
+firstcompat=1.29
if [ "$1" = configure ] && \
dpkg --compare-versions "$2" lt "$firstcompat"; then
not be deleted.
(The linkmap plugin has the same problem with the png files it creates.)
+
+[[bugs/done]]
1. Avoids any security issues with imagemagick.
2. Avoids issue of how to clean up old scaled images that are no longer being
used. (Granted, this is a general ikiwiki problem that will eventually
- be fixed in a general way.)
+ be fixed in a general way. (Update: now fixed in a general way, use the
+ will_render function.))
3. Makes clicking on thumbnails display the full version really fast, since
it's cached. :-)
-
--[[Joey]]
* `%links` lists the names of each page that a page links to, in an array
reference.
-* `%renderedfiles` contains the name of the file rendered by a page.
+* `%renderedfiles` lists names of the files rendered by a page, in an array
+ reference.
* `%pagesources` contains the name of the source file for a page.
### Library functions
If the destination directory doesn't exist, it will first be created.
+### `will_render($$)`
+
+Given a page name and a destination file name (not including the base
+destination directory), register that the page will result in that file
+being rendered. It's important to call this before writing to any file in
+the destination directory.
+
#### `pagetype($)`
Given the name of a source file, returns the type of page it is, if it's
foreach my $page (@existing_pages) {
$IkiWiki::pagecase{lc $page}=$page;
$links{$page}=[];
- $renderedfiles{"$page.mdwn"}=$page;
+ $renderedfiles{"$page.mdwn"}=[$page];
}
%config=IkiWiki::defaultconfig();