7ae0c716218d initial-docs

Merge with default.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 12 Jul 2010 23:01:25 -0400
parents 80d2d7acbd6c (current diff) c0afa545124b (diff)
children c1a265bd7578
branches/tags initial-docs
files review/static/style.less

Changes

--- a/bundled/markdown2/lib/markdown2.py	Sat Jul 10 13:57:27 2010 -0400
+++ b/bundled/markdown2/lib/markdown2.py	Mon Jul 12 23:01:25 2010 -0400
@@ -523,6 +523,7 @@
                 try:
                     end_idx = text.index("-->", start_idx) + 3
                 except ValueError, ex:
+                    text = text[:start_idx] + '&lt;' + text[start_idx+1:]
                     break
 
                 # Start position for next comment block search.
--- a/contrib/deploy/wsgi.py	Sat Jul 10 13:57:27 2010 -0400
+++ b/contrib/deploy/wsgi.py	Mon Jul 12 23:01:25 2010 -0400
@@ -12,6 +12,7 @@
 ANON_USER = 'Anonymous <anonymous@example.com>'
 SITE_ROOT = 'http://yoursite.com/optional/path'
 TITLE = 'Your Project'
+PROJECT_URL = 'http://bitbucket.org/your/project/' # or None
 
 from mercurial import hg, ui
 from review.web import app
@@ -26,6 +27,7 @@
 app.title = TITLE
 app.debug = False
 app.ui = _ui
+app.project_url = PROJECT_URL
 app.repo = repo
 
 application = app
--- a/review/static/style.css	Sat Jul 10 13:57:27 2010 -0400
+++ b/review/static/style.css	Mon Jul 12 23:01:25 2010 -0400
@@ -501,6 +501,7 @@
   float: right;
 }
 #changeset .content .item-listing .comment .message, #changeset .content .item-listing .signoff .message {
+  overflow-x: auto;
   width: 690px;
   padding-top: 3px;
 }
@@ -545,6 +546,7 @@
   font-weight: bold;
 }
 #changeset .content .item-listing .signoff .message {
+  overflow-x: auto;
   width: 620px;
 }
 #changeset .content .add-review-comment {
--- a/review/static/style.less	Sat Jul 10 13:57:27 2010 -0400
+++ b/review/static/style.less	Mon Jul 12 23:01:25 2010 -0400
@@ -451,6 +451,7 @@
                 float: right;
             }
             .message {
+                overflow-x: auto;
                 width: 690px;
                 padding-top: 3px;
             }
@@ -493,6 +494,7 @@
                 }
             }
             .message {
+                overflow-x: auto;
                 width: 620px;
             }
         }
--- a/review/static/ui.js	Sat Jul 10 13:57:27 2010 -0400
+++ b/review/static/ui.js	Mon Jul 12 23:01:25 2010 -0400
@@ -1,18 +1,16 @@
 $(function() {
     $("a.fold").toggle(function(event) {
+        $(event.target).closest(".file").find(".file-review-contents").slideUp("fast", function () {
+            $(event.target).closest("h3").find(".status").html("&rarr;");
+        });
+        return false;
+    }, function(event) {
         $(event.target).closest(".file").find(".file-review-contents").slideDown("fast", function() {
             $(event.target).closest("h3").find(".status").html("&darr;");
         });
         return false;
-    },
-    function(event) {
-        $(event.target).closest(".file")
-                        .find(".file-review-contents")
-                        .slideUp("fast", function () {
-            $(event.target).closest("h3").find(".status").html("&rarr;");
-        });
-        return false;
     });
+
     $(".submit").live('click', function() {
         $(this).closest("form").submit();
     });
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/review/templates/404.html	Mon Jul 12 23:01:25 2010 -0400
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block id %}404{% endblock %}
+{% block title %}Page not found - {% endblock %}
+
+{% block content %}
+    <h2>Page not found (404)</h2>
+    <p>The page you requested could not be found. <a href="/">Go home</a>.</p>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/review/templates/500.html	Mon Jul 12 23:01:25 2010 -0400
@@ -0,0 +1,13 @@
+{% extends "base.html" %}
+
+{% block id %}500{% endblock %}
+{% block title %}Server error - {% endblock %}
+
+{% block content %}
+    <h2>Server error (500)</h2>
+    <p>Something went horribly wrong.</p>
+    <p>
+        If you have a few extra minutes you could
+        <a href="http://bitbucket.org/sjl/hg-review/issues/">file a bug report</a>.
+    </p>
+{% endblock %}
--- a/review/templates/base.html	Sat Jul 10 13:57:27 2010 -0400
+++ b/review/templates/base.html	Mon Jul 12 23:01:25 2010 -0400
@@ -61,7 +61,12 @@
         <div class="footer">
             <div class="wrap">
                 <p>
-                    reviewing {{ title }}
+                    reviewing
+                    {% if project_url %}
+                        <a href="{{ project_url }}">{{ title }}</a>
+                    {% else %}
+                        {{ title }}
+                    {% endif %}
                     with <a href="http://bitbucket.org/sjl/hg-review/">hg-review</a>
                 </p>
             </div>
--- a/review/templates/changeset.html	Sat Jul 10 13:57:27 2010 -0400
+++ b/review/templates/changeset.html	Mon Jul 12 23:01:25 2010 -0400
@@ -88,11 +88,11 @@
                 <span class="filename-b64 disabled">{{ utils['b64'](filename) }}</span>
                 <h3>
                     <a class="fold" href="#"><span class="filename-u">{{ ufilename }}</span>{% if commentcount %} ({{ commentcount }} comment{% if commentcount != 1 %}s{% endif %}){% endif %}</a>
-                    <span class="status">&rarr;</span>
+                    <span class="status">&darr;</span>
                 </h3>
             </div>
 
-            <div class="file-review-contents disabled">
+            <div class="file-review-contents">
                 {% if comments %}
                     <div class="comments item-listing">
                         {% for comment in comments %}
--- a/review/web.py	Sat Jul 10 13:57:27 2010 -0400
+++ b/review/web.py	Mon Jul 12 23:01:25 2010 -0400
@@ -75,7 +75,19 @@
 def _render(template, **kwargs):
     return render_template(template, read_only=app.read_only,
         allow_anon=app.allow_anon, utils=utils, datastore=g.datastore,
-        title=app.title, **kwargs)
+        title=app.title, project_url=app.project_url, **kwargs)
+
+def _get_revision_or_404(revhash):
+    revhash = revhash.lower()
+    if not all(c in 'abcdef1234567890' for c in revhash):
+        abort(404)
+
+    try:
+        rcset = g.datastore[revhash]
+        rev = rcset.target[revhash]
+        return rcset, rev
+    except error.RepoLookupError:
+        abort(404)
 
 
 @app.before_request
