Added an option to specify the default page when a directory is the
authorAaron Taylor <ataylor@subgeniuskitty.com>
Mon, 8 Jan 2018 02:00:28 +0000 (18:00 -0800)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Mon, 8 Jan 2018 02:00:28 +0000 (18:00 -0800)
requested URL. This is equivalent to Apache's DirectoryIndex option.

bin/cmless.py
bin/config.py

index 825ec25..44399c9 100755 (executable)
@@ -4,7 +4,7 @@
 # See LICENSE file for copyright and license details.
 
 # Python imports
 # See LICENSE file for copyright and license details.
 
 # Python imports
-import sys
+import sys, os
 
 # CMless imports
 import config, misc, template
 
 # CMless imports
 import config, misc, template
@@ -12,6 +12,9 @@ import config, misc, template
 def main():
     print("Content-Type: text/html;charset=utf-8\n")
 
 def main():
     print("Content-Type: text/html;charset=utf-8\n")
 
+    if os.environ['REQUEST_URI'][-1] == "/":
+        os.environ['REQUEST_URI'] = os.environ['REQUEST_URI'] + config.default_page
+
     content = misc.load_file(config.site_template_prefix + "/" + config.template_file)
     content = template.page_title(content)
     content = template.site_title(content)
     content = misc.load_file(config.site_template_prefix + "/" + config.template_file)
     content = template.page_title(content)
     content = template.site_title(content)
index 5ee585f..83d9d32 100644 (file)
@@ -16,6 +16,12 @@ site_name = "Site Name"
 # the CMless code.
 site_data_prefix = "../site/data"
 
 # the CMless code.
 site_data_prefix = "../site/data"
 
+# Default page name. This specifies the filename to serve (if exists) when a
+# directory is specified as the REQUEST_URI. If is equivalent to Apache's
+# DirectoryIndex configuration option. No file extension is necessary as the
+# markup_file_extension configuration option handles that information.
+default_page = "index"
+
 # The prefix to the website template relative to the bin/ folder which contains
 # the CMless code.
 site_template_prefix = "../site/template"
 # The prefix to the website template relative to the bin/ folder which contains
 # the CMless code.
 site_template_prefix = "../site/template"