Merge branch 'master' into lqc-trunk
authorLukasz <lreqc@debian.(none)>
Tue, 27 Oct 2009 11:54:02 +0000 (07:54 -0400)
committerLukasz <lreqc@debian.(none)>
Tue, 27 Oct 2009 11:54:02 +0000 (07:54 -0400)
apps/api/handlers/library_handlers.py
apps/api/handlers/manage_handlers.py
apps/api/urls.py
apps/explorer/views.py
platforma/static/css/awesome-overlay-sprite.png [new file with mode: 0755]
platforma/static/css/buttons.css [new file with mode: 0644]
platforma/static/css/managment.css
platforma/static/css/pygments.css [new file with mode: 0644]
platforma/templates/base.html
platforma/templates/manager/pull_request.html

index cbd3a0a..f97ff6c 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"))
 
 
 #
@@ -305,7 +313,7 @@ class DocumentHTMLHandler(BaseHandler):
 
     @validate_form(forms.DocumentRetrieveForm, 'GET')
     @hglibrary
-    def read(self, request, form, docid, lib, stylesheet='partial'):
+    def read(self, request, form, docid, lib, stylesheet='full'):
         """Read document as html text"""
         try:
             revision = form.cleaned_data['revision']
@@ -328,7 +336,7 @@ class DocumentHTMLHandler(BaseHandler):
                 return error
 
             return librarian.html.transform(document.data('xml'), is_file=False, \
-                parse_dublincore=False, stylesheet='full',\
+                parse_dublincore=False, stylesheet=stylesheet,\
                 options={
                     "with-paths": 'boolean(1)',                    
                 })
index f9caf7b..f2d41b1 100644 (file)
@@ -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:
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 b17b8c8..2c9b17d 100644 (file)
@@ -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 (executable)
index 0000000..ef8dd2d
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 (file)
index 0000000..034c3b7
--- /dev/null
@@ -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; }
index 3777bcf..d1e2fc2 100644 (file)
@@ -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 (file)
index 0000000..5cea4ab
--- /dev/null
@@ -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 */
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..a44b1ed 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 diffUrl = button.parents('.pull-request').attr('data-diff-url');
+                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(diffUrl + '?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 }}" data-diff-url="{% url diff_resource pullreq.document %}">
+        <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>
+        {% ifnotequal pullreq.status 'A' %}
+        <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>
+        {% endifnotequal %}
+    </div>
     {% endfor %}
 {% else %}
-    <tr><td colspan="6">Brak żądań</td></tr>
+    {# <tr><td colspan="6">Brak żądań</td></tr> #}
 {% endif %}
-</table>
+{# </table> #}
 
 {% endblock %}