commit e0ee33a804c496abbc11e6837a0c41eab687f8e0
Author: Jun Omae <jun66j5@gmail.com>
Date:   Thu Oct 24 12:50:38 2013 +0900

    #6243: ported to genshi template from clearsilver

diff --git a/setup.py b/setup.py
index 2cbd773..f1e543b 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ setup(
     name = 'TracWikiToPdfPlugin',
     version = '2.3.1',
     packages = ['wikitopdf'],
-    package_data={ 'wikitopdf' : [ 'templates/*.cs', 'htdocs/js/*.js' ] },     
+    package_data={ 'wikitopdf' : [ 'templates/*.html', 'htdocs/js/*.js' ] },
     author = "Diorgenes Felipe Grzesiuk",
     author_email = "diorgenes@prognus.com.br",
     description = "Generating PDF files from Wiki pages",
diff --git a/wikitopdf/templates/admin_wikitopdf.cs b/wikitopdf/templates/admin_wikitopdf.cs
deleted file mode 100644
index 0cdaf9c..0000000
--- a/wikitopdf/templates/admin_wikitopdf.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-<h2>Generate WikiToPdf</h2>
-
-<form method="post" onsubmit="compile_pages(this);">
-
-<fieldset>
-	<legend>Book Properties</legend>
-	<table>
-	<tbody>
-		<tr>
-			<td>Title:</td>
-			<td><input type="text" name="title" size="80"/></td>
-		</tr>
-		<tr>
-			<td>Sub-title:</td>
-			<td><input type="text" name="subject" size="80"/></td>
-		</tr>
-		<tr>
-			<td>Version:</td>
-			<td><input type="text" name="version" size="20" /></td>
-		</tr>
-		<tr>
-			<td>Date:</td>
-			<td><input type="text" name="date" size="20"/></td>
-		</tr>
-	</tbody>
-	</table>
-</fieldset>
-
-<fieldset>
-    <legend>Select pages</legend>
-	    <table border="0" width="100%">
-        <tr>
-            <td align="left" colspan="2">All Pages</td>
-        </tr>
-        <tr>
-            <td colspan="2">
-                <select id="leftpages_select" name="leftpages" size="10" style="width: 100%;" multiple="multiple">
-                    <?cs each:page = wikitopdf.leftpages ?>
-                    <option value="<?cs var:page ?>"><?cs var:page ?></option>
-                    <?cs /each ?>
-                </select>
-            </td>
-	</tr>
-	<tr>
-            <td align="center" colspan="2">
-                <input type="button" onclick="move_item('right', 'left')" value="/\" />
-					 &nbsp;&nbsp; 
-                <input type="button" onclick="move_item('left', 'right')" value="\/" />
-            </td>
-	</tr>	
-	<tr>
-            <td align="left" colspan="2">Selected Pages</td>
-         </tr>
-	 <tr>
-	 	<td width="95%">
-	                <select id="rightpages_select" name="rightpages" size="10" style="width: 100%;" multiple="multiple">
-                    		<?cs each:page = wikitopdf.rightpages ?>
-                    		<option value="<?cs var:page ?>"><?cs var:page ?></option>
-                    		<?cs /each ?>
-                	</select>
-		</td>
-		<td width="5%" align="center">
-			<input type="button" onclick="reorder_item('right', -1)" value="/\" />
-			<br><br>
-			<input type="button" onclick="reorder_item('right', 1)" value="\/" />
-		</td>
-        </tr>
-  </table>    
-</fieldset>
-
-<fieldset>
-    <legend>Output Format</legend>
-    <?cs each:format = wikitopdf.formats ?>
-    <label><input type="radio" name="format" value="<?cs name:format ?>" <?cs if:name(format)==wikitopdf.default_format ?>checked="checked"<?cs /if ?> /><?cs var:format.name ?></label>
-    <?cs /each ?>
-</fieldset>
-
-<input type="hidden" name="rightpages_all" value="" />
-
-<div class="buttons">
-    <input type="submit" name="create" value="Create" />
-</div>
-</form>
-
-
diff --git a/wikitopdf/templates/admin_wikitopdf.html b/wikitopdf/templates/admin_wikitopdf.html
new file mode 100644
index 0000000..a8b1234
--- /dev/null
+++ b/wikitopdf/templates/admin_wikitopdf.html
@@ -0,0 +1,97 @@
+<!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"
+      xmlns:xi="http://www.w3.org/2001/XInclude"
+      xmlns:py="http://genshi.edgewall.org/">
+
+<xi:include href="admin.html" />
+
+<head>
+  <title>Generate WikiToPdf</title>
+</head>
+
+<body>
+<h2>Generate WikiToPdf</h2>
+
+<form method="post" onsubmit="compile_pages(this);">
+
+<fieldset>
+	<legend>Book Properties</legend>
+	<table>
+	<tbody>
+		<tr>
+			<td>Title:</td>
+			<td><input type="text" name="title" size="80"/></td>
+		</tr>
+		<tr>
+			<td>Sub-title:</td>
+			<td><input type="text" name="subject" size="80"/></td>
+		</tr>
+		<tr>
+			<td>Version:</td>
+			<td><input type="text" name="version" size="20" /></td>
+		</tr>
+		<tr>
+			<td>Date:</td>
+			<td><input type="text" name="date" size="20"/></td>
+		</tr>
+	</tbody>
+	</table>
+</fieldset>
+
+<fieldset>
+    <legend>Select pages</legend>
+	    <table border="0" width="100%">
+        <tr>
+            <td align="left" colspan="2">All Pages</td>
+        </tr>
+        <tr>
+            <td colspan="2">
+                <select id="leftpages_select" name="leftpages" size="10" style="width: 100%;" multiple="multiple">
+                    <option py:for="page in wikitopdf.leftpages" value="$page">$page</option>
+                </select>
+            </td>
+	</tr>
+	<tr>
+            <td align="center" colspan="2">
+                <input type="button" onclick="move_item('right', 'left')" value="/\" />
+					 &nbsp;&nbsp; 
+                <input type="button" onclick="move_item('left', 'right')" value="\/" />
+            </td>
+	</tr>	
+	<tr>
+            <td align="left" colspan="2">Selected Pages</td>
+         </tr>
+	 <tr>
+	 	<td width="95%">
+	                <select id="rightpages_select" name="rightpages" size="10" style="width: 100%;" multiple="multiple">
+                                <option py:for="page in wikitopdf.rightpages" value="$page">$page</option>
+                	</select>
+		</td>
+		<td width="5%" align="center">
+			<input type="button" onclick="reorder_item('right', -1)" value="/\" />
+                        <br /><br />
+			<input type="button" onclick="reorder_item('right', 1)" value="\/" />
+		</td>
+        </tr>
+  </table>    
+</fieldset>
+
+<fieldset>
+    <legend>Output Format</legend>
+    <label py:for="idx, (key, format) in enumerate(wikitopdf.formats.iteritems())">
+        <input type="radio" name="format" value="$key"
+               checked="${(None, 'checked')[idx == 0]}"
+               />${format.name}
+    </label>
+</fieldset>
+
+<input type="hidden" name="rightpages_all" value="" />
+
+<div class="buttons">
+    <input type="submit" name="create" value="Create" />
+</div>
+</form>
+</body>
+</html>
diff --git a/wikitopdf/web_ui.py b/wikitopdf/web_ui.py
index 02287ef..54e9d12 100644
--- a/wikitopdf/web_ui.py
+++ b/wikitopdf/web_ui.py
@@ -3,26 +3,21 @@ Copyright (C) 2008 Prognus Software Livre - www.prognus.com.br
 Author: Diorgenes Felipe Grzesiuk <diorgenes@prognus.com.br>
 """
 
-from genshi.core import Markup
-from trac.admin.web_ui import IAdminPanelProvider
-from trac.core import Component, ExtensionPoint, implements
-from trac.perm import IPermissionRequestor
+from trac.admin.api import IAdminPanelProvider
+from trac.core import Component, ExtensionPoint, TracError, implements
 from trac.util.translation import _
-from trac.web.api import IRequestFilter
 from trac.web.chrome import ITemplateProvider, add_script
 from trac.wiki.api import WikiSystem
+
 from api import IWikiToPdfFormat
 
+
 class WikiToPdfAdmin(Component):
     """A plugin allowing the export of multiple wiki pages in a single file."""
 
     formats = ExtensionPoint(IWikiToPdfFormat)
 
-    implements(IPermissionRequestor, IAdminPanelProvider, ITemplateProvider, IRequestFilter)
-
-    # IPermissionRequestor methods
-    def get_permission_actions(self):
-        return []
+    implements(IAdminPanelProvider, ITemplateProvider)
 
     # ITemplateProvider methods
     def get_templates_dirs(self):
@@ -38,16 +33,10 @@ class WikiToPdfAdmin(Component):
         if req.perm.has_permission('WIKI_ADMIN'):
             yield ('general', _('General'), 'wikitopdf', _('WikiToPdf'))
 
-    # IRequestFilter methods
-    def pre_process_request(self, req, handler):
-        return handler
-
-    def post_process_request(self, req, template, data, content_type):
-        return template, data, content_type	
-
-    def process_admin_request(self, req, cat, page, path_info):
+    def render_admin_panel(self, req, cat, page, path_info):
         allpages = list(WikiSystem(self.env).get_pages())
-        rightpages = [x for x in req.session.get('wikitopdf_rightpages', '').split(',') if x]
+        rightpages = req.session.get('wikitopdf_rightpages', '')
+        rightpages = filter(None, rightpages.split(','))
 
         formats = {}
         for provider in self.formats:
@@ -78,15 +67,13 @@ class WikiToPdfAdmin(Component):
             
             return formats[format]['provider'].process_wikitopdf(req, format, title, subject, rightpages, date, version, pdfbookname)
             
-        req.hdf['wikitopdf.allpages'] = allpages
-        leftpages = [x for x in allpages if x not in rightpages]
-        leftpages.sort()
-        req.hdf['wikitopdf.leftpages'] = leftpages
-        req.hdf['wikitopdf.rightpages'] = rightpages
-        req.hdf['wikitopdf.formats'] = formats
-        req.hdf['wikitopdf.default_format'] = formats.iterkeys().next()
+        data = {
+            'allpages': allpages,
+            'leftpages': sorted(x for x in allpages if x not in rightpages),
+            'rightpages': rightpages,
+            'formats': formats,
+        }
 
         add_script(req, 'wikitopdf/js/admin_wikitopdf.js') 
 
-        return 'admin_wikitopdf.cs', None
-
+        return 'admin_wikitopdf.html', {'wikitopdf': data}
