manipulate.
* Only exclude rss and atom files from processing if the inline plugin
is enabled and that feed type is enabled. Else it's just a copyable file
type.
* Move rss and atom option handling code into the inline plugin.
* Applied a rather old patch from Recai to fix the "pruning is too strict"
issue. Now you can have wiki source directories inside dotdirs and the
like, if you want.
use Memoize;
memoize("abs2rel");
memoize("pagespec_translate");
+memoize("file_pruned");
my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
sub defaultconfig () { #{{{
- wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.x?html?$|\.rss$|\.atom$|.arch-ids/|{arch}/)},
+ wiki_file_prune_regexps => [qr/\.\./, qr/^\./, qr/\/\./, qr/\.x?html?$/,
+ qr/(^|\/).svn\//, qr/.arch-ids\//, qr/{arch}\//],
wiki_link_regexp => qr/\[\[(?:([^\]\|]+)\|)?([^\s\]]+)\]\]/,
wiki_file_regexp => qr/(^[-[:alnum:]_.:\/+]+$)/,
web_commit_regexp => qr/^web commit (by (.*?(?=: |$))|from (\d+\.\d+\.\d+\.\d+)):?(.*)/,
if ($config{cgi} && ! length $config{url}) {
error("Must specify url to wiki with --url when using --cgi\n");
}
- if (($config{rss} || $config{atom}) && ! length $config{url}) {
- error("Must specify url to wiki with --url when using --rss or --atom\n");
- }
$config{wikistatedir}="$config{srcdir}/.ikiwiki"
unless exists $config{wikistatedir};
}
} # }}}
+sub file_pruned ($$) { #{{{
+ require File::Spec;
+ my $file=File::Spec->canonpath(shift);
+ my $base=File::Spec->canonpath(shift);
+ $file=~s#^\Q$base\E/*##;
+
+ my $regexp='('.join('|', @{$config{wiki_file_prune_regexps}}).')';
+ $file =~ m/$regexp/;
+} #}}}
+
sub pagespec_match ($$) { #{{{
my $page=shift;
my $spec=shift;
# characters.
my ($page)=$form->field('page');
$page=titlepage(possibly_foolish_untaint($page));
- if (! defined $page || ! length $page ||
- $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) {
+ if (! defined $page || ! length $page || file_pruned($page, $config{srcdir}) || $page=~/^\//) {
error("bad page name");
}
my $best_loc;
if (! defined $from || ! length $from ||
$from ne $form->field('from') ||
- $from=~/$config{wiki_file_prune_regexp}/ ||
+ file_pruned($from, $config{srcdir}) ||
$from=~/^\// ||
$form->submitted eq "Preview") {
@page_locs=$best_loc=$page;
# ikiwiki defaults to skipping .html files as a security measure;
# make it process them so this plugin can take effect
- $config{wiki_file_prune_regexp} =~ s/\|\\\.x\?html\?\$//;
+ $config{wiki_file_prune_regexps} = [ grep { !m/\\\.x\?html\?\$/ } @{$config{wiki_file_prune_regexps}} ];
} # }}}
sub htmlize (@) { #{{{
use URI;
sub import { #{{{
+ hook(type => "getopt", id => "inline", call => \&getopt);
+ hook(type => "checkconfig", id => "inline", call => \&checkconfig);
hook(type => "preprocess", id => "inline",
call => \&IkiWiki::preprocess_inline);
hook(type => "pagetemplate", id => "inline",
call => \&IkiWiki::pingurl);
} # }}}
+sub getopt () { #{{{
+ eval q{use Getopt::Long};
+ error($@) if $@;
+ Getopt::Long::Configure('pass_through');
+ GetOptions(
+ "rss!" => \$config{rss},
+ "atom!" => \$config{atom},
+ );
+}
+
+sub checkconfig () { #{{{
+ if (($config{rss} || $config{atom}) && ! length $config{url}) {
+ error("Must specify url to wiki with --url when using --rss or --atom");
+ }
+ if ($config{rss}) {
+ print STDERR "!!\n";
+ push @{$config{wiki_file_prune_regexps}}, qr/\.rss$/;
+ }
+ if ($config{atom}) {
+ push @{$config{wiki_file_prune_regexps}}, qr/\.atom$/;
+ }
+} #}}}
+
# Back to ikiwiki namespace for the rest, this code is very much
# internal to ikiwiki even though it's separated into a plugin.
package IkiWiki;
no_chdir => 1,
wanted => sub {
$_=decode_utf8($_);
- if (/$config{wiki_file_prune_regexp}/) {
+ if (file_pruned($_, $config{srcdir})) {
$File::Find::prune=1;
}
elsif (! -d $_ && ! -l $_) {
no_chdir => 1,
wanted => sub {
$_=decode_utf8($_);
- if (/$config{wiki_file_prune_regexp}/) {
+ if (file_pruned($_, $config{underlaydir})) {
$File::Find::prune=1;
}
elsif (! -d $_ && ! -l $_) {
delete $setup{disable_plugins};
}
if (exists $setup{exclude}) {
- $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$setup{exclude}/;
+ push @{$config{wiki_file_prune_regexps}}, $setup{exclude};
}
if (! $config{render} && (! $config{refresh} || $config{wrappers})) {
* Fix man page perms in install.
* Fix an issue with inlining a page with a rss feed inside another
page with an rss feed.
-
- -- Joey Hess <joeyh@debian.org> Thu, 21 Dec 2006 08:50:41 -0500
+ * Turn $config{wiki_file_prune_regexps} into an array that is easier to
+ manipulate.
+ * Only exclude rss and atom files from processing if the inline plugin
+ is enabled and that feed type is enabled. Else it's just a copyable file
+ type.
+ * Move rss and atom option handling code into the inline plugin.
+ * Applied a rather old patch from Recai to fix the "pruning is too strict"
+ issue. Now you can have wiki source directories inside dotdirs and the
+ like, if you want.
+
+ -- Joey Hess <joeyh@debian.org> Thu, 21 Dec 2006 13:54:24 -0500
ikiwiki (1.35) unstable; urgency=low
I think the prune regexp would be more useful if it was only used to check the relative path from the src root to a file in the wiki.
> I agree with this feature wish. Here is a _first cut_
-> [[implementation|patchqueue/pruning_is_too_strict]] for this feature.
+> implementation for this feature.
>
-> --[[roktas]]
\ No newline at end of file
+> --[[roktas]]
+
+[[bugs/Done]], and sorry it took so long to apply --[[Joey]]
+++ /dev/null
-Preliminary patch for a feature wishlist item: [[bugs/pruning_is_too_strict]].
-
- diff -ur ikiwiki-orig/IkiWiki/CGI.pm ikiwiki/IkiWiki/CGI.pm
- --- ikiwiki-orig/IkiWiki/CGI.pm 2006-10-27 20:15:17.000000000 -0700
- +++ ikiwiki/IkiWiki/CGI.pm 2006-11-07 22:32:41.000000000 -0800
- @@ -405,7 +405,7 @@
- my ($page)=$form->field('page');
- $page=titlepage(possibly_foolish_untaint($page));
- if (! defined $page || ! length $page ||
- - $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) {
- + is_prune($page) || $page=~/^\//) {
- error("bad page name");
- }
-
- @@ -495,8 +495,7 @@
- my $best_loc;
- if (! defined $from || ! length $from ||
- $from ne $form->field('from') ||
- - $from=~/$config{wiki_file_prune_regexp}/ ||
- - $from=~/^\// ||
- + is_prune($from) || $from=~/^\// ||
- $form->submitted eq "Preview") {
- @page_locs=$best_loc=$page;
- }
- diff -ur ikiwiki-orig/IkiWiki/Render.pm ikiwiki/IkiWiki/Render.pm
- --- ikiwiki-orig/IkiWiki/Render.pm 2006-10-27 20:15:17.000000000 -0700
- +++ ikiwiki/IkiWiki/Render.pm 2006-11-07 22:36:48.000000000 -0800
- @@ -189,7 +193,7 @@
- no_chdir => 1,
- wanted => sub {
- $_=decode_utf8($_);
- - if (/$config{wiki_file_prune_regexp}/) {
- + if (is_prune($_)) {
- $File::Find::prune=1;
- }
- elsif (! -d $_ && ! -l $_) {
- @@ -209,7 +213,7 @@
- no_chdir => 1,
- wanted => sub {
- $_=decode_utf8($_);
- - if (/$config{wiki_file_prune_regexp}/) {
- + if (is_prune($_, $config{underlaydir})) {
- $File::Find::prune=1;
- }
- elsif (! -d $_ && ! -l $_) {
- diff -ur ikiwiki-orig/IkiWiki.pm ikiwiki/IkiWiki.pm
- --- ikiwiki-orig/IkiWiki.pm 2006-10-27 20:15:23.000000000 -0700
- +++ ikiwiki/IkiWiki.pm 2006-11-07 22:21:17.000000000 -0800
- @@ -21,6 +21,8 @@
- # Optimisation.
- use Memoize;
- memoize("abs2rel");
- +memoize("basefile");
- +memoize("is_prune");
- memoize("pagespec_translate");
-
- my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
- @@ -343,6 +352,22 @@
- return $page;
- } #}}}
-
- +sub basefile ($;$) { #{{{
- + my $file=shift;
- + my $base=shift || $config{srcdir};
- +
- + require File::Spec;
- + $base=File::Spec->canonpath($base);
- + my $ret=File::Spec->canonpath($file);
- +
- + $ret=~s#^$base/*##;
- + return $ret;
- +} #}}}
- +
- +sub is_prune ($;$) { #{{{
- + return basefile($_[0], $_[1])=~m/$config{wiki_file_prune_regexp}/;
- +} #}}}
- +
- sub abs2rel ($$) { #{{{
- # Work around very innefficient behavior in File::Spec if abs2rel
- # is passed two relative paths. It's much faster if paths are
"rcs=s" => \$config{rcs},
"no-rcs" => sub { $config{rcs}="" },
"anonok!" => \$config{anonok},
- "rss!" => \$config{rss},
- "atom!" => \$config{atom},
"cgi!" => \$config{cgi},
"discussion!" => \$config{discussion},
"w3mmode!" => \$config{w3mmode},
"sslcookie!" => \$config{sslcookie},
"httpauth!" => \$config{httpauth},
"exclude=s@" => sub {
- $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
+ push @{$config{wiki_file_prune_regexp}}, $_[1];
},
"adminuser=s@" => sub {
push @{$config{adminuser}}, $_[1]