Skip to content

Commit 24b915f

Browse files
committed
update(integrations): remove custom code related to former Material for Mkdocs Insiders edition
Since there is no insiders edition anymore. See: https://squidfunk.github.io/mkdocs-material/blog/2025/11/11/insiders-now-free-for-everyone/
1 parent 54e1793 commit 24b915f

File tree

2 files changed

+23
-70
lines changed

2 files changed

+23
-70
lines changed

mkdocs_rss_plugin/integrations/theme_material_base.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
class IntegrationMaterialThemeBase:
3434
# attributes
3535
IS_THEME_MATERIAL: bool = False
36-
IS_INSIDERS: bool | None = False
3736

3837
def __init__(self, mkdocs_config: MkDocsConfig) -> None:
3938
"""Integration instantiation.
@@ -45,7 +44,6 @@ def __init__(self, mkdocs_config: MkDocsConfig) -> None:
4544
self.mkdocs_config = mkdocs_config
4645

4746
self.IS_THEME_MATERIAL = self.is_mkdocs_theme_material()
48-
self.IS_INSIDERS = self.is_mkdocs_theme_material_insiders()
4947

5048
def is_mkdocs_theme_material(
5149
self, mkdocs_config: MkDocsConfig | None = None
@@ -63,22 +61,3 @@ def is_mkdocs_theme_material(
6361

6462
self.IS_THEME_MATERIAL = mkdocs_config.theme.name == "material"
6563
return self.IS_THEME_MATERIAL
66-
67-
def is_mkdocs_theme_material_insiders(self) -> bool | None:
68-
"""Check if the material theme is community or insiders edition.
69-
70-
Returns:
71-
bool: True if the theme is Insiders edition. False if community. None if
72-
the Material theme is not installed.
73-
"""
74-
if not self.IS_THEME_MATERIAL:
75-
return None
76-
77-
if material_version is not None and "insiders" in material_version:
78-
logger.debug("Material theme edition INSIDERS")
79-
self.IS_INSIDERS = True
80-
return True
81-
else:
82-
logger.debug("Material theme edition COMMUNITY")
83-
self.IS_INSIDERS = False
84-
return False

mkdocs_rss_plugin/integrations/theme_material_social_plugin.py

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
# standard library
88
import json
9-
from hashlib import md5
109
from pathlib import Path
1110

1211
# 3rd party
@@ -98,8 +97,7 @@ def __init__(self, mkdocs_config: MkDocsConfig, switch_force: bool = True) -> No
9897
mkdocs_config=mkdocs_config
9998
)
10099

101-
if self.is_mkdocs_theme_material_insiders():
102-
self.load_cache_cards_manifest()
100+
self.load_cache_cards_manifest()
103101

104102
# store some attributes used to compute social card hash
105103
self.site_name = mkdocs_config.site_name
@@ -307,61 +305,37 @@ def get_social_card_cache_path_for_page(
307305
) -> Path | None:
308306
"""Get social card path in social plugin cache folder for a specific page.
309307
310-
Note:
311-
As we write this code (June 2024), the cache mechanism in Insiders edition
312-
has stores images directly with the corresponding Page's path and name and
313-
keep a correspondance matrix with hashes in a manifest.json;
314-
the cache mechanism in Community edition uses the hash as file names without
315-
any exposed matching criteria.
308+
The cache mechanism in stores images directly with the
309+
corresponding Page's path and name and keep a correspondance matrix with hashes
310+
in a manifest.json.
316311
317312
Args:
318313
mkdocs_page: Mkdocs page object.
319314
320315
Returns:
321316
path to the image in local cache folder if it exists
322317
"""
323-
if self.IS_INSIDERS:
324-
325-
# if page is a blog post
326-
if (
327-
self.integration_material_blog.IS_BLOG_PLUGIN_ENABLED
328-
and self.integration_material_blog.is_page_a_blog_post(mkdocs_page)
329-
):
330-
expected_cached_card_path = self.social_cards_cache_dir.joinpath(
331-
f"assets/images/social/{Path(mkdocs_page.dest_uri).parent}.png"
332-
)
333-
else:
334-
expected_cached_card_path = self.social_cards_cache_dir.joinpath(
335-
f"assets/images/social/{Path(mkdocs_page.src_uri).with_suffix('.png')}"
336-
)
337-
338-
if expected_cached_card_path.is_file():
339-
logger.debug(
340-
f"Social card file found in cache folder: {expected_cached_card_path}"
341-
)
342-
return expected_cached_card_path
343-
else:
344-
logger.debug(
345-
f"Social card not found in cache folder: {expected_cached_card_path}"
346-
)
347-
348-
else:
349-
if "description" in mkdocs_page.meta:
350-
description = mkdocs_page.meta["description"]
351-
else:
352-
description = self.site_description
353-
354-
page_hash = md5(
355-
"".join(
356-
[
357-
self.site_name,
358-
str(mkdocs_page.meta.get("title", mkdocs_page.title)),
359-
description,
360-
]
361-
).encode("utf-8")
318+
# if page is a blog post
319+
if (
320+
self.integration_material_blog.IS_BLOG_PLUGIN_ENABLED
321+
and self.integration_material_blog.is_page_a_blog_post(mkdocs_page)
322+
):
323+
expected_cached_card_path = self.social_cards_cache_dir.joinpath(
324+
f"assets/images/social/{Path(mkdocs_page.dest_uri).parent}.png"
362325
)
326+
else:
363327
expected_cached_card_path = self.social_cards_cache_dir.joinpath(
364-
f"{page_hash.hexdigest()}.png"
328+
f"assets/images/social/{Path(mkdocs_page.src_uri).with_suffix('.png')}"
329+
)
330+
331+
if expected_cached_card_path.is_file():
332+
logger.debug(
333+
f"Social card file found in cache folder: {expected_cached_card_path}"
334+
)
335+
return expected_cached_card_path
336+
else:
337+
logger.debug(
338+
f"Social card not found in cache folder: {expected_cached_card_path}"
365339
)
366340

367341
if expected_cached_card_path.is_file():

0 commit comments

Comments
 (0)