damned-lies r1535 - in trunk: . media/img stats stats/templatetags templates templates/languages templates/people



Author: claudep
Date: Wed Apr 15 21:27:31 2009
New Revision: 1535
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1535&view=rev

Log:
2009-04-15  Claude Paroz  <claude 2xlibre net>

	* media/img/open.png:
	* media/img/closed.png: triangle icons to indicate the hidden/displayed
	states.
	* stats/templatetags/stats_extras.py: Add a custom tag to be able to do an
	'if less than' in templates.
	* stats/views.py:
	* templates/branch_detail.html: Separate the branch stats to be able to
	load them dynamically from the module_detail template.
	* templates/module_detail.html: Only two first branch stats are displayed
	initially. Other branch stats can be loaded dynamically (jquery).
	* urls.py: Add the url for the single branch view.
	* templates/languages/language_all_modules.html:
	* templates/languages/language_release.html:
	* templates/people/person_detail.html:
	* templates/release_compare.html:
	* templates/base.html: Add the jquery include in the base.

Added:
   trunk/media/img/closed.png   (contents, props changed)
   trunk/media/img/open.png   (contents, props changed)
   trunk/templates/branch_detail.html
Modified:
   trunk/ChangeLog
   trunk/stats/templatetags/stats_extras.py
   trunk/stats/views.py
   trunk/templates/base.html
   trunk/templates/languages/language_all_modules.html
   trunk/templates/languages/language_release.html
   trunk/templates/module_detail.html
   trunk/templates/people/person_detail.html
   trunk/templates/release_compare.html
   trunk/urls.py

Added: trunk/media/img/closed.png
==============================================================================
Binary file. No diff available.

Added: trunk/media/img/open.png
==============================================================================
Binary file. No diff available.

Modified: trunk/stats/templatetags/stats_extras.py
==============================================================================
--- trunk/stats/templatetags/stats_extras.py	(original)
+++ trunk/stats/templatetags/stats_extras.py	Wed Apr 15 21:27:31 2009
@@ -17,3 +17,30 @@
     elif value >= 50:
         return "partially"
     return "not_supported"
+
+class IfLessNode(template.Node):
+    def __init__(self, val1, val2, nodelist_true, nodelist_false):
+        self.val1 = val1
+        self.val2 = val2
+        self.nodelist_true = nodelist_true
+        self.nodelist_false = nodelist_false
+    
+    def render(self, context):
+        if self.val1.resolve(context) < self.val2.resolve(context):
+            return self.nodelist_true.render(context)
+        else:
+            return self.nodelist_false.render(context)
+    
+ register tag
+def ifless(parser, token):
+    bits = list(token.split_contents())
+    if len(bits) != 3:
+        raise TemplateSyntaxError, "%r takes two arguments" % bits[0]
+    nodelist_true = parser.parse(('else', 'endifless'))
+    token = parser.next_token()
+    if token.contents == 'else':
+        nodelist_false = parser.parse(('endifless',))
+        parser.delete_first_token()
+    else:
+        nodelist_false = template.NodeList()
+    return IfLessNode(parser.compile_filter(bits[1]), parser.compile_filter(bits[2]), nodelist_true, nodelist_false)

Modified: trunk/stats/views.py
==============================================================================
--- trunk/stats/views.py	(original)
+++ trunk/stats/views.py	Wed Apr 15 21:27:31 2009
@@ -60,6 +60,16 @@
     }
     return render_to_response('module_detail.html', context, context_instance=RequestContext(request))
 
+def module_branch(request, module_name, branch_name):
+    """ This view is used to dynamically load a specific branch stats (jquery.load) """
+    mod = get_object_or_404(Module, name=module_name)
+    branch = mod.branch_set.get(name=branch_name)
+    context = {
+        'module': mod,
+        'branch': branch,
+    }
+    return render_to_response('branch_detail.html', context, context_instance=RequestContext(request))
+    
 @login_required
 def module_edit_branches(request, module_name):
     mod = get_object_or_404(Module, name=module_name)

