* 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
parent
c648b2b79b
commit
472dabbb60
17
IkiWiki.pm
17
IkiWiki.pm
|
@ -22,12 +22,14 @@ our $VERSION = 1.01; # plugin interface version
|
||||||
use Memoize;
|
use Memoize;
|
||||||
memoize("abs2rel");
|
memoize("abs2rel");
|
||||||
memoize("pagespec_translate");
|
memoize("pagespec_translate");
|
||||||
|
memoize("file_pruned");
|
||||||
|
|
||||||
my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
|
my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
|
||||||
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
|
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
|
||||||
|
|
||||||
sub defaultconfig () { #{{{
|
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_link_regexp => qr/\[\[(?:([^\]\|]+)\|)?([^\s\]]+)\]\]/,
|
||||||
wiki_file_regexp => qr/(^[-[:alnum:]_.:\/+]+$)/,
|
wiki_file_regexp => qr/(^[-[:alnum:]_.:\/+]+$)/,
|
||||||
web_commit_regexp => qr/^web commit (by (.*?(?=: |$))|from (\d+\.\d+\.\d+\.\d+)):?(.*)/,
|
web_commit_regexp => qr/^web commit (by (.*?(?=: |$))|from (\d+\.\d+\.\d+\.\d+)):?(.*)/,
|
||||||
|
@ -96,9 +98,6 @@ sub checkconfig () { #{{{
|
||||||
if ($config{cgi} && ! length $config{url}) {
|
if ($config{cgi} && ! length $config{url}) {
|
||||||
error("Must specify url to wiki with --url when using --cgi\n");
|
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"
|
$config{wikistatedir}="$config{srcdir}/.ikiwiki"
|
||||||
unless exists $config{wikistatedir};
|
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 ($$) { #{{{
|
sub pagespec_match ($$) { #{{{
|
||||||
my $page=shift;
|
my $page=shift;
|
||||||
my $spec=shift;
|
my $spec=shift;
|
||||||
|
|
|
@ -303,8 +303,7 @@ sub cgi_editpage ($$) { #{{{
|
||||||
# characters.
|
# characters.
|
||||||
my ($page)=$form->field('page');
|
my ($page)=$form->field('page');
|
||||||
$page=titlepage(possibly_foolish_untaint($page));
|
$page=titlepage(possibly_foolish_untaint($page));
|
||||||
if (! defined $page || ! length $page ||
|
if (! defined $page || ! length $page || file_pruned($page, $config{srcdir}) || $page=~/^\//) {
|
||||||
$page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) {
|
|
||||||
error("bad page name");
|
error("bad page name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +393,7 @@ sub cgi_editpage ($$) { #{{{
|
||||||
my $best_loc;
|
my $best_loc;
|
||||||
if (! defined $from || ! length $from ||
|
if (! defined $from || ! length $from ||
|
||||||
$from ne $form->field('from') ||
|
$from ne $form->field('from') ||
|
||||||
$from=~/$config{wiki_file_prune_regexp}/ ||
|
file_pruned($from, $config{srcdir}) ||
|
||||||
$from=~/^\// ||
|
$from=~/^\// ||
|
||||||
$form->submitted eq "Preview") {
|
$form->submitted eq "Preview") {
|
||||||
@page_locs=$best_loc=$page;
|
@page_locs=$best_loc=$page;
|
||||||
|
|
|
@ -12,7 +12,7 @@ sub import { #{{{
|
||||||
|
|
||||||
# ikiwiki defaults to skipping .html files as a security measure;
|
# ikiwiki defaults to skipping .html files as a security measure;
|
||||||
# make it process them so this plugin can take effect
|
# 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 (@) { #{{{
|
sub htmlize (@) { #{{{
|
||||||
|
|
|
@ -9,6 +9,8 @@ use IkiWiki::Render; # for displaytime
|
||||||
use URI;
|
use URI;
|
||||||
|
|
||||||
sub import { #{{{
|
sub import { #{{{
|
||||||
|
hook(type => "getopt", id => "inline", call => \&getopt);
|
||||||
|
hook(type => "checkconfig", id => "inline", call => \&checkconfig);
|
||||||
hook(type => "preprocess", id => "inline",
|
hook(type => "preprocess", id => "inline",
|
||||||
call => \&IkiWiki::preprocess_inline);
|
call => \&IkiWiki::preprocess_inline);
|
||||||
hook(type => "pagetemplate", id => "inline",
|
hook(type => "pagetemplate", id => "inline",
|
||||||
|
@ -20,6 +22,29 @@ sub import { #{{{
|
||||||
call => \&IkiWiki::pingurl);
|
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
|
# Back to ikiwiki namespace for the rest, this code is very much
|
||||||
# internal to ikiwiki even though it's separated into a plugin.
|
# internal to ikiwiki even though it's separated into a plugin.
|
||||||
package IkiWiki;
|
package IkiWiki;
|
||||||
|
|
|
@ -218,7 +218,7 @@ sub refresh () { #{{{
|
||||||
no_chdir => 1,
|
no_chdir => 1,
|
||||||
wanted => sub {
|
wanted => sub {
|
||||||
$_=decode_utf8($_);
|
$_=decode_utf8($_);
|
||||||
if (/$config{wiki_file_prune_regexp}/) {
|
if (file_pruned($_, $config{srcdir})) {
|
||||||
$File::Find::prune=1;
|
$File::Find::prune=1;
|
||||||
}
|
}
|
||||||
elsif (! -d $_ && ! -l $_) {
|
elsif (! -d $_ && ! -l $_) {
|
||||||
|
@ -238,7 +238,7 @@ sub refresh () { #{{{
|
||||||
no_chdir => 1,
|
no_chdir => 1,
|
||||||
wanted => sub {
|
wanted => sub {
|
||||||
$_=decode_utf8($_);
|
$_=decode_utf8($_);
|
||||||
if (/$config{wiki_file_prune_regexp}/) {
|
if (file_pruned($_, $config{underlaydir})) {
|
||||||
$File::Find::prune=1;
|
$File::Find::prune=1;
|
||||||
}
|
}
|
||||||
elsif (! -d $_ && ! -l $_) {
|
elsif (! -d $_ && ! -l $_) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ sub setup_standard {
|
||||||
delete $setup{disable_plugins};
|
delete $setup{disable_plugins};
|
||||||
}
|
}
|
||||||
if (exists $setup{exclude}) {
|
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})) {
|
if (! $config{render} && (! $config{refresh} || $config{wrappers})) {
|
||||||
|
|
|
@ -7,8 +7,17 @@ ikiwiki (1.36) UNRELEASED; urgency=low
|
||||||
* Fix man page perms in install.
|
* Fix man page perms in install.
|
||||||
* Fix an issue with inlining a page with a rss feed inside another
|
* Fix an issue with inlining a page with a rss feed inside another
|
||||||
page with an rss feed.
|
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
|
ikiwiki (1.35) unstable; urgency=low
|
||||||
|
|
||||||
|
|
|
@ -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 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_
|
> 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]]
|
||||||
|
|
|
@ -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
|
|
|
@ -32,8 +32,6 @@ sub getconfig () { #{{{
|
||||||
"rcs=s" => \$config{rcs},
|
"rcs=s" => \$config{rcs},
|
||||||
"no-rcs" => sub { $config{rcs}="" },
|
"no-rcs" => sub { $config{rcs}="" },
|
||||||
"anonok!" => \$config{anonok},
|
"anonok!" => \$config{anonok},
|
||||||
"rss!" => \$config{rss},
|
|
||||||
"atom!" => \$config{atom},
|
|
||||||
"cgi!" => \$config{cgi},
|
"cgi!" => \$config{cgi},
|
||||||
"discussion!" => \$config{discussion},
|
"discussion!" => \$config{discussion},
|
||||||
"w3mmode!" => \$config{w3mmode},
|
"w3mmode!" => \$config{w3mmode},
|
||||||
|
@ -49,7 +47,7 @@ sub getconfig () { #{{{
|
||||||
"sslcookie!" => \$config{sslcookie},
|
"sslcookie!" => \$config{sslcookie},
|
||||||
"httpauth!" => \$config{httpauth},
|
"httpauth!" => \$config{httpauth},
|
||||||
"exclude=s@" => sub {
|
"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 {
|
"adminuser=s@" => sub {
|
||||||
push @{$config{adminuser}}, $_[1]
|
push @{$config{adminuser}}, $_[1]
|
||||||
|
|
Loading…
Reference in New Issue