* Add a destpage parameter to the filter hook.

* Fix links to smilies generated by the smiley plugin for inlined pages. The
  old links were often wrong, but often still worked by accident.
master
joey 2007-05-17 19:55:11 +00:00
parent fca6ab6def
commit cf35ee04cd
13 changed files with 29 additions and 21 deletions

View File

@ -651,12 +651,14 @@ sub preprocess ($$$;$$) { #{{{
return $content;
} #}}}
sub filter ($$) { #{{{
sub filter ($$$) { #{{{
my $page=shift;
my $destpage=shift;
my $content=shift;
run_hooks(filter => sub {
$content=shift->(page => $page, content => $content);
$content=shift->(page => $page, destpage => $destpage,
content => $content);
});
return $content;

View File

@ -401,7 +401,7 @@ sub cgi_editpage ($$) { #{{{
htmlize($page, $type,
linkify($page, "",
preprocess($page, $page,
filter($page, $form->field('editcontent')), 0, 1))));
filter($page, $page, $form->field('editcontent')), 0, 1))));
}
else {
$form->tmpl_param("page_preview", "");

View File

@ -56,7 +56,7 @@ sub preprocess_if (@) { #{{{
$ret="";
}
return IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page}, $ret));
IkiWiki::filter($params{page}, $params{destpage}, $ret));
} # }}}
package IkiWiki::PageSpec;

View File

@ -212,7 +212,7 @@ sub preprocess_inline (@) { #{{{
$ret.="\n".
linkify($page, $params{page},
preprocess($page, $params{page},
filter($page,
filter($page, $params{page},
readfile(srcfile($file)))));
}
}
@ -266,7 +266,7 @@ sub get_inline_content ($$) { #{{{
return htmlize($page, $type,
linkify($page, $destpage,
preprocess($page, $destpage,
filter($page,
filter($page, $destpage,
readfile(srcfile($file))))));
}
else {

View File

@ -24,7 +24,7 @@ sub preprocess (@) { #{{{
}
else {
$params{text}=IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page}, $params{text}));
IkiWiki::filter($params{page}, $params{destpage}, $params{text}));
return "<a name=\"more\"></a>\n\n".$params{text};
}
}

View File

@ -30,7 +30,7 @@ sub sidebar_content ($) { #{{{
return IkiWiki::htmlize($page, $sidebar_type,
IkiWiki::linkify($sidebar_page, $page,
IkiWiki::preprocess($sidebar_page, $page,
IkiWiki::filter($sidebar_page, $content))));
IkiWiki::filter($sidebar_page, $page, $content))));
}
} # }}}

View File

@ -36,7 +36,7 @@ sub filter (@) { #{{{
build_regexp() unless defined $smiley_regexp;
$params{content} =~ s{(?:^|(?<=\s))(\\?)$smiley_regexp(?:(?=\s)|$)}{
$1 ? $2 : htmllink($params{page}, $params{page}, $smileys{$2}, linktext => $2)
$1 ? $2 : htmllink($params{page}, $params{destpage}, $smileys{$2}, linktext => $2)
}egs if length $smiley_regexp;
return $params{content};

View File

@ -50,7 +50,7 @@ sub preprocess (@) { #{{{
}
return IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page},
IkiWiki::filter($params{page}, $params{destpage},
$template->output));
} # }}}

View File

@ -89,7 +89,7 @@ sub preprocess_toggleable (@) { #{{{
# Preprocess the text to expand any preprocessor directives
# embedded inside it.
$params{text}=IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page}, $params{text}));
IkiWiki::filter($params{page}, $params{destpage}, $params{text}));
my $id=genid($params{page}, $params{id});

View File

@ -159,7 +159,7 @@ sub scan ($) { #{{{
# Always needs to be done, since filters might add links
# to the content.
$content=filter($page, $content);
$content=filter($page, $page, $content);
my @links;
while ($content =~ /(?<!\\)$config{wiki_link_regexp}/g) {
@ -186,15 +186,15 @@ sub render ($) { #{{{
my $type=pagetype($file);
my $srcfile=srcfile($file);
if (defined $type) {
my $content=readfile($srcfile);
my $page=pagename($file);
delete $depends{$page};
will_render($page, htmlpage($page), 1);
$content=filter($page, $content);
$content=preprocess($page, $page, $content);
$content=linkify($page, $page, $content);
$content=htmlize($page, $type, $content);
my $content=htmlize($page, $type,
linkify($page, $page,
preprocess($page, $page,
filter($page, $page,
readfile($srcfile)))));
writefile(htmlpage($page), $config{destdir},
genpage($page, $content, mtime($srcfile)));
@ -454,7 +454,7 @@ sub commandline_render () { #{{{
my $content=readfile($srcfile);
my $page=pagename($file);
$pagesources{$page}=$file;
$content=filter($page, $content);
$content=filter($page, $page, $content);
$content=preprocess($page, $page, $content);
$content=linkify($page, $page, $content);
$content=htmlize($page, $type, $content);

5
debian/changelog vendored
View File

@ -36,8 +36,11 @@ ikiwiki (2.1) UNRELEASED; urgency=low
- If the password is empty in preferences, don't clear the existing
password.
- Actually check the confirm password field, even if it's left empty.
* Add a destpage parameter to the filter hook.
* Fix links to smilies generated by the smiley plugin for inlined pages. The
old links were often wrong, but often still worked by accident.
-- Joey Hess <joeyh@debian.org> Thu, 17 May 2007 04:02:04 -0400
-- Joey Hess <joeyh@debian.org> Thu, 17 May 2007 15:14:42 -0400
ikiwiki (2.00) unstable; urgency=low

View File

@ -1,3 +1,6 @@
RSS output contains relative links. Ie.
http://kitenet.net/~joey/blog/index.rss contains a link to
http://kitenet.net/~joey/blog/../blog.html
> I think I've fixed the last of these, but not 100% sure. Calling it
> [[done]] for now. --[[Joey]]

View File

@ -76,8 +76,8 @@ adding or removing files from it.
hook(type => "filter", id => "foo", call => \&filter);
Runs on the raw source of a page, before anything else touches it, and can
make arbitrary changes. The function is passed named parameters `page` and
`content` and should return the filtered content.
make arbitrary changes. The function is passed named parameters "page",
"destpage", and "content". It should return the filtered content.
### preprocess