From a8d60ac238363bde5fe5c4b0363f46bf0b1fed7f Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 29 Dec 2008 13:06:44 +0000 Subject: inizio dei feed git-svn-id: svn://luxion/repos/WebCoso/trunk@396 fcb26f47-9200-0410-b104-b98ab5b095f3 --- lib/WebCoso/Common.pm | 14 +++++++++----- lib/WebCoso/Maker.pm | 8 ++++---- t/test-site/src/common/fillFeed.xsl | 28 ++++++++++++++++++++++++++++ t/test-site/src/feed.it.tt | 1 + t/test-site/src/feed.tt | 14 ++++++++++++++ t/test-site/src/fillFeed.xsl | 1 + 6 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 t/test-site/src/common/fillFeed.xsl create mode 120000 t/test-site/src/feed.it.tt create mode 100644 t/test-site/src/feed.tt create mode 120000 t/test-site/src/fillFeed.xsl diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm index 7b610f2..665de33 100644 --- a/lib/WebCoso/Common.pm +++ b/lib/WebCoso/Common.pm @@ -20,19 +20,19 @@ $xpath->registerNs('x', 'http://www.w3.org/1999/xhtml'); sub langOf { my ($name)=@_; - $name=~m{(^|/)document\.([^.]+)(\.|$)} and return $2; + $name=~m{(^|/)(?:document|feed)\.([^.]+)(\.|$)} and return $2; return; } sub typeOf { my ($name)=@_; - $name=~m{(^|/)document\.[^.]+\.([^.]+\.[^.]+)$} and return $2; + $name=~m{(^|/)(?:document|feed)\.[^.]+\.((?:[^.]+\.)*[^.]+)$} and return $2; return; } sub typedAs { my ($name,$newtype)=@_; - $name=~s{(^|/)(document\.[^.]+\.)([^.]+\.[^.]+)$}{$1$2$newtype}; + $name=~s{(^|/)((?:document|feed)\.[^.]+\.)((?:[^.]+\.)*[^.]+)$}{$1$2$newtype}; return $name; } @@ -172,6 +172,7 @@ sub fromTo { else { push @ret,$file while $file=$iter->(); } + DEBUG("fromTo: @ret"); return uniq(@ret); } @@ -214,7 +215,10 @@ our %docfiles=( files=>sub{m{^document\.}}, dirs=>sub{!m{^(tags$|_|\.)}}); our %feedfiles=( - files=>sub{m{^feed\.[.]+\.tt$}}, - dirs=>sub{!m{^[^_.]}}); + files=>sub{m{^feed\.[^.]+\.tt$}}, + dirs=>sub{!m{^[_.]}}); +our %feedfilesXML=( + files=>sub{m{^feed\.[^.]+\.xml$}}, + dirs=>sub{!m{^[_.]}}); 1; diff --git a/lib/WebCoso/Maker.pm b/lib/WebCoso/Maker.pm index e8943be..11aa9c4 100644 --- a/lib/WebCoso/Maker.pm +++ b/lib/WebCoso/Maker.pm @@ -163,7 +163,7 @@ my @passes=( WebCoso::Common::fromTo("$WebCoso::Common::SRCPATH/", { %WebCoso::Common::feedfiles, - transform=>sub{WebCoso::Common::typedAs($_[0],'.xml')}, + transform=>sub{WebCoso::Common::typedAs($_[0],'xml')}, }), "$WebCoso::Common::SRCPATH/_webcoso/tags.yml", "$WebCoso::Common::SRCPATH/_webcoso/changes.yml", @@ -205,9 +205,9 @@ my @passes=( "$WebCoso::Common::SRCPATH/\$1/feed.\$2.xml", '=', $xslt->fillFeed()], - ["$WebCoso::Common::DSTPATH/feed.(*).xml", + ["$WebCoso::Common::DSTPATH/()feed.(*).xml", ':', - "$WebCoso::Common::SRCPATH/feed.\$1.xml", + "$WebCoso::Common::SRCPATH/feed.\$2.xml", '=', $xslt->fillFeed()], ], @@ -233,7 +233,7 @@ my @passes=( }), WebCoso::Common::fromTo("$WebCoso::Common::SRCPATH/", { - %WebCoso::Common::feedfiles, + %WebCoso::Common::feedfilesXML, transform=>sub{ (my $file=$_[0]) =~s{^\Q$WebCoso::Common::SRCPATH\E/}{$WebCoso::Common::DSTPATH/}; diff --git a/t/test-site/src/common/fillFeed.xsl b/t/test-site/src/common/fillFeed.xsl new file mode 100644 index 0000000..d19bf2b --- /dev/null +++ b/t/test-site/src/common/fillFeed.xsl @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + <x:apply-templates select="wc:title-for($language,$filename,.)"/> + + + + \ No newline at end of file diff --git a/t/test-site/src/feed.it.tt b/t/test-site/src/feed.it.tt new file mode 120000 index 0000000..3902f44 --- /dev/null +++ b/t/test-site/src/feed.it.tt @@ -0,0 +1 @@ +feed.tt \ No newline at end of file diff --git a/t/test-site/src/feed.tt b/t/test-site/src/feed.tt new file mode 100644 index 0000000..398eaf3 --- /dev/null +++ b/t/test-site/src/feed.tt @@ -0,0 +1,14 @@ +[% USE df = DateTime::Format('DateTime::Format::Strptime', + { pattern => '%F %T', + locale => 'en_US', + time_zone => 'GMT' }) -%] + + +[% FOR c IN changed -%] + + [% IF c.value.creation %][% df.format(c.value.creation) %][% END %] + [% IF c.value.last_change %][% df.format(c.value.last_change) %][% END %] + [% dstUriFor(c.key) %] + +[% END -%] + diff --git a/t/test-site/src/fillFeed.xsl b/t/test-site/src/fillFeed.xsl new file mode 120000 index 0000000..d94f4d6 --- /dev/null +++ b/t/test-site/src/fillFeed.xsl @@ -0,0 +1 @@ +common/fillFeed.xsl \ No newline at end of file -- cgit v1.2.3