X-Git-Url: http://git.subgeniuskitty.com/cmless/.git/blobdiff_plain/bc9c2a94fc68775e98d9bb3087c4d32cb2d112df..73c5dba96df5b81d7e05ec9a75e81306c709883b:/bin/cmless.py diff --git a/bin/cmless.py b/bin/cmless.py index 500edb6..f4a5a28 100755 --- a/bin/cmless.py +++ b/bin/cmless.py @@ -12,16 +12,28 @@ 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) content = template.current_year(content) content = template.head_meta_description(content) content = template.head_meta_keywords(content) + content = template.menu_top_level(content) + content = template.menu_current_dir(content) content = template.body(content) print(content)