damned-lies r1199 - in trunk: . common/templatetags media/css templates templates/languages



Author: stephaner
Date: Mon Dec  1 08:42:46 2008
New Revision: 1199
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1199&view=rev

Log:
2008-12-01  StÃphane Raimbault  <stephane raimbault gmail com>

	Same feature as previous commit, just more simple!
	
	* common/templatetags/list_to_columns.py: New name and updated.
	* common/templatetags/list_to_three_columns.py:
	* media/css/style.css: Only one column definition.
	* templates/module_list.html:
	* templates/languages/language_list.html: Natural column order.


Added:
   trunk/common/templatetags/list_to_columns.py   (contents, props changed)
      - copied, changed from r1198, /trunk/common/templatetags/list_to_three_columns.py
Removed:
   trunk/common/templatetags/list_to_three_columns.py
Modified:
   trunk/ChangeLog
   trunk/media/css/style.css
   trunk/templates/languages/language_list.html
   trunk/templates/module_list.html

Copied: trunk/common/templatetags/list_to_columns.py (from r1198, /trunk/common/templatetags/list_to_three_columns.py)
==============================================================================
--- /trunk/common/templatetags/list_to_three_columns.py	(original)
+++ trunk/common/templatetags/list_to_columns.py	Mon Dec  1 08:42:46 2008
@@ -19,37 +19,34 @@
 # along with Damned Lies; if not, write to the Free Software Foundation, Inc.,
 # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-"""Splits query results list into multiple sublists for template display.
-   The order is column 1, then 3 and 2 to respect the CSS order."""
-from django import template
 
+from django import template
+     
 register = template.Library()
 
 class SplitListNode(template.Node):
-    def __init__(self, list, new_list):
+    def __init__(self, list, cols, new_list):
         self.list = list
+        self.cols = cols
         self.new_list = new_list
 
-    def split_seq(self, list):
-        # Simpler as a loop (KISS)
-        len_col1 = len(list[0::3])
-        len_col2 = len(list[1::3])
-        len_col3 = len(list[2::3])
-        # Column 1
-        yield list[0:len_col1]
-        # Column 3
-        yield list[len_col1+len_col2:len_col1+len_col2+len_col3]
-        # Column 2
-        yield list[len_col1:len_col1+len_col2]
+    def split_seq(self, list, cols=2):
+        start = 0 
+        for i in xrange(cols): 
+            stop = start + len(list[i::cols]) 
+            yield list[start:stop] 
+            start = stop
 
     def render(self, context):
-        context[self.new_list] = self.split_seq(context[self.list])
+        context[self.new_list] = self.split_seq(context[self.list], int(self.cols))
         return ''
 
-def list_to_three_columns(parser, token):
-    """Parse template tag: {% list_to_three_columns list as columns %}"""
+def list_to_columns(parser, token):
+    """Parse template tag: {% list_to_columns list as new_list 2 %}"""
     bits = token.contents.split()
+    if len(bits) != 5:
+        raise template.TemplateSyntaxError, "list_to_columns list as new_list 2"
     if bits[2] != 'as':
-        raise TemplateSyntaxError, "second argument to the list_to_three_columns tag must be 'as'"
-    return SplitListNode(bits[1], bits[3])
-list_to_three_columns = register.tag(list_to_three_columns)
+        raise template.TemplateSyntaxError, "second argument to the list_to_columns tag must be 'as'"
+    return SplitListNode(bits[1], bits[4], bits[3])
+list_to_columns = register.tag(list_to_columns)

Modified: trunk/media/css/style.css
==============================================================================
--- trunk/media/css/style.css	(original)
+++ trunk/media/css/style.css	Mon Dec  1 08:42:46 2008
@@ -146,29 +146,12 @@
  border-bottom: 1px solid #888
 }
 
-.col3_container {
-  float: left;
-  width: 100%;
-  overflow: hidden;
-}
-
 .col3_container ul {
   margin-top: 0;
 }
 
-.col3_left {
+.col3_column {
   float: left;
-  margin: 0;
-  width: 33.3%;
+  width: 33.3%
 }
 
-.col3_middle {
-  margin-left: 33.3%;
-  margin-right: 33.3%;
-}
-
-.col3_right {
-  float: right;
-  margin: 0;
-  width: 33.3%;
-}

Modified: trunk/templates/languages/language_list.html
==============================================================================
--- trunk/templates/languages/language_list.html	(original)
+++ trunk/templates/languages/language_list.html	Mon Dec  1 08:42:46 2008
@@ -12,11 +12,11 @@
 {% plural %}GNOME is being translated to following {{ numb }} languages.
 {% endblocktrans %}</p>
 
-{% load list_to_three_columns %}
+{% load list_to_columns %}
 <div class="col3_container">
-  {% list_to_three_columns languages as columns %}
+  {% list_to_columns languages as columns 3 %}
   {% for column in columns %}
-  <div class="{% cycle 'col3_left' 'col3_right' 'col3_middle' %}">
+  <div class="col3_column">
     <ul class="foot">
       {% for lang in column %}
       <li><a href="{{ lang.get_team_url }}">{{ lang.get_name }}</a></li>

Modified: trunk/templates/module_list.html
==============================================================================
--- trunk/templates/module_list.html	(original)
+++ trunk/templates/module_list.html	Mon Dec  1 08:42:46 2008
@@ -10,11 +10,11 @@
 
 <p>{% trans "Select a module below to see some of the damned lies about it:" %}</p>
 
-{% load list_to_three_columns %}
+{% load list_to_columns %}
 <div class="col3_container">
-  {% list_to_three_columns modules as columns %}
+  {% list_to_columns modules as columns 3 %}
   {% for l in columns %}
-  <div class="{% cycle 'col3_left' 'col3_right' 'col3_middle' %}">
+  <div class="col3_column">
     <ul class="foot">
       {% for m in l %}
       <li><a href="{% url stats.views.module m.name %}">{{ m.get_description }}</a></li>



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