Modified: trunk/templates/base.html
==============================================================================
--- trunk/templates/base.html	(original)
+++ trunk/templates/base.html	Wed Apr 15 21:27:31 2009
@@ -14,7 +14,8 @@
 {% if LANGUAGE_BIDI %}
   <link rel="stylesheet" href="/media/css/rtl.css"/>
 {% endif %}
-  <script src="/media/js/main.js" type="text/javascript"></script>
+  <script type="text/javascript" src="{{ MEDIA_URL }}js/main.js"></script>
+  <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.min.js"></script> 
   {% block extrahead %}
   {% endblock %}
 </head>

Added: trunk/templates/branch_detail.html
==============================================================================
--- (empty file)
+++ trunk/templates/branch_detail.html	Wed Apr 15 21:27:31 2009
@@ -0,0 +1,31 @@
+{% load i18n %}
+
+{% if branch.has_string_frozen %}
+  <p>{% trans "This branch is currently string-frozen." %}</p>
+{% endif %}
+
+<table width="100%">
+  <tr>
+    <td valign="top"><!-- split to two columns -->
+      {% with branch.get_ui_stats as stats %}
+      {% if stats|length %}
+      {% if not stats|length_is:"1" %}
+      <h3>{% trans "Translation" %}</h3>
+      {% endif %}
+      {% include "stats_show.html" %}
+      {% endif %}
+      {% endwith %}
+    </td>
+    <td valign="top"><!-- split to two columns -->
+      {% with branch.get_doc_stats as stats %}
+      {% if stats|length %}
+      {% if not stats|length_is:"1" %}
+      <h3>{% trans "Documentation" %}</h3>
+      {% endif %}
+      {% include "stats_show.html" %}
+      {% endif %}
+      {% endwith %}
+    </td>
+  </tr>
+</table>
+

Modified: trunk/templates/languages/language_all_modules.html
==============================================================================
--- trunk/templates/languages/language_all_modules.html	(original)
+++ trunk/templates/languages/language_all_modules.html	Wed Apr 15 21:27:31 2009
@@ -4,7 +4,6 @@
 {% block title %} {% trans "All modules" %} - {{ language.get_name }}{% endblock %}
 
 {% block extrahead %}
-<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.min.js"></script> 
 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.tablesorter.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function() 

Modified: trunk/templates/languages/language_release.html
==============================================================================
--- trunk/templates/languages/language_release.html	(original)
+++ trunk/templates/languages/language_release.html	Wed Apr 15 21:27:31 2009
@@ -3,7 +3,6 @@
 
 {% block title %} {% trans release.description %} - {% trans language.name %}{% endblock %}
 {% block extrahead %}
-<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.min.js"></script> 
 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.tablesorter.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function() 

Modified: trunk/templates/module_detail.html
==============================================================================
--- trunk/templates/module_detail.html	(original)
+++ trunk/templates/module_detail.html	Wed Apr 15 21:27:31 2009
@@ -1,10 +1,36 @@
 {% extends "base.html" %}
 {% load i18n %}
+{% load stats_extras %}
 
 {% block title %}
 {% blocktrans with module.get_description as name %}Module Statistics: {{ name }}{% endblocktrans %}
 {% endblock %}
 
+{% block extrahead %}
+<script type="text/javascript">
+$(document).ready(function() { 
+        $(".branch").click(function(event) {
+            event.preventDefault();
+            branch_div = $("#div-"+this.id);
+            is_visible = branch_div.is(':visible');
+            if (is_visible) {
+                branch_div.hide();
+                $(this).children('img').attr("src", "{{ MEDIA_URL }}img/closed.png");
+            } else {
+                if (branch_div.attr("class") == "empty") {
+                    // Load the branch stats dynamically
+                    branch_div.load("/module/{{ module.name }}/branch/"+this.id+"/");
+                    branch_div.attr("class", "loaded");
+                }
+                branch_div.show();
+                $(this).children('img').attr("src", "{{ MEDIA_URL }}img/open.png");
+            }
+        });
+    }
+);
+</script>
+{% endblock %}
+
 {% block content %}
 <div class="mainpage">
 
