[damned-lies] Replace video item by a template filter



commit ee5b11250faca15d46c9b86e9a19d1526358f78d
Author: Claude Paroz <claude 2xlibre net>
Date:   Thu Aug 4 00:10:57 2011 +0200

    Replace video item by a template filter

 stats/models.py                    |    2 +-
 stats/templatetags/stats_extras.py |    3 +++
 stats/utils.py                     |    5 ++---
 templates/module_images.html       |    6 +++---
 4 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 02dd7a8..d7aa26c 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1332,7 +1332,7 @@ class Statistics(models.Model):
 
     def get_figures(self):
         """ self.figures is a list of dicts:
-            [{'path':, 'video':, 'hash':, 'fuzzy':, 'translated':, 'translated_file':}, ...] """
+            [{'path':, 'hash':, 'fuzzy':, 'translated':, 'translated_file':}, ...] """
         if self.figures is None and self.domain.dtype == 'doc':
             self.figures = utils.get_fig_stats(self.po_path())
             # something like: "http://git.gnome.org/browse/vinagre / plain / help / %s / %s ?h=master"
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index 0b65422..e147453 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -68,3 +68,6 @@ def vis_stats(stat, scope='full'):
           'untrans': untrans,
         })
 
+ register filter
+def is_video(fig):
+    return fig['path'].endswith('.ogv')
diff --git a/stats/utils.py b/stats/utils.py
index 6245f6b..86c587f 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -399,7 +399,7 @@ def get_doc_linguas(module_path, po_path):
 
 def get_fig_stats(pofile):
     """ Extract image strings from pofile and return a list of figures dict:
-        [{'path':, 'video':, 'hash':, 'fuzzy':, 'translated':}, ...] """
+        [{'path':, 'hash':, 'fuzzy':, 'translated':}, ...] """
     # Extract image strings: beforeline/msgid/msgstr/grep auto output a fourth line
     command = "msgcat --no-wrap %(pofile)s| grep -A 1 -B 1 '^msgid \"@@image:'" % locals()
     (status, output, errs) = run_shell_command(command)
@@ -414,12 +414,11 @@ def get_fig_stats(pofile):
     figures = []
 
     for i, line in islice(enumerate(lines), 0, None, 4):
-        fig = {'path': '', 'hash': '', 'video': False}
+        fig = {'path': '', 'hash': ''}
         fig['fuzzy'] = (line=='#, fuzzy' or line[:8]=='#| msgid')
         path_match = re_path.match(lines[i+1])
         if path_match and len(path_match.groups()):
             fig['path'] = path_match.group(1)
-            fig['video'] = fig['path'].endswith(".ogv")
         hash_match = re_hash.match(lines[i+1])
         if hash_match and len(hash_match.groups()):
             fig['hash'] = hash_match.group(1)
diff --git a/templates/module_images.html b/templates/module_images.html
index c559edb..7ed5fd7 100644
--- a/templates/module_images.html
+++ b/templates/module_images.html
@@ -16,7 +16,7 @@
 {% for fig in stat.get_figures %}
   <tr><td valign="top">
     <a href="{{ fig.orig_remote_url }}"><span class="path">C/{{ fig.path }}</span><br/></a>
-    {% if fig.video %}<video src="{{ fig.orig_remote_url }}" controls></video>
+    {% if fig|video %}<video src="{{ fig.orig_remote_url }}" controls></video>
     {% else %}<a href="{{ fig.orig_remote_url }}"><img class="screenshot" src="{{ fig.orig_remote_url }}"/></a>
     {% endif %}
     </td>
@@ -24,7 +24,7 @@
     {% if fig.translated %}
       {% if fig.translated_file %}
         <a href="{{ fig.trans_remote_url }}"><span class="path">{{ locale }}/{{ fig.path }}</span></a><br/>
-        {% if fig.video %}<video src="{{ fig.orig_remote_url }}" controls></video>
+        {% if fig|video %}<video src="{{ fig.orig_remote_url }}" controls></video>
         {% else %}<a href="{{ fig.trans_remote_url }}"><img class="screenshot" src="{{ fig.trans_remote_url }}"/></a>
         {% endif %}
       {% else %}
@@ -35,7 +35,7 @@
         <em>{% trans "Fuzzy" %}</em><br/>
         {% if fig.translated_file %}
           <a href="{{ fig.trans_remote_url }}"><span class="path">{{ locale }}/{{ fig.path }}</span></a><br/>
-          {% if fig.video %}<video src="{{ fig.orig_remote_url }}" controls></video>
+          {% if fig|video %}<video src="{{ fig.orig_remote_url }}" controls></video>
           {% else %}<a href="{{ fig.trans_remote_url }}"><img class="screenshot" src="{{ fig.trans_remote_url }}"/></a>
           {% endif %}
         {% else %}



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