@@ -118,22 +130,18 @@
     body = request.form.get('new-signoff-body', '')
     style = 'markdown' if request.form.get('signoff-markdown') else ''
 
-    try:
-        current = request.form.get('current')
-        if current:
-            g.datastore.edit_signoff(current, body, signoff, style=style)
-        else:
-            rcset = g.datastore[revhash]
-            rcset.add_signoff(body, signoff, style=style)
-    except error.RepoLookupError:
-        abort(404)
+    current = request.form.get('current')
+    if current:
+        g.datastore.edit_signoff(current, body, signoff, style=style)
+    else:
+        rcset, rev = _get_revision_or_404(revhash)
+        rcset.add_signoff(body, signoff, style=style)
 
     return redirect("%s/changeset/%s/" % (app.site_root, revhash))
 
 def _handle_comment(revhash):
     filename = base64.b64decode(request.form.get('filename-b64', u''))
     ufilename = request.form.get('filename-u', u'')
-    print repr(filename), repr(ufilename)
 
     lines = str(request.form.get('lines', ''))
     if lines:
@@ -141,18 +149,15 @@
 
     body = request.form['new-comment-body']
     style = 'markdown' if request.form.get('comment-markdown') else ''
-    
-    try:
-        if body:
-            current = request.form.get('current')
-            if current:
-                g.datastore.edit_comment(current, body, ufilename, filename, lines, style)
-            else:
-                rcset = g.datastore[revhash]
-                rcset.add_comment(body, ufilename, filename, lines, style)
-    except error.RepoLookupError:
-        abort(404)
-    
+
+    if body:
+        current = request.form.get('current')
+        if current:
+            g.datastore.edit_comment(current, body, ufilename, filename, lines, style)
+        else:
+            rcset, rev = _get_revision_or_404(revhash)
+            rcset.add_comment(body, ufilename, filename, lines, style)
+
     return redirect("%s/changeset/%s/" % (app.site_root, revhash))
 
 @app.route('/changeset/<revhash>/', methods=['GET', 'POST'])
@@ -163,20 +168,16 @@
             return _handle_signoff(revhash)
         elif not app.read_only or app.allow_anon:
             return _handle_comment(revhash)
-    
-    try:
-        rcset = g.datastore[revhash]
-    except error.RepoLookupError:
-        abort(404)
-    rev = rcset.target[revhash]
-    
+
+    rcset, rev = _get_revision_or_404(revhash)
+
     cu_signoffs = rcset.signoffs_for_current_user()
     cu_signoff = cu_signoffs[0] if cu_signoffs else None
-    
+
     tip = g.datastore.target['tip'].rev()
     newer = rcset.target[rev.rev() + 1] if rev.rev() < tip else None
     older = rcset.target[rev.rev() - 1] if rev.rev() > 0 else None
-    
+
     return _render('changeset.html', rcset=rcset, rev=rev, cu_signoff=cu_signoff,
         newer=newer, older=older)
 
@@ -188,6 +189,8 @@
         cmdutil.export(g.datastore.target, [revhash], fp=result)
     except error.RepoLookupError:
         abort(404)
+    except UnicodeEncodeError:
+        abort(404)
     return Response(result.getvalue(), content_type="text/plain")
 
 @app.route('/pull/', methods=['POST'])
@@ -207,12 +210,21 @@
     return redirect('%s/' % app.site_root)
 
 
+@app.errorhandler(404)
+def page_not_found(error):
+    return _render('404.html'), 404
+
+@app.errorhandler(500)
+def server_error(error):
+    return _render('500.html'), 500
+
+
 def load_interface(ui, repo, read_only=False, allow_anon=False,
         open=False, address='127.0.0.1', port=8080):
     if open:
         import webbrowser
         webbrowser.open('http://localhost:%d/' % port)
-        
+
     app.read_only = read_only
     app.debug = ui.debugflag
     app.allow_anon = allow_anon
@@ -224,6 +236,7 @@
     app.ui = ui
     app.repo = repo
     app.title = os.path.basename(repo.root)
+    app.project_url = None
 
     if app.debug:
         from flaskext.lesscss import lesscss