| 1 |
<?xml version="1.0"?> |
|---|
| 2 |
|
|---|
| 3 |
<!-- |
|---|
| 4 |
todo2xhtml_css - convert a devtodo database to a CSS+XHTML page |
|---|
| 5 |
|
|---|
| 6 |
Version: 0.6 |
|---|
| 7 |
|
|---|
| 8 |
Copyright (c) 2004-2005 Francesco Poli, <frx@firenze.linux.it> |
|---|
| 9 |
|
|---|
| 10 |
Permission is hereby granted, free of charge, to any person obtaining |
|---|
| 11 |
a copy of this software and associated documentation files (the |
|---|
| 12 |
"Software"), to deal in the Software without restriction, including |
|---|
| 13 |
without limitation the rights to use, copy, modify, merge, publish, |
|---|
| 14 |
distribute, sublicense, and/or sell copies of the Software, and to |
|---|
| 15 |
permit persons to whom the Software is furnished to do so, subject to |
|---|
| 16 |
the following conditions: |
|---|
| 17 |
|
|---|
| 18 |
The above copyright notice and this permission notice shall be included |
|---|
| 19 |
in all copies or substantial portions of the Software. |
|---|
| 20 |
|
|---|
| 21 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|---|
| 22 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|---|
| 23 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|---|
| 24 |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|---|
| 25 |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|---|
| 26 |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|---|
| 27 |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
As a special exception, when parts of this file are copied by the XSLT |
|---|
| 31 |
transformation into an output file, you may use that output file without |
|---|
| 32 |
restriction. |
|---|
| 33 |
--> |
|---|
| 34 |
|
|---|
| 35 |
<!-- |
|---|
| 36 |
Suggested usage: |
|---|
| 37 |
a) put todo2xhtml_css.xslt and todo.css in /usr/local/share/devtodo/ |
|---|
| 38 |
b) put something like the following in your ~/.todorc |
|---|
| 39 |
|
|---|
| 40 |
# When saving a database, also create an XHTML+CSS version as .todo.html. |
|---|
| 41 |
# This requires the libxslt library from xmlsoft.org in addition to the |
|---|
| 42 |
# XSLT and CSS files in the devtodo contrib directory. |
|---|
| 43 |
on save { |
|---|
| 44 |
echo XHTML+CSS created |
|---|
| 45 |
exec if test ! -e $HOME/.todo.css ; then cp /usr/local/share/devtodo/todo.css $HOME/.todo.css ; fi |
|---|
| 46 |
exec if test ! -e `dirname $TODODB`/.todo.css ; then cp $HOME/.todo.css `dirname $TODODB`/.todo.css ; fi |
|---|
| 47 |
exec xsltproc /usr/local/share/devtodo/todo2xhtml_css.xslt $TODODB > `dirname $TODODB`/.todo.html |
|---|
| 48 |
exec chmod 600 `dirname $TODODB`/.todo.html |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
Rationale: |
|---|
| 53 |
The XSLT transformation generates an XHTML page representing the todo |
|---|
| 54 |
list; this XHTML page refers to an external CSS stylesheet to be |
|---|
| 55 |
found in the same directory. |
|---|
| 56 |
The XHTML page will be updated after every todolist database change. |
|---|
| 57 |
A user-specific CSS stylesheet will be copied from the system-wide |
|---|
| 58 |
default one, *only* if it is not already in the user's home directory. |
|---|
| 59 |
The CSS stylesheet in the current directory will be copied from the |
|---|
| 60 |
user-specific one, *only* if it is not already there. |
|---|
| 61 |
The user can customize (or even completely replace) his/her ~/.todo.css |
|---|
| 62 |
of even some local ./.todo.css : they will not be touched at all, as |
|---|
| 63 |
long as they are present with the right filename. |
|---|
| 64 |
--> |
|---|
| 65 |
|
|---|
| 66 |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
|---|
| 67 |
|
|---|
| 68 |
<xsl:output method="xml" indent="yes" /> |
|---|
| 69 |
|
|---|
| 70 |
<xsl:template match="/"> |
|---|
| 71 |
<xsl:text disable-output-escaping = "yes"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
|---|
| 72 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 73 |
|
|---|
| 74 |
</xsl:text> |
|---|
| 75 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
|---|
| 76 |
<head> |
|---|
| 77 |
<title>Todo list</title> |
|---|
| 78 |
<xsl:text disable-output-escaping = "yes"> |
|---|
| 79 |
<link rel='stylesheet' href='todo.css' type='text/css'/> |
|---|
| 80 |
</xsl:text> |
|---|
| 81 |
<script type="text/javascript"> |
|---|
| 82 |
<xsl:text disable-output-escaping = "yes"> |
|---|
| 83 |
<!-- |
|---|
| 84 |
function updateDisplay() |
|---|
| 85 |
{ |
|---|
| 86 |
var spans = document.getElementsByTagName("span"); |
|---|
| 87 |
for (var i=0; i<spans.length; i++) { |
|---|
| 88 |
var thing=spans[i]; |
|---|
| 89 |
if (thing.className=="old") { |
|---|
| 90 |
if (document.getElementById("dispform").dispold.checked) { |
|---|
| 91 |
thing.style.display="inline"; |
|---|
| 92 |
} else { |
|---|
| 93 |
thing.style.display="none"; |
|---|
| 94 |
} |
|---|
| 95 |
} |
|---|
| 96 |
} |
|---|
| 97 |
} |
|---|
| 98 |
//--> |
|---|
| 99 |
</xsl:text> |
|---|
| 100 |
</script> |
|---|
| 101 |
</head> |
|---|
| 102 |
<body onLoad="updateDisplay()"> |
|---|
| 103 |
<div id="outercontainer"> |
|---|
| 104 |
<div id="innercontainer"> |
|---|
| 105 |
<div id="outertitle"> |
|---|
| 106 |
<div id="innertitle"> |
|---|
| 107 |
<h1>Todo list</h1> |
|---|
| 108 |
</div> |
|---|
| 109 |
</div> |
|---|
| 110 |
<div id="outerlegend"> |
|---|
| 111 |
<div id="innerlegend"> |
|---|
| 112 |
<ol> |
|---|
| 113 |
<li class="veryhigh"> |
|---|
| 114 |
<span>veryhigh</span> |
|---|
| 115 |
<span class="old"><span class="done">(done)</span></span> |
|---|
| 116 |
</li> |
|---|
| 117 |
<li class="high"> |
|---|
| 118 |
<span>high</span> |
|---|
| 119 |
<span class="old"><span class="done">(done)</span></span> |
|---|
| 120 |
</li> |
|---|
| 121 |
<li class="medium"> |
|---|
| 122 |
<span>medium</span> |
|---|
| 123 |
<span class="old"><span class="done">(done)</span></span> |
|---|
| 124 |
</li> |
|---|
| 125 |
<li class="low"> |
|---|
| 126 |
<span>low</span> |
|---|
| 127 |
<span class="old"><span class="done">(done)</span></span> |
|---|
| 128 |
</li> |
|---|
| 129 |
<li class="verylow"> |
|---|
| 130 |
<span>verylow</span> |
|---|
| 131 |
<span class="old"><span class="done">(done)</span></span> |
|---|
| 132 |
</li> |
|---|
| 133 |
</ol> |
|---|
| 134 |
<form action="." method="get" id="dispform"> |
|---|
| 135 |
<input type="checkbox" name="dispold" checked="" onChange="updateDisplay()"/> |
|---|
| 136 |
Display done items. |
|---|
| 137 |
</form> |
|---|
| 138 |
</div> |
|---|
| 139 |
</div> |
|---|
| 140 |
<div id="outerlist"> |
|---|
| 141 |
<div id="innerlist"> |
|---|
| 142 |
<xsl:apply-templates /> |
|---|
| 143 |
</div> |
|---|
| 144 |
</div> |
|---|
| 145 |
</div> |
|---|
| 146 |
</div> |
|---|
| 147 |
</body> |
|---|
| 148 |
</html> |
|---|
| 149 |
</xsl:template> |
|---|
| 150 |
|
|---|
| 151 |
<xsl:template match="/todo"> |
|---|
| 152 |
<xsl:call-template name="list_of_notes" /> |
|---|
| 153 |
</xsl:template> |
|---|
| 154 |
|
|---|
| 155 |
<xsl:template name="list_of_notes"> |
|---|
| 156 |
<ol> |
|---|
| 157 |
<xsl:for-each select="./note"> |
|---|
| 158 |
<xsl:apply-templates select="." /> |
|---|
| 159 |
</xsl:for-each> |
|---|
| 160 |
</ol> |
|---|
| 161 |
</xsl:template> |
|---|
| 162 |
|
|---|
| 163 |
<xsl:template match="note"> |
|---|
| 164 |
<xsl:element name="span"> |
|---|
| 165 |
<xsl:if test="@done"> |
|---|
| 166 |
<xsl:attribute name="class">old</xsl:attribute> |
|---|
| 167 |
</xsl:if> |
|---|
| 168 |
<xsl:element name="li"> |
|---|
| 169 |
<xsl:attribute name="class"> |
|---|
| 170 |
<xsl:value-of select="@priority" /> |
|---|
| 171 |
</xsl:attribute> |
|---|
| 172 |
<xsl:element name="span"> |
|---|
| 173 |
<xsl:if test="@done"> |
|---|
| 174 |
<xsl:attribute name="class">done</xsl:attribute> |
|---|
| 175 |
</xsl:if> |
|---|
| 176 |
<xsl:value-of select="child::text()" /> |
|---|
| 177 |
</xsl:element> |
|---|
| 178 |
<xsl:if test="./note"> |
|---|
| 179 |
<xsl:call-template name="list_of_notes" /> |
|---|
| 180 |
</xsl:if> |
|---|
| 181 |
</xsl:element> |
|---|
| 182 |
</xsl:element> |
|---|
| 183 |
</xsl:template> |
|---|
| 184 |
|
|---|
| 185 |
</xsl:stylesheet> |
|---|