diff options
Diffstat (limited to 'lib/WebCoso/Common.pm')
-rw-r--r-- | lib/WebCoso/Common.pm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm index 9640135..6b6ba9e 100644 --- a/lib/WebCoso/Common.pm +++ b/lib/WebCoso/Common.pm @@ -6,6 +6,7 @@ use Path::Class; use XML::LibXML::XPathContext; use DateTime; use DateTime::Format::DateParse; +use Log::Log4perl ':easy'; our $SRCPATH='src'; our $DSTPATH='dst'; @@ -35,7 +36,7 @@ sub typedAs { sub dstUriFor { my ($name,$short)=(@_,1); - warn "dstUriFor($name,$short)\n"; + DEBUG("dstUriFor($name,$short)"); if ($short) { $name=~s{/[^/]+$}{/}; } @@ -43,12 +44,13 @@ sub dstUriFor { $name=typedAs($name,'html'); } $name=~s{^\Q$SRCPATH\E/}{$DSTBASEURL}; + DEBUG("dstUriFor -> $name"); return $name; } sub isLang { my ($lang,$name)=@_; - warn "isLang($lang,$name)\n"; + 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; @@ -56,6 +58,7 @@ sub isLang { sub getTitleFor { my ($fc,$lang,$path,$name)=@_; + DEBUG("getTitleFor($lang,$path,$name)"); my $doc_name=$name; $doc_name=~s{\.html$}{.du.xml}; @@ -67,11 +70,11 @@ sub getTitleFor { $doc_name=file($doc_name)->absolute(file($path)->parent)->relative($SRCPATH); # absolutize it $doc_name="$SRCPATH/$doc_name"; } - warn "getTitleFor($lang,$path,$name)->$doc_name\n"; + DEBUG("getTitleFor -> $doc_name"); my $doc=$fc->get($doc_name); unless ($doc) { - warn "No document for <$doc_name>, returning <$name>\n"; + LOGWARN("No document for <$doc_name>, returning <$name>"); return $name; } my $title=$xpath->findnodes( @@ -84,6 +87,7 @@ sub getTitleFor { my $zero=DateTime->from_epoch(epoch=>0); sub getDatesFor { my ($fc,$lang,$path,$name)=@_; + DEBUG("getDatesFor($lang,$path,$name)"); my $doc_name=$name; $doc_name=~s{\.html$}{.du.xml}; @@ -95,11 +99,11 @@ sub getDatesFor { $doc_name=file($doc_name)->absolute(file($path)->parent)->relative($SRCPATH); # absolutize it $doc_name="$SRCPATH/$doc_name"; } - warn "getDatesFor($lang,$path,$name)->$doc_name\n"; + DEBUG("getDatesFor -> $doc_name"); my $doc=$fc->get($doc_name); unless ($doc) { - warn "No document for <$doc_name>, returning <0>\n"; + LOGWARN("No document for <$doc_name>, returning <0>"); return {creation=>$zero,last_change=>$zero}; } my ($creation_date)=map {$_->textContent} |