From 3ca3fc205d3741a86282566fc932f3cc347fc6fb Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 2 Jan 2008 12:50:03 +0000 Subject: testing new dir structure git-svn-id: svn://luxion/repos/WebCoso/trunk@316 fcb26f47-9200-0410-b104-b98ab5b095f3 --- stest.pl | 69 ++++++++++++++++------ t/test-site/common/document-listing.tt | 2 +- t/test-site/src/tags/one/document-listing.tt | 1 + t/test-site/src/tags/one/document.en.rest.tt | 5 ++ t/test-site/src/tags/one/document.it.rest.tt | 5 ++ t/test-site/src/tags/one/du2html.xsl | 1 + t/test-site/src/tags/three/bis/document-listing.tt | 1 + t/test-site/src/tags/three/bis/document.en.rest.tt | 5 ++ t/test-site/src/tags/three/bis/document.it.rest.tt | 5 ++ t/test-site/src/tags/three/bis/du2html.xsl | 1 + t/test-site/src/tags/three/document-listing.tt | 1 + t/test-site/src/tags/three/document.en.rest.tt | 5 ++ t/test-site/src/tags/three/document.it.rest.tt | 5 ++ t/test-site/src/tags/three/du2html.xsl | 1 + t/test-site/src/tags/two/document-listing.tt | 1 + t/test-site/src/tags/two/document.en.rest.tt | 5 ++ t/test-site/src/tags/two/document.it.rest.tt | 5 ++ t/test-site/src/tags/two/du2html.xsl | 1 + t/test-site/tags/du2html.xsl | 1 - t/test-site/tags/one/document-listing.tt | 1 - t/test-site/tags/one/document.en.rest.tt | 5 -- t/test-site/tags/one/document.it.rest.tt | 5 -- t/test-site/tags/one/du2html.xsl | 1 - t/test-site/tags/three/bis/document-listing.tt | 1 - t/test-site/tags/three/bis/document.en.rest.tt | 5 -- t/test-site/tags/three/bis/document.it.rest.tt | 5 -- t/test-site/tags/three/bis/du2html.xsl | 1 - t/test-site/tags/three/document-listing.tt | 1 - t/test-site/tags/three/document.en.rest.tt | 5 -- t/test-site/tags/three/document.it.rest.tt | 5 -- t/test-site/tags/three/du2html.xsl | 1 - t/test-site/tags/two/document-listing.tt | 1 - t/test-site/tags/two/document.en.rest.tt | 5 -- t/test-site/tags/two/document.it.rest.tt | 5 -- t/test-site/tags/two/du2html.xsl | 1 - 35 files changed, 99 insertions(+), 69 deletions(-) create mode 120000 t/test-site/src/tags/one/document-listing.tt create mode 100644 t/test-site/src/tags/one/document.en.rest.tt create mode 100644 t/test-site/src/tags/one/document.it.rest.tt create mode 120000 t/test-site/src/tags/one/du2html.xsl create mode 120000 t/test-site/src/tags/three/bis/document-listing.tt create mode 100644 t/test-site/src/tags/three/bis/document.en.rest.tt create mode 100644 t/test-site/src/tags/three/bis/document.it.rest.tt create mode 120000 t/test-site/src/tags/three/bis/du2html.xsl create mode 120000 t/test-site/src/tags/three/document-listing.tt create mode 100644 t/test-site/src/tags/three/document.en.rest.tt create mode 100644 t/test-site/src/tags/three/document.it.rest.tt create mode 120000 t/test-site/src/tags/three/du2html.xsl create mode 120000 t/test-site/src/tags/two/document-listing.tt create mode 100644 t/test-site/src/tags/two/document.en.rest.tt create mode 100644 t/test-site/src/tags/two/document.it.rest.tt create mode 120000 t/test-site/src/tags/two/du2html.xsl delete mode 120000 t/test-site/tags/du2html.xsl delete mode 120000 t/test-site/tags/one/document-listing.tt delete mode 100644 t/test-site/tags/one/document.en.rest.tt delete mode 100644 t/test-site/tags/one/document.it.rest.tt delete mode 120000 t/test-site/tags/one/du2html.xsl delete mode 120000 t/test-site/tags/three/bis/document-listing.tt delete mode 100644 t/test-site/tags/three/bis/document.en.rest.tt delete mode 100644 t/test-site/tags/three/bis/document.it.rest.tt delete mode 120000 t/test-site/tags/three/bis/du2html.xsl delete mode 120000 t/test-site/tags/three/document-listing.tt delete mode 100644 t/test-site/tags/three/document.en.rest.tt delete mode 100644 t/test-site/tags/three/document.it.rest.tt delete mode 120000 t/test-site/tags/three/du2html.xsl delete mode 120000 t/test-site/tags/two/document-listing.tt delete mode 100644 t/test-site/tags/two/document.en.rest.tt delete mode 100644 t/test-site/tags/two/document.it.rest.tt delete mode 120000 t/test-site/tags/two/du2html.xsl diff --git a/stest.pl b/stest.pl index 69f3918..0d48333 100644 --- a/stest.pl +++ b/stest.pl @@ -12,6 +12,19 @@ use Text::Restructured::Writer::LibXML; use XML::LibXML; use XML::LibXSLT; use YAML::Syck; +use Getopt::Long; + +my $SRCPATH='src'; +my $DSTPATH='dst'; +my $DSTBASEURL='/'; + +{ +my $res=GetOptions('src|s=s'=>$SRCPATH, + 'dst|d=s'=>$DSTPATH, + 'url|u=s'=>$DSTBASEURL, + ); +exit 1 unless $res; +} my $stash={}; my $template_provider=Template::Provider->new({ @@ -50,6 +63,22 @@ $fc->add_writer(qr{\.ya?ml$} => sub { DumpFile($_[0],$_[1]) }); +sub dstUriFor { + my ($name)=@_; + $name=~s{^\Q$SRCPATH\E/}{$DSTBASEURL}; + return $name; +} + +sub isLang { + my ($lang,$name)=@_; + return 1 if $name=~m{/$}; # assume that MultiViews on the server will work + return 1 if $name=~m{/document\.$lang(\.|$)}; + return; +} + +$stash->{dstUriFor}=\&dstUriFor; +$stash->{isLang}=\&isLang; + sub expandTT { my ($maker,$target,$deps,$matches)=@_; @@ -171,22 +200,24 @@ sub keepEarliest { return @ret; } -my %files=(files=>sub{m{^document\.} and ($File::Next::dir !~ m{/\.svn/})}); +my %docfiles=( + files=>sub{m{^document\.} and ($File::Next::dir !~ m{/\.svn/})}, + dirs=>sub{!m{^(tags|_webcoso)$}}); 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], - ['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], - ['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], + ["$SRCPATH/(**)/document.(*).rest.txt",':',ifExists("$SRCPATH/\$1/document.\$2.rest.tt"),'=',\&expandTT], + ["$SRCPATH/(**)/document.(*).du.xml",':',ifExists("$SRCPATH/\$1/document.\$2.rest.txt"),'=',\&parseRST], + ["$SRCPATH/()document.(*).rest.txt",':',ifExists("$SRCPATH/document.\$2.rest.tt"),'=',\&expandTT], + ["$SRCPATH/()document.(*).du.xml",':',ifExists("$SRCPATH/document.\$2.rest.txt"),'=',\&parseRST], + ["$SRCPATH/_webcoso/tags.yml",':',fromTo("$SRCPATH/",{%docfiles,transform=>sub{my $s=shift;$s=~s{\.[^.]+\.[^.]+$}{.du.xml};$s}}),'=',\&getTags], + #["$SRCPATH/_webcoso/changes.xml",':',keepEarliest(fromTo("$SRCPATH/",{%docfiles})),'=',\&getChanges], + + ["$SRCPATH/tags/(**)/document.(*).rest.txt",':',"$SRCPATH/_webcoso/tags.yml",ifExists("$SRCPATH/tags/\$1/document.\$2.rest.tt"),'=',\&expandTT], + ["$SRCPATH/tags/(**)/document.(*).du.xml",':',"$SRCPATH/_webcoso/tags.yml",ifExists("$SRCPATH/tags/\$1/document.\$2.rest.txt"),'=',\&parseRST], + ["$DSTPATH/tags/(**)/document.(*).html",':',"$SRCPATH/_webcoso/tags.yml","$SRCPATH/tags/\$1/document.\$2.du.xml",'=',\&du2html], + ["$DESTPATH/(**)/document.(*).html",':',"$SRCPATH/_webcoso/tags.yml","$SRCPATH/\$1/document.\$2.du.xml",'=',\&du2html], + ["$DESTPATH/()document.(*).html",':',"$SRCPATH/_webcoso/tags.yml","$SRCPATH/document.\$2.du.xml",'=',\&du2html], ], options => { auto_create_dirs => 1, @@ -196,23 +227,23 @@ my $maker=Slay::Maker->new({ }, }); -my @targets=(fromTo('src/', +my @targets=(fromTo("$SRCPATH/", { - %files, + %docfiles, transform=>sub{ my $src=shift; $src=~s{\.[^.]+\.[^.]+$}{.html}; - $src=~s{^src/}{dst/}; + $src=~s{^\Q$SRCPATH\E/}{$DSTPATH/}; return $src; }, }), - fromTo('tags/', + fromTo("$SRCPATH/tags/", { - %files, + %tagfiles, transform=>sub{ my $src=shift; $src=~s{\.[^.]+\.[^.]+$}{.html}; - $src=~s{^tags/}{dtags/}; + $src=~s{^\Q$SRCPATH\E/tags/}{$DSTPATH/tags/}; return $src; }, })); diff --git a/t/test-site/common/document-listing.tt b/t/test-site/common/document-listing.tt index ec3adbb..729e08c 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.$path %] -* `<[% doc %]>`_ +[% IF isLang(language,doc) %]* `<[% dstUriFor(doc) %]>`_[% END %] [% END %] diff --git a/t/test-site/src/tags/one/document-listing.tt b/t/test-site/src/tags/one/document-listing.tt new file mode 120000 index 0000000..9444be1 --- /dev/null +++ b/t/test-site/src/tags/one/document-listing.tt @@ -0,0 +1 @@ +../../common/document-listing.tt \ No newline at end of file diff --git a/t/test-site/src/tags/one/document.en.rest.tt b/t/test-site/src/tags/one/document.en.rest.tt new file mode 100644 index 0000000..6435637 --- /dev/null +++ b/t/test-site/src/tags/one/document.en.rest.tt @@ -0,0 +1,5 @@ +================ + Category 'one' +================ + +[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/src/tags/one/document.it.rest.tt b/t/test-site/src/tags/one/document.it.rest.tt new file mode 100644 index 0000000..0dae4f0 --- /dev/null +++ b/t/test-site/src/tags/one/document.it.rest.tt @@ -0,0 +1,5 @@ +================= + Categoria 'uno' +================= + +[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/src/tags/one/du2html.xsl b/t/test-site/src/tags/one/du2html.xsl new file mode 120000 index 0000000..6737f0e --- /dev/null +++ b/t/test-site/src/tags/one/du2html.xsl @@ -0,0 +1 @@ +../../common/du2html.xsl \ No newline at end of file diff --git a/t/test-site/src/tags/three/bis/document-listing.tt b/t/test-site/src/tags/three/bis/document-listing.tt new file mode 120000 index 0000000..b2b2ee2 --- /dev/null +++ b/t/test-site/src/tags/three/bis/document-listing.tt @@ -0,0 +1 @@ +../../../common/document-listing.tt \ No newline at end of file diff --git a/t/test-site/src/tags/three/bis/document.en.rest.tt b/t/test-site/src/tags/three/bis/document.en.rest.tt new file mode 100644 index 0000000..3b5629c --- /dev/null +++ b/t/test-site/src/tags/three/bis/document.en.rest.tt @@ -0,0 +1,5 @@ +====================== + Category 'three/bis' +====================== + +[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/src/tags/three/bis/document.it.rest.tt b/t/test-site/src/tags/three/bis/document.it.rest.tt new file mode 100644 index 0000000..330b121 --- /dev/null +++ b/t/test-site/src/tags/three/bis/document.it.rest.tt @@ -0,0 +1,5 @@ +======================= + Categoria 'three/bis' +======================= + +[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/src/tags/three/bis/du2html.xsl b/t/test-site/src/tags/three/bis/du2html.xsl new file mode 120000 index 0000000..b6e8ebc --- /dev/null +++ b/t/test-site/src/tags/three/bis/du2html.xsl @@ -0,0 +1 @@ +../../../common/du2html.xsl \ No newline at end of file diff --git a/t/test-site/src/tags/three/document-listing.tt b/t/test-site/src/tags/three/document-listing.tt new file mode 120000 index 0000000..9444be1 --- /dev/null +++ b/t/test-site/src/tags/three/document-listing.tt @@ -0,0 +1 @@ +../../common/document-listing.tt \ No newline at end of file diff --git a/t/test-site/src/tags/three/document.en.rest.tt b/t/test-site/src/tags/three/document.en.rest.tt new file mode 100644 index 0000000..ac13056 --- /dev/null +++ b/t/test-site/src/tags/three/document.en.rest.tt @@ -0,0 +1,5 @@ +================== + Category 'three' +================== + +[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/src/tags/three/document.it.rest.tt b/t/test-site/src/tags/three/document.it.rest.tt new file mode 100644 index 0000000..bcd13ef --- /dev/null +++ b/t/test-site/src/tags/three/document.it.rest.tt @@ -0,0 +1,5 @@ +=================== + Categoria 'three' +=================== + +[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/src/tags/three/du2html.xsl b/t/test-site/src/tags/three/du2html.xsl new file mode 120000 index 0000000..6737f0e --- /dev/null +++ b/t/test-site/src/tags/three/du2html.xsl @@ -0,0 +1 @@ +../../common/du2html.xsl \ No newline at end of file diff --git a/t/test-site/src/tags/two/document-listing.tt b/t/test-site/src/tags/two/document-listing.tt new file mode 120000 index 0000000..9444be1 --- /dev/null +++ b/t/test-site/src/tags/two/document-listing.tt @@ -0,0 +1 @@ +../../common/document-listing.tt \ No newline at end of file diff --git a/t/test-site/src/tags/two/document.en.rest.tt b/t/test-site/src/tags/two/document.en.rest.tt new file mode 100644 index 0000000..5b5579a --- /dev/null +++ b/t/test-site/src/tags/two/document.en.rest.tt @@ -0,0 +1,5 @@ +================ + Category 'two' +================ + +[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/src/tags/two/document.it.rest.tt b/t/test-site/src/tags/two/document.it.rest.tt new file mode 100644 index 0000000..3291828 --- /dev/null +++ b/t/test-site/src/tags/two/document.it.rest.tt @@ -0,0 +1,5 @@ +================= + Categoria 'two' +================= + +[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/src/tags/two/du2html.xsl b/t/test-site/src/tags/two/du2html.xsl new file mode 120000 index 0000000..6737f0e --- /dev/null +++ b/t/test-site/src/tags/two/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 deleted file mode 120000 index 6737f0e..0000000 --- a/t/test-site/tags/du2html.xsl +++ /dev/null @@ -1 +0,0 @@ -../../common/du2html.xsl \ No newline at end of file diff --git a/t/test-site/tags/one/document-listing.tt b/t/test-site/tags/one/document-listing.tt deleted file mode 120000 index 9444be1..0000000 --- a/t/test-site/tags/one/document-listing.tt +++ /dev/null @@ -1 +0,0 @@ -../../common/document-listing.tt \ No newline at end of file diff --git a/t/test-site/tags/one/document.en.rest.tt b/t/test-site/tags/one/document.en.rest.tt deleted file mode 100644 index 6435637..0000000 --- a/t/test-site/tags/one/document.en.rest.tt +++ /dev/null @@ -1,5 +0,0 @@ -================ - Category 'one' -================ - -[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/tags/one/document.it.rest.tt b/t/test-site/tags/one/document.it.rest.tt deleted file mode 100644 index 0dae4f0..0000000 --- a/t/test-site/tags/one/document.it.rest.tt +++ /dev/null @@ -1,5 +0,0 @@ -================= - Categoria 'uno' -================= - -[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/tags/one/du2html.xsl b/t/test-site/tags/one/du2html.xsl deleted file mode 120000 index 6737f0e..0000000 --- a/t/test-site/tags/one/du2html.xsl +++ /dev/null @@ -1 +0,0 @@ -../../common/du2html.xsl \ No newline at end of file diff --git a/t/test-site/tags/three/bis/document-listing.tt b/t/test-site/tags/three/bis/document-listing.tt deleted file mode 120000 index b2b2ee2..0000000 --- a/t/test-site/tags/three/bis/document-listing.tt +++ /dev/null @@ -1 +0,0 @@ -../../../common/document-listing.tt \ 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 deleted file mode 100644 index 3b5629c..0000000 --- a/t/test-site/tags/three/bis/document.en.rest.tt +++ /dev/null @@ -1,5 +0,0 @@ -====================== - Category 'three/bis' -====================== - -[% 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 deleted file mode 100644 index 330b121..0000000 --- a/t/test-site/tags/three/bis/document.it.rest.tt +++ /dev/null @@ -1,5 +0,0 @@ -======================= - Categoria 'three/bis' -======================= - -[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/tags/three/bis/du2html.xsl b/t/test-site/tags/three/bis/du2html.xsl deleted file mode 120000 index b6e8ebc..0000000 --- a/t/test-site/tags/three/bis/du2html.xsl +++ /dev/null @@ -1 +0,0 @@ -../../../common/du2html.xsl \ No newline at end of file diff --git a/t/test-site/tags/three/document-listing.tt b/t/test-site/tags/three/document-listing.tt deleted file mode 120000 index 9444be1..0000000 --- a/t/test-site/tags/three/document-listing.tt +++ /dev/null @@ -1 +0,0 @@ -../../common/document-listing.tt \ 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 deleted file mode 100644 index ac13056..0000000 --- a/t/test-site/tags/three/document.en.rest.tt +++ /dev/null @@ -1,5 +0,0 @@ -================== - Category 'three' -================== - -[% 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 deleted file mode 100644 index bcd13ef..0000000 --- a/t/test-site/tags/three/document.it.rest.tt +++ /dev/null @@ -1,5 +0,0 @@ -=================== - Categoria 'three' -=================== - -[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/tags/three/du2html.xsl b/t/test-site/tags/three/du2html.xsl deleted file mode 120000 index 6737f0e..0000000 --- a/t/test-site/tags/three/du2html.xsl +++ /dev/null @@ -1 +0,0 @@ -../../common/du2html.xsl \ No newline at end of file diff --git a/t/test-site/tags/two/document-listing.tt b/t/test-site/tags/two/document-listing.tt deleted file mode 120000 index 9444be1..0000000 --- a/t/test-site/tags/two/document-listing.tt +++ /dev/null @@ -1 +0,0 @@ -../../common/document-listing.tt \ No newline at end of file diff --git a/t/test-site/tags/two/document.en.rest.tt b/t/test-site/tags/two/document.en.rest.tt deleted file mode 100644 index 5b5579a..0000000 --- a/t/test-site/tags/two/document.en.rest.tt +++ /dev/null @@ -1,5 +0,0 @@ -================ - Category 'two' -================ - -[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/tags/two/document.it.rest.tt b/t/test-site/tags/two/document.it.rest.tt deleted file mode 100644 index 3291828..0000000 --- a/t/test-site/tags/two/document.it.rest.tt +++ /dev/null @@ -1,5 +0,0 @@ -================= - Categoria 'two' -================= - -[% PROCESS 'document-listing.tt' %] diff --git a/t/test-site/tags/two/du2html.xsl b/t/test-site/tags/two/du2html.xsl deleted file mode 120000 index 6737f0e..0000000 --- a/t/test-site/tags/two/du2html.xsl +++ /dev/null @@ -1 +0,0 @@ -../../common/du2html.xsl \ No newline at end of file -- cgit v1.2.3