diff options
author | dakkar <dakkar@luxion> | 2009-01-07 14:11:50 +0000 |
---|---|---|
committer | dakkar <dakkar@luxion> | 2009-01-07 14:11:50 +0000 |
commit | 6ef2ff64a7489335489be54495d47d0ca232b937 (patch) | |
tree | 0b02c116dace706065712e8214e8b6256e5de1a7 | |
parent | messi i tag / category nel feed (diff) | |
download | WebCoso-6ef2ff64a7489335489be54495d47d0ca232b937.tar.gz WebCoso-6ef2ff64a7489335489be54495d47d0ca232b937.tar.bz2 WebCoso-6ef2ff64a7489335489be54495d47d0ca232b937.zip |
pulizia dei path, ma non va proprio bene
git-svn-id: svn://luxion/repos/WebCoso/trunk@404 fcb26f47-9200-0410-b104-b98ab5b095f3
-rw-r--r-- | lib/WebCoso/Common.pm | 12 | ||||
-rw-r--r-- | lib/WebCoso/TT.pm | 2 | ||||
-rw-r--r-- | script/webcoso.pl | 2 | ||||
-rw-r--r-- | t/test-site/src/common/base-feed.tt | 12 |
4 files changed, 23 insertions, 5 deletions
diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm index 46f63b6..6c9a433 100644 --- a/lib/WebCoso/Common.pm +++ b/lib/WebCoso/Common.pm @@ -15,6 +15,13 @@ our $DSTBASEURL='/'; our @TMPLPATH=('common/'); our $VERBOSITY=0; +sub setpaths { + for my $path ($SRCPATH,$DSTPATH,@TMPLPATH) { + $path=file($path)->absolute()->stringify; + } + return; +} + my $xpath=XML::LibXML::XPathContext->new(); $xpath->registerNs('x', 'http://www.w3.org/1999/xhtml'); @@ -49,7 +56,7 @@ sub dstUriFor { } if ($path) { $name=file($name)->absolute(file($path)->parent)->relative($SRCPATH); - $name="$SRCPATH/$name"; + $name=dir("$SRCPATH/$name/")->cleanup->stringify . '/'; } $name=~s{^\Q$SRCPATH\E/}{$DSTBASEURL}; DEBUG("dstUriFor -> $name"); @@ -182,7 +189,8 @@ sub getTags { my %tagged; for my $doc_name (uniq(@docs)) { - my $doc=$fc->get($doc_name); + my $xml_name=typedAs($doc_name,'du.xml'); + my $doc=$fc->get($xml_name); my @tags=map {$_->textContent} $xpath->findnodes( q{/document/docinfo/field[field_name='tags']/field_body/*/list_item|/document/docinfo/field[field_name='tags']/field_body/paragraph}, diff --git a/lib/WebCoso/TT.pm b/lib/WebCoso/TT.pm index 15e2072..50b28a3 100644 --- a/lib/WebCoso/TT.pm +++ b/lib/WebCoso/TT.pm @@ -39,6 +39,7 @@ sub new { dstUriFor => \&WebCoso::Common::dstUriFor, isLang => \&WebCoso::Common::isLang, atomIdFor => sub{WebCoso::Common::getAtomIdFor($self->{fc},@_)}, + typedAs => \&WebCoso::Common::typedAs, }; $self->{template_provider}=Template::Provider->new({ @@ -64,6 +65,7 @@ sub new { my $tmpl=$self->{fc}->get($deps->[-1]); my $vars={ path=> $matches->[0], language => $matches->[1], + filename => $deps->[-1], %{$self->{stash}}, }; if (@$deps>1) { diff --git a/script/webcoso.pl b/script/webcoso.pl index a4f9407..cfa9f75 100644 --- a/script/webcoso.pl +++ b/script/webcoso.pl @@ -25,7 +25,7 @@ Log::Log4perl->easy_init({level=> ->[$WebCoso::Common::VERBOSITY] }); - +WebCoso::Common::setpaths(); if ($CLEAN) { require WebCoso::Cleaner; WebCoso::Cleaner::clean(); diff --git a/t/test-site/src/common/base-feed.tt b/t/test-site/src/common/base-feed.tt index e2669e3..2559f29 100644 --- a/t/test-site/src/common/base-feed.tt +++ b/t/test-site/src/common/base-feed.tt @@ -4,15 +4,23 @@ time_zone => 'GMT' }) -%] [% USE Dumper -%] [% docs=changed.nsortf('last_change') -%] +[% tag='';IF (matches = path.match('^(?:.*/)?tags/(.*)$')); tag = matches.0; END -%] <?xml version="1.0" encoding="utf-8"?> <a:feed xmlns:a="http://www.w3.org/2005/Atom"> +<a:tag>[% tag %] ( [% path %] )</a:tag> <a:updated>[% l=docs.last;df.format(changed.$l.last_change) %]</a:updated> [% FOR doc IN docs; NEXT UNLESS isLang(language,doc) -%] +[% IF tag; + doc_duxml=typedAs(doc,'du.xml'); + IF tagged.$tag.grep(doc_duxml).size == 0; # bad regex... + NEXT; + END; + END -%] <a:entry> [% IF changed.$doc.creation %]<a:published>[% df.format(changed.$doc.creation) %]</a:published>[% END %] [% IF changed.$doc.last_change %]<a:updated>[% df.format(changed.$doc.last_change) %]</a:updated>[% END %] - <a:id>[% atomIdFor(language,doc,path) %]</a:id> - <a:PH>[% dstUriFor(doc,path) %]</a:PH> + <a:id>[% atomIdFor(language,filename,dstUriFor(doc,filename)) %]</a:id> + <a:PH>[% dstUriFor(doc,filename) %]</a:PH> </a:entry> [% END -%] </a:feed> |