aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso/Common.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WebCoso/Common.pm')
-rw-r--r--lib/WebCoso/Common.pm47
1 files changed, 22 insertions, 25 deletions
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$}},