Because the search plugin needed it, also because it's one of the few
plugins that didn't already have it.
I also considered adding it to htmlize, but I really cannot imagine caring
what the destpage is when htmlizing. (I'll probably be poven wrong later.)
15 files changed:
-sub htmlize ($$$) { #{{{
+sub htmlize ($$$$) { #{{{
my $type=shift;
my $content=shift;
my $type=shift;
my $content=shift;
run_hooks(sanitize => sub {
$content=shift->(
page => $page,
run_hooks(sanitize => sub {
$content=shift->(
page => $page,
content => $content,
);
});
content => $content,
);
});
);
});
$form->tmpl_param("page_preview",
);
});
$form->tmpl_param("page_preview",
+ htmlize($page, $page, $type,
linkify($page, $page,
preprocess($page, $page,
filter($page, $page, $content), 0, 1))));
linkify($page, $page,
preprocess($page, $page,
filter($page, $page, $content), 0, 1))));
my $type=pagetype($file);
if (defined $type) {
$nested++;
my $type=pagetype($file);
if (defined $type) {
$nested++;
- my $ret=htmlize($page, $type,
+ my $ret=htmlize($page, $destpage, $type,
linkify($page, $destpage,
preprocess($page, $destpage,
filter($page, $destpage,
linkify($page, $destpage,
preprocess($page, $destpage,
filter($page, $destpage,
my $page = shift;
my $destpage = shift;
my $page = shift;
my $destpage = shift;
- return IkiWiki::htmlize($page, pagetype($pagesources{$page}),
+ return IkiWiki::htmlize($page, $destpage, pagetype($pagesources{$page}),
IkiWiki::linkify($page, $destpage,
IkiWiki::preprocess($page, $destpage, shift)));
}
IkiWiki::linkify($page, $destpage,
IkiWiki::preprocess($page, $destpage, shift)));
}
sub index (@) { #{{{
my %params=@_;
sub index (@) { #{{{
my %params=@_;
- return $params{content} if %IkiWiki::preprocessing;
+ return $params{content} if $IkiWiki::preprocessing{$params{destpage}};
my $db=xapiandb();
my $doc=Search::Xapian::Document->new();
my $db=xapiandb();
my $doc=Search::Xapian::Document->new();
$title=IkiWiki::pagetitle($params{page});
}
$title=IkiWiki::pagetitle($params{page});
}
- # Remove any html from text to be indexed.
+ # Remove html from text to be indexed.
if (! defined $scrubber) {
eval q{use HTML::Scrubber};
if (! $@) {
if (! defined $scrubber) {
eval q{use HTML::Scrubber};
if (! $@) {
my $content=readfile(srcfile($sidebar_file));
return unless length $content;
my $content=readfile(srcfile($sidebar_file));
return unless length $content;
- return IkiWiki::htmlize($page, $sidebar_type,
+ return IkiWiki::htmlize($sidebar_page, $page, $sidebar_type,
IkiWiki::linkify($sidebar_page, $page,
IkiWiki::preprocess($sidebar_page, $page,
IkiWiki::filter($sidebar_page, $page, $content))));
IkiWiki::linkify($sidebar_page, $page,
IkiWiki::preprocess($sidebar_page, $page,
IkiWiki::filter($sidebar_page, $page, $content))));
my $page = shift;
my $destpage = shift;
my $page = shift;
my $destpage = shift;
- return IkiWiki::htmlize($page, pagetype($pagesources{$page}),
+ return IkiWiki::htmlize($page, $destpage, pagetype($pagesources{$page}),
IkiWiki::preprocess($page, $destpage, shift));
}
IkiWiki::preprocess($page, $destpage, shift));
}
foreach my $param (keys %params) {
if ($template->query(name => $param)) {
$template->param($param =>
foreach my $param (keys %params) {
if ($template->query(name => $param)) {
$template->param($param =>
- IkiWiki::htmlize($params{page},
+ IkiWiki::htmlize($params{page}, $params{destpage},
pagetype($pagesources{$params{page}}),
$params{$param}));
}
pagetype($pagesources{$params{page}}),
$params{$param}));
}
will_render($page, htmlpage($page), 1);
return if $type=~/^_/;
will_render($page, htmlpage($page), 1);
return if $type=~/^_/;
- my $content=htmlize($page, $type,
+ my $content=htmlize($page, $page, $type,
linkify($page, $page,
preprocess($page, $page,
filter($page, $page,
linkify($page, $page,
preprocess($page, $page,
filter($page, $page,
$content=filter($page, $page, $content);
$content=preprocess($page, $page, $content);
$content=linkify($page, $page, $content);
$content=filter($page, $page, $content);
$content=preprocess($page, $page, $content);
$content=linkify($page, $page, $content);
- $content=htmlize($page, $type, $content);
+ $content=htmlize($page, $page, $type, $content);
$pagemtime{$page}=(stat($srcfile))[9];
print genpage($page, $content);
$pagemtime{$page}=(stat($srcfile))[9];
print genpage($page, $content);
* Filter hooks are no longer called during the scan phase. This will
prevent wikilinks added by filters from being scanned properly. But
no known filter hook does that, so let's not waste time on it.
* Filter hooks are no longer called during the scan phase. This will
prevent wikilinks added by filters from being scanned properly. But
no known filter hook does that, so let's not waste time on it.
+ * Pass a destpage parameter to the sanitize hook.
-- Joey Hess <joeyh@debian.org> Fri, 30 May 2008 19:08:54 -0400
-- Joey Hess <joeyh@debian.org> Fri, 30 May 2008 19:08:54 -0400
and the [[cpan Search::Xapian]] perl module. (The [[cpan HTML::Scrubber]]
perl module will also be used, if available.)
and the [[cpan Search::Xapian]] perl module. (The [[cpan HTML::Scrubber]]
perl module will also be used, if available.)
-Ikiwiki will handle indexing new and changed page contents. Note that it
-indexes page contents before they are preprocessed and converted to html,
-as this tends to produce less noisy search results. Also, since it only
-indexes page contents, files copied by the [[rawhtml]] plugin will not be
-indexed, nor will other types of data files.
+Ikiwiki will handle indexing new and changed page contents. Note that since
+it only indexes page contents, files copied by the [[rawhtml]] plugin will
+not be indexed, nor will other types of data files.
There is one setting you may need to use in the config file. `omega_cgi`
should point to the location of the omega cgi program. The default location
There is one setting you may need to use in the config file. `omega_cgi`
should point to the location of the omega cgi program. The default location
Use this to implement html sanitization or anything else that needs to
modify the body of a page after it has been fully converted to html.
Use this to implement html sanitization or anything else that needs to
modify the body of a page after it has been fully converted to html.
-The function is passed named parameters: "page" and "content", and
-should return the sanitized content.
+The function is passed named parameters: "page", "destpage", and "content",
+and should return the sanitized content.
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-06-04 00:52-0400\n"
+"POT-Creation-Date: 2008-06-04 01:17-0400\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"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr ""
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr ""
%config=IkiWiki::defaultconfig();
$config{srcdir}=$config{destdir}="/dev/null";
IkiWiki::loadplugins(); IkiWiki::checkconfig();
%config=IkiWiki::defaultconfig();
$config{srcdir}=$config{destdir}="/dev/null";
IkiWiki::loadplugins(); IkiWiki::checkconfig();
-ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test1.mdwn")));
-ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test3.mdwn")),
+ok(IkiWiki::htmlize("foo", "foo", "mdwn", readfile("t/test1.mdwn")));
+ok(IkiWiki::htmlize("foo", "foo", "mdwn", readfile("t/test3.mdwn")),
IkiWiki::loadplugins();
IkiWiki::checkconfig();
IkiWiki::loadplugins();
IkiWiki::checkconfig();
-is(IkiWiki::htmlize("foo", "mdwn", "foo\n\nbar\n"), "<p>foo</p>\n\n<p>bar</p>\n",
+is(IkiWiki::htmlize("foo", "foo", "mdwn", "foo\n\nbar\n"), "<p>foo</p>\n\n<p>bar</p>\n",
-is(IkiWiki::htmlize("foo", "mdwn", readfile("t/test1.mdwn")),
+is(IkiWiki::htmlize("foo", "foo", "mdwn", readfile("t/test1.mdwn")),
Encode::decode_utf8(qq{<p><img src="../images/o.jpg" alt="o" title="ó" />\nóóóóó</p>\n}),
"utf8; bug #373203");
Encode::decode_utf8(qq{<p><img src="../images/o.jpg" alt="o" title="ó" />\nóóóóó</p>\n}),
"utf8; bug #373203");
-ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test2.mdwn")),
+ok(IkiWiki::htmlize("foo", "foo", "mdwn", readfile("t/test2.mdwn")),
"this file crashes markdown if it's fed in as decoded utf-8");
sub gotcha {
"this file crashes markdown if it's fed in as decoded utf-8");
sub gotcha {
- my $html=IkiWiki::htmlize("foo", "mdwn", shift);
+ my $html=IkiWiki::htmlize("foo", "foo", "mdwn", shift);
return $html =~ /GOTCHA/;
}
ok(!gotcha(q{<a href="javascript:alert('GOTCHA')">click me</a>}),
return $html =~ /GOTCHA/;
}
ok(!gotcha(q{<a href="javascript:alert('GOTCHA')">click me</a>}),
be perverse and assume it is?)");
ok(gotcha(q{<img src="javascript.png?GOTCHA">}), "not javascript");
ok(gotcha(q{<a href="javascript.png?GOTCHA">foo</a>}), "not javascript");
be perverse and assume it is?)");
ok(gotcha(q{<img src="javascript.png?GOTCHA">}), "not javascript");
ok(gotcha(q{<a href="javascript.png?GOTCHA">foo</a>}), "not javascript");
-is(IkiWiki::htmlize("foo", "mdwn",
+is(IkiWiki::htmlize("foo", "foo", "mdwn",
q{<img alt="foo" src="foo.gif">}),
q{<img alt="foo" src="foo.gif">}, "img with alt tag allowed");
q{<img alt="foo" src="foo.gif">}),
q{<img alt="foo" src="foo.gif">}, "img with alt tag allowed");
-is(IkiWiki::htmlize("foo", "mdwn",
+is(IkiWiki::htmlize("foo", "foo", "mdwn",
q{<a href="http://google.com/">}),
q{<a href="http://google.com/">}, "absolute url allowed");
q{<a href="http://google.com/">}),
q{<a href="http://google.com/">}, "absolute url allowed");
-is(IkiWiki::htmlize("foo", "mdwn",
+is(IkiWiki::htmlize("foo", "foo", "mdwn",
q{<a href="foo.html">}),
q{<a href="foo.html">}, "relative url allowed");
q{<a href="foo.html">}),
q{<a href="foo.html">}, "relative url allowed");
-is(IkiWiki::htmlize("foo", "mdwn",
+is(IkiWiki::htmlize("foo", "foo", "mdwn",
q{<span class="foo">bar</span>}),
q{<span class="foo">bar</span>}, "class attribute allowed");
q{<span class="foo">bar</span>}),
q{<span class="foo">bar</span>}, "class attribute allowed");