| 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 |
So you want to write your own template for Getting things GNOME? |
| 27 |
Cool. Now, these templates are interpreted with a python library |
| 28 |
called Cheetah. If you know a little about python or some other |
| 29 |
scripting languare, just dive in, it's really straightforward. |
| 30 |
A little note: #slurp is used to avoid the trailing newline addition, |
| 31 |
like echo -n if you are into CLIs. |
| 32 |
Otherwise, a nice and easy tutorial about it can be found |
| 33 |
here: |
| 34 |
http://www.devshed.com/c/a/Python/Templating-with-Cheetah/ |
| 35 |
|
| 36 |
The last thing you may want to know are the variables you can use. |
| 37 |
Here's the list: |
| 38 |
tasks -> The list of all exported tasks |
| 39 |
task.title -> The task title |
| 40 |
task.has_title -> True/False, wheter the task has a title (it should) |
| 41 |
task.text -> The task description |
| 42 |
task.has_text |
| 43 |
task.status -> The task status (Active,..) |
| 44 |
task.has_status |
| 45 |
task.subtasks -> List of subtasks |
| 46 |
task.has_subtasks |
| 47 |
task.tags -> List of tags |
| 48 |
task.has_tags |
| 49 |
task.modified |
| 50 |
task.has_modified |
| 51 |
task.due_date |
| 52 |
task.has_due_date |
| 53 |
task.closed_date |
| 54 |
task.has_closed_date |
| 55 |
task.start_date |
| 56 |
task.has_start_date |
| 57 |
task.days_left |
| 58 |
task.has_days_left |
| 59 |
|
| 60 |
## Remember to put a $ before any varible (e.g.: $tasks), I won't do |
| 61 |
## it here so that it shows up in the source of the generated html |
| 62 |
## (the ## are the comment escaping in Cheetah, so these line won't |
| 63 |
## show up) |
| 64 |
|
| 65 |
If you write down a nice template, please send it back to the GTG project: |
| 66 |
go to https://edge.launchpad.net/gtg, and open a bug requesting to include your |
| 67 |
template (remember to attach the file). It's good karma! |
| 68 |
|
| 69 |
For a more advanced usage of templates, scroll down to the end of this document |
| 70 |
|
| 71 |
~~Luca Invernizzi: <[email protected]> ~~ |
| 72 |
--> |
| 73 |
#from GTG.gtk.colors import get_colored_tag_markup |
| 74 |
|
| 75 |
<html> |
| 76 |
<head> |
| 77 |
<title> Things to do </title> |
| 78 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" > |
| 79 |
<style type="text/css"> |
| 80 |
ul{list-style-type: square;} |
| 81 |
</style> |
| 82 |
|
| 83 |
</head> |
| 84 |
<body> |
| 85 |
|
| 86 |
<ul> |
| 87 |
#for $task in $tasks |
| 88 |
$task_template($task) |
| 89 |
#end for |
| 90 |
|
| 91 |
</ul> |
| 92 |
|
| 93 |
<!-- this is the function that generates a task --> |
| 94 |
#def task_template($task) |
| 95 |
<li> |
| 96 |
|
| 97 |
#if $task.has_title |
| 98 |
<b>$task.title</b> |
| 99 |
#if $task.has_tags |
| 100 |
(#slurp |
| 101 |
#for $tag in $task.tags: |
| 102 |
$get_colored_tag_markup($plugin_api.get_requester(), $tag, True) #slurp |
| 103 |
#end for |
| 104 |
)#slurp |
| 105 |
#end if |
| 106 |
<br> |
| 107 |
#end if |
| 108 |
|
| 109 |
#if $task.has_due_date |
| 110 |
<i>Due: $task.due_date</i><br> |
| 111 |
#end if |
| 112 |
|
| 113 |
#if $task.has_text |
| 114 |
$remove_html_tags($task.text) |
| 115 |
#end if |
| 116 |
|
| 117 |
|
| 118 |
#if $task.has_subtasks |
| 119 |
<ul> |
| 120 |
#for $subtask in $task.subtasks: |
| 121 |
$task_template($subtask) |
| 122 |
#end for |
| 123 |
</ul> |
| 124 |
#end if |
| 125 |
</li> |
| 126 |
#end def |
| 127 |
|
| 128 |
|
| 129 |
##This is just to avoid annoying characters around. If you don't believe me, |
| 130 |
## just take it out |
| 131 |
#import re |
| 132 |
#def remove_html_tags($data): |
| 133 |
#return $data |
| 134 |
##Removing subtask anchor points |
| 135 |
#set $p = $re.compile(r'^.*<subtask>[0-9]*@[0-9]*</subtask>.*$',$re.MULTILINE) |
| 136 |
#set $data = $p.sub('', $data) |
| 137 |
##Removing tags |
| 138 |
#set $p = $re.compile(r'@[a-z,0-9]*',$re.IGNORECASE) |
| 139 |
#set $data = $p.sub('', $data) |
| 140 |
##Removing <something> and </something> |
| 141 |
#set $p = $re.compile(r'<.*?>') |
| 142 |
#set $data = $p.sub('', $data) |
| 143 |
##Removing lines only with commas (tags lines) |
| 144 |
#set $p = $re.compile(r'^[\s,\,]*$') |
| 145 |
#return $p.sub('', $data) |
| 146 |
#end def |
| 147 |
|
| 148 |
|
| 149 |
<!-- If you need to write something fancy, GTG's templates let you do so. |
| 150 |
You're given full access to GTG's API through the $plugin_api variable. |
| 151 |
Have a look in GTG/core/plugins/api.py to discover how to use it, |
| 152 |
or look at http://live.gnome.org/gtg/pluginHowTo (you are only interested |
| 153 |
in the "Plugin API" part of that page, so scroll down). |
| 154 |
|
| 155 |
An example of usage of that is given in the following lines, that list |
| 156 |
all GTG's tags. |
| 157 |
To see this code working, delete the "##" at the beginning of each line |
| 158 |
and take it out of the html comment |
| 159 |
|
| 160 |
|
| 161 |
## #for $tag in $plugin_api.get_requester().get_tag_tree().get_all_nodes() |
| 162 |
## $tag.get_friendly_name() |
| 163 |
## #end for |
| 164 |
|
| 165 |
--> |
| 166 |
|
| 167 |
|
| 168 |
</body> |
| 169 |
</html> |
| 170 |
|