X-Git-Url: http://git.subgeniuskitty.com/cmless/.git/blobdiff_plain/765a8ad0e324feadea26e6e310cf77f186396907..78e2ec48966bc0c60db77c4e7a46f866c89c5351:/bin/cmless.py diff --git a/bin/cmless.py b/bin/cmless.py index 44399c9..97b944c 100755 --- a/bin/cmless.py +++ b/bin/cmless.py @@ -4,7 +4,7 @@ # See LICENSE file for copyright and license details. # Python imports -import sys, os +import sys, os, urllib.parse # CMless imports import config, misc, template @@ -12,9 +12,20 @@ import config, misc, template def main(): print("Content-Type: text/html;charset=utf-8\n") + # Since we can't use Apache's DirectoryIndex directive due to a RewriteCond + # passing all non-file objects to this script, we implement equivalent + # functionality here. if os.environ['REQUEST_URI'][-1] == "/": os.environ['REQUEST_URI'] = os.environ['REQUEST_URI'] + config.default_page + # Since we use REQUEST_URI to navigate the filesystem we need to unquote it. + # In other words, replace things like '%20' with ' ' (a space character). + os.environ['REQUEST_URI'] = urllib.parse.unquote(os.environ['REQUEST_URI']) + + # The template engine operates like a micropass compiler with each pass + # handling one tag from the template. Extensions to the template engine + # should be executed from here and should not have or create + # inter-dependencies. content = misc.load_file(config.site_template_prefix + "/" + config.template_file) content = template.page_title(content) content = template.site_title(content)