Skip to content

Commit

Permalink
Fixed fatal error with map path not existing
Browse files Browse the repository at this point in the history
  • Loading branch information
KayOhtie committed Dec 13, 2023
1 parent 1648193 commit 3397886
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pelican/plugins/pelimoji/pelimoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "-"

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "AGPL-3.0"
Expand Down

0 comments on commit 3397886

Please sign in to comment.