[damned-lies] Display video tag for video media



commit bdf102285b048f2bc957bd0ec4a03f837092d24d
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Apr 23 22:43:27 2010 +0200

    Display video tag for video media

 stats/models.py              |    2 +-
 stats/utils.py               |    5 +++--
 templates/module_images.html |    9 ++++++---
 3 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 8a1e5ae..e00bd11 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1103,7 +1103,7 @@ class Statistics(models.Model):
 
     def get_figures(self):
         """ self.figures is a list of dicts:
-            [{'path':, 'hash':, 'fuzzy':, 'translated':, 'translated_file':}, ...] """
+            [{'path':, 'video':, '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/cgit/vinagre / plain / help / %s / %s ?h=master"
diff --git a/stats/utils.py b/stats/utils.py
index de0abfc..cd086e1 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -334,7 +334,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':, 'hash':, 'fuzzy':, 'translated':}, ...] """
+        [{'path':, 'video':, '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)
@@ -349,11 +349,12 @@ def get_fig_stats(pofile):
     figures = []
 
     for i, line in islice(enumerate(lines), 0, None, 4):
-        fig = {'path': '', 'hash': ''}
+        fig = {'path': '', 'hash': '', 'video': False}
         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 c9ce494..b300bcd 100644
--- a/templates/module_images.html
+++ b/templates/module_images.html
@@ -19,13 +19,15 @@
   {% with stat.language.locale as locale %}
   <tr><td valign="top">
     <a href="{{ fig.orig_remote_url }}"><span class="path">C/{{ fig.path }}</span><br/></a>
-    <a href="{{ fig.orig_remote_url }}"><img class="screenshot" src="{{ fig.orig_remote_url }}"/></a>
+    <a href="{{ fig.orig_remote_url }}">{% if fig.video %}<video src="{{ fig.orig_remote_url }}" controls></video>
+                                        {% else %}<img class="screenshot" src="{{ fig.orig_remote_url }}"/>{% endif %}</a>
     </td>
     <td valign="top" class="{{ fig.fuzzy|yesno:"fuzzy," }}">
     {% if fig.translated %}
       {% if fig.translated_file %}
       <a href="{{ fig.trans_remote_url }}"><span class="path">{{ locale }}/{{ fig.path }}</span></a><br/>
-      <a href="{{ fig.trans_remote_url }}"><img class="screenshot" src="{{ fig.trans_remote_url }}"/></a>
+      <a href="{{ fig.trans_remote_url }}">{% if fig.video %}<video src="{{ fig.orig_remote_url }}" controls></video>
+                                           {% else %}<img class="screenshot" src="{{ fig.trans_remote_url }}"/>{% endif %}</a>
       {% else %}
       <p><em>{% trans "Translated, but uses original one (maybe the figure doesn't contain any string to translate)" %}</em></p>
       {% endif %}
@@ -34,7 +36,8 @@
         <em>{% trans "Fuzzy" %}</em><br/>
         {% if fig.translated_file %}
       <a href="{{ fig.trans_remote_url }}"><span class="path">{{ locale }}/{{ fig.path }}</span></a><br/>
-      <a href="{{ fig.trans_remote_url }}"><img class="screenshot" src="{{ fig.trans_remote_url }}"/></a>
+      <a href="{{ fig.trans_remote_url }}">{% if fig.video %}<video src="{{ fig.orig_remote_url }}" controls></video>
+                                           {% else %}<img class="screenshot" src="{{ fig.trans_remote_url }}"/>{% endif %}</a>
         {% else %}
       <p><em><small>{% trans "No existing file (&quot;Technical&quot; fuzzy)" %}</small></em></p>
         {% endif %}



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