From 26ff8bed4c6560f04b00ab8b5e3867645b740807 Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 29 Dec 2008 13:44:50 +0000 Subject: forse i feed vanno (tranne i body); cleaner non elimina i sorgenti dei feed git-svn-id: svn://luxion/repos/WebCoso/trunk@397 fcb26f47-9200-0410-b104-b98ab5b095f3 --- lib/WebCoso/Cleaner.pm | 7 +++--- lib/WebCoso/Common.pm | 47 +++++++++++++++++-------------------- lib/WebCoso/XSLT.pm | 4 +++- 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 @@ + + - + + + + + - + + @@ -21,8 +29,12 @@ - <x:apply-templates select="wc:title-for($language,$filename,.)"/> + <x:value-of select="wc:title-for($language,$filename,.)"/> + - \ No newline at end of file -- cgit v1.2.3