summaryrefslogtreecommitdiff
path: root/p
diff options
context:
space:
mode:
Diffstat (limited to 'p')
-rw-r--r--p/tools/todo.css21
-rw-r--r--p/tools/todo.html.tt44
-rw-r--r--p/tools/todo.pl72
-rw-r--r--p/tools/todo.text.tt16
4 files changed, 147 insertions, 6 deletions
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 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
+ <head>
+ <meta http-equiv="Content-Type" content="application/html+xml; charset=ISO-8859-1" />
+ <title>ToDo</title>
+ <link rel="stylesheet" type="text/css" href="todo.css" media="screen" title="Normal" />
+ </head>
+ <body>
+ <ul>
+ [% PROCESS task tasks = tasks %]
+ </ul>
+ </body>
+</html>
+
+[% BLOCK leaf %]
+<li class="task"><p><span id="state">[% task.state %]</span> <span class="text">[% task.text %]</span> <span class="owner">[% task.owner.join (', ') %]</span></p></li>
+[% 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 %]
+ <li><p>[% t.key %]</p>
+ <ul>
+ [% PROCESS task tasks = t.value %]
+ </ul>
+ </li>
+ [% END %]
+ [% ELSE %]
+ [% PROCESS task tasks = t.value %]
+ [% END %]
+ [% END %]
+ [% END %]
+ [% ELSE %]
+ <li><p>Aucune Tache</p></li>
+ [% 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 (<FILE>)
{
@@ -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 <<EOF;
+todo.pl - Parse todo files.
+
+Usage: todo.pl [OPTIONS]
+
+Options:
+ -t, --todo-dir=DIR Set the todo directory (defaults to'../todo').
+ -T, --template-dir=DIR Set the template directory (defaults to '.').
+ -f, --format=FORMAT Set the output format ('text' or 'html', defaults to
+ 'text').
+ -d, --dump Dump todo hash instead of normal output.
+ -h, --help Print this help screen.
+EOF
+}
-parse_dir (\%todos, '', '.');
+# Parse options.
+sub config
+{
+ my %config = (
+ 'todo-dir' => '../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 = '' %]