# HG changeset patch # User Steve Losh # Date 1278990085 14400 # Node ID 7ae0c716218db38eef951016b699c54c6594e97d # Parent 80d2d7acbd6cc4cbe953fbef2785faef921a8e73# Parent c0afa545124bec3beab72a7d7ef5c8f48aa9827e Merge with default. diff -r 80d2d7acbd6c -r 7ae0c716218d bundled/markdown2/lib/markdown2.py --- 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] + '<' + text[start_idx+1:] break # Start position for next comment block search. diff -r 80d2d7acbd6c -r 7ae0c716218d contrib/deploy/wsgi.py --- 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 ' 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 diff -r 80d2d7acbd6c -r 7ae0c716218d review/static/style.css --- 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 { diff -r 80d2d7acbd6c -r 7ae0c716218d review/static/style.less --- 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; } } diff -r 80d2d7acbd6c -r 7ae0c716218d review/static/ui.js --- 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("→"); + }); + return false; + }, function(event) { $(event.target).closest(".file").find(".file-review-contents").slideDown("fast", function() { $(event.target).closest("h3").find(".status").html("↓"); }); return false; - }, - function(event) { - $(event.target).closest(".file") - .find(".file-review-contents") - .slideUp("fast", function () { - $(event.target).closest("h3").find(".status").html("→"); - }); - return false; }); + $(".submit").live('click', function() { $(this).closest("form").submit(); }); diff -r 80d2d7acbd6c -r 7ae0c716218d review/templates/404.html --- /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 %} +

Page not found (404)

+

The page you requested could not be found. Go home.

+{% endblock %} diff -r 80d2d7acbd6c -r 7ae0c716218d review/templates/500.html --- /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 %} +

Server error (500)

+

Something went horribly wrong.

+

+ If you have a few extra minutes you could + file a bug report. +

+{% endblock %} diff -r 80d2d7acbd6c -r 7ae0c716218d review/templates/base.html --- 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 @@ -
+
{% if comments %}
{% for comment in comments %} diff -r 80d2d7acbd6c -r 7ae0c716218d review/web.py --- 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//', 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