Commit ee5b1125 authored by Claude Paroz's avatar Claude Paroz

Replace video item by a template filter

parent 10fcd732
......@@ -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"
......
......@@ -68,3 +68,6 @@ def vis_stats(stat, scope='full'):
'untrans': untrans,
})
@register.filter
def is_video(fig):
return fig['path'].endswith('.ogv')
......@@ -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)
......
......@@ -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 %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment