summaryrefslogtreecommitdiff
path: root/p/tools
diff options
context:
space:
mode:
Diffstat (limited to 'p/tools')
-rw-r--r--p/tools/todo.css41
-rw-r--r--p/tools/todo.html.tt60
-rw-r--r--p/tools/todo.pl36
-rw-r--r--p/tools/todo.text.tt17
4 files changed, 106 insertions, 48 deletions
diff --git a/p/tools/todo.css b/p/tools/todo.css
index ae1e494..1cd4241 100644
--- a/p/tools/todo.css
+++ b/p/tools/todo.css
@@ -1,21 +1,38 @@
-li {
+ul {
+ margin: 1ex; border: 0; padding: 0;
list-style-type: none
}
-li>ul>li.task {
- border : 1px solid #000000;
+p {
+ margin: 0; border: 0; padding: 0;
+}
+li {
+ margin: 1px; border: 0; padding: 1px;
}
-div>li>ul>li.task {
- border : 0px;
+li.section {
+ margin: 1px; border: 1px solid; padding: 1px;
+ margin-bottom: 1ex;
+ background: #88d;
}
-
-div>li>p {
- border : 1px solid #ff0000;
+li.section > p {
+ border-bottom: 1px solid;
}
-div>li>ul>div>li>p {
- border : 1px solid #00ff00;
+span.owners {
+ text-align: right;
}
-div>li>ul>div>li>ul>div>li>p {
- border : 1px solid #0000ff;
+li.opened-task {
+ background: #d88;
+}
+li.closed-task {
+ background: #8d8;
+}
+li.running-task {
+ background: #b66;
+}
+li.canceled-task {
+ background: #bbb;
+}
+li.closed-task, li.canceled-task {
+ color: #666;
}
diff --git a/p/tools/todo.html.tt b/p/tools/todo.html.tt
index 285c7e8..82951fc 100644
--- a/p/tools/todo.html.tt
+++ b/p/tools/todo.html.tt
@@ -8,37 +8,47 @@
</head>
<body>
<ul>
- [% PROCESS task tasks = tasks %]
+[%+ PROCESS tasks tasks = tasks indent = ' ' %]
</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>
+[% BLOCK state %]
+[%
+IF s == '-' ;
+ 'opened' ;
+ELSIF s == '+' ;
+ 'closed' ;
+ELSIF s == '=' ;
+ 'running' ;
+ELSIF s == 'x' ;
+ 'canceled' ;
+ELSE ;
+ 'unknown' ;
+END %]
[% 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 %]
+$indent<li class="[% PROCESS state s = t.state %]-task">[%
+%]<p><span class="state">[% t.state +%]</span> [%+
+%]<span class="text">[% t.text %]</span>
+[% IF t.deadline
++%] <span class="deadline">[[% t.deadline %]]</span>[% END %]
+[% IF t.owners.size
++%] <span class="owners">([% t.owners.join (', ') %])</span>[% END %]
+</p></li>
+[%+ END %]
+
+[% BLOCK tasks %]
+ [% FOREACH t = tasks %]
+ [% IF t.key %]
+$indent<li class="section"><p>[% t.key %]</p><ul>
+[%+ INCLUDE tasks tasks = t.value indent = "$indent " %]
+$indent</ul></li>
+[%+ %]
+ [% ELSE %]
+ [% PROCESS task FOREACH t = t.value %]
[% END %]
- [% ELSE +%]
- <li><p>Aucune Tache</p></li>
- [%+ END %]
+ [% END %]
[% END %]
+
diff --git a/p/tools/todo.pl b/p/tools/todo.pl
index c0fed89..ceee0f5 100644
--- a/p/tools/todo.pl
+++ b/p/tools/todo.pl
@@ -97,6 +97,26 @@ sub parse_dir
foreach @tododirs;
}
+# Drop empty nodes.
+sub drop_empty
+{
+ my ($todos) = @_;
+ for (keys %$todos)
+ {
+ if ($_)
+ {
+ # Recurse.
+ drop_empty ($$todos{$_});
+ # Drop if empty.
+ delete $$todos{$_} unless scalar keys %{$$todos{$_}};
+ }
+ else
+ {
+ delete $$todos{$_} unless scalar @{$$todos{$_}};
+ }
+ }
+}
+
# Output todo tree file.
sub output_tree
{
@@ -109,7 +129,6 @@ sub output_tree
});
$tt->process ('todo.' . $$config{'format'} . '.tt', {
'tasks' => $t,
- 'keep' => $$config{'keep-empty'},
'owner' => !defined $$config{'owner'},
})
or die $tt->error;
@@ -129,7 +148,9 @@ Options:
-f, --format=FORMAT Set the output format ('text' or 'html', defaults to
'text').
-k, --keep-empty Keep empty sections.
- -o, --owner=OWNER Output only task for OWNER
+ -o, --owner=OWNER Output only task for OWNER.
+ -O, --opened Output only opened tasks.
+ -s, --scheduled Output only scheduled task (i.e. with a deadline).
-d, --dump Dump todo hash instead of normal output.
-h, --help Print this help screen.
EOF
@@ -149,6 +170,8 @@ sub config
'format=s',
'keep-empty',
'owner=s',
+ 'open|O',
+ 'scheduled',
'dump|d',
'help',
) or die;
@@ -165,9 +188,18 @@ my $filter = sub {
{
return 0 unless grep { $_ eq $config{'owner'} } @{$t{'owners'}};
}
+ if ($config{'open'})
+ {
+ return 0 unless $t{'state'} =~ /[-=]/;
+ }
+ if ($config{'scheduled'})
+ {
+ return 0 unless defined $t{'deadline'};
+ }
1;
};
parse_dir (\%todos, '', $config{'todo-dir'}, $filter);
+drop_empty \%todos unless $config{'keep-empty'};
if (exists ($config{'dump'}))
{
use Data::Dumper;
diff --git a/p/tools/todo.text.tt b/p/tools/todo.text.tt
index 9982766..77207e0 100644
--- a/p/tools/todo.text.tt
+++ b/p/tools/todo.text.tt
@@ -1,20 +1,19 @@
[% BLOCK task %]
-$indent${s.state} [%+
-"(${s.owners.join (', ')}) " IF s.owners.size && owner
+$indent${t.state} [%+
+"[${t.deadline}] " IF t.deadline ;
+"(${t.owners.join (', ')}) " IF t.owners.size && owner
%]
-${s.text}
+${t.text}
[%+ END %]
[% BLOCK tasks %]
[% FOREACH t = tasks %]
- [% IF t.value.size || keep %]
- [% IF t.key %]
+ [% IF t.key %]
$indent${t.key}
[%+ %]
- [% INCLUDE tasks tasks = t.value indent = "$indent " %]
- [% ELSE %]
- [% PROCESS task FOREACH s = t.value %]
- [% END %]
+ [% INCLUDE tasks tasks = t.value indent = "$indent " %]
+ [% ELSE %]
+ [% PROCESS task FOREACH t = t.value %]
[% END %]
[% END %]
[% END %]