summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/bzr.pm25
-rw-r--r--IkiWiki/Plugin/comments.pm4
-rw-r--r--IkiWiki/Plugin/filecheck.pm18
-rw-r--r--IkiWiki/Plugin/htmlscrubber.pm2
-rw-r--r--IkiWiki/Plugin/openid.pm47
-rw-r--r--IkiWiki/Plugin/po.pm2
-rw-r--r--IkiWiki/Plugin/remove.pm2
-rw-r--r--IkiWiki/Plugin/rename.pm4
-rw-r--r--IkiWiki/Plugin/tag.pm25
-rw-r--r--IkiWiki/Plugin/template.pm10
-rw-r--r--IkiWiki/Plugin/tla.pm2
-rw-r--r--IkiWiki/Plugin/txt.pm9
-rw-r--r--IkiWiki/Render.pm35
-rw-r--r--IkiWiki/Setup/Automator.pm9
-rw-r--r--IkiWiki/Setup/Yaml.pm11
-rw-r--r--IkiWiki/Wrapper.pm6
16 files changed, 142 insertions, 69 deletions
diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm
index 1ffdc2353..0efc26b49 100644
--- a/IkiWiki/Plugin/bzr.pm
+++ b/IkiWiki/Plugin/bzr.pm
@@ -73,31 +73,40 @@ sub bzr_log ($) {
my @infos = ();
my $key = undef;
+ my %info;
while (<$out>) {
my $line = $_;
my ($value);
if ($line =~ /^message:/) {
$key = "message";
- $infos[$#infos]{$key} = "";
+ $info{$key} = "";
}
elsif ($line =~ /^(modified|added|renamed|renamed and modified|removed):/) {
$key = "files";
- unless (defined($infos[$#infos]{$key})) { $infos[$#infos]{$key} = ""; }
+ $info{$key} = "" unless defined $info{$key};
}
elsif (defined($key) and $line =~ /^ (.*)/) {
- $infos[$#infos]{$key} .= "$1\n";
+ $info{$key} .= "$1\n";
}
elsif ($line eq "------------------------------------------------------------\n") {
+ push @infos, {%info} if keys %info;
+ %info = ();
$key = undef;
- push (@infos, {});
}
- else {
+ elsif ($line =~ /: /) {
chomp $line;
+ if ($line =~ /^revno: (\d+)/) {
+ $key = "revno";
+ $value = $1;
+ }
+ else {
($key, $value) = split /: +/, $line, 2;
- $infos[$#infos]{$key} = $value;
- }
+ }
+ $info{$key} = $value;
+ }
}
close $out;
+ push @infos, {%info} if keys %info;
return @infos;
}
@@ -213,7 +222,7 @@ sub rcs_recentchanges ($) {
foreach my $info (bzr_log($out)) {
my @pages = ();
my @message = ();
-
+
foreach my $msgline (split(/\n/, $info->{message})) {
push @message, { line => $msgline };
}
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 98786f432..460341710 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -221,7 +221,9 @@ sub preprocess {
}
if (defined $params{subject}) {
- $pagestate{$page}{meta}{title} = $params{subject};
+ # encode title the same way meta does
+ eval q{use HTML::Entities};
+ $pagestate{$page}{meta}{title} = HTML::Entities::encode_numeric(decode_entities($params{subject}));
}
if ($params{page} =~ m/\/\Q$config{comments_pagename}\E\d+_/) {
diff --git a/IkiWiki/Plugin/filecheck.pm b/IkiWiki/Plugin/filecheck.pm
index 01d490961..1549b82db 100644
--- a/IkiWiki/Plugin/filecheck.pm
+++ b/IkiWiki/Plugin/filecheck.pm
@@ -5,7 +5,7 @@ use warnings;
use strict;
use IkiWiki 3.00;
-my %units=( #{{{ # size in bytes
+my %units=( # size in bytes
B => 1,
byte => 1,
KB => 2 ** 10,
@@ -75,9 +75,9 @@ sub match_maxsize ($$;@) {
}
my %params=@_;
- my $file=exists $params{file} ? $params{file} : $IkiWiki::pagesources{$page};
+ my $file=exists $params{file} ? $params{file} : IkiWiki::srcfile($IkiWiki::pagesources{$page});
if (! defined $file) {
- return IkiWiki::ErrorReason->new("no file specified");
+ return IkiWiki::ErrorReason->new("file does not exist");
}
if (-s $file > $maxsize) {
@@ -96,9 +96,9 @@ sub match_minsize ($$;@) {
}
my %params=@_;
- my $file=exists $params{file} ? $params{file} : $IkiWiki::pagesources{$page};
+ my $file=exists $params{file} ? $params{file} : IkiWiki::srcfile($IkiWiki::pagesources{$page});
if (! defined $file) {
- return IkiWiki::ErrorReason->new("no file specified");
+ return IkiWiki::ErrorReason->new("file does not exist");
}
if (-s $file < $minsize) {
@@ -114,9 +114,9 @@ sub match_mimetype ($$;@) {
my $wanted=shift;
my %params=@_;
- my $file=exists $params{file} ? $params{file} : $IkiWiki::pagesources{$page};
+ my $file=exists $params{file} ? $params{file} : IkiWiki::srcfile($IkiWiki::pagesources{$page});
if (! defined $file) {
- return IkiWiki::ErrorReason->new("no file specified");
+ return IkiWiki::ErrorReason->new("file does not exist");
}
# Use ::magic to get the mime type, the idea is to only trust
@@ -147,9 +147,9 @@ sub match_virusfree ($$;@) {
my $wanted=shift;
my %params=@_;
- my $file=exists $params{file} ? $params{file} : $IkiWiki::pagesources{$page};
+ my $file=exists $params{file} ? $params{file} : IkiWiki::srcfile($IkiWiki::pagesources{$page});
if (! defined $file) {
- return IkiWiki::ErrorReason->new("no file specified");
+ return IkiWiki::ErrorReason->new("file does not exist");
}
if (! exists $IkiWiki::config{virus_checker} ||
diff --git a/IkiWiki/Plugin/htmlscrubber.pm b/IkiWiki/Plugin/htmlscrubber.pm
index 26e18ffc7..9f40c752f 100644
--- a/IkiWiki/Plugin/htmlscrubber.pm
+++ b/IkiWiki/Plugin/htmlscrubber.pm
@@ -32,7 +32,7 @@ sub import {
);
# data is a special case. Allow a few data:image/ types,
# but disallow data:text/javascript and everything else.
- $safe_url_regexp=qr/^(?:(?:$uri_schemes):|data:image\/(?:png|jpeg|gif)|[^:]+(?:$|\/))/i;
+ $safe_url_regexp=qr/^(?:(?:$uri_schemes):|data:image\/(?:png|jpeg|gif)|[^:]+(?:$|[\/\?]))/i;
}
sub getsetup () {
diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm
index 9355cd85a..7b1a17831 100644
--- a/IkiWiki/Plugin/openid.pm
+++ b/IkiWiki/Plugin/openid.pm
@@ -116,23 +116,25 @@ sub validate ($$$;$) {
# Ask for client to provide a name and email, if possible.
# Try sreg and ax
- $claimed_identity->set_extension_args(
- 'http://openid.net/extensions/sreg/1.1',
- {
- optional => 'email,fullname,nickname',
- },
- );
- $claimed_identity->set_extension_args(
- 'http://openid.net/srv/ax/1.0',
- {
- mode => 'fetch_request',
- 'required' => 'email,fullname,nickname,firstname',
- 'type.email' => "http://schema.openid.net/contact/email",
- 'type.fullname' => "http://axschema.org/namePerson",
- 'type.nickname' => "http://axschema.org/namePerson/friendly",
- 'type.firstname' => "http://axschema.org/namePerson/first",
- },
- );
+ if ($claimed_identity->can("set_extension_args")) {
+ $claimed_identity->set_extension_args(
+ 'http://openid.net/extensions/sreg/1.1',
+ {
+ optional => 'email,fullname,nickname',
+ },
+ );
+ $claimed_identity->set_extension_args(
+ 'http://openid.net/srv/ax/1.0',
+ {
+ mode => 'fetch_request',
+ 'required' => 'email,fullname,nickname,firstname',
+ 'type.email' => "http://schema.openid.net/contact/email",
+ 'type.fullname' => "http://axschema.org/namePerson",
+ 'type.nickname' => "http://axschema.org/namePerson/friendly",
+ 'type.firstname' => "http://axschema.org/namePerson/first",
+ },
+ );
+ }
my $check_url = $claimed_identity->check_url(
return_to => IkiWiki::cgiurl(do => "postsignin"),
@@ -161,10 +163,13 @@ sub auth ($$) {
elsif (my $vident = $csr->verified_identity) {
$session->param(name => $vident->url);
- my @extensions=grep { defined } (
- $vident->signed_extension_fields('http://openid.net/extensions/sreg/1.1'),
- $vident->signed_extension_fields('http://openid.net/srv/ax/1.0'),
- );
+ my @extensions;
+ if ($vident->can("signed_extension_fields")) {
+ @extensions=grep { defined } (
+ $vident->signed_extension_fields('http://openid.net/extensions/sreg/1.1'),
+ $vident->signed_extension_fields('http://openid.net/srv/ax/1.0'),
+ );
+ }
foreach my $ext (@extensions) {
foreach my $field (qw{value.email email}) {
if (exists $ext->{$field} &&
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 2cbfb0a45..2250a7f9f 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -308,7 +308,7 @@ sub pagetemplate (@) {
if (ishomepage($page) && $template->query(name => "title")) {
$template->param(title => $config{wikiname});
}
-} # }}}
+}
# Add the renamed page translations to the list of to-be-renamed pages.
sub renamepages (@) {
diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm
index f59d0269e..0fc180f69 100644
--- a/IkiWiki/Plugin/remove.pm
+++ b/IkiWiki/Plugin/remove.pm
@@ -49,7 +49,7 @@ sub check_canremove ($$$) {
# This is sorta overkill, but better safe than sorry.
if (! defined pagetype($pagesources{$page})) {
if (IkiWiki::Plugin::attachment->can("check_canattach")) {
- IkiWiki::Plugin::attachment::check_canattach($session, $page, $file);
+ IkiWiki::Plugin::attachment::check_canattach($session, $page, "$config{srcdir}/$file");
}
else {
error("removal of attachments is not allowed");
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm
index 3908443ca..1a9da6363 100644
--- a/IkiWiki/Plugin/rename.pm
+++ b/IkiWiki/Plugin/rename.pm
@@ -50,7 +50,7 @@ sub check_canrename ($$$$$$) {
IkiWiki::check_canedit($src, $q, $session);
if ($attachment) {
if (IkiWiki::Plugin::attachment->can("check_canattach")) {
- IkiWiki::Plugin::attachment::check_canattach($session, $src, $srcfile);
+ IkiWiki::Plugin::attachment::check_canattach($session, $src, "$config{srcdir}/$srcfile");
}
else {
error("renaming of attachments is not allowed");
@@ -85,7 +85,7 @@ sub check_canrename ($$$$$$) {
if ($attachment) {
# Note that $srcfile is used here, not $destfile,
# because it wants the current file, to check it.
- IkiWiki::Plugin::attachment::check_canattach($session, $dest, $srcfile);
+ IkiWiki::Plugin::attachment::check_canattach($session, $dest, "$config{srcdir}/$srcfile");
}
}
diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
index cdcfaf536..7a85874f6 100644
--- a/IkiWiki/Plugin/tag.pm
+++ b/IkiWiki/Plugin/tag.pm
@@ -6,8 +6,6 @@ use warnings;
use strict;
use IkiWiki 3.00;
-my %tags;
-
sub import {
hook(type => "getopt", id => "tag", call => \&getopt);
hook(type => "getsetup", id => "tag", call => \&getsetup);
@@ -71,9 +69,8 @@ sub preprocess_tag (@) {
foreach my $tag (keys %params) {
$tag=linkpage($tag);
- $tags{$page}{$tag}=1;
# hidden WikiLink
- add_link($page, tagpage($tag));
+ add_link($page, tagpage($tag), 'tag');
}
return "";
@@ -87,15 +84,13 @@ sub preprocess_taglink (@) {
return join(" ", map {
if (/(.*)\|(.*)/) {
my $tag=linkpage($2);
- $tags{$params{page}}{$tag}=1;
- add_link($params{page}, tagpage($tag));
+ add_link($params{page}, tagpage($tag), 'tag');
return taglink($params{page}, $params{destpage}, $tag,
linktext => pagetitle($1));
}
else {
my $tag=linkpage($_);
- $tags{$params{page}}{$tag}=1;
- add_link($params{page}, tagpage($tag));
+ add_link($params{page}, tagpage($tag), 'tag');
return taglink($params{page}, $params{destpage}, $tag);
}
}
@@ -110,17 +105,19 @@ sub pagetemplate (@) {
my $destpage=$params{destpage};
my $template=$params{template};
+ my $tags = $typedlinks{$page}{tag};
+
$template->param(tags => [
map {
link => taglink($page, $destpage, $_, rel => "tag")
- }, sort keys %{$tags{$page}}
- ]) if exists $tags{$page} && %{$tags{$page}} && $template->query(name => "tags");
+ }, sort keys %$tags
+ ]) if defined $tags && %$tags && $template->query(name => "tags");
if ($template->query(name => "categories")) {
# It's an rss/atom template. Add any categories.
- if (exists $tags{$page} && %{$tags{$page}}) {
+ if (defined $tags && %$tags) {
$template->param(categories => [map { category => $_ },
- sort keys %{$tags{$page}}]);
+ sort keys %$tags]);
}
}
}
@@ -128,9 +125,7 @@ sub pagetemplate (@) {
package IkiWiki::PageSpec;
sub match_tagged ($$;@) {
- my $page = shift;
- my $glob = shift;
- return match_link($page, IkiWiki::Plugin::tag::tagpage($glob));
+ return match_link($_[0], IkiWiki::Plugin::tag::tagpage($_[1]), linktype => 'tag');
}
1
diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
index 3e024c5f8..98a13b5fa 100644
--- a/IkiWiki/Plugin/template.pm
+++ b/IkiWiki/Plugin/template.pm
@@ -37,7 +37,13 @@ sub preprocess (@) {
my $template_page="templates/$params{id}";
add_depends($params{page}, $template_page);
- my $template_file=$pagesources{$template_page};
+ my $template_file;
+ if (exists $pagesources{$template_page}) {
+ $template_file=srcfile($pagesources{$template_page});
+ }
+ else {
+ $template_file=IkiWiki::template_file("$params{id}.tmpl")
+ }
return sprintf(gettext("template %s not found"),
htmllink($params{page}, $params{destpage}, "/".$template_page))
unless defined $template_file;
@@ -50,7 +56,7 @@ sub preprocess (@) {
$$text_ref=&Encode::decode_utf8($$text_ref);
chomp $$text_ref;
},
- filename => srcfile($template_file),
+ filename => $template_file,
die_on_bad_params => 0,
no_includes => 1,
blind_cache => 1,
diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm
index 16d73b136..764da9b98 100644
--- a/IkiWiki/Plugin/tla.pm
+++ b/IkiWiki/Plugin/tla.pm
@@ -162,7 +162,7 @@ sub rcs_remove ($) {
error("rcs_remove not implemented for tla"); # TODO
}
-sub rcs_rename ($$) { # {{{a
+sub rcs_rename ($$) {
my ($src, $dest) = @_;
error("rcs_rename not implemented for tla"); # TODO
diff --git a/IkiWiki/Plugin/txt.pm b/IkiWiki/Plugin/txt.pm
index 1ed9f0856..0d9a0b35b 100644
--- a/IkiWiki/Plugin/txt.pm
+++ b/IkiWiki/Plugin/txt.pm
@@ -39,7 +39,14 @@ sub filter (@) {
my %params = @_;
my $content = $params{content};
- if (defined $pagesources{$params{page}} && $pagesources{$params{page}} =~ /\.txt$/) {
+ if (defined $pagesources{$params{page}} &&
+ $pagesources{$params{page}} =~ /\.txt$/) {
+ if ($pagesources{$params{page}} eq 'robots.txt' &&
+ $params{page} eq $params{destpage}) {
+ will_render($params{page}, 'robots.txt');
+ writefile('robots.txt', $config{destdir}, $content);
+ }
+
encode_entities($content, "<>&");
if ($findurl) {
my $finder = URI::Find->new(sub {
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index af24df155..e98888d76 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -167,6 +167,7 @@ sub scan ($) {
else {
$links{$page}=[];
}
+ delete $typedlinks{$page};
run_hooks(scan => sub {
shift->(
@@ -398,6 +399,7 @@ sub find_del_files ($) {
push @del, $pagesources{$page};
}
$links{$page}=[];
+ delete $typedlinks{$page};
$renderedfiles{$page}=[];
$pagemtime{$page}=0;
}
@@ -499,6 +501,29 @@ sub remove_unrendered () {
}
}
+sub link_types_changed ($$) {
+ # each is of the form { type => { link => 1 } }
+ my $new = shift;
+ my $old = shift;
+
+ return 0 if !defined $new && !defined $old;
+ return 1 if !defined $new || !defined $old;
+
+ while (my ($type, $links) = each %$new) {
+ foreach my $link (keys %$links) {
+ return 1 unless exists $old->{$type}{$link};
+ }
+ }
+
+ while (my ($type, $links) = each %$old) {
+ foreach my $link (keys %$links) {
+ return 1 unless exists $new->{$type}{$link};
+ }
+ }
+
+ return 0;
+}
+
sub calculate_changed_links ($$$) {
my ($changed, $del, $oldlink_targets)=@_;
@@ -525,6 +550,14 @@ sub calculate_changed_links ($$$) {
}
$linkchangers{lc($page)}=1;
}
+
+ # we currently assume that changing the type of a link doesn't
+ # change backlinks
+ if (!exists $linkchangers{lc($page)}) {
+ if (link_types_changed($typedlinks{$page}, $oldtypedlinks{$page})) {
+ $linkchangers{lc($page)}=1;
+ }
+ }
}
return \%backlinkchanged, \%linkchangers;
@@ -565,7 +598,7 @@ sub render_dependent ($$$$$$$) {
if (exists $depends{$p} && ! defined $reason) {
foreach my $dep (keys %{$depends{$p}}) {
my $sub=pagespec_translate($dep);
- next if $@ || ! defined $sub;
+ next unless defined $sub;
# only consider internal files
# if the page explicitly depends
diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm
index e9a572450..2dcb424e5 100644
--- a/IkiWiki/Setup/Automator.pm
+++ b/IkiWiki/Setup/Automator.pm
@@ -72,9 +72,15 @@ sub import (@) {
}
elsif ($config{rcs} eq 'bzr') {
# TODO
+ print STDERR "warning: do not know how to set up the bzr_wrapper hook!\n";
}
elsif ($config{rcs} eq 'mercurial') {
# TODO
+ print STDERR "warning: do not know how to set up the mercurial_wrapper hook!\n";
+ }
+ elsif ($config{rcs} eq 'tla') {
+ # TODO
+ print STDERR "warning: do not know how to set up the tla_wrapper hook!\n";
}
elsif ($config{rcs} eq 'cvs') {
$config{cvs_wrapper}=$config{repository}."/CVSROOT/post-commit";
@@ -124,9 +130,10 @@ sub import (@) {
IkiWiki::run_hooks(checkconfig => sub { shift->() });
};
if ($@) {
+ my $err=$@;
print STDERR sprintf(gettext("** Disabling plugin %s, since it is failing with this message:"),
$plugin)."\n";
- print STDERR "$@\n";
+ print STDERR "$err\n";
push @{$bakconfig{disable_plugins}}, $plugin;
}
}
diff --git a/IkiWiki/Setup/Yaml.pm b/IkiWiki/Setup/Yaml.pm
index 0fc273675..904784728 100644
--- a/IkiWiki/Setup/Yaml.pm
+++ b/IkiWiki/Setup/Yaml.pm
@@ -10,17 +10,16 @@ sub loaddump ($$) {
my $class=shift;
my $content=shift;
- eval q{use YAML};
+ eval q{use YAML::Any};
+ eval q{use YAML} if $@;
die $@ if $@;
+ $YAML::Syck::ImplicitUnicode=1;
IkiWiki::Setup::merge(Load($content));
}
sub gendump ($@) {
my $class=shift;
- eval q{use YAML};
- die $@ if $@;
-
"# IkiWiki::Setup::Yaml - YAML formatted setup file",
"#",
(map { "# $_" } @_),
@@ -35,7 +34,11 @@ sub dumpline ($$$$) {
my $type=shift;
my $prefix=shift;
+ eval q{use YAML::Old};
+ eval q{use YAML} if $@;
+ die $@ if $@;
$YAML::UseHeader=0;
+
my $dump=Dump({$key => $value});
chomp $dump;
if (length $prefix) {
diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm
index f175b4a0b..3f3e63ca6 100644
--- a/IkiWiki/Wrapper.pm
+++ b/IkiWiki/Wrapper.pm
@@ -101,6 +101,7 @@ EOF
#include <string.h>
#include <sys/file.h>
+extern char **environ;
char *newenviron[$#envsave+6];
int i=0;
@@ -121,12 +122,17 @@ $envsave
newenviron[i++]="HOME=$ENV{HOME}";
newenviron[i++]="WRAPPED_OPTIONS=$configstring";
+#ifdef __TINYC__
if (clearenv() != 0) {
perror("clearenv");
exit(1);
}
for (; i>0; i--)
putenv(newenviron[i-1]);
+#else
+ newenviron[i]=NULL;
+ environ=newenviron;
+#endif
if (setregid(getegid(), -1) != 0 &&
setregid(getegid(), -1) != 0) {