| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 |
|
| 3 |
<!-- |
| 4 |
-*- coding: utf-8 -*- |
| 5 |
----------------------------------------------------------------------------- |
| 6 |
Getting Things GNOME! - a personal organizer for the GNOME desktop |
| 7 |
Copyright (c) 2008-2013 - Lionel Dricot & Bertrand Rousseau |
| 8 |
|
| 9 |
This program is free software: you can redistribute it and/or modify it under |
| 10 |
the terms of the GNU General Public License as published by the Free Software |
| 11 |
Foundation, either version 3 of the License, or (at your option) any later |
| 12 |
version. |
| 13 |
|
| 14 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 |
details. |
| 18 |
|
| 19 |
You should have received a copy of the GNU General Public License along with |
| 20 |
this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 |
----------------------------------------------------------------------------- |
| 22 |
--> |
| 23 |
|
| 24 |
<!-- |
| 25 |
----------------------------------------------------------------------------- |
| 26 |
Author: Duncan Lock <[email protected]> |
| 27 |
Date: 2010-10-24 |
| 28 |
This is a modified version of Luca's original template_simple.html |
| 29 |
----------------------------------------------------------------------------- |
| 30 |
--> |
| 31 |
|
| 32 |
<!-- |
| 33 |
So you want to write your own template for Getting things GNOME? |
| 34 |
Cool. Now, these templates are interpreted with a python library |
| 35 |
called Cheetah. If you know a little about python or some other |
| 36 |
scripting languare, just dive in, it's really straightforward. |
| 37 |
A little note: #slurp is used to avoid the trailing newline addition, |
| 38 |
like echo -n if you are into CLIs. |
| 39 |
Otherwise, a nice and easy tutorial about it can be found |
| 40 |
here: |
| 41 |
http://www.devshed.com/c/a/Python/Templating-with-Cheetah/ |
| 42 |
|
| 43 |
The last thing you may want to know are the variables you can use. |
| 44 |
Here's the list: |
| 45 |
tasks -> The list of all exported tasks |
| 46 |
task.title -> The task title |
| 47 |
task.has_title -> True/False, wheter the task has a title (it should) |
| 48 |
task.text -> The task description |
| 49 |
task.has_text |
| 50 |
task.status -> The task status (Active,..) |
| 51 |
task.has_status |
| 52 |
task.subtasks -> List of subtasks |
| 53 |
task.has_subtasks |
| 54 |
task.tags -> List of tags |
| 55 |
task.has_tags |
| 56 |
task.modified |
| 57 |
task.has_modified |
| 58 |
task.due_date |
| 59 |
task.has_due_date |
| 60 |
task.closed_date |
| 61 |
task.has_closed_date |
| 62 |
task.start_date |
| 63 |
task.has_start_date |
| 64 |
task.days_left |
| 65 |
task.has_days_left |
| 66 |
|
| 67 |
## Remember to put a $ before any varible (e.g.: $tasks), I won't do |
| 68 |
## it here so that it shows up in the source of the generated html |
| 69 |
## (the ## are the comment escaping in Cheetah, so these line won't |
| 70 |
## show up) |
| 71 |
|
| 72 |
If you write down a nice template, please send it back to the GTG project: |
| 73 |
go to https://edge.launchpad.net/gtg, and open a bug requesting to include your |
| 74 |
template (remember to attach the file). It's good karma! |
| 75 |
|
| 76 |
For a more advanced usage of templates, scroll down to the end of this document |
| 77 |
|
| 78 |
~~Luca Invernizzi: <[email protected]> ~~ |
| 79 |
--> |
| 80 |
<html> |
| 81 |
<head> |
| 82 |
<title>Tasklist</title> |
| 83 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" > |
| 84 |
|
| 85 |
<style> |
| 86 |
body { font-family: 'Droid Sans', Calibri, 'Lucida Grande' Helvetica, sans-serif; padding: 0 0.5em 2em 0.5em; } |
| 87 |
div.tags-key { padding: 0.2em; border: 1px solid #ccc; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; } |
| 88 |
div.tags-key h3 { margin: 0.4em 0.5em; padding: 0.15em 0.2em; border-bottom: 1px solid #ddd; } |
| 89 |
p.tag { float: left; padding: 0.3em; margin: 0.1em 0.3em; width: 20%; } |
| 90 |
|
| 91 |
table { border-collapse: collapse; margin-bottom: 2em; } |
| 92 |
th { border: 1px solid #ddd; background-color: #dedede; padding: 0.2em; } |
| 93 |
td { border: 1px solid #ddd; padding: 0.2em; } |
| 94 |
|
| 95 |
p.tag span, td.tag span { display: inline-block; width: 20px; height: 20px; margin: 0.2em; border: 1px solid #bbb; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; } |
| 96 |
td.tag span { display: inline-block; margin: 0 0.2em; float: left; } |
| 97 |
td.tag { width: 60px; } |
| 98 |
|
| 99 |
td p.task { margin: 0.1em 0 0.1em 0.2em; } |
| 100 |
td p.subtask { color: #666; margin: 0.1em 0 0.1em 2em; } |
| 101 |
td p.subtask:before { content: "\21d2 "; margin-right: 0.3em; } |
| 102 |
td p.description { font-style: italic; font-size: 90%; color: #bbb; margin: 0 0.5em 0.2em 0.7em; } |
| 103 |
|
| 104 |
.clear { float: none; clear: both; } |
| 105 |
|
| 106 |
## Output CSS classes for each of the tags, setting background-color to the tag colour |
| 107 |
#for $tag in $plugin_api.get_requester().get_tag_tree().get_all_nodes(): |
| 108 |
#set $tag_obj = $plugin_api.get_requester().get_tag_tree().get_node($tag) |
| 109 |
#if $tag_obj.is_special(): |
| 110 |
#continue |
| 111 |
#end if |
| 112 |
#try: |
| 113 |
span.#slurp |
| 114 |
$tag.replace('@', '') { background-color: $tag_obj.get_attribute('color'); } |
| 115 |
#except: |
| 116 |
#pass |
| 117 |
#end try |
| 118 |
#end for |
| 119 |
</style> |
| 120 |
</head> |
| 121 |
<body> |
| 122 |
<h1>Tasklist</h1> |
| 123 |
|
| 124 |
<table> |
| 125 |
<thead> |
| 126 |
<tr> |
| 127 |
<th>Tags</th> |
| 128 |
<th>Title</th> |
| 129 |
<th>Due</th> |
| 130 |
</tr> |
| 131 |
</thead> |
| 132 |
<colgroup> |
| 133 |
<col width="10%"> |
| 134 |
<col width="*"> |
| 135 |
<col width="10%"> |
| 136 |
<colgroup> |
| 137 |
<tbody> |
| 138 |
#for $task in $tasks: |
| 139 |
$task_template($task)#slurp |
| 140 |
#end for |
| 141 |
</tbody> |
| 142 |
</table> |
| 143 |
|
| 144 |
<!-- this is the function that generates a task --> |
| 145 |
#def task_template($task, $is_subtask = '') |
| 146 |
<tr> |
| 147 |
#if $task.has_tags |
| 148 |
<td class="tag">#slurp |
| 149 |
#for $tag in $task.tags: |
| 150 |
<span class="$tag.replace('@', '')" title="$tag.replace('@', '')"> </span>#slurp |
| 151 |
#end for |
| 152 |
#else |
| 153 |
<td class="tag">#slurp |
| 154 |
#end if#</td> |
| 155 |
<td> |
| 156 |
#if $task.has_title |
| 157 |
<p #if $is_subtask != '' |
| 158 |
class="$is_subtask"#slurp |
| 159 |
#else |
| 160 |
class="task"#slurp |
| 161 |
#end if |
| 162 |
>$task.title</p> |
| 163 |
#if $task.has_text |
| 164 |
<p class="description">$remove_html_tags($task.text)</p> |
| 165 |
#end if |
| 166 |
#end if |
| 167 |
</td> |
| 168 |
<td>#slurp |
| 169 |
#if $task.has_due_date |
| 170 |
$task.due_date#slurp |
| 171 |
#end if#</td> |
| 172 |
</tr> |
| 173 |
#if $task.has_subtasks |
| 174 |
<tr> |
| 175 |
#for $subtask in $task.subtasks: |
| 176 |
$task_template($subtask, 'subtask') |
| 177 |
#end for |
| 178 |
</tr> |
| 179 |
#end if |
| 180 |
#end def |
| 181 |
|
| 182 |
<div class="tags-key"> |
| 183 |
<h3>Tags Key</h3> |
| 184 |
#for $tag in $plugin_api.get_requester().get_tag_tree().get_all_nodes(): |
| 185 |
#set $tag_obj = $plugin_api.get_requester().get_tag_tree().get_node($tag) |
| 186 |
#if $tag_obj.is_special(): |
| 187 |
#continue |
| 188 |
#end if |
| 189 |
<p class="tag"><span class="$tag.replace('@', '')" title="$tag.replace('@', '')"> </span>$tag.replace('@', '')</p> |
| 190 |
#end for |
| 191 |
<br class="clear" /> |
| 192 |
</div> |
| 193 |
|
| 194 |
|
| 195 |
##This is just to avoid annoying characters around. If you don't believe me, |
| 196 |
## just take it out |
| 197 |
#import re |
| 198 |
#def remove_html_tags($data): |
| 199 |
##Removing subtask anchor points |
| 200 |
#set $p = $re.compile(r'^.*<subtask>[0-9]*@[0-9]*</subtask>.*$',$re.MULTILINE) |
| 201 |
#set $data = $p.sub('', $data) |
| 202 |
##Removing tags |
| 203 |
#set $p = $re.compile(r'@[a-z,0-9]*',$re.IGNORECASE) |
| 204 |
#set $data = $p.sub('', $data) |
| 205 |
##Removing <something> and </something> |
| 206 |
#set $p = $re.compile(r'<.*?>') |
| 207 |
#set $data = $p.sub('', $data) |
| 208 |
##Removing lines only with commas (tags lines) |
| 209 |
#set $p = $re.compile(r'^[\s,\,]*$') |
| 210 |
#return $p.sub('', $data).strip().strip(',') |
| 211 |
#end def |
| 212 |
|
| 213 |
|
| 214 |
<!-- If you need to write something fancy, GTG's templates let you do so. |
| 215 |
You're given full access to GTG's API through the $plugin_api variable. |
| 216 |
Have a look in GTG/core/plugins/api.py to discover how to use it, |
| 217 |
or look at http://live.gnome.org/gtg/pluginHowTo (you are only interested |
| 218 |
in the "Plugin API" part of that page, so scroll down). |
| 219 |
|
| 220 |
An example of usage of that is given in the following lines, that list |
| 221 |
all GTG's tags. |
| 222 |
To see this code working, delete the "##" at the beginning of each line |
| 223 |
and take it out of the html comment |
| 224 |
|
| 225 |
|
| 226 |
## #for $tag in $plugin_api.get_requester().get_all_tags() |
| 227 |
## $tag |
| 228 |
## #end for |
| 229 |
|
| 230 |
--> |
| 231 |
|
| 232 |
|
| 233 |
</body> |
| 234 |
</html> |
| 235 |
|