From: Joey Hess Date: Sun, 23 Feb 2014 18:09:51 +0000 (-0400) Subject: Merge remote-tracking branch 'anarcat/dev/syslog_utf8' X-Git-Tag: debian/3.20140227~25 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/c5d63c549de267dfc5de44f60b619f576e57023d?ds=sidebyside;hp=-c Merge remote-tracking branch 'anarcat/dev/syslog_utf8' --- c5d63c549de267dfc5de44f60b619f576e57023d diff --combined IkiWiki.pm index eb480969b,86c850811..a254177f2 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@@ -14,7 -14,7 +14,7 @@@ use vars qw{%config %links %oldlinks %p %pagestate %wikistate %renderedfiles %oldrenderedfiles %pagesources %delpagesources %destsources %depends %depends_simple @mass_depends %hooks %forcerebuild %loaded_plugins %typedlinks - %oldtypedlinks %autofiles}; + %oldtypedlinks %autofiles @underlayfiles $lastrev}; use Exporter q{import}; our @EXPORT = qw(hook debug error htmlpage template template_depends @@@ -134,13 -134,6 +134,13 @@@ sub getsetup () safe => 1, rebuild => 0, }, + only_committed_changes => { + type => "boolean", + default => 0, + description => "enable optimization of only refreshing committed changes?", + safe => 1, + rebuild => 0, + }, rcs => { type => "string", default => '', @@@ -527,14 -520,6 +527,14 @@@ safe => 0, # hooks into perl module internals rebuild => 0, }, + useragent => { + type => "string", + default => undef, + example => "Wget/1.13.4 (linux-gnu)", + description => "set custom user agent string for outbound HTTP requests e.g. when fetching aggregated RSS feeds", + safe => 0, + rebuild => 0, + }, } sub defaultconfig () { @@@ -743,6 -728,7 +743,7 @@@ sub debug ($) } my $log_open=0; + my $log_failed=0; sub log_message ($$) { my $type=shift; @@@ -753,9 -739,18 +754,18 @@@ Sys::Syslog::openlog('ikiwiki', '', 'user'); $log_open=1; } - return eval { - Sys::Syslog::syslog($type, "[$config{wikiname}] %s", join(" ", @_)); + eval { + # keep a copy to avoid editing the original config repeatedly + my $wikiname = $config{wikiname}; + utf8::encode($wikiname); + Sys::Syslog::syslog($type, "[$wikiname] %s", join(" ", @_)); }; + if ($@) { + print STDERR "failed to syslog: $@" unless $log_failed; + $log_failed=1; + print STDERR "@_\n"; + } + return $@; } elsif (! $config{cgi}) { return print "@_\n"; @@@ -1796,8 -1791,7 +1806,8 @@@ sub enable_commit_hook () sub loadindex () { %oldrenderedfiles=%pagectime=(); - if (! $config{rebuild}) { + my $rebuild=$config{rebuild}; + if (! $rebuild) { %pagesources=%pagemtime=%oldlinks=%links=%depends= %destsources=%renderedfiles=%pagecase=%pagestate= %depends_simple=%typedlinks=%oldtypedlinks=(); @@@ -1837,16 -1831,10 +1847,16 @@@ foreach my $src (keys %$pages) { my $d=$pages->{$src}; - my $page=pagename($src); + my $page; + if (exists $d->{page} && ! $rebuild) { + $page=$d->{page}; + } + else { + $page=pagename($src); + } $pagectime{$page}=$d->{ctime}; $pagesources{$page}=$src; - if (! $config{rebuild}) { + if (! $rebuild) { $pagemtime{$page}=$d->{mtime}; $renderedfiles{$page}=$d->{dest}; if (exists $d->{links} && ref $d->{links}) { @@@ -1896,8 -1884,6 +1906,8 @@@ foreach my $page (keys %renderedfiles) { $destsources{$_}=$page foreach @{$renderedfiles{$page}}; } + $lastrev=$index->{lastrev}; + @underlayfiles=@{$index->{underlayfiles}} if ref $index->{underlayfiles}; return close($in); } @@@ -1919,7 -1905,6 +1929,7 @@@ sub saveindex () my $src=$pagesources{$page}; $index{page}{$src}={ + page => $page, ctime => $pagectime{$page}, mtime => $pagemtime{$page}, dest => $renderedfiles{$page}, @@@ -1939,7 -1924,11 +1949,7 @@@ } if (exists $pagestate{$page}) { - foreach my $id (@plugins) { - foreach my $key (keys %{$pagestate{$page}{$id}}) { - $index{page}{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key}; - } - } + $index{page}{$src}{state}=$pagestate{$page}; } } @@@ -1951,9 -1940,6 +1961,9 @@@ } } + $index{lastrev}=$lastrev; + $index{underlayfiles}=\@underlayfiles; + $index{version}="3"; my $ret=Storable::nstore_fd(\%index, $out); return if ! defined $ret || ! $ret; @@@ -2309,7 -2295,6 +2319,7 @@@ sub useragent () return LWP::UserAgent->new( cookie_jar => $config{cookiejar}, env_proxy => 1, # respect proxy env vars + agent => $config{useragent}, ); }