From 15b9d85e5514d1ba481ee493c15f5aab80424ae9 Mon Sep 17 00:00:00 2001 From: schodet Date: Wed, 5 Oct 2005 22:04:28 +0000 Subject: Ajout d'une préversion de la sortie HTML. Ajout d'une préversion de la sortie texte. --- p/tools/todo.css | 21 +++++++++++++++ p/tools/todo.html.tt | 44 ++++++++++++++++++++++++++++++++ p/tools/todo.pl | 72 +++++++++++++++++++++++++++++++++++++++++++++++----- p/tools/todo.text.tt | 16 ++++++++++++ 4 files changed, 147 insertions(+), 6 deletions(-) create mode 100644 p/tools/todo.css create mode 100644 p/tools/todo.html.tt create mode 100644 p/tools/todo.text.tt (limited to 'p') diff --git a/p/tools/todo.css b/p/tools/todo.css new file mode 100644 index 0000000..ae1e494 --- /dev/null +++ b/p/tools/todo.css @@ -0,0 +1,21 @@ +li { + list-style-type: none +} +li>ul>li.task { + border : 1px solid #000000; +} +div>li>ul>li.task { + border : 0px; +} + +div>li>p { + border : 1px solid #ff0000; +} + +div>li>ul>div>li>p { + border : 1px solid #00ff00; +} + +div>li>ul>div>li>ul>div>li>p { + border : 1px solid #0000ff; +} diff --git a/p/tools/todo.html.tt b/p/tools/todo.html.tt new file mode 100644 index 0000000..fe25164 --- /dev/null +++ b/p/tools/todo.html.tt @@ -0,0 +1,44 @@ + + + + + + ToDo + + + + + + + +[% BLOCK leaf %] +
  • [% task.state %] [% task.text %] [% task.owner.join (', ') %]

  • +[% END %] + +[% BLOCK task %] + [% IF tasks.size > 0 %] + [% FOREACH t = tasks %] + [% IF t.exists ('text') %] + [% PROCESS leaf task = t %] + [% ELSE %] + [% IF t.key %] + [% IF t.value.value.exists ('text') %] + prout + [% ELSE %] +
  • [% t.key %]

    + +
  • + [% END %] + [% ELSE %] + [% PROCESS task tasks = t.value %] + [% END %] + [% END %] + [% END %] + [% ELSE %] +
  • Aucune Tache

  • + [% END %] +[% END %] diff --git a/p/tools/todo.pl b/p/tools/todo.pl index 31e55da..13be3cb 100644 --- a/p/tools/todo.pl +++ b/p/tools/todo.pl @@ -3,11 +3,14 @@ # Tool to parse todo files. # use strict; +use Template; +use Getopt::Long; # Parse a todo file and add tasks to \%todos. sub parse_todo { my ($todos, $path, $file) = @_; + #print "$path...\n"; my $owner; local $_; local *FILE; @@ -22,10 +25,11 @@ sub parse_todo { chomp; # Task line. - /^([-+=x]) (?:\(([^)]+)\) |)(.+)$/ and do { - my ($state, $owner, $text) = ($1, $2 || $owner, $3); - #$owner = $1 if $2 =~ /^\((.*)\) $/; - my @owners = split /, */, $owner; + /^([-+=x]) (?:\[(\d\d\/\d\d\/\d{4})\] |)(?:\(([^)]+)\) |)(.+)$/ and do { + my ($state, $deadline, $owner, $text) = + ($1, $2, $3 || $owner, $4); + my @owners; + @owners = split /, */, $owner if defined $owner; # Read next lines. while () { @@ -39,6 +43,7 @@ sub parse_todo # Add task. push @$tasks, { state => $state, + deadline => $deadline, owner => [ @owners ], text => $text }; @@ -89,11 +94,66 @@ sub parse_dir parse_dir ($$todos{$_}, "$path/$_", "$dir/$_") foreach @tododirs; } -my %todos; +# Output todo tree file. +sub output_tree +{ + my ($d, $f, $t) = @_; + my $tt = new Template ({ + INCLUDE_PATH => $d, + PRE_CHOMP => 1, + POST_CHOMP => 1, + INTERPOLATE => 1, + }); + $tt->process ("todo.$f.tt", { 'tasks' => $t }) or die $tt->error; +} + +# Print short help. +sub usage +{ + print < '../todo', + 'template-dir' => '.', + 'format' => 'text', + ); + GetOptions (\%config, + 'todo-dir=s', + 'template-dir|T=s', + 'format=s', + 'dump', + 'help', + ) or die; + usage () and exit 0 if (exists ($config{help})); + return %config; +} +my %todos; + +my %config = config (); +parse_dir (\%todos, '', $config{'todo-dir'}); +if (exists ($config{'dump'})) { use Data::Dumper; print Dumper \%todos; } +else +{ + output_tree ($config{'template-dir'}, $config{'format'}, \%todos); +} diff --git a/p/tools/todo.text.tt b/p/tools/todo.text.tt new file mode 100644 index 0000000..610b385 --- /dev/null +++ b/p/tools/todo.text.tt @@ -0,0 +1,16 @@ +[% BLOCK subtask %] +[% END %] + +[% BLOCK task %] + [% FOREACH t = tasks.keys %] + [% IF t == '' %] + [% INCLUDE subtask FOREACH tasks.$t %] + [% ELSE %] +$indent$t +[%+ %] + [% INCLUDE task tasks = tasks.$t indent = "$indent " %] + [% END %] + [% END %] +[% END %] + +[% INCLUDE task tasks = tasks indent = '' %] -- cgit v1.2.3