[enh] store the fact that gm is present or not
This commit is contained in:
parent
c8ceee9e9e
commit
89399375a4
@ -13,7 +13,7 @@ gallery_index_template = templates.get_template("gallery-index.html")
|
|||||||
|
|
||||||
|
|
||||||
class TemplateFunctions():
|
class TemplateFunctions():
|
||||||
def __init__(self, base_dir, target_dir):
|
def __init__(self, base_dir, target_dir, has_gm):
|
||||||
self.base_dir = base_dir
|
self.base_dir = base_dir
|
||||||
self.target_dir = target_dir
|
self.target_dir = target_dir
|
||||||
|
|
||||||
@ -34,7 +34,9 @@ def error(test, error_message):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
has_gm = True
|
||||||
if os.system("which gm > /dev/null") != 0:
|
if os.system("which gm > /dev/null") != 0:
|
||||||
|
has_gm = False
|
||||||
sys.stderr.write("WARNING: I can't locate the 'gm' binary, I won't be able to resize images.\n")
|
sys.stderr.write("WARNING: I can't locate the 'gm' binary, I won't be able to resize images.\n")
|
||||||
|
|
||||||
error(os.path.exists(os.path.join(os.getcwd(), "settings.yaml")), "I can't find a settings.yaml in the current working directory")
|
error(os.path.exists(os.path.join(os.getcwd(), "settings.yaml")), "I can't find a settings.yaml in the current working directory")
|
||||||
@ -83,11 +85,11 @@ def main():
|
|||||||
if not os.path.exists(os.path.join("build", gallery)):
|
if not os.path.exists(os.path.join("build", gallery)):
|
||||||
os.makedirs(os.path.join("build", gallery))
|
os.makedirs(os.path.join("build", gallery))
|
||||||
|
|
||||||
open(os.path.join("build", gallery, "index.html"), "w").write(gallery_index_template.render(settings=settings, gallery=gallery_settings, helpers=TemplateFunctions(os.path.join(os.getcwd(), gallery), os.path.join(os.getcwd(), "build", gallery))).encode("Utf-8"))
|
open(os.path.join("build", gallery, "index.html"), "w").write(gallery_index_template.render(settings=settings, gallery=gallery_settings, helpers=TemplateFunctions(os.path.join(os.getcwd(), gallery), os.path.join(os.getcwd(), "build", gallery), has_gm=has_gm)).encode("Utf-8"))
|
||||||
|
|
||||||
front_page_galleries_cover = sorted(front_page_galleries_cover, key=lambda x: x["date"])
|
front_page_galleries_cover = sorted(front_page_galleries_cover, key=lambda x: x["date"])
|
||||||
|
|
||||||
open(os.path.join("build", "index.html"), "w").write(index_template.render(settings=settings, galleries=front_page_galleries_cover, helpers=TemplateFunctions(os.getcwd(), os.path.join(os.getcwd(), "build"))).encode("Utf-8"))
|
open(os.path.join("build", "index.html"), "w").write(index_template.render(settings=settings, galleries=front_page_galleries_cover, helpers=TemplateFunctions(os.getcwd(), os.path.join(os.getcwd(), "build"), has_gm=has_gm)).encode("Utf-8"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user