aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2007-09-09 12:01:07 +0000
committerdakkar <dakkar@luxion>2007-09-09 12:01:07 +0000
commit8dc8570439db6d929aed1d485a7d77f8b7c0831d (patch)
tree1d89c408ea0e3962d4f3f2fc9f04cd6ba57aef3f
parentfirst test (preparation) (diff)
downloadWebCoso-8dc8570439db6d929aed1d485a7d77f8b7c0831d.tar.gz
WebCoso-8dc8570439db6d929aed1d485a7d77f8b7c0831d.tar.bz2
WebCoso-8dc8570439db6d929aed1d485a7d77f8b7c0831d.zip
almost works!
git-svn-id: svn://luxion/repos/WebCoso/trunk@287 fcb26f47-9200-0410-b104-b98ab5b095f3
-rw-r--r--stest.pl39
-rw-r--r--t/test-site/common/document-listing.tt2
-rw-r--r--t/test-site/src/bar/document.en.rest.tt2
-rw-r--r--t/test-site/src/bar/document.it.rest.tt2
-rw-r--r--t/test-site/src/document.en.rest.txt2
-rw-r--r--t/test-site/src/document.it.rest.txt2
l---------t/test-site/src/du2html.xsl1
l---------t/test-site/tags/du2html.xsl1
l---------t/test-site/tags/one/du2html.xsl1
-rw-r--r--t/test-site/tags/three/bis/document.en.rest.tt6
-rw-r--r--t/test-site/tags/three/bis/document.it.rest.tt6
l---------t/test-site/tags/three/bis/du2html.xsl1
-rw-r--r--t/test-site/tags/three/document.en.rest.tt6
-rw-r--r--t/test-site/tags/three/document.it.rest.tt6
l---------t/test-site/tags/three/du2html.xsl1
l---------t/test-site/tags/two/du2html.xsl1
16 files changed, 50 insertions, 29 deletions
diff --git a/stest.pl b/stest.pl
index fc87b8b..69f3918 100644
--- a/stest.pl
+++ b/stest.pl
@@ -14,7 +14,14 @@ use XML::LibXSLT;
use YAML::Syck;
my $stash={};
-my $template=Template->new();
+my $template_provider=Template::Provider->new({
+ INCLUDE_PATH=> 'common/',
+ ABSOLUTE=>1,
+ RELATIVE=>1,
+});
+my $template=Template->new({
+ LOAD_TEMPLATES=>[$template_provider],
+});
my $rest=Text::Restructured->new({},'WebCoso');
my $xml_parser=XML::LibXML->new();
my $xslt_proc=XML::LibXSLT->new();
@@ -54,15 +61,18 @@ sub expandTT {
if (@$deps>1) {
$vars->{tagged}=$fc->get($deps->[0]);
}
+ push @{$template_provider->include_path},
+ file($deps->[-1])->parent;
$fc->put($target,
$template->context->process($tmpl,
$vars));
+ pop @{$template_provider->include_path};
}
sub parseRST {
my ($maker,$target,$deps,$matches)=@_;
- $fc->put($target,$fc->get($deps->[0]));
+ $fc->put($target,$fc->get($deps->[-1]));
}
sub du2html {
@@ -87,10 +97,11 @@ sub getTags {
my %tagged;
for my $doc_name (@$deps) {
my $doc=$fc->get($doc_name);
- my @tags=map {$_->textContext}
- $xpath->find(
+ my @tags=map {$_->textContent}
+ $xpath->findnodes(
q{/document/docinfo/field[field_name='tags']/field_body/*/list_item},
$doc);
+ chomp for @tags;
push @{$tagged{$_}},$doc_name for @tags;
}
$fc->put($target,\%tagged);
@@ -160,18 +171,22 @@ sub keepEarliest {
return @ret;
}
-my %files=(files=>sub{m{^document\.}});
+my %files=(files=>sub{m{^document\.} and ($File::Next::dir !~ m{/\.svn/})});
my $maker=Slay::Maker->new({
rules => [
['src/(**)/document.(*).rest.txt',':',ifExists('src/$1/document.$2.rest.tt'),'=',\&expandTT],
['src/(**)/document.(*).du.xml',':',ifExists('src/$1/document.$2.rest.txt'),'=',\&parseRST],
- ['deps/tags.xml',':',fromTo('src/',{%files,transform=>sub{my $s=shift;$s=~s{\.[^.]+\.[^.]+$}{.du.xml};$s}}),'=',\&getTags],
+ ['src/()document.(*).rest.txt',':',ifExists('src/document.$2.rest.tt'),'=',\&expandTT],
+ ['src/()document.(*).du.xml',':',ifExists('src/document.$2.rest.txt'),'=',\&parseRST],
+ ['deps/tags.yml',':',fromTo('src/',{%files,transform=>sub{my $s=shift;$s=~s{\.[^.]+\.[^.]+$}{.du.xml};$s}}),'=',\&getTags],
#['deps/changes.xml',':',keepEarliest(fromTo('src/',{%files})),'=',\&getChanges],
['tags/(**)/document.(*).rest.txt',':','deps/tags.yml',ifExists('tags/$1/document.$2.rest.tt'),'=',\&expandTT],
['tags/(**)/document.(*).du.xml',':','deps/tags.yml',ifExists('tags/$1/document.$2.rest.txt'),'=',\&parseRST],
- ['dst/(**)/document.(*).xhtml',':','deps/tags.yml','deps/changes.xml',ifExists('src/$1/document.$2.du.xml'),ifExists('tags/$1/document.$2.du.xml'),'=',\&du2html],
+ ['dtags/(**)/document.(*).html',':','deps/tags.yml','tags/$1/document.$2.du.xml','=',\&du2html],
+ ['dst/(**)/document.(*).html',':','deps/tags.yml','src/$1/document.$2.du.xml','=',\&du2html],
+ ['dst/()document.(*).html',':','deps/tags.yml','src/document.$2.du.xml','=',\&du2html],
],
options => {
auto_create_dirs => 1,
@@ -181,12 +196,12 @@ my $maker=Slay::Maker->new({
},
});
-my @targets=fromTo('src/',
+my @targets=(fromTo('src/',
{
%files,
transform=>sub{
my $src=shift;
- $src=~s{\.[^.]+\.[^.]+$}{.xhtml};
+ $src=~s{\.[^.]+\.[^.]+$}{.html};
$src=~s{^src/}{dst/};
return $src;
},
@@ -196,11 +211,11 @@ my @targets=fromTo('src/',
%files,
transform=>sub{
my $src=shift;
- $src=~s{\.[^.]+\.[^.]+$}{.xhtml};
- $src=~s{^tags/}{dst/};
+ $src=~s{\.[^.]+\.[^.]+$}{.html};
+ $src=~s{^tags/}{dtags/};
return $src;
},
- });
+ }));
print "targets: @targets\n";
$maker->make(@targets);
diff --git a/t/test-site/common/document-listing.tt b/t/test-site/common/document-listing.tt
index 5210458..ec3adbb 100644
--- a/t/test-site/common/document-listing.tt
+++ b/t/test-site/common/document-listing.tt
@@ -1,3 +1,3 @@
-[% FOR doc IN tagged.$current_cat %]
+[% FOR doc IN tagged.$path %]
* `<[% doc %]>`_
[% END %]
diff --git a/t/test-site/src/bar/document.en.rest.tt b/t/test-site/src/bar/document.en.rest.tt
index 0d1e3f2..b9fa835 100644
--- a/t/test-site/src/bar/document.en.rest.tt
+++ b/t/test-site/src/bar/document.en.rest.tt
@@ -2,4 +2,4 @@
bar (from template)
=====================
-[% PROCESS list %]
+[% PROCESS list.tt %]
diff --git a/t/test-site/src/bar/document.it.rest.tt b/t/test-site/src/bar/document.it.rest.tt
index d6f5509..a379637 100644
--- a/t/test-site/src/bar/document.it.rest.tt
+++ b/t/test-site/src/bar/document.it.rest.tt
@@ -2,4 +2,4 @@
bar (generato)
================
-[% PROCESS list %]
+[% PROCESS list.tt %]
diff --git a/t/test-site/src/document.en.rest.txt b/t/test-site/src/document.en.rest.txt
index 15045d2..b7449d0 100644
--- a/t/test-site/src/document.en.rest.txt
+++ b/t/test-site/src/document.en.rest.txt
@@ -6,4 +6,4 @@
* `bar! <bar/>`_
* `baz`_
-.. _`baz`: baz/
+.. _`baz`: bar/baz/
diff --git a/t/test-site/src/document.it.rest.txt b/t/test-site/src/document.it.rest.txt
index f29a12b..ebecda8 100644
--- a/t/test-site/src/document.it.rest.txt
+++ b/t/test-site/src/document.it.rest.txt
@@ -6,4 +6,4 @@
* `bar! <bar/>`_
* `baz`_
-.. _`baz`: baz/
+.. _`baz`: bar/baz/
diff --git a/t/test-site/src/du2html.xsl b/t/test-site/src/du2html.xsl
new file mode 120000
index 0000000..bea6032
--- /dev/null
+++ b/t/test-site/src/du2html.xsl
@@ -0,0 +1 @@
+../common/du2html.xsl \ No newline at end of file
diff --git a/t/test-site/tags/du2html.xsl b/t/test-site/tags/du2html.xsl
new file mode 120000
index 0000000..6737f0e
--- /dev/null
+++ b/t/test-site/tags/du2html.xsl
@@ -0,0 +1 @@
+../../common/du2html.xsl \ No newline at end of file
diff --git a/t/test-site/tags/one/du2html.xsl b/t/test-site/tags/one/du2html.xsl
new file mode 120000
index 0000000..6737f0e
--- /dev/null
+++ b/t/test-site/tags/one/du2html.xsl
@@ -0,0 +1 @@
+../../common/du2html.xsl \ No newline at end of file
diff --git a/t/test-site/tags/three/bis/document.en.rest.tt b/t/test-site/tags/three/bis/document.en.rest.tt
index 18b7ac0..3b5629c 100644
--- a/t/test-site/tags/three/bis/document.en.rest.tt
+++ b/t/test-site/tags/three/bis/document.en.rest.tt
@@ -1,5 +1,5 @@
-================
+======================
Category 'three/bis'
-================
+======================
-[% PROCESS document-listing %]
+[% PROCESS 'document-listing.tt' %]
diff --git a/t/test-site/tags/three/bis/document.it.rest.tt b/t/test-site/tags/three/bis/document.it.rest.tt
index 0f1414d..330b121 100644
--- a/t/test-site/tags/three/bis/document.it.rest.tt
+++ b/t/test-site/tags/three/bis/document.it.rest.tt
@@ -1,5 +1,5 @@
-=================
+=======================
Categoria 'three/bis'
-=================
+=======================
-[% PROCESS document-listing %]
+[% PROCESS 'document-listing.tt' %]
diff --git a/t/test-site/tags/three/bis/du2html.xsl b/t/test-site/tags/three/bis/du2html.xsl
new file mode 120000
index 0000000..b6e8ebc
--- /dev/null
+++ b/t/test-site/tags/three/bis/du2html.xsl
@@ -0,0 +1 @@
+../../../common/du2html.xsl \ No newline at end of file
diff --git a/t/test-site/tags/three/document.en.rest.tt b/t/test-site/tags/three/document.en.rest.tt
index 3848f3c..ac13056 100644
--- a/t/test-site/tags/three/document.en.rest.tt
+++ b/t/test-site/tags/three/document.en.rest.tt
@@ -1,5 +1,5 @@
-================
+==================
Category 'three'
-================
+==================
-[% PROCESS document-listing %]
+[% PROCESS 'document-listing.tt' %]
diff --git a/t/test-site/tags/three/document.it.rest.tt b/t/test-site/tags/three/document.it.rest.tt
index 0c1a4a4..bcd13ef 100644
--- a/t/test-site/tags/three/document.it.rest.tt
+++ b/t/test-site/tags/three/document.it.rest.tt
@@ -1,5 +1,5 @@
-=================
+===================
Categoria 'three'
-=================
+===================
-[% PROCESS document-listing %]
+[% PROCESS 'document-listing.tt' %]
diff --git a/t/test-site/tags/three/du2html.xsl b/t/test-site/tags/three/du2html.xsl
new file mode 120000
index 0000000..6737f0e
--- /dev/null
+++ b/t/test-site/tags/three/du2html.xsl
@@ -0,0 +1 @@
+../../common/du2html.xsl \ No newline at end of file
diff --git a/t/test-site/tags/two/du2html.xsl b/t/test-site/tags/two/du2html.xsl
new file mode 120000
index 0000000..6737f0e
--- /dev/null
+++ b/t/test-site/tags/two/du2html.xsl
@@ -0,0 +1 @@
+../../common/du2html.xsl \ No newline at end of file