From: joey Date: Thu, 17 May 2007 19:55:11 +0000 (+0000) Subject: * Add a destpage parameter to the filter hook. X-Git-Tag: 2.1~17 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cf35ee04cddd7b9b39636499dd24b689443c0e97;p=ikiwiki.git * 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. --- diff --git a/IkiWiki.pm b/IkiWiki.pm index aea5b7abf..a0b902794 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -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; diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index d92bdd330..3b1cab9a8 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -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", ""); diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm index 6c14361f7..68ed36cc9 100644 --- a/IkiWiki/Plugin/conditional.pm +++ b/IkiWiki/Plugin/conditional.pm @@ -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; diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 3c029e001..063673730 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -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 { diff --git a/IkiWiki/Plugin/more.pm b/IkiWiki/Plugin/more.pm index 6a34682ba..667cd6415 100644 --- a/IkiWiki/Plugin/more.pm +++ b/IkiWiki/Plugin/more.pm @@ -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 "\n\n".$params{text}; } } diff --git a/IkiWiki/Plugin/sidebar.pm b/IkiWiki/Plugin/sidebar.pm index f0dd0ca03..a49726768 100644 --- a/IkiWiki/Plugin/sidebar.pm +++ b/IkiWiki/Plugin/sidebar.pm @@ -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)))); } } # }}} diff --git a/IkiWiki/Plugin/smiley.pm b/IkiWiki/Plugin/smiley.pm index 1a9833e6e..96e714d3d 100644 --- a/IkiWiki/Plugin/smiley.pm +++ b/IkiWiki/Plugin/smiley.pm @@ -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}; diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index b169f7e75..c87ba5102 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -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)); } # }}} diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm index 4a16ef32c..3f9c48672 100644 --- a/IkiWiki/Plugin/toggle.pm +++ b/IkiWiki/Plugin/toggle.pm @@ -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}); diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 92993fd95..ef4d11235 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -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 =~ /(? Thu, 17 May 2007 04:02:04 -0400 + -- Joey Hess Thu, 17 May 2007 15:14:42 -0400 ikiwiki (2.00) unstable; urgency=low diff --git a/doc/bugs/rss_output_relative_links.mdwn b/doc/bugs/rss_output_relative_links.mdwn index ff607cbb3..ba5f90867 100644 --- a/doc/bugs/rss_output_relative_links.mdwn +++ b/doc/bugs/rss_output_relative_links.mdwn @@ -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]] diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 9d85d4a9f..6593ab018 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -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