From d3aaf6e01fe7f90a530e640957b5908d5dba2f7f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 May 2010 22:19:14 -0400 Subject: fix pagediff to not display as "preview" I think originally, the page preview header was not displayed, so diff was hacked in using it. --- IkiWiki/Plugin/editdiff.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/editdiff.pm b/IkiWiki/Plugin/editdiff.pm index d8f53a42e..015ce9c14 100644 --- a/IkiWiki/Plugin/editdiff.pm +++ b/IkiWiki/Plugin/editdiff.pm @@ -71,7 +71,7 @@ sub formbuilder_setup { $content=~s/\r/\n/g; my $diff = diff(srcfile($pagesources{$page}), $content); - $form->tmpl_param("page_preview", $diff); + $form->tmpl_param("page_diff", $diff); } } -- cgit v1.2.3 From 4c320176c080038f95131f39ecaca3101b4b1745 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 May 2010 22:27:12 -0400 Subject: simplify formbuilder stylesheet specification Since all forms are wrapped in a template that defines the actual stylesheets, formbuilder just has to be told to turn on stylesheet mode, not what file is the style sheet. --- IkiWiki/CGI.pm | 4 ++-- IkiWiki/Plugin/remove.pm | 2 +- IkiWiki/Plugin/rename.pm | 2 +- IkiWiki/Plugin/websetup.pm | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 07369ac10..49a505514 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -108,7 +108,7 @@ sub cgi_signin ($$) { action => $config{cgiurl}, header => 0, template => {type => 'div'}, - stylesheet => baseurl()."style.css", + stylesheet => 1, ); my $buttons=["Login"]; @@ -187,7 +187,7 @@ sub cgi_prefs ($$) { params => $q, action => $config{cgiurl}, template => {type => 'div'}, - stylesheet => baseurl()."style.css", + stylesheet => 1, fieldsets => [ [login => gettext("Login")], [preferences => gettext("Preferences")], diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index 0fc180f69..a46294e78 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -103,7 +103,7 @@ sub confirmation_form ($$) { javascript => 0, params => $q, action => $config{cgiurl}, - stylesheet => IkiWiki::baseurl()."style.css", + stylesheet => 1, fields => [qw{do page}], ); diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index 69e615ead..537e91317 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -126,7 +126,7 @@ sub rename_form ($$$) { javascript => 0, params => $q, action => $config{cgiurl}, - stylesheet => IkiWiki::baseurl()."style.css", + stylesheet => 1, fields => [qw{do page new_name attachment}], ); diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 4d2e611eb..9cb5eb13c 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -293,7 +293,7 @@ sub showform ($$) { ], action => $config{cgiurl}, template => {type => 'div'}, - stylesheet => IkiWiki::baseurl()."style.css", + stylesheet => 1, ); $form->field(name => "do", type => "hidden", value => "setup", -- cgit v1.2.3 From 121e2ffc2f25bf264a68d35e80a9386995fa9e5a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 May 2010 23:07:08 -0400 Subject: Renamed postscan hook to indexhtml, to reflect its changed position. Probably only the search plugin uses it, so this seemed safe. --- IkiWiki/Plugin/search.pm | 2 +- IkiWiki/Plugin/skeleton.pm.example | 6 +++--- IkiWiki/Render.pm | 2 +- debian/changelog | 2 ++ doc/bugs/pagetitle_function_does_not_respect_meta_titles.mdwn | 2 +- doc/plugins/po/discussion.mdwn | 2 +- doc/plugins/write.mdwn | 6 +++--- 7 files changed, 12 insertions(+), 10 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index 9e875c79c..b1f4747fe 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -10,7 +10,7 @@ sub import { hook(type => "getsetup", id => "search", call => \&getsetup); hook(type => "checkconfig", id => "search", call => \&checkconfig); hook(type => "pagetemplate", id => "search", call => \&pagetemplate); - hook(type => "postscan", id => "search", call => \&index); + hook(type => "indexhtml", id => "search", call => \&index); hook(type => "delete", id => "search", call => \&delete); hook(type => "cgi", id => "search", call => \&cgi); } diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example index a404e24af..34713c73b 100644 --- a/IkiWiki/Plugin/skeleton.pm.example +++ b/IkiWiki/Plugin/skeleton.pm.example @@ -20,7 +20,7 @@ sub import { hook(type => "scan", id => "skeleton", call => \&scan); hook(type => "htmlize", id => "skeleton", call => \&htmlize); hook(type => "sanitize", id => "skeleton", call => \&sanitize); - hook(type => "postscan", id => "skeleton", call => \&postscan); + hook(type => "indexhtml", id => "skeleton", call => \&indexhtml); hook(type => "format", id => "skeleton", call => \&format); hook(type => "pagetemplate", id => "skeleton", call => \&pagetemplate); hook(type => "templatefile", id => "skeleton", call => \&templatefile); @@ -118,10 +118,10 @@ sub sanitize (@) { return $params{content}; } -sub postscan (@) { +sub indexhtml (@) { my %params=@_; - debug("skeleton plugin running as postscan"); + debug("skeleton plugin running as indexhtml"); } sub format (@) { diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index e5ba0079b..30e3d4199 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -62,7 +62,7 @@ sub genpage ($$) { my $page=shift; my $content=shift; - run_hooks(postscan => sub { + run_hooks(indexhtml => sub { shift->(page => $page, content => $content); }); diff --git a/debian/changelog b/debian/changelog index 77fd13826..eb67c2bde 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ ikiwiki (3.20100505) UNRELEASED; urgency=low * If you have a locally customised page.tmpl, it needs to be updated to set when BASEURL or FORCEBAREURL is set. * Gave comment and page editing forms some CSS and accessability love. + * Renamed postscan hook to indexhtml, to reflect its changed position, + and typical use. -- Joey Hess Wed, 05 May 2010 18:07:29 -0400 diff --git a/doc/bugs/pagetitle_function_does_not_respect_meta_titles.mdwn b/doc/bugs/pagetitle_function_does_not_respect_meta_titles.mdwn index be14e5126..c6e3cd4fd 100644 --- a/doc/bugs/pagetitle_function_does_not_respect_meta_titles.mdwn +++ b/doc/bugs/pagetitle_function_does_not_respect_meta_titles.mdwn @@ -144,7 +144,7 @@ So, looking at your meta branch: --[[Joey]] has no title, then A will display the link as "B". Now page B is modified and a title is added. Nothing updates "A". The added overhead of rebuilding every page that links to B when B is - changed (as the `postscan` hook of the po plugin does) is IMHO a killer. + changed (as the `indexhtml` hook of the po plugin does) is IMHO a killer. That could be hundreds or thousands of pages, making interactive editing way slow. This is probably the main reason I had not attempted this whole thing myself. IMHO this calls for some kind of intellegent dependency diff --git a/doc/plugins/po/discussion.mdwn b/doc/plugins/po/discussion.mdwn index ab822e76c..27683f1ea 100644 --- a/doc/plugins/po/discussion.mdwn +++ b/doc/plugins/po/discussion.mdwn @@ -513,7 +513,7 @@ finish it at some point in the first quarter of 2009. --[[intrigeri]] >>>> >>>>> Done. --[[intrigeri]] >>> -> * I'm very fearful of the `add_depends` in `postscan`. +> * I'm very fearful of the `add_depends` in `indexhtml`. > Does this make every page depend on every page that links > to it? Won't this absurdly bloat the dependency pagespecs > and slow everything down? And since nicepagetitle is given diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 3b1d770eb..7180237a4 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -39,7 +39,7 @@ built. Now that it knows what pages it needs to build, ikiwiki runs two compile passes. First, it runs `scan` hooks, which collect metadata about the pages. Then it runs a page rendering pipeline, by calling in turn these -hooks: `filter`, `preprocess`, `linkify`, `htmlize`, `postscan`, +hooks: `filter`, `preprocess`, `linkify`, `htmlize`, `indexhtml`, `pagetemplate`, `sanitize`, `format`. After all necessary pages are built, it calls the `change` hook. Finally, @@ -282,9 +282,9 @@ like `Makefile` that have no extension. If `hook` is passed an optional "longname" parameter, this value is used when prompting a user to choose a page type on the edit page form. -### postscan +### indexhtml - hook(type => "postscan", id => "foo", call => \&postscan); + hook(type => "indexhtml", id => "foo", call => \&indexhtml); This hook is called once the page has been converted to html (but before the generated html is put in a template). The most common use is to -- cgit v1.2.3 From ea4967f184bf0a27eaa2dc81da1084780756156a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 May 2010 23:20:48 -0400 Subject: inline: Call indexhtml when inlining internal pages, so their text can be indexed for searching. --- IkiWiki/Plugin/inline.pm | 7 +++++++ IkiWiki/Plugin/search.pm | 6 +++--- IkiWiki/Render.pm | 2 +- debian/changelog | 2 ++ doc/plugins/write.mdwn | 4 ++-- 5 files changed, 15 insertions(+), 6 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 933e30646..715a3d652 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -476,6 +476,13 @@ sub get_inline_content ($$) { filter($page, $destpage, readfile(srcfile($file)))))); $nested--; + if (isinternal($page)) { + # make inlined text of internal pages searchable + run_hooks(indexhtml => sub { + shift->(page => $page, destpage => $page, + content => $ret); + }); + } } if ($cached_destpage ne $destpage) { diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index b1f4747fe..c578b44ab 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -10,7 +10,7 @@ sub import { hook(type => "getsetup", id => "search", call => \&getsetup); hook(type => "checkconfig", id => "search", call => \&checkconfig); hook(type => "pagetemplate", id => "search", call => \&pagetemplate); - hook(type => "indexhtml", id => "search", call => \&index); + hook(type => "indexhtml", id => "search", call => \&indexhtml); hook(type => "delete", id => "search", call => \&delete); hook(type => "cgi", id => "search", call => \&cgi); } @@ -68,7 +68,7 @@ sub pagetemplate (@) { my $scrubber; my $stemmer; -sub index (@) { +sub indexhtml (@) { my %params=@_; setupfiles(); @@ -117,7 +117,7 @@ sub index (@) { eval q{use HTML::Entities}; error $@ if $@; $doc->set_data( - "url=".urlto($params{page}, "")."\n". + "url=".urlto($params{destpage}, "")."\n". "sample=".decode_entities($sample)."\n". "caption=".decode_entities($caption)."\n". "modtime=$IkiWiki::pagemtime{$params{page}}\n". diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 30e3d4199..b0bd8dee0 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -63,7 +63,7 @@ sub genpage ($$) { my $content=shift; run_hooks(indexhtml => sub { - shift->(page => $page, content => $content); + shift->(page => $page, destpage => $page, content => $content); }); my $templatefile; diff --git a/debian/changelog b/debian/changelog index eb67c2bde..10a4912af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ ikiwiki (3.20100505) UNRELEASED; urgency=low * Gave comment and page editing forms some CSS and accessability love. * Renamed postscan hook to indexhtml, to reflect its changed position, and typical use. + * inline: Call indexhtml when inlining internal pages, so their + text can be indexed for searching. -- Joey Hess Wed, 05 May 2010 18:07:29 -0400 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 7180237a4..193005565 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -290,8 +290,8 @@ This hook is called once the page has been converted to html (but before the generated html is put in a template). The most common use is to update search indexes. Added in ikiwiki 2.54. -The function is passed named parameters "page" and "content". Its return -value is ignored. +The function is passed named parameters "page", "destpage", and "content". +Its return value is ignored. ### pagetemplate -- cgit v1.2.3 From 575080d6ef114f24e23c17bd63cf406b22460657 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 May 2010 23:28:40 -0400 Subject: respect permalinks --- IkiWiki/Plugin/search.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index c578b44ab..cc26b7ac1 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -112,12 +112,17 @@ sub indexhtml (@) { } $sample=~s/\n/ /g; + my $url=urlto($params{destpage}, ""); + if (defined $pagestate{$params{page}}{meta}{permalink}) { + $url=$pagestate{$params{page}}{meta}{permalink} + } + # data used by omega # Decode html entities in it, since omega re-encodes them. eval q{use HTML::Entities}; error $@ if $@; $doc->set_data( - "url=".urlto($params{destpage}, "")."\n". + "url=".$url."\n". "sample=".decode_entities($sample)."\n". "caption=".decode_entities($caption)."\n". "modtime=$IkiWiki::pagemtime{$params{page}}\n". -- cgit v1.2.3 From 1678604fe36e2a1397e13aa1b36e7807be8f2bc6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 7 May 2010 00:22:05 -0400 Subject: avoid redir loop when going to an internal page that has no permalink --- IkiWiki/Plugin/goto.pm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm index 03bd682b3..669211691 100644 --- a/IkiWiki/Plugin/goto.pm +++ b/IkiWiki/Plugin/goto.pm @@ -41,14 +41,15 @@ sub cgi_goto ($;$) { IkiWiki::loadindex(); - # If the page is internal (like a comment), see if it has a - # permalink. Comments do. - if (IkiWiki::isinternal($page) && - defined $pagestate{$page}{meta}{permalink}) { - IkiWiki::redirect($q, $pagestate{$page}{meta}{permalink}); + my $link; + if (! IkiWiki::isinternal($page)) { + $link = bestlink("", $page); + } + elsif (defined $pagestate{$page}{meta}{permalink}) { + # Can only redirect to an internal page if it has a + # permalink. + IkiWiki::redirect($q, $pagestate{$page}{meta}{permalink}); } - - my $link = bestlink("", $page); if (! length $link) { IkiWiki::cgi_custom_failure( -- cgit v1.2.3