From: Lukasz Date: Tue, 27 Oct 2009 11:19:12 +0000 (-0400) Subject: Merge branch 'master' of git@stigma:platforma X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/5b657c3e3fa3cf2724560a7e38fa59efa61558ad?hp=82b5933a517aaf239dbb577190e067f1d703bbc3 Merge branch 'master' of git@stigma:platforma --- diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index 46038771..f97ff6ca 100755 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -31,6 +31,10 @@ import api.response as response from api.utils import validate_form, hglibrary, natural_order from api.models import PartCache, PullRequest +from pygments import highlight +from pygments.lexers import DiffLexer +from pygments.formatters import HtmlFormatter + # import settings @@ -205,19 +209,23 @@ class DiffHandler(BaseHandler): allowed_methods = ('GET',) @hglibrary - def read(self, request, source_revision, target_revision, lib): - '''Return diff between source_revision and target_revision)''' - source_document = lib.document_for_revision(source_revision) - target_document = lib.document_for_revision(target_revision) - print source_document, - print target_document + def read(self, request, docid, lib): + '''Return diff between source_revision and target_revision)''' + revision = request.GET.get('revision') + if not revision: + return '' + source_document = lib.document(docid) + target_document = lib.document_for_revision(revision) + print source_document, target_document + diff = difflib.unified_diff( source_document.data('xml').splitlines(True), target_document.data('xml').splitlines(True), 'source', 'target') - return ''.join(list(diff)) + s = ''.join(list(diff)) + return highlight(s, DiffLexer(), HtmlFormatter(cssclass="pastie")) # diff --git a/apps/api/handlers/manage_handlers.py b/apps/api/handlers/manage_handlers.py index f9caf7ba..f2d41b1b 100644 --- a/apps/api/handlers/manage_handlers.py +++ b/apps/api/handlers/manage_handlers.py @@ -60,7 +60,7 @@ class PullRequestHandler(BaseHandler): 'message': "This pull request is alredy resolved. Can't accept." }) - src_doc = lib.document_for_rev( prq.source_revision ) + src_doc = lib.document_for_revision( prq.source_revision ) lock = lib.lock() try: diff --git a/apps/api/urls.py b/apps/api/urls.py index 0ed64591..52b0ccc5 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -76,7 +76,7 @@ urlpatterns = patterns('', url(urlpath(r'documents', DOC, 'revision', format=False), document_merge, {'emitter_format': 'json'}, name="docmerge_view"), - url(r'diffs/(?Platest|[0-9a-fA-F]+)/(?Platest|[0-9a-fA-F]+)/$', + url(r'documents/(?P[^/]+)/diff$', diff_resource, {'emitter_format': 'raw'}, name="diff_resource"), diff --git a/apps/explorer/views.py b/apps/explorer/views.py index b17b8c8e..2c9b17da 100644 --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -109,11 +109,10 @@ def _get_issues_for_file(fileid): # = Pull requests = # ================= def pull_requests(request): - objects = PullRequest.objects.order_by('status') + objects = PullRequest.objects.order_by('-status', 'timestamp') if not request.user.has_perm('explorer.book.can_share'): objects = objects.filter(comitter=request.user) - return direct_to_template(request, 'manager/pull_request.html', extra_context = {'objects': objects} ) diff --git a/platforma/static/css/awesome-overlay-sprite.png b/platforma/static/css/awesome-overlay-sprite.png new file mode 100755 index 00000000..ef8dd2d5 Binary files /dev/null and b/platforma/static/css/awesome-overlay-sprite.png differ diff --git a/platforma/static/css/buttons.css b/platforma/static/css/buttons.css new file mode 100644 index 00000000..034c3b7a --- /dev/null +++ b/platforma/static/css/buttons.css @@ -0,0 +1,93 @@ +/* set an awesome color for the buttons */ +button.awesome, +input.awesome, +a.button.awesome { + background-color: #111; +} +/* Touch the rest at your onw risk. */ +button.awesome, +input.awesome, +a.button.awesome { + + font: inherit; + background-repeat: repeat-x; + color: #fff; + text-decoration: none; + position: relative; + cursor: pointer; + border: 0; + font-style: normal; + font-weight: bold; + line-height: 1; + + padding: 5px 10px 6px; + font-size: 13px; + + /* IE only stuff */ + border-bottom: 1px solid transparent\9; + + /* not all browser support these, but who cares? */ + text-shadow: 0 -1px 1px rgba(0,0,0,0.25), -2px 0 1px rgba(0,0,0,0.25); + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.5); + -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.5); + + /* one image for all states + see http://www.alistapart.com/articles/sprites */ + background-image: url(awesome-overlay-sprite.png); + background-position: 0 0; + + /* cross browser inline block hack + see http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/ */ + display: -moz-inline-stack; + display: inline-block; + vertical-align: middle; + *display: inline !important; + position: relative; + + /* help IE to calm down a bit */ + zoom: 1; + + /*disable text selection (Firefox only)*/ + -moz-user-select: none; +} +/* hide selection background color */ +.awesome::selection { + background: transparent; +} + +button.awesome:hover, +input.awesome:hover, +a.button.awesome:hover { + background-position: 0 -50px; + color: #fff; +} +button.awesome:active, +input.awesome:active, +a.button.awesome:active { + background-position: 0 100%; + -moz-box-shadow: inset 0 1px 2px rgba(0,0,0,0.7); + /* unfortunately, Safari seems not to support inset yet */ + -webkit-box-shadow: none; + + /* IE only stuff */ + border-bottom: 0\9; + border-top: 1px solid #666\9; +} + +/* Remove extra padding in Firefox */ +button::-moz-focus-inner { + border: 0; + padding: 0; +} + +button.awesome.small, input.awesome.small, a.button.awesome.small { padding: 4px 7px 5px; font-size: 10px; } +button.awesome.small:active, input.awesome.small:active, a.button.awesome.small:active { padding: 5px 7px 4px; } +button.awesome.medium, input.awesome.medium, a.button.awesome.medium { /* default */ } +button.awesome.medium:active, input.awesome.medium:active, a.button.awesome.medium:active { padding: 6px 10px 5px; } +button.awesome.large, input.awesome.large, a.button.awesome.large { padding: 8px 14px 9px; font-size: 14px; } +button.awesome.large:active, input.awesome.large:active, a.button.awesome.large:active { padding: 9px 14px 8px; } + +.awesome.green { background-color: #3ACC00 !important; } diff --git a/platforma/static/css/managment.css b/platforma/static/css/managment.css index 3777bcfc..d1e2fc20 100644 --- a/platforma/static/css/managment.css +++ b/platforma/static/css/managment.css @@ -9,28 +9,62 @@ table.request-report margin-right: auto; } -.request-report td, .request-report th { - vertical-align: top; - border-right: 1px solid black; - border-bottom: 1px solid black; +.pull-request { + padding: 20px 20px 10px 20px; + border-bottom: 1px dotted #CCC; +} + +.pull-request h2 { + padding: 0; + margin: 0; + font-size: 22px; +} + +.pull-request .request-info { + color: #999; + list-style: none; + margin: 0; + padding: 0; +} + +.pull-request .request-info li { + float: left; + padding-right: 20px; +} + +.pull-request p.comment { + clear: left; + padding: 20px 0; +} - padding: 0.4em 1em; - margin: 0em; +.pull-request p { + margin: 0; + padding: 0; } -.request-report th { - background-color: black; - color: white; +.awesome.button { + margin-right: 10px; } -.request-report .status-N { - background-color: teal; +.pull-request.status-N { + background-color: #FFF; } -.request-report .status-R { +.pull-request.status-R { background-color: red; } -.request-report .status-A { - background-color: gray; -} \ No newline at end of file +.pull-request.status-A { + background-color: #DDD; +} + +.pull-request .diff { + white-space: pre; + height: 360px; + width: 960px; + overflow: auto; + border: 1px solid #CCC; + margin-top: 10px; + background-color: #F9F9F9; + padding: 2px; +} diff --git a/platforma/static/css/pygments.css b/platforma/static/css/pygments.css new file mode 100644 index 00000000..5cea4ab7 --- /dev/null +++ b/platforma/static/css/pygments.css @@ -0,0 +1,60 @@ +.hll { background-color: #ffffcc } +.c { color: #888888 } /* Comment */ +.err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.k { color: #008800; font-weight: bold } /* Keyword */ +.cm { color: #888888 } /* Comment.Multiline */ +.cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ +.c1 { color: #888888 } /* Comment.Single */ +.cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ +.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.ge { font-style: italic } /* Generic.Emph */ +.gr { color: #aa0000 } /* Generic.Error */ +.gh { color: #303030 } /* Generic.Heading */ +.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.go { color: #888888 } /* Generic.Output */ +.gp { color: #555555 } /* Generic.Prompt */ +.gs { font-weight: bold } /* Generic.Strong */ +.gu { color: #606060 } /* Generic.Subheading */ +.gt { color: #aa0000 } /* Generic.Traceback */ +.kc { color: #008800; font-weight: bold } /* Keyword.Constant */ +.kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ +.kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ +.kp { color: #008800 } /* Keyword.Pseudo */ +.kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ +.kt { color: #888888; font-weight: bold } /* Keyword.Type */ +.m { color: #0000DD; font-weight: bold } /* Literal.Number */ +.s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ +.na { color: #336699 } /* Name.Attribute */ +.nb { color: #003388 } /* Name.Builtin */ +.nc { color: #bb0066; font-weight: bold } /* Name.Class */ +.no { color: #003366; font-weight: bold } /* Name.Constant */ +.nd { color: #555555 } /* Name.Decorator */ +.ne { color: #bb0066; font-weight: bold } /* Name.Exception */ +.nf { color: #0066bb; font-weight: bold } /* Name.Function */ +.nl { color: #336699; font-style: italic } /* Name.Label */ +.nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ +.py { color: #336699; font-weight: bold } /* Name.Property */ +.nt { color: #bb0066; font-weight: bold } /* Name.Tag */ +.nv { color: #336699 } /* Name.Variable */ +.ow { color: #008800 } /* Operator.Word */ +.w { color: #bbbbbb } /* Text.Whitespace */ +.mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ +.mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ +.mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ +.mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ +.sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ +.sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ +.sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ +.s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ +.se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ +.sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ +.si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ +.sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ +.sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ +.s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ +.ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ +.bp { color: #003388 } /* Name.Builtin.Pseudo */ +.vc { color: #336699 } /* Name.Variable.Class */ +.vg { color: #dd7700 } /* Name.Variable.Global */ +.vi { color: #3333bb } /* Name.Variable.Instance */ +.il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ diff --git a/platforma/templates/base.html b/platforma/templates/base.html index 06fbc628..590825a1 100644 --- a/platforma/templates/base.html +++ b/platforma/templates/base.html @@ -5,6 +5,7 @@ {% block title %}Platforma Redakcyjna{% block subtitle %}{% endblock subtitle %}{% endblock title%} + {% block extrahead %} diff --git a/platforma/templates/manager/pull_request.html b/platforma/templates/manager/pull_request.html index 3b19c3bd..a44b1ede 100644 --- a/platforma/templates/manager/pull_request.html +++ b/platforma/templates/manager/pull_request.html @@ -1,7 +1,10 @@ {% extends 'base.html' %} +{% block bodyid %}management{% endblock %} + {% block extrahead %} + {% endblock %} {% block maincontent %} - - - - - {% if objects %} {% for pullreq in objects %} - - - - - - - - - +
+

{{ pullreq.document }}

+
    +
  • commiter: {{ pullreq.comitter }}
  • +
  • revision: {{ pullreq.source_revision }}
  • +
  • status: {{ pullreq.status }}
  • +
  • data: {{ pullreq.timestamp }}
  • +
+

{{ pullreq.comment }}

+ {% ifnotequal pullreq.status 'A' %} +

+ + + Zobacz +

+ {% endifnotequal %} +
{% endfor %} {% else %} - + {# #} {% endif %} -
UtwórUżytkownikKomentarzStanZgłoszonoAkcje
{{ pullreq.document }}{{ pullreq.comitter }}{{ pullreq.comment }} {{ pullreq.status }}{{ pullreq.timestamp }} - - Zobacz -
Brak żądań
Brak żądań
+{# #} {% endblock %}