David Chambers committed f1efbe9

Added support for category names (i.e. directory names) which lose fidelity when converted to lowercase (e.g. "JavaScript"). URLs remain lowercase in all instances.

  • Participants
  • Parent commits dc14e6c

Comments (0)

Files changed (3)

File templates/category.dhtml

 {% extends 'base.dhtml' %}
 {% load mango_extras %}
 {% block content %}
-			<h1>{{ name|capfirst }}</h1>
+			<h1>{{ name|smart_capfirst }}</h1>
 			{% if category_pages %}{% if category_posts %}
 			<h2>Pages</h2>{% endif %}{% for document in category_pages %}{% include 'excerpt.dhtml' %}{% endfor %}{% endif %}
 			{% if category_posts %}{% if category_pages %}

File templatetags/

+def smart_capfirst(string):
+    if string.islower():
+        string = string[0].upper() + string[1:]
+    return string
 def slugify(string):
     return string.replace(' ', '-').lower()
 from mango import settings, utils
 from mango.forms import CommentForm, ContactForm
-from mango.models import Document, RE
+from mango.models import RE
 from mango.settings import *
 from mango.templatetags.mango_extras import slugify
                 'tagged': [doc for doc in utils.documents() if tag in [slugify(t) for t in doc.meta.get('tags', [])]],
             }, **context_defaults(request)))
-#TODO - this name should be changed as it now is also an index page, should this be combined with the index post?
 def post(request, path, view_source=False):
     filepath = UNIX_PATH_TO_POSTS
     is_short = False
     def match_fragment(dirnames=[], filenames=[]):
         for name in dirnames or filenames:
-            match = re.match(RE['alias=>canon'], name if dirnames else os.path.splitext(name)[0])
+            match = re.match(RE['alias=>canon'],
+                    name.lower() if dirnames else os.path.splitext(name)[0])
             if fragment in match.groupdict().values():
                 return (True, os.path.join(filepath, name), is_short or fragment =='alias'))
         return (False, filepath, is_short)
             url += 'm/'
         return HttpResponseRedirect(url)
-    if os.path.islink(filepath): # symbolic link - must appear before view source
+    if os.path.islink(filepath): # symbolic link
         return HttpResponseRedirect(document.urls['canon']['rel'])
-    if view_source: # Return the plain text of the Markdown page.
+    elif view_source: # Return the plain text of the Markdown page.
         return HttpResponse(document.body, content_type='text/plain; charset=utf-8')
     # Parse the Markdown and return it through the Django template.