From f548d799911fc63699d665c70f76f0c1479ed97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Krzy=C5=9Bk=C3=B3w?= Date: Tue, 25 Jul 2023 19:25:45 +0100 Subject: [PATCH] Updated social plugin to use `theme.custom_dir` --- material/plugins/social/plugin.py | 16 ++++------------ src/plugins/social/plugin.py | 16 ++++------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/material/plugins/social/plugin.py b/material/plugins/social/plugin.py index de16f609889..4c203e2a177 100644 --- a/material/plugins/social/plugin.py +++ b/material/plugins/social/plugin.py @@ -78,7 +78,6 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]): def __init__(self): self._executor = concurrent.futures.ThreadPoolExecutor(4) - self.custom_dir = None # Retrieve configuration def on_config(self, config): @@ -145,13 +144,6 @@ def on_config(self, config): "text": options.get("color", self.color["text"]) } - # Retrieve custom_dir path - for user_config in config.user_configs: - custom_dir = user_config.get("theme", {}).get("custom_dir") - if custom_dir: - self.custom_dir = custom_dir - break - # Retrieve logo and font self._resized_logo_promise = self._executor.submit(self._load_resized_logo, config) self.font = self._load_font(config) @@ -403,8 +395,8 @@ def _load_logo(self, config): path = os.path.join(config.docs_dir, theme["logo"]) # Allow users to put the logo inside their custom_dir (theme["logo"] case) - if self.custom_dir: - custom_dir_logo = os.path.join(self.custom_dir, theme["logo"]) + if theme.custom_dir: + custom_dir_logo = os.path.join(theme.custom_dir, theme["logo"]) if os.path.exists(custom_dir_logo): path = custom_dir_logo @@ -431,8 +423,8 @@ def _load_logo(self, config): path = f"{base}/.icons/{logo}.svg" # Allow users to put the logo inside their custom_dir (theme["icon"]["logo"] case) - if self.custom_dir: - custom_dir_logo = os.path.join(self.custom_dir, ".icons", f"{logo}.svg") + if theme.custom_dir: + custom_dir_logo = os.path.join(theme.custom_dir, ".icons", f"{logo}.svg") if os.path.exists(custom_dir_logo): path = custom_dir_logo diff --git a/src/plugins/social/plugin.py b/src/plugins/social/plugin.py index de16f609889..4c203e2a177 100644 --- a/src/plugins/social/plugin.py +++ b/src/plugins/social/plugin.py @@ -78,7 +78,6 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]): def __init__(self): self._executor = concurrent.futures.ThreadPoolExecutor(4) - self.custom_dir = None # Retrieve configuration def on_config(self, config): @@ -145,13 +144,6 @@ def on_config(self, config): "text": options.get("color", self.color["text"]) } - # Retrieve custom_dir path - for user_config in config.user_configs: - custom_dir = user_config.get("theme", {}).get("custom_dir") - if custom_dir: - self.custom_dir = custom_dir - break - # Retrieve logo and font self._resized_logo_promise = self._executor.submit(self._load_resized_logo, config) self.font = self._load_font(config) @@ -403,8 +395,8 @@ def _load_logo(self, config): path = os.path.join(config.docs_dir, theme["logo"]) # Allow users to put the logo inside their custom_dir (theme["logo"] case) - if self.custom_dir: - custom_dir_logo = os.path.join(self.custom_dir, theme["logo"]) + if theme.custom_dir: + custom_dir_logo = os.path.join(theme.custom_dir, theme["logo"]) if os.path.exists(custom_dir_logo): path = custom_dir_logo @@ -431,8 +423,8 @@ def _load_logo(self, config): path = f"{base}/.icons/{logo}.svg" # Allow users to put the logo inside their custom_dir (theme["icon"]["logo"] case) - if self.custom_dir: - custom_dir_logo = os.path.join(self.custom_dir, ".icons", f"{logo}.svg") + if theme.custom_dir: + custom_dir_logo = os.path.join(theme.custom_dir, ".icons", f"{logo}.svg") if os.path.exists(custom_dir_logo): path = custom_dir_logo