* 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.
master
joey 2006-12-21 19:36:15 +00:00
parent c648b2b79b
commit 472dabbb60
10 changed files with 59 additions and 97 deletions

View File

@ -22,12 +22,14 @@ our $VERSION = 1.01; # plugin interface version
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+)):?(.*)/,
@ -96,9 +98,6 @@ sub checkconfig () { #{{{
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};
@ -780,6 +779,16 @@ sub add_depends ($$) { #{{{
}
} # }}}
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;

View File

@ -303,8 +303,7 @@ sub cgi_editpage ($$) { #{{{
# 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");
}
@ -394,7 +393,7 @@ sub cgi_editpage ($$) { #{{{
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;

View File

@ -12,7 +12,7 @@ sub import { #{{{
# 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 (@) { #{{{

View File

@ -9,6 +9,8 @@ use IkiWiki::Render; # for displaytime
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",
@ -20,6 +22,29 @@ sub import { #{{{
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;

View File

@ -218,7 +218,7 @@ sub refresh () { #{{{
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 $_) {
@ -238,7 +238,7 @@ sub refresh () { #{{{
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 $_) {

View File

@ -31,7 +31,7 @@ sub setup_standard {
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})) {

11
debian/changelog vendored
View File

@ -7,8 +7,17 @@ ikiwiki (1.36) UNRELEASED; urgency=low
* Fix man page perms in install.
* Fix an issue with inlining a page with a rss feed inside another
page with an rss feed.
* 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 08:50:41 -0500
-- Joey Hess <joeyh@debian.org> Thu, 21 Dec 2006 13:54:24 -0500
ikiwiki (1.35) unstable; urgency=low

View File

@ -3,6 +3,8 @@ ikiwiki compiles my wiki successfully. But the svn post-commit hook it installs
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]]
> --[[roktas]]
[[bugs/Done]], and sorry it took so long to apply --[[Joey]]

View File

@ -1,80 +0,0 @@
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

View File

@ -32,8 +32,6 @@ sub getconfig () { #{{{
"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},
@ -49,7 +47,7 @@ sub getconfig () { #{{{
"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]