summaryrefslogtreecommitdiff
path: root/panfry/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'panfry/main.py')
-rwxr-xr-xpanfry/main.py79
1 files changed, 45 insertions, 34 deletions
diff --git a/panfry/main.py b/panfry/main.py
index 40c2b15..1b90181 100755
--- a/panfry/main.py
+++ b/panfry/main.py
@@ -36,8 +36,10 @@ class StoppableHttpServer(BaseHTTPServer.HTTPServer):
def get_env():
env = panfry.cli.init_argparser().parse_args()
env.pub_path = os.path.abspath(env.pub_path)
+ env.index = ['']
if env.cmd in ['gen']:
+ INDEX = os.path.join(env.doc_path, 'src', 'INDEX')
if not os.path.isdir(env.doc_path):
print("%s directory not found. Aborting..." % env.doc_path)
exit(1)
@@ -52,44 +54,53 @@ def get_env():
if env.pandoc_options:
env.pandoc_options = list(shlex.split(env.pandoc_options))
+ if os.path.isfile(INDEX):
+ env.index += open(INDEX, 'r').readlines()
+
return env
def gen(env):
- document = Document(env.doc_path)
- document.set_templater(Templater(env.templates_path))
- document.set_pandoc_options(env.pandoc_options)
- if env.simple_toc:
- document.set_simple_toc
-
- if env.clean and os.path.exists(env.pub_path):
- print("Cleanup, removing %s..." % env.pub_path)
- shutil.rmtree(env.pub_path)
- if not os.path.exists(env.pub_path):
- os.mkdir(env.pub_path)
-
- if env.assets:
- print("Publishing assets only...", end=' ')
- document.publish_assets(env.pub_path)
- print("done.")
- exit(0)
-
- print("\nUsing pandoc options:")
- for opt in env.pandoc_options:
- print(" --%s" % opt)
-
- print()
-
- ###### Create PDF
- pdffile = document.publish_pdf(env.pub_path)
- print("Wrote PDF: %s" % pdffile)
-
- ###### Create epub
- epubfile = document.publish_epub(env.pub_path)
- print("Wrote epub: %s" % epubfile)
-
- ###### Create HTML
- document.publish_html(env.pub_path)
+ for item in env.index:
+ item = item.strip()
+ docpubpath = os.path.join(env.pub_path, item)
+ document = Document(env.doc_path, item)
+ document.set_templater(Templater(env.templates_path))
+ document.set_pandoc_options(env.pandoc_options)
+ if env.simple_toc:
+ document.set_simple_toc
+
+ if env.json_toc:
+ document.set_json_toc
+
+ if env.clean and os.path.exists(env.pub_path):
+ print("Cleanup, removing %s..." % env.pub_path)
+ shutil.rmtree(env.pub_path)
+ if not os.path.exists(docpubpath):
+ os.makedirs(docpubpath)
+
+ if env.assets:
+ print("Publishing assets only...", end=' ')
+ document.publish_assets(env.pub_path)
+ print("done.")
+ exit(0)
+
+ print("\nUsing pandoc options:")
+ for opt in env.pandoc_options:
+ print(" --%s" % opt)
+
+ print()
+
+ ###### Create PDF
+ pdffile = document.publish_pdf(docpubpath)
+ print("Wrote PDF: %s" % pdffile)
+
+ ###### Create epub
+ epubfile = document.publish_epub(docpubpath)
+ print("Wrote epub: %s" % epubfile)
+
+ ###### Create HTML
+ document.publish_html(docpubpath)
exit(0)