efc3c9173ce1 webui

Add template inheritance.  Not liking Templetor so far...
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 14 Oct 2009 19:06:00 -0400
parents 78cd41b87ea2
children 43d109fde61e
branches/tags webui
files review/web_media/style.css review/web_templates/base.html review/web_templates/index.html review/web_templates/review.html review/web_ui.py

Changes

--- a/review/web_media/style.css	Tue Oct 13 21:12:15 2009 -0400
+++ b/review/web_media/style.css	Wed Oct 14 19:06:00 2009 -0400
@@ -1,13 +1,28 @@
 /* Basic layout and typography. */
 body {
-    background: #666;
+    background: #f5f5f5;
 }
 div#main-wrap {
-    background: #f5f5f5;
     width: 65em;
-    margin: 3em auto;
+    margin: 0em auto;
     padding: 3em;
-    border: 1px solid #333;
+}
+div#head-wrap {
+    text-align: center;
+    padding: 1.5em 0em .5em;
+    background-color: #105E0F;
+    color: #fff;
+    border-bottom: 1px solid #114700;
+}
+
+/* Links. */
+a {
+    text-decoration: none;
+    font-weight: bold;
+    color: #297E00;
+}
+a:hover {
+    color: #EA0076;
 }
 
 /* Tables. */
@@ -31,8 +46,8 @@
     white-space: pre;
 }
 table tr.add {
-    background: #beb;
+    background: #DBF3D1;
 }
 table tr.rem {
-    background: #fcc;
+    background: #FBDBDA;
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/review/web_templates/base.html	Wed Oct 14 19:06:00 2009 -0400
@@ -0,0 +1,20 @@
+$def with (rd, content)
+<!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>
+        <link rel="stylesheet" href="/media/aal.css" type="text/css" media="screen" />
+        <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" />
+    </head>
+    
+    <body>
+        <div id="head-wrap">
+            <h1>${ basename(rd.target.root) }</h1>
+        </div>
+        <div id="main-wrap">
+            $:{ content }
+        </div>
+    </body>
+</html>
\ No newline at end of file
--- a/review/web_templates/index.html	Tue Oct 13 21:12:15 2009 -0400
+++ b/review/web_templates/index.html	Wed Oct 14 19:06:00 2009 -0400
@@ -1,34 +1,18 @@
 $def with (rd, revs)
-<!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>
-        <link rel="stylesheet" href="/media/aal.css" type="text/css" media="screen" />
-        <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" />
-    </head>
-    
-    <body>
-        <div id="main-wrap">
-            <h1>${ basename(rd.target.root) }</h1>
-            
-            <h2>Changesets</h2>
-            <table>
-                $for ctx in revs:
-                    $ ctx_node = ctx.node()
-                    $ ctx_node_short = node_short(ctx_node)
-                    $ ctx_comments = rd[ctx_node].comments
-                    $ ctx_signoffs = rd[ctx_node].signoffs
-                    <tr class="${ loop.parity }">
-                        <td>${ ctx.rev() }:${ ctx_node_short }</td>
-                        <td>
-                            <a href="/review/${ ctx_node_short }/">${ ctx.description() }</a>
-                        </td>
-                        <td>${ len(ctx_comments) } comments,
-                            ${ len(ctx_signoffs) } signoffs</td>
-                    </tr>
-            </table>
-        </div>
-    </body>
-</html>
\ No newline at end of file
+<h2>Changesets</h2>
+<table>
+    $for ctx in revs:
+        $ ctx_node = ctx.node()
+        $ ctx_node_short = node_short(ctx_node)
+        $ ctx_comments = rd[ctx_node].comments
+        $ ctx_signoffs = rd[ctx_node].signoffs
+        <tr class="${ loop.parity }">
+            <td>${ ctx.rev() }:${ ctx_node_short }</td>
+            <td>
+                <a href="/review/${ ctx_node_short }/">${ ctx.description() }</a>
+            </td>
+            <td>${ len(ctx_comments) } comments,
+                ${ len(ctx_signoffs) } signoffs</td>
+        </tr>
+</table>
\ No newline at end of file
--- a/review/web_templates/review.html	Tue Oct 13 21:12:15 2009 -0400
+++ b/review/web_templates/review.html	Wed Oct 14 19:06:00 2009 -0400
@@ -1,34 +1,17 @@
 $def with (rd, rcset)
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+$ ctx = rd.target[rcset.node]
+<h2>Changeset ${ ctx.rev() }: ${ ctx.description() }</h2>
 
-<html>
-    <head>
-        <title>${ basename(rd.target.root) } / 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" />
-    </head>
-    
-    <body>
-        <div id="main-wrap">
-            <h1>${ basename(rd.target.root) }</h1>
-            
-            $ ctx = rd.target[rcset.node]
-            <h2>Changeset ${ ctx.rev() }: ${ ctx.description() }</h2>
-            
-            $for filename, diff in rcset.diffs().iteritems():
-                <h3>${ filename }</h3>
-                <div class="diff">
-                    <table>
-                        $ max_line = diff['max']
-                        $ content = diff['content']
-                        $for n, line in content:
-                            $ kind = 'rem' if line[0] == '-' else 'add' if line[0] == '+' else ''
-                            <tr class="${ kind }">
-                                <td class="diff-line"><code>${ line[1:] or ' ' }</code></td>
-                            </tr>
-                    </table>
-                </div>
-        </div>
-    </body>
-</html>
\ No newline at end of file
+$for filename, diff in rcset.diffs().iteritems():
+    <h3>${ filename }</h3>
+    <div class="diff">
+        <table>
+            $ max_line = diff['max']
+            $ content = diff['content']
+            $for n, line in content:
+                $ kind = 'rem' if line[0] == '-' else 'add' if line[0] == '+' else ''
+                <tr class="${ kind }">
+                    <td class="diff-line"><code>${ line[1:] or ' ' }</code></td>
+                </tr>
+        </table>
\ No newline at end of file
--- a/review/web_ui.py	Tue Oct 13 21:12:15 2009 -0400
+++ b/review/web_ui.py	Wed Oct 14 19:06:00 2009 -0400
@@ -29,7 +29,14 @@
 
 LOG_PAGE_LEN = 15
 
+def render_in_base(fn):
+    def _fn(*args, **kwargs):
+        content = fn(*args, **kwargs)
+        return render.base(_rd, content)
+    return _fn
+
 class index:
+    @render_in_base
     def GET(self):
         rev_max = _rd.target['tip'].rev()
         rev_min = rev_max - LOG_PAGE_LEN if rev_max >= LOG_PAGE_LEN else 0
@@ -38,6 +45,7 @@
     
 
 class review:
+    @render_in_base
     def GET(self, node_short):
         return render.review(_rd, _rd[node_short])