From 0eabe6f79498e3339205aeff2c79ae1e85498ab4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 1 Jul 2010 16:20:03 -0400 Subject: git: Added git_wrapper_background_command option. Can be used to eg, make the git wrapper push to github in the background after ikiwiki runs. --- IkiWiki/Plugin/git.pm | 8 ++++++++ IkiWiki/Wrapper.pm | 52 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 992c6226b..0f92476c9 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', 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 -- cgit v1.2.3 From be49679fe9235f0fe9a28dabf3d91c9ee173106f Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 29 Jun 2010 15:45:34 +0200 Subject: po: added a needstranslation() pagespec (cherry picked from commit b225fdc44d4b3d2853db622d59aed7b59788aeec) --- IkiWiki/Plugin/po.pm | 15 +++++++++++++++ doc/ikiwiki/pagespec/po.mdwn | 2 ++ 2 files changed, 17 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 86d5087f4..f12c69d5f 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -1220,4 +1220,19 @@ sub match_currentlang ($$;@) { } } +sub match_needstranslation ($$;@) { + my $page=shift; + + my $percenttranslated=IkiWiki::Plugin::po::percenttranslated($page); + if ($percenttranslated eq 'N/A') { + return IkiWiki::FailReason->new("file is not a translation page"); + } + elsif ($percenttranslated < 100) { + return IkiWiki::SuccessReason->new("file has $percenttranslated translated"); + } + else { + return IkiWiki::FailReason->new("file is fully translated"); + } +} + 1 diff --git a/doc/ikiwiki/pagespec/po.mdwn b/doc/ikiwiki/pagespec/po.mdwn index 40ed9efb6..f8b398575 100644 --- a/doc/ikiwiki/pagespec/po.mdwn +++ b/doc/ikiwiki/pagespec/po.mdwn @@ -11,6 +11,8 @@ wiki: specified as a ISO639-1 (two-letter) language code. * "`currentlang()`" - tests whether a page is written in the same language as the current page. +* "`needstranslation()`" - tests whether a page needs translation + work. Only slave pages match this PageSpec. Note that every non-po page is considered to be written in `po_master_language`, as specified in `ikiwiki.setup`. -- cgit v1.2.3 From 8a8914151cee44592dfdc3df3bb2c45b19b8c29c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 4 Jul 2010 14:22:19 -0400 Subject: review of needstranslation() pagespec Minor wording fix; changelog; etc. --- IkiWiki/Plugin/po.pm | 2 +- debian/changelog | 1 + doc/todo/po_needstranslation_pagespec.mdwn | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index f12c69d5f..0b2251668 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -1225,7 +1225,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/debian/changelog b/debian/changelog index 7d857d9c0..bdcf52884 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,7 @@ ikiwiki (3.20100624) UNRELEASED; urgency=low * git: Added git_wrapper_background_command option. Can be used to eg, make the git wrapper push to github in the background after ikiwiki runs. + * po: Added needstranslation() pagespec. (intrigeri) -- Joey Hess Wed, 23 Jun 2010 15:30:04 -0400 diff --git a/doc/todo/po_needstranslation_pagespec.mdwn b/doc/todo/po_needstranslation_pagespec.mdwn index acc5641a4..77449dc2b 100644 --- a/doc/todo/po_needstranslation_pagespec.mdwn +++ b/doc/todo/po_needstranslation_pagespec.mdwn @@ -2,4 +2,8 @@ Commit b225fdc44d4b3d in my po branch adds a `needstranslation()` PageSpec. It makes it easy to list pages that need translation work. Please review. --[[intrigeri]] -[[!tag patch]] +> Looks good, cherry-picked. The only improvment I can +> think of is that `needstranslation(50)` could match +> only pages less than 50% translated. --[[Joey]] + +[[!tag patch done]] -- cgit v1.2.3 From a6e629e5cf612e3c32c61c3fc0a9d859c1a7a5d9 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sat, 26 Jun 2010 01:16:56 +0200 Subject: po: s/utf-8/UTF-8, to solve part of the double commit bug. (cherry picked from commit 4f44534d72c9a9a947bc38a3cb4987705c25bea5) --- IkiWiki/Plugin/po.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 0b2251668..e85c9d760 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -851,15 +851,15 @@ sub refreshpot ($) { my %options = ("markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0); my $doc=Locale::Po4a::Chooser::new('text',%options); $doc->{TT}{utf_mode} = 1; - $doc->{TT}{file_in_charset} = 'utf-8'; - $doc->{TT}{file_out_charset} = 'utf-8'; + $doc->{TT}{file_in_charset} = 'UTF-8'; + $doc->{TT}{file_out_charset} = 'UTF-8'; $doc->read($masterfile); # let's cheat a bit to force porefs option to be passed to # Locale::Po4a::Po; this is undocument use of internal # Locale::Po4a::TransTractor's data, compulsory since this module # prevents us from using the porefs option. $doc->{TT}{po_out}=Locale::Po4a::Po->new({ 'porefs' => 'none' }); - $doc->{TT}{po_out}->set_charset('utf-8'); + $doc->{TT}{po_out}->set_charset('UTF-8'); # do the actual work $doc->parse; IkiWiki::prep_writefile(basename($potfile),dirname($potfile)); @@ -947,8 +947,8 @@ sub percenttranslated ($) { $doc->process( 'po_in_name' => [ $file ], 'file_in_name' => [ $masterfile ], - 'file_in_charset' => 'utf-8', - 'file_out_charset' => 'utf-8', + 'file_in_charset' => 'UTF-8', + 'file_out_charset' => 'UTF-8', ) or error("po(percenttranslated) ". sprintf(gettext("failed to translate %s"), $page)); my ($percent,$hit,$queries) = $doc->stats(); @@ -1101,8 +1101,8 @@ sub po_to_markup ($$) { $doc->process( 'po_in_name' => [ $infile ], 'file_in_name' => [ $masterfile ], - 'file_in_charset' => 'utf-8', - 'file_out_charset' => 'utf-8', + 'file_in_charset' => 'UTF-8', + 'file_out_charset' => 'UTF-8', ) or return $fail->(gettext("failed to translate")); $doc->write($outfile) or return $fail->(sprintf(gettext("failed to write %s"), $outfile)); -- cgit v1.2.3 From cd03bd0b804cf4919a5d195c53bcea1f9730a51f Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 25 Jun 2010 23:18:34 +0200 Subject: po: added support for html pagetype ... after having audited the po4a Xml and Xhtml modules for security issues. Signed-off-by: intrigeri (cherry picked from commit a128c256a51392fcf752bf612d83a90e8c68027e) --- IkiWiki/Plugin/po.pm | 47 +++++++++++++++++++++++++++++++++--------- doc/plugins/po.mdwn | 10 ++++----- doc/plugins/po/discussion.mdwn | 17 +++++++++++++++ 3 files changed, 59 insertions(+), 15 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index e85c9d760..4e6eff94f 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -848,8 +848,8 @@ sub refreshpot ($) { my $masterfile=shift; my $potfile=potfile($masterfile); - my %options = ("markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0); - my $doc=Locale::Po4a::Chooser::new('text',%options); + my $doc=Locale::Po4a::Chooser::new(po4a_type($masterfile), + po4a_options($masterfile)); $doc->{TT}{utf_mode} = 1; $doc->{TT}{file_in_charset} = 'UTF-8'; $doc->{TT}{file_out_charset} = 'UTF-8'; @@ -940,10 +940,8 @@ sub percenttranslated ($) { return gettext("N/A") unless istranslation($page); my $file=srcfile($pagesources{$page}); my $masterfile = srcfile($pagesources{masterpage($page)}); - my %options = ( - "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0, - ); - my $doc=Locale::Po4a::Chooser::new('text',%options); + my $doc=Locale::Po4a::Chooser::new(po4a_type($masterfile), + po4a_options($masterfile)); $doc->process( 'po_in_name' => [ $file ], 'file_in_name' => [ $masterfile ], @@ -1094,10 +1092,8 @@ sub po_to_markup ($$) { or return $fail->(sprintf(gettext("failed to write %s"), $infile)); my $masterfile = srcfile($pagesources{masterpage($page)}); - my %options = ( - "markdown" => (pagetype($masterfile) eq 'mdwn') ? 1 : 0, - ); - my $doc=Locale::Po4a::Chooser::new('text',%options); + my $doc=Locale::Po4a::Chooser::new(po4a_type($masterfile), + po4a_options($masterfile)); $doc->process( 'po_in_name' => [ $infile ], 'file_in_name' => [ $masterfile ], @@ -1160,6 +1156,37 @@ sub isvalidpo ($) { "to previous page to continue edit")); } +sub po4a_type ($) { + my $file = shift; + + my $pagetype = pagetype($file); + if ($pagetype eq 'html') { + return 'xhtml'; + } + return 'text'; +} + +sub po4a_options($) { + my $file = shift; + + my %options; + my $pagetype = pagetype($file); + + if ($pagetype eq 'html') { + # how to disable options is not consistent across po4a modules + $options{includessi} = ''; + $options{includeexternal} = 0; + } + elsif ($pagetype eq 'mdwn') { + $options{markdown} = 1; + } + else { + $options{markdown} = 0; + } + + return %options; +} + # ,---- # | PageSpecs # `---- diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index 646d0cef3..fab6053b3 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -213,16 +213,16 @@ preferred `$EDITOR`, without needing to be online. Markup languages support ------------------------ -[[Markdown|mdwn]] is well supported. Some other markup languages supported -by ikiwiki mostly work, but some pieces of syntax are not rendered -correctly on the slave pages: +[[Markdown|mdwn]] and [[html]] are well supported. Some other markup +languages supported by ikiwiki mostly work, but some pieces of syntax +are not rendered correctly on the slave pages: * [[reStructuredText|rst]]: anonymous hyperlinks and internal cross-references * [[wikitext]]: conversion of newlines to paragraphs * [[creole]]: verbatim text is wrapped, tables are broken -* [[html]] and LaTeX: not supported yet; the dedicated po4a modules - could be used to support them, but they would need a security audit +* LaTeX: not supported yet; the dedicated po4a module + could be used to support it, but it would need a security audit * other markup languages have not been tested. Security diff --git a/doc/plugins/po/discussion.mdwn b/doc/plugins/po/discussion.mdwn index 27683f1ea..73858c818 100644 --- a/doc/plugins/po/discussion.mdwn +++ b/doc/plugins/po/discussion.mdwn @@ -150,6 +150,23 @@ The following analysis was done with his help. variables; according to [[Joey]], this is "Freaky code, but seems ok due to use of `quotementa`". +##### Locale::Po4a::Xhtml + +* does not run any external program +* does not build regexp's from untrusted variables + +=> Seems safe as far as the `includessi` option is disabled; the po +plugin explicitly disables it. + +Relies on Locale::Po4a::Xml` to do most of the work. + +##### Locale::Po4a::Xml + +* does not run any external program +* the `includeexternal` option makes it able to read external files; + the po plugin explicitly disables it +* untrusted variables are escaped when used to build regexp's + ##### Text::WrapI18N `Text::WrapI18N` can cause DoS -- cgit v1.2.3 From acde95751260e305da3d8d84b6b09dcd3b2d03b6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 4 Jul 2010 16:12:50 -0400 Subject: further sanitize nickname characters --- IkiWiki/Plugin/openid.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index d393afd23..4727577f3 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -212,6 +212,7 @@ sub auth ($$) { } if (defined $nickname) { $nickname=~s/\s+/_/g; + $nickname=~s/[^-_0-9[:alnum:]]+//g; $session->param(nickname => $nickname); } } -- cgit v1.2.3 From e72ef3b070b18f4cb0a667be915266b27d7d3071 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 4 Jul 2010 16:19:22 -0400 Subject: comment: Fix problem moderating comments of certian pages with utf-8 in their name. --- IkiWiki/Plugin/comments.pm | 1 + debian/changelog | 2 ++ 2 files changed, 3 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index d34951570..30ade5634 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -569,6 +569,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/debian/changelog b/debian/changelog index 1450e502e..baf7a6a35 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ ikiwiki (3.20100624) UNRELEASED; urgency=low runs. * po: Added needstranslation() pagespec. (intrigeri) * po: Added support for .html source pages. (intrigeri) + * comment: Fix problem moderating comments of certian pages with utf-8 + in their name. -- Joey Hess Wed, 23 Jun 2010 15:30:04 -0400 -- cgit v1.2.3 From 7fdf1f1d007b5ef9a16f5c6d41200cadb25c1975 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 4 Jul 2010 16:44:38 -0400 Subject: move nickname sanitization out Probably best to store it unsanitized and sanitize as needed on use. And it already was for comments, leaving only the need to sanitize the nickname when git committing, to ensure the email address is legal. --- IkiWiki/Plugin/git.pm | 2 ++ IkiWiki/Plugin/openid.pm | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 0f92476c9..cb3437e18 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -517,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/openid.pm b/IkiWiki/Plugin/openid.pm index 4727577f3..b1a9a7a15 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -211,8 +211,6 @@ sub auth ($$) { } } if (defined $nickname) { - $nickname=~s/\s+/_/g; - $nickname=~s/[^-_0-9[:alnum:]]+//g; $session->param(nickname => $nickname); } } -- cgit v1.2.3 From f6db10df21f04df83e109924647b07672050dbf3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 5 Jul 2010 14:04:49 -0400 Subject: img: Add a margin around images displayed by this directive. Particularly important for floating images, which could before be placed uncomfortably close to text. --- IkiWiki/Plugin/img.pm | 7 +++++++ debian/changelog | 6 ++++++ doc/style.css | 4 ++++ 3 files changed, 17 insertions(+) (limited to 'IkiWiki') 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/debian/changelog b/debian/changelog index 9f1a33f2f..d426be019 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.20100705) UNRELEASED; urgency=low + + * img: Add a margin around images displayed by this directive. + + -- Joey Hess Mon, 05 Jul 2010 13:59:42 -0400 + ikiwiki (3.20100704) unstable; urgency=low * Changes to avoid display of ugly google openids, by displaying diff --git a/doc/style.css b/doc/style.css index bf000dae1..8dd3b1c15 100644 --- a/doc/style.css +++ b/doc/style.css @@ -91,6 +91,10 @@ nav { text-align: center; } +img.img { + margin: 0.5ex; +} + .align-left { float:left; } -- cgit v1.2.3 From 7e3fb8b8a230a725df7814c15745c6fee9ddd5b1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 5 Jul 2010 20:19:31 -0400 Subject: comments: Added commentmoderation directive for easy linking to the comment moderation queue. --- IkiWiki/Plugin/comments.pm | 17 +++++++++++++++++ debian/changelog | 2 ++ doc/examples/blog/comments.mdwn | 2 +- doc/ikiwiki/directive/commentmoderation.mdwn | 9 +++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 doc/ikiwiki/directive/commentmoderation.mdwn (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 30ade5634..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 ''.$params{desc}.''; + } + else { + return $params{desc}; + } +} + sub sessioncgi ($$) { my $cgi=shift; my $session=shift; diff --git a/debian/changelog b/debian/changelog index d426be019..18db7c0c2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ ikiwiki (3.20100705) UNRELEASED; urgency=low * img: Add a margin around images displayed by this directive. + * comments: Added commentmoderation directive for easy linking to the + comment moderation queue. -- Joey Hess Mon, 05 Jul 2010 13:59:42 -0400 diff --git a/doc/examples/blog/comments.mdwn b/doc/examples/blog/comments.mdwn index 52c7d3132..e22b50a34 100644 --- a/doc/examples/blog/comments.mdwn +++ b/doc/examples/blog/comments.mdwn @@ -1,7 +1,7 @@ [[!sidebar content=""" [[!inline pages="comment_pending(./posts/*)" feedfile=pendingmoderation description="comments pending moderation" show=-1]] -Comments in the moderation queue: +Comments in the [[!commentmoderation desc="moderation queue"]]: [[!pagecount pages="comment_pending(./posts/*)"]] """]] diff --git a/doc/ikiwiki/directive/commentmoderation.mdwn b/doc/ikiwiki/directive/commentmoderation.mdwn new file mode 100644 index 000000000..8553b5b17 --- /dev/null +++ b/doc/ikiwiki/directive/commentmoderation.mdwn @@ -0,0 +1,9 @@ +The `commentmoderation` directive is supplied by the +[[!iki plugins/comments desc=comments]] plugin, and is used to link +to the comment moderation queue. + +Example: + + \[[!commentmoderation desc="here is the comment moderation queue"]] + +[[!meta robots="noindex, follow"]] -- cgit v1.2.3 From 2dd0c177a6b33488dfcfff9041a3749b44484f34 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 6 Jul 2010 13:57:17 -0400 Subject: aggregate: Write timestamp next aggregation can happen to .ikiwiki/aggregatetime, to allow for more sophisticated cron jobs. --- IkiWiki/Plugin/aggregate.pm | 18 ++++++++++++++++-- debian/changelog | 2 ++ doc/plugins/aggregate.mdwn | 15 ++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) (limited to 'IkiWiki') 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 () { $_=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/debian/changelog b/debian/changelog index 18db7c0c2..9d88b5c9c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ ikiwiki (3.20100705) UNRELEASED; urgency=low * img: Add a margin around images displayed by this directive. * comments: Added commentmoderation directive for easy linking to the comment moderation queue. + * aggregate: Write timestamp next aggregation can happen to + .ikiwiki/aggregatetime, to allow for more sophisticated cron jobs. -- Joey Hess Mon, 05 Jul 2010 13:59:42 -0400 diff --git a/doc/plugins/aggregate.mdwn b/doc/plugins/aggregate.mdwn index bb828b05c..2925b6fba 100644 --- a/doc/plugins/aggregate.mdwn +++ b/doc/plugins/aggregate.mdwn @@ -5,9 +5,13 @@ This plugin allows content from other feeds to be aggregated into the wiki. To specify feeds to aggregate, use the [[ikiwiki/directive/aggregate]] [[ikiwiki/directive]]. -The [[meta]] and [[tag]] plugins are also recommended. Either the -[[htmltidy]] or [[htmlbalance]] plugin is suggested, since feeds can easily -contain html problems, some of which these plugins can fix. +## requirements + +The [[meta]] and [[tag]] plugins are also recommended to be used with this +one. Either the [[htmltidy]] or [[htmlbalance]] plugin is suggested, since +feeds can easily contain html problems, some of which these plugins can fix. + +## triggering aggregation You will need to run ikiwiki periodically from a cron job, passing it the --aggregate parameter, to make it check for new posts. Here's an example @@ -15,6 +19,11 @@ crontab entry: */15 * * * * ikiwiki --setup my.wiki --aggregate --refresh +The plugin updates a file `.ikiwiki/aggregatetime` with the unix time stamp +when the next aggregation run could occur. (The file may be empty, if no +aggregation is required.) This can be integrated into more complex cron +jobs or systems to trigger aggregation only when needed. + Alternatively, you can allow `ikiwiki.cgi` to trigger the aggregation. You should only need this if for some reason you cannot use cron, and instead want to use a service such as [WebCron](http://webcron.org). To enable -- cgit v1.2.3 From 45a5e8e972b3f56fbc2b32aa7b9c218c076da7e3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 6 Jul 2010 15:59:08 -0400 Subject: bugfix --- IkiWiki/Plugin/aggregate.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index 7789c4c2a..e473fc643 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -359,9 +359,14 @@ sub savestate () { my $timestamp=undef; foreach my $feed (keys %feeds) { - my $t=$feeds{$feed}->{lastupdate}+$feeds{$feed}->{updateinterval}; - if (! defined $timestamp || $timestamp > $t) { - $timestamp=$t; + if (defined $feeds{$feed}->{lastupdate}) { + my $t=$feeds{$feed}->{lastupdate}+$feeds{$feed}->{updateinterval}; + if (! defined $timestamp || $timestamp > $t) { + $timestamp=$t; + } + } + else { + $timestamp=0; } } $newfile=~s/\.new$/time/; -- cgit v1.2.3 From c23cb312b457c1ac2e0682649fc7ef7035103681 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 6 Jul 2010 16:02:41 -0400 Subject: revert bugfix Not needed; lastupdate will be 0 for new feeds. --- IkiWiki/Plugin/aggregate.pm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index e473fc643..7789c4c2a 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -359,14 +359,9 @@ sub savestate () { my $timestamp=undef; foreach my $feed (keys %feeds) { - if (defined $feeds{$feed}->{lastupdate}) { - my $t=$feeds{$feed}->{lastupdate}+$feeds{$feed}->{updateinterval}; - if (! defined $timestamp || $timestamp > $t) { - $timestamp=$t; - } - } - else { - $timestamp=0; + my $t=$feeds{$feed}->{lastupdate}+$feeds{$feed}->{updateinterval}; + if (! defined $timestamp || $timestamp > $t) { + $timestamp=$t; } } $newfile=~s/\.new$/time/; -- cgit v1.2.3 From d4c11466bad0e0aa3ac3c6f0bfc7577633d0d744 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 8 Jul 2010 13:55:30 -0400 Subject: fork a child to run dumpsetup --- IkiWiki/Setup.pm | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index 2b0259e2a..5b77a6471 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,23 @@ 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 $? if $?; + } } sub merge ($) { -- cgit v1.2.3 From b6f7906da6055ebefe9047a5e065829a8f8024a9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 8 Jul 2010 14:14:59 -0400 Subject: fix child process error propigation $? holds the full exit status --- IkiWiki/Setup.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index 5b77a6471..7af744f6a 100644 --- a/IkiWiki/Setup.pm +++ b/IkiWiki/Setup.pm @@ -75,7 +75,8 @@ sub dump ($) { } else { waitpid $pid, 0; - exit $? if $?; + exit($? >> 8) if $? >> 8; + exit(1) if $?; } } -- cgit v1.2.3