aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/WebCoso/Cleaner.pm5
-rw-r--r--lib/WebCoso/Common.pm16
-rw-r--r--lib/WebCoso/Maker.pm5
-rw-r--r--lib/WebCoso/ReST.pm1
-rw-r--r--lib/WebCoso/TT.pm5
-rw-r--r--lib/WebCoso/XSLT.pm6
-rw-r--r--script/webcoso.pl4
7 files changed, 30 insertions, 12 deletions
diff --git a/lib/WebCoso/Cleaner.pm b/lib/WebCoso/Cleaner.pm
index e9f9dcf..8c7eb32 100644
--- a/lib/WebCoso/Cleaner.pm
+++ b/lib/WebCoso/Cleaner.pm
@@ -4,6 +4,7 @@ use warnings;
use File::Next;
use Path::Class;
use WebCoso::Common;
+use Log::Log4perl ':easy';
sub clean {
my %to_keep;
@@ -12,10 +13,14 @@ sub clean {
my $iter=File::Next::files({descend_filter=>sub{!m{^\.svn$}}},$WebCoso::Common::SRCPATH,$WebCoso::Common::DSTPATH);
while (defined (my $file=$iter->())) {
+ DEBUG("Examining $file");
next if exists $to_keep{$file};
+ INFO("Removing $file");
unlink $file;
}
+ INFO("Removing $WebCoso::Common::DSTPATH");
dir($WebCoso::Common::DSTPATH)->rmtree;
+ INFO("Removing $WebCoso::Common::SRCPATH/_webcoso");
dir($WebCoso::Common::SRCPATH,'_webcoso')->rmtree;
}
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}
diff --git a/lib/WebCoso/Maker.pm b/lib/WebCoso/Maker.pm
index 1000c22..73fdbbb 100644
--- a/lib/WebCoso/Maker.pm
+++ b/lib/WebCoso/Maker.pm
@@ -11,6 +11,7 @@ use WebCoso::Common;
use WebCoso::TT;
use WebCoso::XSLT;
use WebCoso::ReST;
+use Log::Log4perl ':easy';
my $fc=File::Cache::Parsed->new(follow=>1);
$fc->add_parser(qr{\.ya?ml$} =>
@@ -24,20 +25,22 @@ my $rest=WebCoso::ReST->new(fc=>$fc);
sub parseRST {
my ($maker,$target,$deps,$matches)=@_;
+ DEBUG("parseRST($maker,$target,(@$deps),(@$matches))");
$fc->put($target,$fc->get($deps->[-1]));
}
sub getTags {
my ($maker,$target,$deps,$matches)=@_;
+ DEBUG("getTags($maker,$target,(@$deps),(@$matches))");
$fc->put($target,WebCoso::Common::getTags($fc,@$deps));
}
sub getChanges {
my ($maker,$target,$deps,$matches)=@_;
+ DEBUG("getChanges($maker,$target,(@$deps),(@$matches))");
- warn "changes: $target <- @$deps, @$matches\n";
open my $fh,'>',$target;
}
diff --git a/lib/WebCoso/ReST.pm b/lib/WebCoso/ReST.pm
index bd43528..f8cda3f 100644
--- a/lib/WebCoso/ReST.pm
+++ b/lib/WebCoso/ReST.pm
@@ -5,6 +5,7 @@ use WebCoso::Common;
use Path::Class;
use Text::Restructured;
use Text::Restructured::Writer::LibXML;
+use Log::Log4perl ':easy';
sub new {
my ($class,%opts)=@_;
diff --git a/lib/WebCoso/TT.pm b/lib/WebCoso/TT.pm
index fc5d114..8c4b216 100644
--- a/lib/WebCoso/TT.pm
+++ b/lib/WebCoso/TT.pm
@@ -4,6 +4,7 @@ use warnings;
use WebCoso::Common;
use Path::Class;
use Template;
+use Log::Log4perl ':easy';
sub new {
my ($class,%opts)=@_;
@@ -33,7 +34,7 @@ sub new {
$self->{expander}=sub {
my ($maker,$target,$deps,$matches)=@_;
- warn "expandTT($target,@$deps,@$matches)\n";
+ DEBUG("expandTT($target,@$deps,@$matches)");
my $tmpl=$self->{fc}->get($deps->[-1]);
my $vars={ path=> $matches->[0],
@@ -41,7 +42,7 @@ sub new {
%{$self->{stash}},
};
if (@$deps>1) {
- warn "tagging as $deps->[0]\n";
+ INFO("tagging as $deps->[0]");
$vars->{tagged}=$self->{fc}->get($deps->[0]);
}
push @{$self->{template_provider}->include_path},
diff --git a/lib/WebCoso/XSLT.pm b/lib/WebCoso/XSLT.pm
index 1f9208a..0d36652 100644
--- a/lib/WebCoso/XSLT.pm
+++ b/lib/WebCoso/XSLT.pm
@@ -6,6 +6,7 @@ use Path::Class;
use XML::LibXML;
use XML::LibXSLT;
use DateTime::Format::Strptime;
+use Log::Log4perl ':easy';
my $NS='http://webcoso.thenautilus.net/';
@@ -33,12 +34,13 @@ sub new {
$self->{du2html}=sub {
my ($maker,$target,$deps,$matches)=@_;
+ DEBUG("du2html($maker,$target,(@$deps),(@$matches))");
my $du=$self->{fc}->get($deps->[-1]);
my $xslt=file($deps->[-1])->parent->file('du2html.xsl');
$xslt=$self->{fc}->get($xslt);
if (@$deps>1) {
- warn "xml tagging as $deps->[0]\n";
+ INFO("xml tagging as $deps->[0]");
$self->setXMLTagsSource($self->{fc}->get($deps->[0]));
} else {
$self->setXMLTagsSource(undef);
@@ -69,8 +71,6 @@ sub getTagsXML {
my $doc=XML::LibXML::Document->new();
return $doc unless defined $self->{tags_source};
- warn "getTagsXML()\n";
-
my $de=$doc->createElementNS($NS,'wc:tags');
$doc->setDocumentElement($de);
my ($tagname,$doclist);
diff --git a/script/webcoso.pl b/script/webcoso.pl
index a247be0..660d7dd 100644
--- a/script/webcoso.pl
+++ b/script/webcoso.pl
@@ -3,6 +3,7 @@ use strict;
use warnings;
use Getopt::Long;
use WebCoso::Common;
+use Log::Log4perl ':easy';
my $CLEAN=0;
@@ -11,6 +12,7 @@ my $res=GetOptions('src|s=s'=>\$WebCoso::Common::SRCPATH,
'dst|d=s'=>\$WebCoso::Common::DSTPATH,
'url|u=s'=>\$WebCoso::Common::DSTBASEURL,
'include|I=s'=>\@WebCoso::Common::TMPLPATH,
+ 'verbose|v+'=>\$WebCoso::Common::VERBOSITY,
'clean'=>\$CLEAN,
);
exit 1 unless $res;
@@ -18,6 +20,8 @@ $WebCoso::Common::SRCPATH=~s{/+$}{};
$WebCoso::Common::DSTPATH=~s{/+$}{};
$WebCoso::Common::DSTBASEURL=~s{/*$}{/};
}
+Log::Log4perl->easy_init({level=>$WebCoso::Common::VERBOSITY});
+
if ($CLEAN) {
require WebCoso::Cleaner;