Merge branch 'master' of stigma.nowoczesnapolska.org.pl:platforma
authorzuber <marek@stepniowski.com>
Mon, 26 Oct 2009 10:05:46 +0000 (11:05 +0100)
committerzuber <marek@stepniowski.com>
Mon, 26 Oct 2009 10:05:46 +0000 (11:05 +0100)
apps/api/handlers/library_handlers.py
apps/api/urls.py
platforma/static/css/managment.css
platforma/templates/base.html
platforma/templates/manager/pull_request.html

index 8f8f2bc..b635d4e 100755 (executable)
@@ -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"))
 
 
 #
index 0ed6459..52b0ccc 100644 (file)
@@ -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/(?P<source_revision>latest|[0-9a-fA-F]+)/(?P<target_revision>latest|[0-9a-fA-F]+)/$',
+    url(r'documents/(?P<docid>[^/]+)/diff$',
         diff_resource, {'emitter_format': 'raw'}, name="diff_resource"),
     
 
index 3777bcf..5e1c541 100644 (file)
@@ -9,18 +9,41 @@ 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 {
@@ -33,4 +56,8 @@ table.request-report
 
 .request-report .status-A {
     background-color: gray;
-}
\ No newline at end of file
+}
+
+.pull-request .diff {
+    white-space: pre;
+}
index 06fbc62..590825a 100644 (file)
@@ -5,6 +5,7 @@
         <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
         <title>{% block title %}Platforma Redakcyjna{% block subtitle %}{% endblock subtitle %}{% endblock title%}</title>
         <link rel="stylesheet" href="{{ STATIC_URL }}css/master.css" type="text/css" />
+        <link rel="stylesheet" href="{{ STATIC_URL }}css/buttons.css" type="text/css" />
         <script src="{{ STATIC_URL }}js/lib/jquery.js" type="text/javascript" charset="utf-8"></script>
        <script src="{{ STATIC_URL }}js/lib/jquery.logging.js" type="text/javascript" charset="utf-8"></script>
         {% block extrahead %}
index 3b19c3b..9b23551 100644 (file)
@@ -1,7 +1,10 @@
 {% extends 'base.html' %}
 
+{% block bodyid %}management{% endblock %}
+
 {% block extrahead %}
 <link rel="stylesheet" href="{{ STATIC_URL }}css/managment.css" type="text/css" />
+<link rel="stylesheet" href="{{ STATIC_URL }}css/pygments.css" type="text/css" />
 <script type="text/javascript">
 
     
@@ -32,7 +35,6 @@
         $('.accept-button').click(function()
         {
             var id = parseInt($(this).attr('title'));
-            
 
             $.ajax({
                 url: '{% url pullrequest_list %}/'+id,
             
         });
         
+        $('.show-diff').click(function() {
+            var button = $(this);
+            
+            if (button.attr('disabled') != 'disabled') {
+                button.attr('disabled', 'disabled');
+                var id = parseInt(button.attr('title'));
+                var docid = $('h2', button.parents('.pull-request')).html();
+                var revision = $('.pull-request-revision', button.parents('.pull-request')).html();
+                
+                $('.diff').slideUp(function() { $(this).remove() });
+                $('<div class="diff"></div>')
+                    .hide()
+                    .appendTo($(this).parents('.pull-request'))
+                    .slideDown('slow')
+                    .load('/api/documents/' + docid + '/diff?revision=' + revision, null, function() {
+                        button.attr('disabled', null);
+                    });
+            }
+        });
+        
     });
 </script>
 {% endblock %}
 
 {% block maincontent %}
-<table class="request-report" cellspacing="0">
-    <tr>
-        <th>Utwór</th><th>Użytkownik</th><th>Komentarz</th><th>Stan</th>
-        <th>Zgłoszono</th><th>Akcje</th>
-    </tr>
 {% if objects %}
     {% for pullreq in objects %}
-    <tr class="status-{{pullreq.status}}" id="request-{{pullreq.id}}">
-        <td class="column-doc">{{ pullreq.document }}</td>
-        <td class="column-user">{{ pullreq.comitter }}</td>
-        <td class="column-comment">{{ pullreq.comment }}</td>
-        <td class="column-status"> {{ pullreq.status }}</td>
-        <td class="column-data">{{ pullreq.timestamp }}</td>
-        <td>
-            <button type="button" class="accept-button" title="{{pullreq.id}}">Akceptuj</button>
-            <a href="{% url editor_view pullreq.document %}?user=$prq-{{pullreq.id}}">Zobacz</a>
-        </td>
-    </tr>
-    
+    <div class="status-{{ pullreq.status }} pull-request" id="request-{{ pullreq.id }}">
+        <h2>{{ pullreq.document }}</h2>
+        <ul class="request-info">
+            <li>commiter: {{ pullreq.comitter }}</li>
+            <li>revision: <span class="pull-request-revision">{{ pullreq.source_revision }}</span></li>
+            <li>status: {{ pullreq.status }}</li>
+            <li>data: {{ pullreq.timestamp }}</li>
+        </ul>
+        <p class="comment">{{ pullreq.comment }}</p>
+        <p class="buttons">
+            <button type="button" class="awesome button green accept-button" title="{{pullreq.id}}">Akceptuj</button>
+            <button type="button" class="awesome button show-diff" title="{{pullreq.id}}">Zmiany</button>
+            <a class="awesome button" href="{% url editor_view pullreq.document %}?user=$prq-{{pullreq.id}}">Zobacz</a>
+        </p>
+    </div>
     {% endfor %}
 {% else %}
-    <tr><td colspan="6">Brak żądań</td></tr>
+    {# <tr><td colspan="6">Brak żądań</td></tr> #}
 {% endif %}
-</table>
+{# </table> #}
 
 {% endblock %}