b39562553ee2

web: make the title configurable for deployments
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 13 Jun 2010 12:43:46 -0400
parents a82d0a798b84
children cec804c97165
branches/tags (none)
files contrib/deploy/wsgi.py review/templates/base.html review/web_ui.py

Changes

--- a/contrib/deploy/wsgi.py	Sun Jun 13 12:32:45 2010 -0400
+++ b/contrib/deploy/wsgi.py	Sun Jun 13 12:43:46 2010 -0400
@@ -11,6 +11,7 @@
 ALLOW_ANON_COMMENTS = False
 ANON_USER = 'Anonymous <anonymous@example.com>'
 SITE_ROOT = 'http://yoursite.com/optional/path'
+TITLE = 'Your Project'
 
 from mercurial import hg, ui
 from web_ui import app
@@ -23,6 +24,7 @@
 app.read_only = READ_ONLY
 app.allow_anon = ALLOW_ANON_COMMENTS
 app.site_root = SITE_ROOT.rstrip('/')
+app.title = TITLE
 app.debug = False
 app.datastore = ReviewDatastore(_ui, repo)
 
--- a/review/templates/base.html	Sun Jun 13 12:32:45 2010 -0400
+++ b/review/templates/base.html	Sun Jun 13 12:43:46 2010 -0400
@@ -5,7 +5,7 @@
 
 <html>
     <head>
-        <title>{% block title %}{% endblock %}Reviewing {{ utils["basename"](datastore.target.root) }} with hg-review</title>
+        <title>{% block title %}{% endblock %}Reviewing {{ title }} with hg-review</title>
         <link rel="stylesheet" href="/static/aal.css" type="text/css" media="screen" />
         <link rel="stylesheet" href="/static/style.css" type="text/css" media="screen" />
         <link rel="stylesheet" href="/static/extra.css" type="text/css" media="screen" />
@@ -23,7 +23,7 @@
             <div class="wrap">
                 <h1>
                     Reviewing
-                    <a href="/">{{ utils["basename"](datastore.target.root) }}</a>
+                    <a href="/">{{ title }}</a>
                 </h1>
                 <div class="remotes">
                     {% if not read_only %}
@@ -56,7 +56,7 @@
         <div class="footer">
             <div class="wrap">
                 <p>
-                    reviewing {{ utils["basename"](datastore.target.root) }}
+                    reviewing {{ title }}
                     with <a href="http://bitbucket.org/sjl/hg-review/">hg-review</a>
                 </p>
             </div>
--- a/review/web_ui.py	Sun Jun 13 12:32:45 2010 -0400
+++ b/review/web_ui.py	Sun Jun 13 12:43:46 2010 -0400
@@ -36,7 +36,7 @@
 LOG_PAGE_LEN = 1000000
 
 def _item_gravatar(item):
-    return 'http://www.gravatar.com/avatar/%s/' % md5(email(item.author)).hexdigest()
+    return 'http://www.gravatar.com/avatar/%s?s=30' % md5(email(item.author)).hexdigest()
 
 def _line_type(line):
     return 'rem' if line[0] == '-' else 'add' if line[0] == '+' else 'con'
@@ -47,7 +47,6 @@
              'neutral': len(filter(lambda s: s.opinion == '', signoffs)),}
 utils = {
     'node_short': short,
-    'basename': os.path.basename,
     'md5': md5,
     'email': email,
     'templatefilters': templatefilters,
@@ -61,7 +60,8 @@
 
 def _render(template, **kwargs):
     return render_template(template, read_only=app.read_only,
-        allow_anon=app.allow_anon, utils=utils, datastore=app.datastore, **kwargs)
+        allow_anon=app.allow_anon, utils=utils, datastore=app.datastore,
+        title=app.title, **kwargs)
 
 
 @app.route('/')
@@ -69,7 +69,7 @@
     rev_max = app.datastore.target['tip'].rev()
     rev_min = rev_max - LOG_PAGE_LEN if rev_max >= LOG_PAGE_LEN else 0
     rcsets = [app.datastore[r] for r in xrange(rev_max, rev_min, -1)]
-    return _render('index.html', title='', rcsets=rcsets)
+    return _render('index.html', rcsets=rcsets)
 
 
 def _handle_signoff(revhash):
@@ -116,7 +116,6 @@
     cu_signoff = cu_signoffs[0] if cu_signoffs else None
     
     return _render('changeset.html',
-        title='%s:%s' % (rev.rev(), short(rev.node())),
         rcset=rcset, rev=rev, cu_signoff=cu_signoff
     )
 
@@ -151,6 +150,7 @@
         ui.setconfig('ui', 'username', 'Anonymous <anonymous@example.com>')
 
     app.datastore = api.ReviewDatastore(ui, repo)
+    app.title = os.path.basename(repo.root)
 
     if app.debug:
         from flaskext.lesscss import lesscss