aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-03-06 22:37:05 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-03-06 22:37:05 +0000
commit1202b4fd7b305b223d64f9e9f24424b72c81ab6d (patch)
tree2cb5344f43eff42b1bdb45bc8ae2c2e2ef3b663b /IkiWiki
parent2f9d9c9ef58af5bc1315e98db147349a2b018cd2 (diff)
downloadikiwiki-1202b4fd7b305b223d64f9e9f24424b72c81ab6d.tar
ikiwiki-1202b4fd7b305b223d64f9e9f24424b72c81ab6d.tar.gz
* Add preview parameter to preprocesser calls, use this rather than the
previous ugly hack used to avoid writing rss feeds in previews. * Fix the img plugin to avoid overwriting images in previews. Instead it does all the work to make sure the resizing works, and dummys up a resized image using width and height attributes. * Also fixes img preview display, the links were wrong in preview before.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/CGI.pm3
-rw-r--r--IkiWiki/Plugin/img.pm29
-rw-r--r--IkiWiki/Plugin/inline.pm1
3 files changed, 23 insertions, 10 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index cd6ddc034..8d86d8d3e 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -396,12 +396,11 @@ sub cgi_editpage ($$) { #{{{
value => $content, force => 1);
$form->field(name => "comments",
value => $comments, force => 1);
- $config{rss}=$config{atom}=0; # avoid preview writing a feed!
$form->tmpl_param("page_preview",
htmlize($page, $type,
linkify($page, "",
preprocess($page, $page,
- filter($page, $content)))));
+ filter($page, $content), 0, 1))));
}
else {
$form->tmpl_param("page_preview", "");
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm
index 2a6533e39..9135c688f 100644
--- a/IkiWiki/Plugin/img.pm
+++ b/IkiWiki/Plugin/img.pm
@@ -49,7 +49,6 @@ sub preprocess (@) { #{{{
my $outfile = "$config{destdir}/$dir/${w}x${h}-$base";
$imglink = "$dir/${w}x${h}-$base";
- will_render($params{page}, $imglink);
if (-e $outfile && (-M srcfile($file) >= -M $outfile)) {
$r = $im->Read($outfile);
@@ -62,8 +61,15 @@ sub preprocess (@) { #{{{
$r = $im->Resize(geometry => "${w}x${h}");
return "[[img failed to resize: $r]]" if $r;
- my @blob = $im->ImageToBlob();
- writefile($imglink, $config{destdir}, $blob[0], 1);
+ # don't actually write file in preview mode
+ if (! $params{preview}) {
+ will_render($params{page}, $imglink);
+ my @blob = $im->ImageToBlob();
+ writefile($imglink, $config{destdir}, $blob[0], 1);
+ }
+ else {
+ $imglink = $file;
+ }
}
}
else {
@@ -74,12 +80,19 @@ sub preprocess (@) { #{{{
add_depends($imglink, $params{page});
- return '<a href="'.
- IkiWiki::abs2rel($file, IkiWiki::dirname($params{destpage})).
- '"><img src="'.
- IkiWiki::abs2rel($imglink, IkiWiki::dirname($params{destpage})).
+ my ($fileurl, $imgurl);
+ if (! $params{preview}) {
+ $fileurl=IkiWiki::abs2rel($file, IkiWiki::dirname($params{destpage}));
+ $imgurl=IkiWiki::abs2rel($imglink, IkiWiki::dirname($params{destpage}));
+ }
+ else {
+ $fileurl="$config{url}/$file";
+ $imgurl="$config{url}/$imglink";
+ }
+
+ return '<a href="'.$fileurl.'"><img src="'.$imgurl.
'" alt="'.$alt.'" width="'.$im->Get("width").
'" height="'.$im->Get("height").'" /></a>';
} #}}}
-1;
+1
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index d49993e5f..6656a821c 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -67,6 +67,7 @@ sub preprocess_inline (@) { #{{{
my $atom=($config{atom} && exists $params{atom}) ? yesno($params{atom}) : $config{atom};
my $quick=exists $params{quick} ? yesno($params{quick}) : 0;
my $feeds=exists $params{feeds} ? yesno($params{feeds}) : !$quick;
+ $feeds=0 if $params{preview};
if (! exists $params{show} && ! $archive) {
$params{show}=10;
}