From da166e74227d084fd15878ce9a3099e07ebcc2c2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 6 Jan 2009 15:05:09 -0500 Subject: table: Fix misparsed links in external files linkify data from external files at the same time as data from an inlined table would be linkified. --- IkiWiki/Plugin/table.pm | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'IkiWiki/Plugin/table.pm') diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm index 479f3d745..dd124929d 100644 --- a/IkiWiki/Plugin/table.pm +++ b/IkiWiki/Plugin/table.pm @@ -50,22 +50,18 @@ sub preprocess (@) { defined $params{delimiter} ? $params{delimiter} : ",",); # linkify after parsing since html link quoting can # confuse CSV parsing - if (! exists $params{file}) { - @data=map { - [ map { - IkiWiki::linkify($params{page}, - $params{destpage}, $_); - } @$_ ] - } @data; - } + @data=map { + [ map { + IkiWiki::linkify($params{page}, + $params{destpage}, $_); + } @$_ ] + } @data; } elsif (lc $params{format} eq 'dsv') { # linkify before parsing since wikilinks can contain the # delimiter - if (! exists $params{file}) { - $params{data} = IkiWiki::linkify($params{page}, - $params{destpage}, $params{data}); - } + $params{data} = IkiWiki::linkify($params{page}, + $params{destpage}, $params{data}); @data=split_dsv($params{data}, defined $params{delimiter} ? $params{delimiter} : "|",); } -- cgit v1.2.3 From 4ce73f2d88e9a177ad84e19b48a17b2d604a808b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 6 Jan 2009 15:35:53 -0500 Subject: table: Find links in external files in scan pass. --- IkiWiki/Plugin/table.pm | 22 ++++++++++++++++++++-- debian/changelog | 1 + doc/bugs/table_external_file_links.mdwn | 2 ++ docwiki.setup | 2 ++ po/ikiwiki.pot | 2 +- 5 files changed, 26 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin/table.pm') diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm index dd124929d..96d63f455 100644 --- a/IkiWiki/Plugin/table.pm +++ b/IkiWiki/Plugin/table.pm @@ -8,7 +8,7 @@ use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "table", call => \&getsetup); - hook(type => "preprocess", id => "table", call => \&preprocess); + hook(type => "preprocess", id => "table", call => \&preprocess, scan => 1); } sub getsetup () { @@ -27,13 +27,31 @@ sub preprocess (@) { ); if (exists $params{file}) { - if (! $pagesources{$params{file}}) { + if (! exists $pagesources{$params{file}}) { error gettext("cannot find file"); } $params{data} = readfile(srcfile($params{file})); add_depends($params{page}, $params{file}); } + if (! defined wantarray) { + # scan mode -- if the table uses an external file, need to + # scan that file too. + return unless exists $params{file}; + + IkiWiki::run_hooks(scan => sub { + shift->( + page => $params{page}, + content => $params{data}, + ); + }); + + # Preprocess in scan-only mode. + IkiWiki::preprocess($params{page}, $params{page}, $params{data}, 1); + + return; + } + if (lc $params{format} eq 'auto') { # first try the more simple format if (is_dsv_data($params{data})) { diff --git a/debian/changelog b/debian/changelog index bf47fda04..e79ad04cc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ ikiwiki (3.02) UNRELEASED; urgency=low * table: Fix misparsed links in external files. + * table: Find links in external files in scan pass. -- Joey Hess Tue, 06 Jan 2009 15:02:52 -0500 diff --git a/doc/bugs/table_external_file_links.mdwn b/doc/bugs/table_external_file_links.mdwn index f86808c77..7b35383c5 100644 --- a/doc/bugs/table_external_file_links.mdwn +++ b/doc/bugs/table_external_file_links.mdwn @@ -5,3 +5,5 @@ table when the pages the links point to change (are added, removed, etc). There seem only two solutions to that bug -- either really make wikilinks in an external table file not work (probably by escaping them), or run the preprocess code also in scan (expensive!). --[[Joey]] + +[[done]] diff --git a/docwiki.setup b/docwiki.setup index 6d732fd6b..ffb4a7c16 100644 --- a/docwiki.setup +++ b/docwiki.setup @@ -15,5 +15,7 @@ use IkiWiki::Setup::Standard { userdir => "users", usedirs => 0, prefix_directives => 1, + cgiurl => "http://me", + url => "http://me", add_plugins => [qw{goodstuff version haiku polygen fortune}], } diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index 560a5b2a1..957c9eea3 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-01-05 18:53-0500\n" +"POT-Creation-Date: 2009-01-06 14:31-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -- cgit v1.2.3