diff --git a/Makefile b/Makefile index 71ecb485ad059da37b4e4c5730e5e7cc58f78d8d..f396ec00ad9ff6563f892876a5222888e8d86b19 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ publish: build .PHONY: build build: mathjax - cd fgs && python3 __main__.py + cd fgs && python3 __main__.py "../content" "../output" "../theme" "../config.json" "../lang.json" .PHONY: mathjax mathjax: diff --git a/fgs/__main__.py b/fgs/__main__.py index fc870f06befb882029455ab2e311256ba7e4934b..0a14ceb46c8cff2e90d464b8abc52da170fb8cba 100644 --- a/fgs/__main__.py +++ b/fgs/__main__.py @@ -12,21 +12,23 @@ import reader import generator import writer -CONTENT_DIR = '../content' -OUTPUT_DIR = '../output' -THEME_DIR = '../theme' +#content_dir = '../content' +#output_dir = '../output' +#theme_dir = '../theme' +#config_file = '../config.json' +#lang_file = '../lang.json' -def main(): +def main(content_dir, output_dir, theme_dir, config_file, lang_file): print("Hello World") config = {} - with open('../config.json') as f: + with open(config_file) as f: config = common.combine(config, json.loads(f.read())) - with open('../lang.json') as f: + with open(lang_file) as f: if 'lang' not in config: config['lang'] = {} config['lang'] = common.combine(config['lang'], json.loads(f.read())) - with open(CONTENT_DIR + '/config.json') as f: + with open(content_dir + '/config.json') as f: config = common.combine(config, json.loads(f.read())) print(config) @@ -49,15 +51,15 @@ def main(): extensions = mimeconfig['extensions'] readers.append(reader.PandocReader(config, factories, mimetype, None, base=mimeconfig['base'], extensions=extensions)) - read_dir(os.path.join(CONTENT_DIR, "."), readers) - read_dir(THEME_DIR + '/static', readers, [config['theme']['static_dir']]) + read_dir(os.path.join(content_dir, "."), readers) + read_dir(theme_dir + '/static', readers, [config['theme']['static_dir']]) context = {} gen = generator.Generator(config, context, factories) gen.generate_context() - wrt = writer.Writer(config, context, OUTPUT_DIR, THEME_DIR) + wrt = writer.Writer(config, context, output_dir, theme_dir) gen.generate_output(wrt) @@ -91,5 +93,9 @@ def read_dir(directory, readers, subpath = []): if __name__ == '__main__': - main() + argv = sys.argv + if len(argv) != 6: + print("Usage:",argv[0],"<content_dir> <output_dir> <theme_dir> <config_file> <lang_file>") + os._exit(1) + main(argv[1], argv[2], argv[3], argv[4], argv[5])