From f4f099e88e287e12f99c92950af5f8143dc4a8b8 Mon Sep 17 00:00:00 2001 From: Jason Blevins Date: Tue, 28 Oct 2008 21:43:44 -0400 Subject: Bug report re shortcuts during preview --- doc/bugs/cannot_preview_shortcuts.mdwn | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 doc/bugs/cannot_preview_shortcuts.mdwn (limited to 'doc/bugs/cannot_preview_shortcuts.mdwn') diff --git a/doc/bugs/cannot_preview_shortcuts.mdwn b/doc/bugs/cannot_preview_shortcuts.mdwn new file mode 100644 index 000000000..a2fd3533a --- /dev/null +++ b/doc/bugs/cannot_preview_shortcuts.mdwn @@ -0,0 +1,2 @@ +Shortcuts such as \[[!google foo]] do not work when previewing pages. +--[[JasonBlevins]] -- cgit v1.2.3 From 33a0e84ddbb9fe9c068cb40641ccec8554514151 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Oct 2008 14:20:31 -0400 Subject: fix preview of shortcuts Move shortcut processing back to checkconfig, and avoid it failing if the srcdir is not defined. --- IkiWiki/Plugin/shortcut.pm | 18 ++++++++++-------- debian/changelog | 1 + doc/bugs/cannot_preview_shortcuts.mdwn | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'doc/bugs/cannot_preview_shortcuts.mdwn') diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm index 7bfce586f..77131edb0 100644 --- a/IkiWiki/Plugin/shortcut.pm +++ b/IkiWiki/Plugin/shortcut.pm @@ -7,7 +7,7 @@ use IkiWiki 2.00; sub import { #{{{ hook(type => "getsetup", id => "shortcut", call => \&getsetup); - hook(type => "refresh", id => "shortcut", call => \&refresh); + hook(type => "checkconfig", id => "shortcut", call => \&checkconfig); hook(type => "preprocess", id => "shortcut", call => \&preprocess_shortcut); } #}}} @@ -19,14 +19,16 @@ sub getsetup () { #{{{ }, } #}}} -sub refresh () { #{{{ - # Preprocess the shortcuts page to get all the available shortcuts - # defined before other pages are rendered. - my $srcfile=srcfile("shortcuts.mdwn", 1); - if (! defined $srcfile) { - error(gettext("shortcut plugin will not work without a shortcuts.mdwn")); +sub checkconfig () { #{{{ + if (defined $config{srcdir}) { + # Preprocess the shortcuts page to get all the available shortcuts + # defined before other pages are rendered. + my $srcfile=srcfile("shortcuts.mdwn", 1); + if (! defined $srcfile) { + error(gettext("shortcut plugin will not work without a shortcuts.mdwn")); + } + IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile)); } - IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile)); } # }}} sub preprocess_shortcut (@) { #{{{ diff --git a/debian/changelog b/debian/changelog index 299cf1af2..4547cda3d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,7 @@ ikiwiki (2.68) UNRELEASED; urgency=low * Add support for checking pushes from untrusted git committers. This can be used to set up anonymous git pushes, and other similar things. * git: Allow [[sha1_commit]] to be used in the diffurl, to support cgit. + * shortcut: Fix display of shortcuts while previewing. -- Joey Hess Fri, 17 Oct 2008 20:11:02 -0400 diff --git a/doc/bugs/cannot_preview_shortcuts.mdwn b/doc/bugs/cannot_preview_shortcuts.mdwn index a2fd3533a..2e7ef13b7 100644 --- a/doc/bugs/cannot_preview_shortcuts.mdwn +++ b/doc/bugs/cannot_preview_shortcuts.mdwn @@ -1,2 +1,4 @@ Shortcuts such as \[[!google foo]] do not work when previewing pages. --[[JasonBlevins]] + +> Broken during the setup dumping changes, now fixed. --[[Joey]] [[done]] -- cgit v1.2.3 From 1be6b0a6275917d12fd2a10da7f0d6dceab6f5fb Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Wed, 29 Oct 2008 20:02:02 -0400 Subject: Note on fix --- doc/bugs/cannot_preview_shortcuts.mdwn | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'doc/bugs/cannot_preview_shortcuts.mdwn') diff --git a/doc/bugs/cannot_preview_shortcuts.mdwn b/doc/bugs/cannot_preview_shortcuts.mdwn index 2e7ef13b7..7c830898d 100644 --- a/doc/bugs/cannot_preview_shortcuts.mdwn +++ b/doc/bugs/cannot_preview_shortcuts.mdwn @@ -2,3 +2,9 @@ Shortcuts such as \[[!google foo]] do not work when previewing pages. --[[JasonBlevins]] > Broken during the setup dumping changes, now fixed. --[[Joey]] [[done]] + +>> Just a quick note that this fix interacts with the way the `listdirectives` +>> directive gets its list of non-shortcut directives. At the moment it +>> still works, but it relies on the fact that the `listdirectives` `checkconfig` +>> hook is called before the `shortcut` `checkconfig` hook. +>> -- [[Will]] -- cgit v1.2.3 From 354d22e27b4d9cb8207e038de4f342545435d2c6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 30 Oct 2008 13:41:19 -0400 Subject: don't rely on plugin load order when determining generated directives Instead, shortcuts will explicitly be marked as such when registered, and listdirectives can filter them out. --- IkiWiki/Plugin/listdirectives.pm | 9 ++++----- IkiWiki/Plugin/shortcut.pm | 1 + doc/bugs/cannot_preview_shortcuts.mdwn | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'doc/bugs/cannot_preview_shortcuts.mdwn') diff --git a/IkiWiki/Plugin/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm index fc8927ccb..2ab3e4665 100644 --- a/IkiWiki/Plugin/listdirectives.pm +++ b/IkiWiki/Plugin/listdirectives.pm @@ -30,7 +30,7 @@ sub getsetup () { #{{{ } #}}} my @fulllist; -my @earlylist; +my @shortlist; my $pluginstring; sub checkconfig () { #{{{ @@ -40,15 +40,14 @@ sub checkconfig () { #{{{ else { $config{directive_description_dir} =~ s/\/+$//; } - - @earlylist = sort keys %{$IkiWiki::hooks{preprocess}}; } #}}} sub needsbuild (@) { #{{{ my $needsbuild=shift; @fulllist = sort keys %{$IkiWiki::hooks{preprocess}}; - $pluginstring = join(' ', @earlylist) . " : " . join(' ', @fulllist); + @shortlist = grep { ! $IkiWiki::hooks{preprocess}{$_}{shortcut} } @fulllist; + $pluginstring = join(' ', @shortlist) . " : " . join(' ', @fulllist); foreach my $page (keys %pagestate) { if (exists $pagestate{$page}{listdirectives}{shown}) { @@ -77,7 +76,7 @@ sub preprocess (@) { #{{{ @pluginlist = @fulllist; } else { - @pluginlist = @earlylist; + @pluginlist = @shortlist; } my $result = '
    '; diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm index 77131edb0..dec8afdb5 100644 --- a/IkiWiki/Plugin/shortcut.pm +++ b/IkiWiki/Plugin/shortcut.pm @@ -39,6 +39,7 @@ sub preprocess_shortcut (@) { #{{{ } hook(type => "preprocess", no_override => 1, id => $params{name}, + shortcut => 1, call => sub { shortcut_expand($params{url}, $params{desc}, @_) }); #translators: This is used to display what shortcuts are defined. diff --git a/doc/bugs/cannot_preview_shortcuts.mdwn b/doc/bugs/cannot_preview_shortcuts.mdwn index 7c830898d..d7045b2dc 100644 --- a/doc/bugs/cannot_preview_shortcuts.mdwn +++ b/doc/bugs/cannot_preview_shortcuts.mdwn @@ -8,3 +8,10 @@ Shortcuts such as \[[!google foo]] do not work when previewing pages. >> still works, but it relies on the fact that the `listdirectives` `checkconfig` >> hook is called before the `shortcut` `checkconfig` hook. >> -- [[Will]] + +>> The order plugins are loaded is effectively random. (`keys %hooks`). +>> So I've made shortcuts pass a 'shortcut' parameter when registering +>> them, which listdirectives can grep out of the full list of directives. +>> That may not be the best name to give it, especially if other plugins +>> generate directives too. Seemed better than forcing shortcut's +>> checkconfig hook to run last tho. --[[Joey]] -- cgit v1.2.3