Skip to content

Commit

Permalink
dev: create post setup step. Allowing plugins to setup there own content
Browse files Browse the repository at this point in the history
  • Loading branch information
Linbreux committed May 27, 2024
1 parent deedfef commit 6b6e391
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/wikmd/plugins/draw/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def __init__(self, flask_app: Flask, config: WikmdConfig, web_dep):
self.web_dep = web_dep
self.drawings_folder = os.path.join(self.config.wiki_directory, config.drawings_route)

def post_setup(self) -> bool:
"""
configure the drawings folder
returns True if folder did not exist and created it
"""
if not os.path.exists(self.drawings_folder):
os.mkdir(self.drawings_folder)

Expand All @@ -28,7 +33,9 @@ def __init__(self, flask_app: Flask, config: WikmdConfig, web_dep):
for item in os.listdir(os.path.join(self.this_location, "drawings")):
print(f"copy {item} to {self.drawings_folder}")
shutil.copy2(os.path.join(self.this_location, "drawings",item), os.path.join(self.drawings_folder, item))
return True

return False

def get_plugin_name(self) -> str:
"""
Expand Down
5 changes: 5 additions & 0 deletions src/wikmd/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@ def setup_wiki_template() -> bool:
app.logger.info("Wiki directory is empty, copy template")
shutil.copytree(root / "wiki_template", cfg.wiki_directory, dirs_exist_ok=True)
return True

for plugin in plugins:
if "post_setup" in dir(plugin):
plugin.post_setup()

return False


Expand Down

0 comments on commit 6b6e391

Please sign in to comment.