summaryrefslogtreecommitdiff
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
parent2f9d9c9ef58af5bc1315e98db147349a2b018cd2 (diff)
* 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.
-rw-r--r--IkiWiki.pm13
-rw-r--r--IkiWiki/CGI.pm3
-rw-r--r--IkiWiki/Plugin/img.pm29
-rw-r--r--IkiWiki/Plugin/inline.pm1
-rw-r--r--debian/changelog10
-rw-r--r--doc/plugins/write.mdwn8
-rw-r--r--po/ikiwiki.pot24
7 files changed, 57 insertions, 31 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index ed74ff85e..763f24e6c 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -17,9 +17,7 @@ our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
displaytime will_render gettext
%config %links %renderedfiles %pagesources);
our $VERSION = 1.02; # plugin interface version, next is ikiwiki version
-our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
-my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
-
+our $version="1.45";my $installdir="/usr";
# Optimisation.
use Memoize;
memoize("abs2rel");
@@ -506,11 +504,17 @@ sub linkify ($$$) { #{{{
} #}}}
my %preprocessing;
-sub preprocess ($$$;$) { #{{{
+our $preprocess_preview=0;
+sub preprocess ($$$;$$) { #{{{
my $page=shift; # the page the data comes from
my $destpage=shift; # the page the data will appear in (different for inline)
my $content=shift;
my $scan=shift;
+ my $preview=shift;
+
+ # Using local because it needs to be set within any nested calls
+ # of this function.
+ local $preprocess_preview=$preview if defined $preview;
my $handle=sub {
my $escape=shift;
@@ -562,6 +566,7 @@ sub preprocess ($$$;$) { #{{{
@params,
page => $page,
destpage => $destpage,
+ preview => $preprocess_preview,
);
$preprocessing{$page}--;
return $ret;
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;
}
diff --git a/debian/changelog b/debian/changelog
index 34c36c06e..d266ee829 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,8 +6,14 @@ ikiwiki (1.45) UNRELEASED; urgency=low
* Add "template" option to inline plugin to allow for use of customised
templates.
* Add titlepage template for inline plugin.
-
- -- Joey Hess <joeyh@debian.org> Tue, 6 Mar 2007 14:16:21 -0500
+ * 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.
+
+ -- Joey Hess <joeyh@debian.org> Tue, 6 Mar 2007 16:41:53 -0500
ikiwiki (1.44) unstable; urgency=low
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 889057e69..5547ae699 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -96,9 +96,11 @@ Each time the directive is processed, the referenced function (`preprocess`
in the example above) is called, and is passed named parameters. A "page"
parameter gives the name of the page that embedded the preprocessor
directive, while a "destpage" parameter gives the name of the page the
-content is going to (different for inlined pages). All parameters included
-in the directive are included as named parameters as well. Whatever the
-function returns goes onto the page in place of the directive.
+content is going to (different for inlined pages), and a "preview"
+parameter is set to a true value if the page is being previewed. All
+parameters included in the directive are included as named parameters as
+well. Whatever the function returns goes onto the page in place of the
+directive.
Note that if the [[htmlscrubber]] is enabled, html in
[[PreProcessorDirective]] output is sanitised, which may limit what your
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index c49dc6b2d..c15ec1fbe 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-03-02 21:27-0500\n"
+"POT-Creation-Date: 2007-03-06 17:08-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -29,28 +29,28 @@ msgstr ""
msgid "%s is not an editable page"
msgstr ""
-#: ../IkiWiki/CGI.pm:428 ../IkiWiki/Plugin/brokenlinks.pm:24
-#: ../IkiWiki/Plugin/inline.pm:171 ../IkiWiki/Plugin/opendiscussion.pm:17
+#: ../IkiWiki/CGI.pm:427 ../IkiWiki/Plugin/brokenlinks.pm:24
+#: ../IkiWiki/Plugin/inline.pm:172 ../IkiWiki/Plugin/opendiscussion.pm:17
#: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:97
#: ../IkiWiki/Render.pm:165
msgid "discussion"
msgstr ""
-#: ../IkiWiki/CGI.pm:474
+#: ../IkiWiki/CGI.pm:473
#, perl-format
msgid "creating %s"
msgstr ""
-#: ../IkiWiki/CGI.pm:491 ../IkiWiki/CGI.pm:527 ../IkiWiki/CGI.pm:571
+#: ../IkiWiki/CGI.pm:490 ../IkiWiki/CGI.pm:526 ../IkiWiki/CGI.pm:570
#, perl-format
msgid "editing %s"
msgstr ""
-#: ../IkiWiki/CGI.pm:668
+#: ../IkiWiki/CGI.pm:667
msgid "You are banned."
msgstr ""
-#: ../IkiWiki/CGI.pm:700
+#: ../IkiWiki/CGI.pm:699
msgid "login failed, perhaps you need to turn on cookies?"
msgstr ""
@@ -121,21 +121,21 @@ msgstr ""
msgid "Must specify url to wiki with --url when using --rss or --atom"
msgstr ""
-#: ../IkiWiki/Plugin/inline.pm:102
+#: ../IkiWiki/Plugin/inline.pm:103
#, perl-format
msgid "unknown sort type %s"
msgstr ""
-#: ../IkiWiki/Plugin/inline.pm:142
+#: ../IkiWiki/Plugin/inline.pm:143
#, perl-format
msgid "nonexistant template %s"
msgstr ""
-#: ../IkiWiki/Plugin/inline.pm:179 ../IkiWiki/Render.pm:101
+#: ../IkiWiki/Plugin/inline.pm:180 ../IkiWiki/Render.pm:101
msgid "Discussion"
msgstr ""
-#: ../IkiWiki/Plugin/inline.pm:394
+#: ../IkiWiki/Plugin/inline.pm:395
msgid "RPC::XML::Client not found, not pinging"
msgstr ""
@@ -454,7 +454,7 @@ msgstr ""
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:557
+#: ../IkiWiki.pm:565
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr ""