Rev 191: Performed most of the conversion from Mako to SimpleTAL. in http://bzr.daniel-watkins.co.uk/pqm/ui
Daniel Watkins
daniel at daniel-watkins.co.uk
Thu Jul 10 11:04:29 BST 2008
At http://bzr.daniel-watkins.co.uk/pqm/ui
------------------------------------------------------------
revno: 191
revision-id: daniel at daniel-watkins.co.uk-20080710100316-e6sje5k9sodt1m3w
parent: daniel at daniel-watkins.co.uk-20080710082146-myykuibjkretytk9
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Thu 2008-07-10 11:03:16 +0100
message:
Performed most of the conversion from Mako to SimpleTAL.
-------------- next part --------------
=== modified file 'pqm/ui/template.py'
--- a/pqm/ui/template.py 2008-07-10 08:21:46 +0000
+++ b/pqm/ui/template.py 2008-07-10 10:03:16 +0000
@@ -1,34 +1,6 @@
from simpletal.simpleTAL import compileHTMLTemplate
template = compileHTMLTemplate("""
-<%!
-import time
-
-def t(text):
- return time.ctime(float(text))
-%>
-
-<%def name="prelude(m)">
-${ m['submission_time'] | t}: ${ m['sender'] },
-</%def>
-
-<%def name="format_message(m)">
-<li>
-<p>
-% if not m['other']:
- ${ prelude(m) } '${ m['subject'] }'
- <ol>
- % for c in m['commands']:
- <li> ${ c } </li>
- % endfor
- </ol>
-% else:
- A request for another project.
-% endif
-</p>
-</li>
-</%def>
-
<html>
<head>
<title>Patch Queue Manager</title>
@@ -36,37 +8,55 @@
<body>
-<h1>PQM Queue: ${ len(messages) } scripts</h1>
-
-% if not processing:
- <h2>PQM is not currently processing additional requests</h2>
-% endif
-
-<p>Current time: ${ time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime()) }</p>
-
-% if len(messages) > 0:
+<h1>PQM Queue: <div tal:omit-tag="" tal:content="python: len(messages)">0</div> scripts</h1>
+
+<h2 tal:condition="not: processing">PQM is not currently processing additional requests</h2>
+
+<p>Current time: <div tal:omit-tag="" tal:content="current_time">foo</div></p>
+
+<div tal:omit-tag="" tal:condition="python: len(messages)">
<h2>Now playing...</h2>
- % if not messages[0]['other']:
- <pre>${ status_text | h }</pre>
- % endif
+ <pre tal:condition="not: python: messages[0]['other']"
+ tal:content="status_text"></pre>
<ul>
- ${ format_message(messages[0]) }
+ <li tal:repeat="message python: messages[:1]">
+ <div tal:omit-tag="" tal:condition="message/other">
+ A request for another project.
+ </div>
+ <div tal:omit-tag="" tal:condition="not: message/other">
+ <div tal:omit-tag="" tal:content="message/submission_time"></div>: <div tal:omit-tag="" tal:content="message/sender"></div>, '<div tal:omit-tag="" tal:content="message/subject"></div>'
+ <ol>
+ <li tal:repeat="command message/commands">
+ <div tal:omit-tag="" tal:content="command"></div>
+ </li>
+ </ol>
+ </div>
+ </li>
</ul>
<h2>Coming up</h2>
<ol>
- % for m in messages[1:]:
- % if m['pqm_managed']:
- ${ format_message(m) }
- % else:
- <li>
- <p> ${ prelude(m) } Request for non-PQM managed branch.</p>
- </li>
- % endif
- % endfor
+ <li tal:repeat="message python: messages[1:]">
+ <div tal:omit-tag="" tal:condition="message/pqm_managed">
+ <div tal:omit-tag="" tal:condition="message/other">
+ A request for another project.
+ </div>
+ <div tal:omit-tag="" tal:condition="not: message/other">
+ <div tal:omit-tag="" tal:content="message/submission_time"></div>: <div tal:omit-tag="" tal:content="message/sender"></div>, '<div tal:omit-tag="" tal:content="message/subject"></div>'
+ <ol>
+ <li tal:repeat="command message/commands">
+ <div tal:omit-tag="" tal:content="command"></div>
+ </li>
+ </ol>
+ </div>
+ </div>
+ <div tal:omit-tag="" tal:condition="not: message/pqm_managed">
+ <p><div tal:omit-tag="" tal:content="message/submission_time"></div>: <div tal:omit-tag="" tal:content="message/sender"></div>, Request for non-PQM managed branch.</p>
+ </div>
+ </li>
</ol>
-%endif
+</div>
</body>
</html>""")
=== modified file 'pqm/ui/twistd.py'
--- a/pqm/ui/twistd.py 2008-07-10 08:21:46 +0000
+++ b/pqm/ui/twistd.py 2008-07-10 10:03:16 +0000
@@ -52,13 +52,16 @@
return self.getProjectPage(None, request).render(request)
def getProjectPage(self, selected_project, request):
- c = Context()
+ c = Context(allowPythonPath=True)
c.addGlobal('processing', self.currentlyProcessing())
- c.addGlobal('messages',[self.getMessageDict(selected_project, m)
+ c.addGlobal('messages', [self.getMessageDict(selected_project, m)
for m in self.queue.messages])
+ c.addGlobal('current_time',
+ time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime()))
+ c.addGlobal('status_text', self.queue.status_text)
text = StringIO()
template.expand(c, text)
- return static.Data(text, 'text/html')
+ return static.Data(text.getvalue(), 'text/html')
def currentlyProcessing(self):
configp = pqm.ConfigParser()
@@ -68,7 +71,7 @@
def getMessageDict(self, selected_project, message):
dict = {}
- dict['submission_time'] = message.getSubmissionTime()
+ dict['submission_time'] = time.ctime(message.getSubmissionTime())
dict['sender'] = message.getSender()
try:
projects = message.getProjects()
More information about the bazaar-commits
mailing list