From 8d25800c67ad65defd98771bba2331ee64104f98 Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 7 Jan 2009 12:51:13 +0000 Subject: feed fatti, e pure col test manca: testare feed intl, fare feed dei tag, mettere i tag nei feed git-svn-id: svn://luxion/repos/WebCoso/trunk@402 fcb26f47-9200-0410-b104-b98ab5b095f3 --- lib/WebCoso/Common.pm | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'lib/WebCoso/Common.pm') diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm index 5420063..eed6f3a 100644 --- a/lib/WebCoso/Common.pm +++ b/lib/WebCoso/Common.pm @@ -37,14 +37,20 @@ sub typedAs { } sub dstUriFor { - my ($name,$short)=(@_,1); - DEBUG("dstUriFor($name,$short)"); + my ($name,$path,$short)=@_; + $short=1 unless defined $short; + $path||=''; + DEBUG("dstUriFor($name,$path,$short)"); if ($short) { $name=~s{/[^/]+$}{/}; } else { $name=typedAs($name,'html'); } + if ($path) { + $name=file($name)->absolute(file($path)->parent)->relative($SRCPATH); + $name="$SRCPATH/$name"; + } $name=~s{^\Q$SRCPATH\E/}{$DSTBASEURL}; DEBUG("dstUriFor -> $name"); return $name; @@ -53,9 +59,7 @@ sub dstUriFor { sub srcXMLFor { my ($lang,$path,$name)=@_; - $name="$name"; # force it to a string, since it might be an XML Node - - my $doc_name=$name; + my $doc_name="$name"; # force it to a string, since it might be an XML Node $doc_name=~s{\.html$}{.du.xml}; $doc_name=~s{/$}{/document.$lang.du.xml}; if ($doc_name=~m{^\Q$DSTBASEURL\E}) { @@ -94,6 +98,24 @@ sub getTitleFor { return $title; } +sub getAtomIdFor { + my ($fc,$lang,$path,$name)=@_; + DEBUG("getAtomIdFor($lang,$path,$name)"); + my $doc_name=srcXMLFor($lang,$path,$name); + DEBUG("getAtomIdFor -> $doc_name"); + + my $doc=$fc->get($doc_name); + unless ($doc) { + LOGWARN("No document for <$doc_name>, returning ''"); + return ''; + } + my $atomId=$xpath->findnodes( + q{/document/docinfo/field[field_name='Id']/field_body}, + $doc); + $atomId=~s{(?:\A\s+)|(?:\s+\z)}{}smgx; + return $atomId; +} + { my $zero=DateTime->from_epoch(epoch=>0); sub getDatesFor { -- cgit v1.2.3