summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-11-10 13:49:14 +0100
committerintrigeri <intrigeri@boum.org>2008-11-10 13:51:00 +0100
commit3174b4c6f3451dd21bf91e2ae98173451a5c403f (patch)
treee37c3ed2e42fddd92b7d0c0c56dd1cb58c35b9c1 /IkiWiki
parent00732f19b9806730ea90de90a3cef59dc858c625 (diff)
po: abstract %filtered implementation details
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/po.pm36
1 files changed, 29 insertions, 7 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index d475158c1..5336de813 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -335,6 +335,31 @@ sub mybestlink ($$) { #{{{
return "";
} #}}}
+sub alreadyfiltered($$) { #{{{
+ my $page=shift;
+ my $destpage=shift;
+
+ return ( exists $filtered{$page}{$destpage}
+ && $filtered{$page}{$destpage} eq 1 );
+} #}}}
+sub setalreadyfiltered($$) { #{{{
+ my $page=shift;
+ my $destpage=shift;
+
+ $filtered{$page}{$destpage}=1;
+} #}}}
+sub unsetalreadyfiltered($$) { #{{{
+ my $page=shift;
+ my $destpage=shift;
+
+ if (exists $filtered{$page}{$destpage}) {
+ delete $filtered{$page}{$destpage};
+ }
+} #}}}
+sub resetalreadyfiltered() { #{{{
+ undef %filtered;
+} #}}}
+
# We use filter to convert PO to the master page's format,
# since the rest of ikiwiki should not work on PO files.
sub filter (@) { #{{{
@@ -345,8 +370,7 @@ sub filter (@) { #{{{
my $content = decode_utf8(encode_utf8($params{content}));
return $content if ( ! istranslation($page)
- || ( exists $filtered{$page}{$destpage}
- && $filtered{$page}{$destpage} eq 1 ));
+ || alreadyfiltered($page, $destpage) );
# CRLF line terminators make poor Locale::Po4a feel bad
$content=~s/\r\n/\n/g;
@@ -394,7 +418,7 @@ sub filter (@) { #{{{
# and Locale::Po4a::write() work.
unlink $infile, $outfile;
- $filtered{$page}{$destpage}=1;
+ setalreadyfiltered($page, $destpage);
return $content;
} #}}}
@@ -569,7 +593,7 @@ sub change(@) { #{{{
IkiWiki::rcs_update();
}
# Reinitialize module's private variables.
- undef %filtered;
+ resetalreadyfiltered();
undef %translations;
# Trigger a wiki refresh.
require IkiWiki::Render;
@@ -582,9 +606,7 @@ sub editcontent () { #{{{
my %params=@_;
# as we're previewing or saving a page, the content may have
# changed, so tell the next filter() invocation it must not be lazy
- if (exists $filtered{$params{page}}{$params{page}}) {
- delete $filtered{$params{page}}{$params{page}};
- }
+ unsetalreadyfiltered($params{page}, $params{page});
return $params{content};
} #}}}