From 339788630c77104d294c60f31431d2a3d6e1f3e2 Mon Sep 17 00:00:00 2001 From: Kay Ohtie Date: Wed, 13 Dec 2023 12:06:22 -0600 Subject: [PATCH] Fixed fatal error with map path not existing --- pelican/plugins/pelimoji/pelimoji.py | 9 +++++++-- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pelican/plugins/pelimoji/pelimoji.py b/pelican/plugins/pelimoji/pelimoji.py index d042c91..2226913 100644 --- a/pelican/plugins/pelimoji/pelimoji.py +++ b/pelican/plugins/pelimoji/pelimoji.py @@ -21,12 +21,17 @@ def init(pelican_object): content_root, pelican_object.settings.get("PELIMOJI_SOURCE", "emoji") ) output_path = Path(content_root, "emoji_map") + if not output_path.exists(): + try: + output_path.mkdir(parents=True) + except Exception as e: + logger.fatal(f"Could not create required path for emoji data at '{str(output_path)}': {e}") pelican_object.settings["STATIC_PATHS"].append(str(output_path)) pelimoji_ext = pelican_object.settings.get( "PELIMOJI_FILE_EXTENSIONS", ["md", "html", "rst"] ) prefix = pelican_object.settings.get("PELIMOJI_PREFIX", "") - output_map_path = "/emoji_map/emoji.png" + output_map_path = output_path / "emoji.png" if prefix: prefix = prefix + "-" @@ -84,7 +89,7 @@ def init(pelican_object): "height": image.size[1], } ) - output_map.save(output_path / "emoji.png") + output_map.save(output_map_path) with open(Path(__file__).parent / "css.j2") as f: template = Template(f.read()) with open(output_path / "emoji.css", "w") as f: diff --git a/pyproject.toml b/pyproject.toml index 50dd8f0..5cdfce8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pelimoji" -version = "1.0.0" +version = "1.0.1" description = "Pelican plugin to add custom emoji to your site" authors = ["Kay Ohtie "] license = "AGPL-3.0"