summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/aggregate.pm18
-rw-r--r--IkiWiki/Plugin/comments.pm18
-rw-r--r--IkiWiki/Plugin/git.pm10
-rw-r--r--IkiWiki/Plugin/img.pm7
-rw-r--r--IkiWiki/Plugin/openid.pm1
-rw-r--r--IkiWiki/Plugin/po.pm2
-rw-r--r--IkiWiki/Setup.pm27
-rw-r--r--IkiWiki/Wrapper.pm52
8 files changed, 117 insertions, 18 deletions
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index 5a9eb433d..7789c4c2a 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -298,7 +298,7 @@ sub loadstate () {
return if $state_loaded;
$state_loaded=1;
if (-e "$config{wikistatedir}/aggregate") {
- open(IN, "$config{wikistatedir}/aggregate") ||
+ open(IN, "<", "$config{wikistatedir}/aggregate") ||
die "$config{wikistatedir}/aggregate: $!";
while (<IN>) {
$_=IkiWiki::possibly_foolish_untaint($_);
@@ -335,7 +335,7 @@ sub savestate () {
garbage_collect();
my $newfile="$config{wikistatedir}/aggregate.new";
my $cleanup = sub { unlink($newfile) };
- open (OUT, ">$newfile") || error("open $newfile: $!", $cleanup);
+ open (OUT, ">", $newfile) || error("open $newfile: $!", $cleanup);
foreach my $data (values %feeds, values %guids) {
my @line;
foreach my $field (keys %$data) {
@@ -356,6 +356,20 @@ sub savestate () {
close OUT || error("save $newfile: $!", $cleanup);
rename($newfile, "$config{wikistatedir}/aggregate") ||
error("rename $newfile: $!", $cleanup);
+
+ my $timestamp=undef;
+ foreach my $feed (keys %feeds) {
+ my $t=$feeds{$feed}->{lastupdate}+$feeds{$feed}->{updateinterval};
+ if (! defined $timestamp || $timestamp > $t) {
+ $timestamp=$t;
+ }
+ }
+ $newfile=~s/\.new$/time/;
+ open (OUT, ">", $newfile) || error("open $newfile: $!", $cleanup);
+ if (defined $timestamp) {
+ print OUT $timestamp."\n";
+ }
+ close OUT || error("save $newfile: $!", $cleanup);
}
sub garbage_collect () {
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index d34951570..f0eec9ace 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -22,6 +22,7 @@ sub import {
hook(type => "checkconfig", id => 'comments', call => \&checkconfig);
hook(type => "getsetup", id => 'comments', call => \&getsetup);
hook(type => "preprocess", id => 'comment', call => \&preprocess);
+ hook(type => "preprocess", id => 'commentmoderation', call => \&preprocess_moderation);
# here for backwards compatability with old comments
hook(type => "preprocess", id => '_comment', call => \&preprocess);
hook(type => "sessioncgi", id => 'comment', call => \&sessioncgi);
@@ -251,6 +252,22 @@ sub preprocess {
return $content;
}
+sub preprocess_moderation {
+ my %params = @_;
+
+ $params{desc}=gettext("Comment Moderation")
+ unless defined $params{desc};
+
+ if (length $config{cgiurl}) {
+ return '<a href="'.
+ IkiWiki::cgiurl(do => 'commentmoderation').
+ '">'.$params{desc}.'</a>';
+ }
+ else {
+ return $params{desc};
+ }
+}
+
sub sessioncgi ($$) {
my $cgi=shift;
my $session=shift;
@@ -569,6 +586,7 @@ sub commentmoderation ($$) {
my $added=0;
foreach my $id (keys %vars) {
if ($id =~ /(.*)\._comment(?:_pending)?$/) {
+ $id=decode_utf8($id);
my $action=$cgi->param($id);
next if $action eq 'Defer' && ! $rejectalldefer;
diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm
index 992c6226b..cb3437e18 100644
--- a/IkiWiki/Plugin/git.pm
+++ b/IkiWiki/Plugin/git.pm
@@ -41,6 +41,7 @@ sub checkconfig () {
push @{$config{wrappers}}, {
wrapper => $config{git_wrapper},
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
+ wrapper_background_command => $config{git_wrapper_background_command},
};
}
@@ -78,6 +79,13 @@ sub getsetup () {
safe => 0, # file
rebuild => 0,
},
+ git_wrapper_background_command => {
+ type => "string",
+ example => "git push github",
+ description => "shell command for git_wrapper to run, in the background",
+ safe => 0, # command
+ rebuild => 0,
+ },
git_wrappermode => {
type => "string",
example => '06755',
@@ -509,6 +517,8 @@ sub rcs_commit_staged (@) {
}
if (defined $params{session}->param("nickname")) {
$u=encode_utf8($params{session}->param("nickname"));
+ $u=~s/\s+/_/g;
+ $u=~s/[^-_0-9[:alnum:]]+//g;
}
if (defined $u) {
$ENV{GIT_AUTHOR_EMAIL}="$u\@web";
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm
index eb1b68124..2375ead89 100644
--- a/IkiWiki/Plugin/img.pm
+++ b/IkiWiki/Plugin/img.pm
@@ -156,6 +156,13 @@ sub preprocess (@) {
$imgurl="$config{url}/$imglink";
}
+ if (exists $params{class}) {
+ $params{class}.=" img";
+ }
+ else {
+ $params{class}="img";
+ }
+
my $attrs='';
foreach my $attr (qw{alt title class id hspace vspace}) {
if (exists $params{$attr}) {
diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm
index d393afd23..b1a9a7a15 100644
--- a/IkiWiki/Plugin/openid.pm
+++ b/IkiWiki/Plugin/openid.pm
@@ -211,7 +211,6 @@ sub auth ($$) {
}
}
if (defined $nickname) {
- $nickname=~s/\s+/_/g;
$session->param(nickname => $nickname);
}
}
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 29945da33..cadc13ba1 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -1296,7 +1296,7 @@ sub match_needstranslation ($$;@) {
my $percenttranslated=IkiWiki::Plugin::po::percenttranslated($page);
if ($percenttranslated eq 'N/A') {
- return IkiWiki::FailReason->new("file is not a translation page");
+ return IkiWiki::FailReason->new("file is not a translatable page");
}
elsif ($percenttranslated < 100) {
return IkiWiki::SuccessReason->new("file has $percenttranslated translated");
diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm
index 2b0259e2a..7af744f6a 100644
--- a/IkiWiki/Setup.pm
+++ b/IkiWiki/Setup.pm
@@ -50,10 +50,8 @@ sub load ($;$) {
sub dump ($) {
my $file=IkiWiki::possibly_foolish_untaint(shift);
-
- eval qq{require IkiWiki::Setup::$config{setuptype}};
- error $@ if $@;
- my @dump="IkiWiki::Setup::$config{setuptype}"->gendump(
+
+ my @header=(
"Setup file for ikiwiki.",
"",
"Passing this to ikiwiki --setup will make ikiwiki generate",
@@ -62,9 +60,24 @@ sub dump ($) {
"Remember to re-run ikiwiki --setup any time you edit this file.",
);
- open (OUT, ">", $file) || die "$file: $!";
- print OUT "$_\n" foreach @dump;
- close OUT;
+ # Fork because dumping setup requires loading all plugins.
+ my $pid=fork();
+ if ($pid == 0) {
+ eval qq{require IkiWiki::Setup::$config{setuptype}};
+ error $@ if $@;
+ my @dump="IkiWiki::Setup::$config{setuptype}"->gendump(@header);
+
+ open (OUT, ">", $file) || die "$file: $!";
+ print OUT "$_\n" foreach @dump;
+ close OUT;
+
+ exit 0;
+ }
+ else {
+ waitpid $pid, 0;
+ exit($? >> 8) if $? >> 8;
+ exit(1) if $?;
+ }
}
sub merge ($) {
diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm
index 73f0896e8..bd134c9a3 100644
--- a/IkiWiki/Wrapper.pm
+++ b/IkiWiki/Wrapper.pm
@@ -73,17 +73,23 @@ EOF
# otherwise. The fd of the lock is stored in
# IKIWIKI_CGILOCK_FD so unlockwiki can close it.
$pre_exec=<<"EOF";
- {
- int fd=open("$config{wikistatedir}/cgilock", O_CREAT | O_RDWR, 0666);
- if (fd != -1 && flock(fd, LOCK_EX) == 0) {
- char *fd_s=malloc(8);
- sprintf(fd_s, "%i", fd);
- setenv("IKIWIKI_CGILOCK_FD", fd_s, 1);
- }
+ lockfd=open("$config{wikistatedir}/cgilock", O_CREAT | O_RDWR, 0666);
+ if (lockfd != -1 && flock(lockfd, LOCK_EX) == 0) {
+ char *fd_s=malloc(8);
+ sprintf(fd_s, "%i", lockfd);
+ setenv("IKIWIKI_CGILOCK_FD", fd_s, 1);
}
EOF
}
+ my $set_background_command='';
+ if (defined $config{wrapper_background_command} &&
+ length $config{wrapper_background_command}) {
+ my $background_command=delete $config{wrapper_background_command};
+ $set_background_command=~s/"/\\"/g;
+ $set_background_command='#define BACKGROUND_COMMAND "'.$background_command.'"';
+ }
+
$Data::Dumper::Indent=0; # no newlines
my $configstring=Data::Dumper->Dump([\%config], ['*config']);
$configstring=~s/\\/\\\\/g;
@@ -114,6 +120,7 @@ void addenv(char *var, char *val) {
}
int main (int argc, char **argv) {
+ int lockfd=-1;
char *s;
$check_commit_hook
@@ -147,9 +154,40 @@ $envsave
}
$pre_exec
+
+$set_background_command
+#ifdef BACKGROUND_COMMAND
+ if (lockfd != -1) {
+ close(lockfd);
+ }
+
+ pid_t pid=fork();
+ if (pid == -1) {
+ perror("fork");
+ exit(1);
+ }
+ else if (pid == 0) {
+ execl("$this", "$this", NULL);
+ perror("exec $this");
+ exit(1);
+ }
+ else {
+ waitpid(pid, NULL, 0);
+
+ if (daemon(1, 0) == 0) {
+ system(BACKGROUND_COMMAND);
+ exit(0);
+ }
+ else {
+ perror("daemon");
+ exit(1);
+ }
+ }
+#else
execl("$this", "$this", NULL);
perror("exec $this");
exit(1);
+#endif
}
EOF