8e18e2c40a06 webpy-sucks

More work on the cherrypy base.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 02 Mar 2010 20:36:17 -0500
parents 36b37712c670
children 538a3dada709
branches/tags webpy-sucks
files review/web_templates/base.html review/web_templates/index.html review/web_ui.py

Changes

--- a/review/web_templates/base.html	Tue Mar 02 20:23:36 2010 -0500
+++ b/review/web_templates/base.html	Tue Mar 02 20:36:17 2010 -0500
@@ -1,10 +1,9 @@
-$def with (rd, content, title)
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
 <html>
     <head>
-        <title>${ basename(rd.target.root) } / hg-review</title>
+        <title>Reviewing {{ utils["basename"](datastore.target.root) }} with hg-review</title>
         <link rel="stylesheet" href="/media/aal.css" type="text/css" media="screen" />
         <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" />
         
@@ -15,7 +14,7 @@
     
     <body>
         <div id="head-wrap">
-            <h1><a href="/">${ basename(rd.target.root) }</a> $:{ title }</a></h1>
+            <h1><a href="/">{{ utils["basename"](datastore.target.root) }}</a> {{ title }}</a></h1>
         </div>
         <div id="content-wrap">
             <div id="remote-wrap">
@@ -37,11 +36,11 @@
                 </span>
             </div>
             <div id="main-wrap">
-                $:{ content }
+                {{ content }}
             </div>
         </div>
         <div id="footer">
-            <p>reviewing: ${ rd.target.root }</p>
+            <p>reviewing: {{ datastore.target.root }}</p>
         </div>
     </body>
 </html>
\ No newline at end of file
--- a/review/web_templates/index.html	Tue Mar 02 20:23:36 2010 -0500
+++ b/review/web_templates/index.html	Tue Mar 02 20:36:17 2010 -0500
@@ -1,4 +1,4 @@
-$def with (rd, revs)
+{% extends "base.html" %}
 
 <h2>Changesets</h2>
 <table>
--- a/review/web_ui.py	Tue Mar 02 20:23:36 2010 -0500
+++ b/review/web_ui.py	Tue Mar 02 20:36:17 2010 -0500
@@ -28,6 +28,14 @@
 TEMPLATE_DIR = os.path.join(package_path, 'web_templates')
 jinja_env = Environment(loader=FileSystemLoader(TEMPLATE_DIR))
 
+utils = {
+    'node_short': short,
+    'basename': os.path.basename,
+    'md5': md5,
+    'email': email,
+    'templatefilters': templatefilters,
+}
+
 class ReviewWebUI(object):
     def __init__(self, datastore):
         self.datastore = datastore
@@ -36,7 +44,8 @@
     @cherrypy.expose
     def index(self):
         return jinja_env.get_template('index.html').render(
-            datastore=self.datastore
+            utils=utils, datastore=self.datastore,
+            title='',
         )
     
 
@@ -45,8 +54,15 @@
     if open:
         import webbrowser
         webbrowser.open('http://localhost:%d/' % port)
+        
+    conf = {
+        '/media': {
+            'tools.staticdir.on': True,
+            'tools.staticdir.dir': media_path,
+        }
+    }
     
-    cherrypy.quickstart(ReviewWebUI(api.ReviewDatastore(ui, repo)))
+    cherrypy.quickstart(ReviewWebUI(api.ReviewDatastore(ui, repo)), config=conf)
 
 
 
@@ -59,13 +75,6 @@
 #     '/pull/', 'pull',
 # )
 # 
-# g = {
-#     'node_short': short,
-#     'basename': os.path.basename,
-#     'md5': md5,
-#     'email': email,
-#     'templatefilters': templatefilters,
-# }
 # render = web.template.render(template_path, globals=g)
 # 
 # LOG_PAGE_LEN = 25