diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 4021661..6d849ca 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -10,11 +10,6 @@ from jinja2 import Environment, FileSystemLoader from .cache import CACHE from .utils import error -templates = Environment(loader=FileSystemLoader([os.path.realpath(os.path.join(os.getcwd(), "templates")), os.path.join(os.path.split(os.path.realpath(__file__))[0], "templates")])) -index_template = templates.get_template("index.html") -gallery_index_template = templates.get_template("gallery-index.html") -page_template = templates.get_template("page.html") - SETTINGS = { "show_date": True, "gm": { @@ -118,19 +113,21 @@ def main(): # XXX recursively merge directories if os.path.exists(os.path.join(os.getcwd(), "build", "static")): shutil.rmtree(os.path.join(os.getcwd(), "build", "static")) - if settings.get("theme"): - if os.path.exists(os.path.join(os.getcwd(), "templates")): - shutil.rmtree(os.path.join(os.getcwd(), "templates")) - shutil.copytree(os.path.join(os.path.split(os.path.realpath(__file__))[0], "themes", settings.get("theme"), "static"), os.path.join(os.getcwd(), "build", "static")) - shutil.copytree(os.path.join(os.path.split(os.path.realpath(__file__))[0], "themes", settings.get("theme"), "templates"), os.path.join(os.getcwd(), "templates")) - templates = Environment(loader=FileSystemLoader([os.path.realpath(os.path.join(os.getcwd(), "templates")), os.path.join(os.path.split(os.path.realpath(__file__))[0], "templates")])) - index_template = templates.get_template("index.html") - gallery_index_template = templates.get_template("gallery-index.html") - page_template = templates.get_template("page.html") - elif os.path.exists(os.path.join(os.getcwd(), "static")): + + if settings.get("theme") is None: + gallery_theme = "exposure" + else: + gallery_theme = settings.get("theme") + + if os.path.exists(os.path.join(os.getcwd(), "static")): shutil.copytree(os.path.join(os.getcwd(), "static"), os.path.join(os.getcwd(), "build", "static")) else: - shutil.copytree(os.path.join(os.path.split(os.path.realpath(__file__))[0], "static"), os.path.join(os.getcwd(), "build", "static")) + shutil.copytree(os.path.join(os.path.split(os.path.realpath(__file__))[0], "themes", gallery_theme, "static"), os.path.join(os.getcwd(), "build", "static")) + + templates = Environment(loader=FileSystemLoader([os.path.realpath(os.path.join(os.getcwd(), "templates")), os.path.join(os.path.split(os.path.realpath(__file__))[0], "themes", gallery_theme, "templates")])) + index_template = templates.get_template("index.html") + gallery_index_template = templates.get_template("gallery-index.html") + page_template = templates.get_template("page.html") for gallery in dirs: gallery_settings = yaml.safe_load(open(os.path.join(os.getcwd(), gallery, "settings.yaml"), "r"))