[damned-lies] Display a special icon when documentation is in mallard format



commit 987b701a8c793dd4935517a34bfdb9a0a50fde67
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Aug 21 11:50:42 2010 +0200

    Display a special icon when documentation is in mallard format

 media/img/mallard.png                           |  Bin 0 -> 725 bytes
 stats/models.py                                 |   10 ++++++++++
 stats/templatetags/stats_extras.py              |    4 ++++
 templates/languages/language_release_stats.html |    5 ++++-
 templates/stats_show.html                       |    5 ++++-
 5 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/media/img/mallard.png b/media/img/mallard.png
new file mode 100644
index 0000000..0ed0645
Binary files /dev/null and b/media/img/mallard.png differ
diff --git a/stats/models.py b/stats/models.py
index 59e3a5b..7a55a99 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -658,6 +658,16 @@ class Domain(models.Model):
         else:
             return self.potbase()
 
+    def get_type(self, branch):
+        """ Returns the type of the domain (ui, docbook, mallard) """
+        if self.dtype == "ui":
+            return "ui"
+        else:
+            if os.access(os.path.join(branch.co_path(), self.directory, "C", "index.page"), os.R_OK):
+                return "mallard"
+            else:
+                return "docbook"
+
     def get_lang_files(self, base_path):
         """ Returns a list of language files on filesystem, as tuple (lang, lang_file) -> lang_file with complete path """
         flist = []
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index 26ab927..0a33bed 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -23,6 +23,10 @@ def escapeat(value):
     """Replace '@' with '__', accepted sequence in JS ids."""
     return value.replace('@', '__')
 
+ register filter
+def domain_type(stat):
+    return stat.domain.get_type(stat.branch)
+
 class IfLessNode(template.Node):
     def __init__(self, val1, val2, nodelist_true, nodelist_false):
         self.val1 = val1
diff --git a/templates/languages/language_release_stats.html b/templates/languages/language_release_stats.html
index 8a928b5..ac183ab 100644
--- a/templates/languages/language_release_stats.html
+++ b/templates/languages/language_release_stats.html
@@ -1,6 +1,6 @@
 {# parent template has to define variable modstats #}
 
-{% load i18n %}
+{% load i18n stats_extras %}
 
 <table>
 <tr>
@@ -61,6 +61,9 @@
           {% for err in stat.info_list %}
             <img src="{{ err.get_icon }}" title="{{ err.get_description|striptags }}" alt="{{ err.type }}" />
           {% endfor %}
+          {% if stat|domain_type == "mallard" %}
+            <img src="{{ MEDIA_URL }}img/mallard.png" width="16" title="{% trans "This document is written in Mallard documentation format" %}" alt="mallard icon"/>
+          {% endif %}
         </td>
           <td><span class="branch">{{ branch }}</span></td>
           <td><span style="display:none;">{{ stat.tr_percentage }}</span>
diff --git a/templates/stats_show.html b/templates/stats_show.html
index c3f65f6..a9c60a5 100644
--- a/templates/stats_show.html
+++ b/templates/stats_show.html
@@ -1,8 +1,11 @@
-{% load i18n %}
+{% load i18n stats_extras %}
 
 {% for dname, stat in stats.items %}
   {% with stat|first as pot_stat %}
   <h3>{% trans pot_stat.domain.get_description %}
+  {% if pot_stat|domain_type == "mallard" %}
+    <img src="{{ MEDIA_URL }}img/mallard.png" width="20" title="{% trans "This document is written in Mallard documentation format" %}" alt="mallard icon"/>
+  {% endif %}
   {% ifnotequal pot_stat.domain.directory 'help' %}
     {% ifnotequal pot_stat.domain.directory 'po' %}
     <br />



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