changeset 126:81f0ff7a5cae

global / subitem index: do not show mimetype as text, but is a mimetype specific link class / icon
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 14 Mar 2011 04:18:36 +0100
parents db239a9ef5d0
children 4408881ee6e3
files MoinMoin/templates/global_index.html MoinMoin/templates/index.html MoinMoin/themes/__init__.py MoinMoin/themes/modernized/static/css/common.css
diffstat 4 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/templates/global_index.html	Mon Mar 14 03:04:21 2011 +0100
+++ b/MoinMoin/templates/global_index.html	Mon Mar 14 04:18:36 2011 +0100
@@ -5,7 +5,12 @@
     {% if index %}
         <ul>
         {% for fullname, relname, mimetype in index %}
-            <li><a href="{{ url_for('show_item', item_name=fullname) }}">{{ relname }} ({{ mimetype }})</a></li>
+            <li>
+                <a href="{{ url_for('show_item', item_name=fullname) }}"
+                   class="{{ mimetype|mimetype_to_class }}">
+                    {{ relname }}
+                </a>
+            </li>
         {% endfor %}
         </ul>
     {% endif %}
--- a/MoinMoin/templates/index.html	Mon Mar 14 03:04:21 2011 +0100
+++ b/MoinMoin/templates/index.html	Mon Mar 14 04:18:36 2011 +0100
@@ -5,7 +5,12 @@
     {% if index %}
         <ul>
         {% for fullname, relname, mimetype in index %}
-            <li><a href="{{ url_for('show_item', item_name=fullname) }}">{{ relname }} ({{ mimetype }})</a></li>
+            <li>
+                <a href="{{ url_for('show_item', item_name=fullname) }}"
+                   class="{{ mimetype|mimetype_to_class }}">
+                    {{ relname }}
+                </a>
+            </li>
         {% endfor %}
         </ul>
     {% endif %}
--- a/MoinMoin/themes/__init__.py	Mon Mar 14 03:04:21 2011 +0100
+++ b/MoinMoin/themes/__init__.py	Mon Mar 14 04:18:36 2011 +0100
@@ -396,8 +396,24 @@
     return name
 
 
+MIMETYPE_TO_CLASS = {
+    'application/pdf': 'pdf',
+}
+
+def mimetype_to_class(mimetype):
+    """
+    Convert a mimetype string to a css class.
+    """
+    cls = MIMETYPE_TO_CLASS.get(mimetype)
+    if not cls:
+        # just use the major part of mimetype
+        cls = mimetype.split('/', 1)[0]
+    return 'moin-mime-%s' % cls
+
+
 def setup_jinja_env():
     app.jinja_env.filters['shorten_item_name'] = shorten_item_name
+    app.jinja_env.filters['mimetype_to_class'] = mimetype_to_class
     # please note that these filters are installed by flask-babel:
     # datetimeformat, dateformat, timeformat, timedeltaformat
 
--- a/MoinMoin/themes/modernized/static/css/common.css	Mon Mar 14 03:04:21 2011 +0100
+++ b/MoinMoin/themes/modernized/static/css/common.css	Mon Mar 14 04:18:36 2011 +0100
@@ -349,6 +349,16 @@
 a.moin-interwiki:before { content: url(../img/moin-inter.png); margin: 0 0.2em; }
 a.moin-action:before { content: url(../img/moin-action.png); margin: 0 0.2em; }
 
+/* icons for links to different mimetypes */
+/* major types */
+a.moin-mime-text:before {}
+a.moin-mime-image:before { content: url(../img/moin-ftp.png); margin: 0 0.2em; }
+a.moin-mime-audio:before { content: url(../img/moin-ftp.png); margin: 0 0.2em; }
+a.moin-mime-video:before { content: url(../img/moin-ftp.png); margin: 0 0.2em; }
+a.moin-mime-application:before { content: url(../img/moin-ftp.png); margin: 0 0.2em; }
+/* some common specific types */
+a.moin-mime-pdf:before { content: url(../img/moin-ftp.png); margin: 0 0.2em; }
+
 /* Flash messages used by Flask */
 .moin-flash { margin: 0; padding: 6px 6px 6px 38px; background-color: #f0f2f5;
             border-bottom: 1px solid #ccc; background-repeat: no-repeat;