@@ -60,39 +86,24 @@
 
   <!-- Main loop through branches -->
   {% for branch in branches %}
-    <h2><a name="{{ branch.name }}"></a>{{ branch.name }}
+    <h2>
+    {% ifless forloop.counter 3 %}
+      <a href="." class="branch" id="{{ branch.name }}"><img src="{{ MEDIA_URL }}img/open.png" /></a>
+    {% else %}
+      <a href="." class="branch" id="{{ branch.name }}"><img src="{{ MEDIA_URL }}img/closed.png" /></a>
+    {% endifless %}
+     <a name="{{ branch.name }}"></a>{{ branch.name }}
     {% if branch.get_vcs_web_url %}
       <small>(<a href="{{ branch.get_vcs_web_url }}">{% trans "Browse Repository" %}</a>)</small>
     {% endif %}
     </h2>
-    {% if branch.release_cat.release.string_frozen %}
-      <p>{% trans "This branch is currently string-frozen." %}</p>
-    {% endif %}
-
-    <table width="100%">
-      <tr>
-        <td valign="top"><!-- split to two columns -->
-          {% with branch.get_ui_stats as stats %}
-          {% if stats|length %}
-          {% if not stats|length_is:"1" %}
-          <h3>{% trans "Translation" %}</h3>
-          {% endif %}
-          {% include "stats_show.html" %}
-          {% endif %}
-          {% endwith %}
-        </td>
-        <td valign="top"><!-- split to two columns -->
-          {% with branch.get_doc_stats as stats %}
-          {% if stats|length %}
-          {% if not stats|length_is:"1" %}
-          <h3>{% trans "Documentation" %}</h3>
-          {% endif %}
-          {% include "stats_show.html" %}
-          {% endif %}
-          {% endwith %}
-        </td>
-      </tr>
-    </table>
+    {% ifless forloop.counter 3 %}
+      <div id="div-{{ branch.name }}" class="loaded">
+      {% include "branch_detail.html" %}
+      </div>
+    {% else %}
+      <div id="div-{{ branch.name }}" class="empty" style="display:none;"></div>
+    {% endifless %}
 
   {% endfor %}
 {% endif %}

Modified: trunk/templates/people/person_detail.html
==============================================================================
--- trunk/templates/people/person_detail.html	(original)
+++ trunk/templates/people/person_detail.html	Wed Apr 15 21:27:31 2009
@@ -4,7 +4,6 @@
 {% load stats_extras %}
 
 {% block extrahead %}
-<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.min.js"></script> 
 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.tablesorter.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function() 

Modified: trunk/templates/release_compare.html
==============================================================================
--- trunk/templates/release_compare.html	(original)
+++ trunk/templates/release_compare.html	Wed Apr 15 21:27:31 2009
@@ -4,7 +4,6 @@
 
 {% block title %} {% trans "Releases Comparison" %} {% endblock %}
 {% block extrahead %}
-<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.min.js"></script> 
 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.tablesorter.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function() 

Modified: trunk/urls.py
==============================================================================
--- trunk/urls.py	(original)
+++ trunk/urls.py	Wed Apr 15 21:27:31 2009
@@ -29,6 +29,7 @@
     url(r'^module/$', 'modules', name='modules'),
     (r'^module/(?P<module_name>[\w\-\+]+)/$', 'module'),
     (r'^module/(?P<module_name>[\w\-\+]+)/edit/branches/$', 'module_edit_branches'),
+    (r'^module/(?P<module_name>[\w\-\+]+)/branch/(?P<branch_name>[\w-]+)/$', 'module_branch'),
     (r'^module/(?P<module_name>[\w\-\+]+)/(?P<potbase>[\w-]+)/(?P<branch_name>[\w-]+)/(?P<langcode>[\w ]+)/images/$', 'docimages'),
     url(r'^releases/(?P<format>(html|json|xml))?/?$', 'releases', name='releases'),
     (r'^releases/(?P<release_name>[\w-]+)/(?P<format>(html|xml))?/?$', 'release'),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]