diff options
-rw-r--r-- | lib/WebCoso/Cleaner.pm | 7 | ||||
-rw-r--r-- | lib/WebCoso/Common.pm | 47 | ||||
-rw-r--r-- | lib/WebCoso/XSLT.pm | 4 | ||||
-rw-r--r-- | t/test-site/src/common/fillFeed.xsl | 20 |
4 files changed, 45 insertions, 33 deletions
diff --git a/lib/WebCoso/Cleaner.pm b/lib/WebCoso/Cleaner.pm index 8c7eb32..69d2bb7 100644 --- a/lib/WebCoso/Cleaner.pm +++ b/lib/WebCoso/Cleaner.pm @@ -8,10 +8,11 @@ use Log::Log4perl ':easy'; sub clean { my %to_keep; - @to_keep{WebCoso::Common::keepEarliest(WebCoso::Common::fromTo($WebCoso::Common::SRCPATH,{%WebCoso::Common::docfiles,dirs=>sub{!m{^(_webcoso|\.svn)$}}}))}=(); - @to_keep{WebCoso::Common::fromTo($WebCoso::Common::SRCPATH,{files=>sub{!m{^document\.}},dirs=>sub{!m{^(_webcoso|\.svn)$}}})}=(); + @to_keep{WebCoso::Common::keepEarliest(WebCoso::Common::fromTo($WebCoso::Common::SRCPATH,{%WebCoso::Common::docfiles,dirs=>sub{!m{^[_.]}}}))}=(); + @to_keep{WebCoso::Common::fromTo($WebCoso::Common::SRCPATH,{%WebCoso::Common::feedfiles})}=(); + @to_keep{WebCoso::Common::fromTo($WebCoso::Common::SRCPATH,{files=>sub{!m{^(?:document|feed)\.}},dirs=>sub{!m{^[_.]}}})}=(); - my $iter=File::Next::files({descend_filter=>sub{!m{^\.svn$}}},$WebCoso::Common::SRCPATH,$WebCoso::Common::DSTPATH); + my $iter=File::Next::files({descend_filter=>sub{!m{^\.}}},$WebCoso::Common::SRCPATH,$WebCoso::Common::DSTPATH); while (defined (my $file=$iter->())) { DEBUG("Examining $file"); next if exists $to_keep{$file}; diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm index 665de33..00f0b6b 100644 --- a/lib/WebCoso/Common.pm +++ b/lib/WebCoso/Common.pm @@ -50,17 +50,8 @@ sub dstUriFor { return $name; } -sub isLang { - my ($lang,$name)=@_; - DEBUG("isLang($lang,$name)"); - return 1 if $name=~m{/$}; # assume that MultiViews on the server will work - return 1 if langOf($name) eq $lang; - return; -} - -sub getTitleFor { - my ($fc,$lang,$path,$name)=@_; - DEBUG("getTitleFor($lang,$path,$name)"); +sub srcXMLFor { + my ($lang,$path,$name)=@_; $name="$name"; # force it to a string, since it might be an XML Node @@ -74,6 +65,22 @@ sub getTitleFor { $doc_name=file($doc_name)->absolute(file($path)->parent)->relative($SRCPATH); # absolutize it $doc_name="$SRCPATH/$doc_name"; } + + return $doc_name; +} + +sub isLang { + my ($lang,$name)=@_; + DEBUG("isLang($lang,$name)"); + return 1 if $name=~m{/$}; # assume that MultiViews on the server will work + return 1 if langOf($name) eq $lang; + return; +} + +sub getTitleFor { + my ($fc,$lang,$path,$name)=@_; + DEBUG("getTitleFor($lang,$path,$name)"); + my $doc_name=srcXMLFor($lang,$path,$name); DEBUG("getTitleFor -> $doc_name"); my $doc=$fc->get($doc_name); @@ -92,19 +99,7 @@ sub getTitleFor { sub getDatesFor { my ($fc,$lang,$path,$name)=@_; DEBUG("getDatesFor($lang,$path,$name)"); - - my $doc_name=$name; - $doc_name=~s{\.html$}{.du.xml}; - $doc_name=~s{/$}{/document.$lang.du.xml}; - if ($doc_name=~m{^\Q$DSTBASEURL\E}) { - $doc_name=~s{^\Q$DSTBASEURL\E}{$SRCPATH/}; - } - else { - $doc_name=file($doc_name)->absolute(file($path)->parent)->relative($SRCPATH); # absolutize it - $doc_name="$SRCPATH/$doc_name"; - } - DEBUG("getDatesFor -> $doc_name"); - + my $doc_name=srcXMLFor($lang,$path,$name); my $doc=$fc->get($doc_name); unless ($doc) { LOGWARN("No document for <$doc_name>, returning <0>"); @@ -178,8 +173,10 @@ sub fromTo { { my %order=( + 'tt'=>0, 'rest.tt'=>0, 'rest.txt'=>1, + 'xml'=>2, 'du.xml'=>2, ); sub earliest { @@ -215,7 +212,7 @@ our %docfiles=( files=>sub{m{^document\.}}, dirs=>sub{!m{^(tags$|_|\.)}}); our %feedfiles=( - files=>sub{m{^feed\.[^.]+\.tt$}}, + files=>sub{m{^feed\.(?:[^.]+\.)*tt$}}, dirs=>sub{!m{^[_.]}}); our %feedfilesXML=( files=>sub{m{^feed\.[^.]+\.xml$}}, diff --git a/lib/WebCoso/XSLT.pm b/lib/WebCoso/XSLT.pm index c47377a..40c945b 100644 --- a/lib/WebCoso/XSLT.pm +++ b/lib/WebCoso/XSLT.pm @@ -23,6 +23,8 @@ sub new { $self->{xslt_proc}->register_function($NS,'tagged',sub{$self->getTagsXML}); $self->{xslt_proc}->register_function($NS,'dates-for', sub{$self->getDatesXML(WebCoso::Common::getDatesFor($self->{fc},@_))}); + $self->{xslt_proc}->register_function($NS,'document', + sub{$self->{fc}->get(WebCoso::Common::srcXMLFor(@_))}); $self->{xslt_proc}->register_function($NS,'message', sub{DEBUG($_[0],' ',$_[1]->get_node(0)->toString());return ''}); $self->{xslt_proc}->debug_callback(sub{DEBUG(@_)}); @@ -43,7 +45,7 @@ sub new { my $xslt=file($deps->[-1])->parent->file('du2html.xsl'); $xslt=$self->{fc}->get($xslt); if (@$deps>1) { - INFO("xml tag source from as $deps->[0]"); + INFO("xml tag source from $deps->[0]"); $self->setXMLTagsSource($self->{fc}->get($deps->[0])); } else { $self->setXMLTagsSource(undef); diff --git a/t/test-site/src/common/fillFeed.xsl b/t/test-site/src/common/fillFeed.xsl index d19bf2b..79c7b57 100644 --- a/t/test-site/src/common/fillFeed.xsl +++ b/t/test-site/src/common/fillFeed.xsl @@ -1,17 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> <x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform" xmlns:wc="http://webcoso.thenautilus.net/" + exclude-result-prefixes="wc" version="1.0"> + <x:import href="du2html.xsl"/> + <x:param name="language" select="'en'"/> <x:param name="path"/> <x:param name="filename"/> - <x:output method="xml" encoding="utf-8"/> + <x:output method="xml" encoding="utf-8" doctype-public=""/> + + <x:template match="/document" priority="10"> + <x:apply-imports/> + </x:template> <x:template match="*"> <x:copy> - <x:apply-templates select="@*|*|text()"/> + <x:apply-templates select="@*"/> + <x:apply-templates select="*|text()"/> </x:copy> </x:template> @@ -21,8 +29,12 @@ <x:template match="PH"> <url><x:value-of select="."/></url> - <title><x:apply-templates select="wc:title-for($language,$filename,.)"/></title> + <title><x:value-of select="wc:title-for($language,$filename,.)"/></title> + <!-- + <body> + <x:apply-templates select="wc:document($language,$filename,.)/document"/> + </body> + --> </x:template> - </x:stylesheet>
\ No newline at end of file |