Commits

Anonymous committed daaa0b0

Add indefart and lower options to link().

Comments (0)

Files changed (5)

 Something to indicate "specification link forthcoming" instead of
 baldly "no specification".
 
-Add indefart_link().  And indefart_linkedlist.  Or really, maybe a
-single function format(value, link=True, indefart=True), which
-can handle a scalar or a list and such.  Dunno, maybe.
+Add a single function format(value, link=True, indefart=True), which
+can handle a scalar or a list and such.
 
 Version numbers on languages.
 

src/chrysoberyl/renderer.py

             else:
                 return "a " + text
 
+        _indefart = indefart
         @expose
-        def link(key, format="%s"):
-            """Return an HTML link to the node with the given key."""
+        def link(key, format="%s", indefart=False, lower=False):
+            """Return an HTML link to the node with the given key.
+
+            indefart causes the link text to be preceded by an indefinite
+            article.  lower causes the link text to be lowercase.
+
+            """
+            link_text = key
+            if lower:
+                link_text = link_text.lower()
+            if indefart:
+                link_text = _indefart(key)
+            link_text = format % link_text
             return '<a href="%s">%s</a>' % (
-                pathname2url(filekey(key)), format % key
-            )
-
-        @expose
-        def link_lower(key, format="%s"):
-            """Return a lowercase HTML link to the node with the given key."""
-            return '<a href="%s">%s</a>' % (
-                pathname2url(filekey(key)), format % key.lower()
+                pathname2url(filekey(key)), link_text
             )
 
         # not the kind you're probably thinking of

templates/Implementation.html

       
       It is
       {% if implementation_type %}
-        <a href="{{ filekey(implementation_type) }}">{{ indefart(implementation_type) }}</a>,
+        {{ link(implementation_type, indefart=true) }},
       {% endif %}
       {{ writtenverb }} in {{ link(host_language) }}
       {%- if host_platform %}

templates/Music by What is this I don't even.html

     <li>
       <p>
         {{ link(thing) }}
-        (<i>{{ link_lower(data[thing].genre) }},
+        (<i>{{ link(data[thing].genre, lower=true) }},
          {{ link(data[thing].composed_on) }},
          {{ data[thing].inception_date }}</i>)
       {% set thing = data[impl].implementation_of[0] %}
       <p>
         {{ link(thing) }}
-        (<i>{{ link_lower(data[thing].genre) }}
+        (<i>{{ link(data[thing].genre, lower=true) }}
          {%- if data[thing].composed_on and data[thing].inception_date -%},
            {{ link(data[thing].composed_on) }},
            {{ data[thing].inception_date }}

templates/bylined.html

           A
         {% endif %}
         {% if genre and type not in ['Programming Language', 'Programming Language Family', 'Conlang'] %}
-          {{ link_lower(genre) }}
+          {{ link(genre, lower=true) }}
         {% endif %}
-        {{ link_lower(type) }}
+        {{ link(type, lower=true) }}
         {% if genre and type in ['Programming Language', 'Programming Language Family', 'Conlang'] %}
-          in the genre of {{ link_lower(genre) }}
+          in the genre of {{ link(genre, lower=true) }}
         {% endif %}
         by {{ linked_list(authors) }}
         {%- if auspices -%}