X-Git-Url: http://git.subgeniuskitty.com/cmless/.git/blobdiff_plain/acd291ea49534cc4957148b0fc1594515ca57698..d955cfad358f87bc92b6f3cb2d1741e5dbb61cc5:/bin/cmless.py diff --git a/bin/cmless.py b/bin/cmless.py index ece2313..ddba963 100755 --- a/bin/cmless.py +++ b/bin/cmless.py @@ -4,38 +4,18 @@ # See LICENSE file for copyright and license details. # Python imports -import os, sys, subprocess, cgi +import sys # CMless imports -import debug, config - -# Accepts a string containing a filesystem path to a text file. -# Returns a string containing the contents of that file. -def load_file(path): - try: - with open(path) as f: - contents = f.read() - except: - if debug.print_to_browser: print("Unable to open " + path + " for reading.") - sys.exit("Unable to open " + path + " for reading.") - return contents - -# Accepts a string containing markup'ed text -# Returns a string containing HTML'ed text -def process_markup(text): - try: - p = subprocess.Popen(config.markup_processor,stdout=subprocess.PIPE,stdin=subprocess.PIPE) - except: - if debug.print_to_browser: print("Unable to open markup processor: " + config.markup_processor) - sys.exit("Unable to open markup processor: " + config.markup_processor) - text = p.communicate(text.encode('UTF-8'))[0] - return(text.decode('UTF-8')) +import config, misc, template def main(): print("Content-Type: text/html;charset=utf-8\n") - text = load_file(config.site_path_prefix + os.environ['REQUEST_URI'] + config.markup_file_extension) - print(process_markup(text)) + content = misc.load_file(config.site_template_prefix + "/" + config.template_file) + content = template.tpl_title(content) + content = template.tpl_body(content) + print(content) if __name__ == "__main__": sys.exit(main())