Commits

Anonymous committed 3e02d3b

Add base_key() and key_ext() functions, and use in base template.

Comments (0)

Files changed (2)

src/chrysoberyl/renderer.py

             return fun
 
         @expose
+        def base_key(key=key):
+            """Returns the 'base' part of the key, that is, with the medium,
+            ('(HTML5)', etc), removed.
+
+            """
+            if key.endswith(' (HTML5)'):
+                return key[:-8]
+            if key.endswith(' (Applet)'):
+                return key[:-9]
+            if key.endswith(' (JaC64)'):
+                return key[:-8]
+            return key
+
+        @expose
+        def key_ext(key=key):
+            """Returns the 'extension' part of the key, that is, the medium,
+            ('(HTML5)', etc).
+
+            """
+            if key.endswith(' (HTML5)'):
+                return 'HTML5'
+            if key.endswith(' (Applet)'):
+                return 'Applet'
+            if key.endswith(' (JaC64)'):
+                return 'JaC64'
+            return ''
+
+        @expose
         def related(relationship, key=key):
             """Return a list of nodes whose attribute named by `relationship`
             contains the given `key`, whether the attribute is a scalar or a

templates/base.html

   <header>
     {%- block breadcrumbs -%}
     <nav id="breadcrumbs">
-      <p>{{ breadcrumbs()|join(' » ') }} »</p>
+      <p>{{ breadcrumbs()|join(' » ') }} {% if key_ext() %}({{ key_ext() }}){% endif %} »</p>
     </nav>
     {%- endblock breadcrumbs -%}
     {%- block header_gadgets -%}
 
     {%- block heading -%}
       <hgroup id="heading">
-        <h1>{{ key }}</h1>
+        <h1>{{ base_key() }}</h1>
         {%- if subtitle -%}
           <h2 id="subtitle">{{ subtitle }}</h2>
         {%- endif -%}