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.
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");
} #}}}
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;
@params,
page => $page,
destpage => $destpage,
+ preview => $preprocess_preview,
);
$preprocessing{$page}--;
return $ret;
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", "");
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);
$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 {
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
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;
}
* 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
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
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"
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 ""
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 ""
#. 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 ""