aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/WebCoso/Common.pm14
-rw-r--r--lib/WebCoso/Maker.pm8
-rw-r--r--t/test-site/src/common/fillFeed.xsl28
l---------t/test-site/src/feed.it.tt1
-rw-r--r--t/test-site/src/feed.tt14
l---------t/test-site/src/fillFeed.xsl1
6 files changed, 57 insertions, 9 deletions
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform"
+ xmlns:wc="http://webcoso.thenautilus.net/"
+ version="1.0">
+
+ <x:param name="language" select="'en'"/>
+ <x:param name="path"/>
+ <x:param name="filename"/>
+
+ <x:output method="xml" encoding="utf-8"/>
+
+ <x:template match="*">
+ <x:copy>
+ <x:apply-templates select="@*|*|text()"/>
+ </x:copy>
+ </x:template>
+
+ <x:template match="@*">
+ <x:copy/>
+ </x:template>
+
+ <x:template match="PH">
+ <url><x:value-of select="."/></url>
+ <title><x:apply-templates select="wc:title-for($language,$filename,.)"/></title>
+ </x:template>
+
+
+</x:stylesheet> \ 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' }) -%]
+<?xml version="1.0" encoding="utf-8"?>
+<feed>
+[% FOR c IN changed -%]
+<item>
+ [% IF c.value.creation %]<created>[% df.format(c.value.creation) %]</created>[% END %]
+ [% IF c.value.last_change %]<last>[% df.format(c.value.last_change) %]</last>[% END %]
+ <PH>[% dstUriFor(c.key) %]</PH>
+</item>
+[% END -%]
+</feed>
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