Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refacto : utilise le plugin group du thème Material pour gérer les plugins selon le niveau d'accès #992

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ jobs:
MKDOCS_ENABLE_PLUGIN_GIT_DATES: true
MKDOCS_ENABLE_PLUGIN_PRIVACY: true
MKDOCS_ENABLE_PLUGIN_RSS: true
MKDOCS_ENABLE_PLUGIN_SOCIAL: true
MKDOCS_ENABLE_PLUGIN_SOCIAL_CARDS: true
MKDOCS_ENABLE_PLUGIN_TAGS: true
MKDOCS_ENABLE_THEME_INSIDERS: true
MKDOCS_GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}

- name: Setup Pages
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/links_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
mkdocs build --clean --config-file mkdocs.yml --quiet --strict
env:
MKDOCS_ENABLE_PLUGIN_RSS: true
MKDOCS_ENABLE_THEME_INSIDERS: true

- name: Run linkcheckr
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pr_checker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ jobs:
if [[ -z "${GH_TOKEN_MATERIAL_INSIDERS}" ]]; then
echo "::warning:: L'accès aux token est réservé aux comptes avec droits d'écriture sur le dépôt. La version gratuite du thème est donc utilisée sans mots-clés, etc.)"
python -m pip install -U -r requirements-free.txt
echo "MKDOCS_CONFIG_FILENAME=mkdocs-free.yml" >> $GITHUB_ENV
echo "MKDOCS_CONFIG_FILENAME=mkdocs.yml" >> $GITHUB_ENV
echo "MKDOCS_ENABLE_THEME_INSIDERS=false" >> $GITHUB_ENV
else
# install insiders version using token
python -m pip install -U -r requirements-insiders.txt
echo "MKDOCS_CONFIG_FILENAME=mkdocs.yml" >> $GITHUB_ENV
echo "MKDOCS_ENABLE_THEME_INSIDERS=true" >> $GITHUB_ENV
fi

- name: Cache build dependencies (external assets downloaded)
Expand Down
13 changes: 0 additions & 13 deletions config/plugins_glightbox.yml

This file was deleted.

21 changes: 0 additions & 21 deletions config/plugins_rss.yml

This file was deleted.

7 changes: 6 additions & 1 deletion hooks/mkdocs/G003_social_cards_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@

# standard library
import logging
from os import getenv
from pathlib import Path
from typing import Optional

from geotribu_cli.utils.str2bool import str2bool

# Mkdocs
from material.plugins.social.plugin import SocialPlugin
from mkdocs.config.defaults import MkDocsConfig
Expand Down Expand Up @@ -71,7 +74,9 @@ def on_page_markdown(
return

# check si c'est la version Insiders (payante) ou la version Communauté (gratuite) du thème
is_insiders = config.theme.get("insiders_flavor")
is_insiders = config.theme.get(
"insiders_flavor", str2bool(getenv("MKDOCS_ENABLE_THEME_INSIDERS", False))
)

# vérifie que le plugin social est bien installé et configuré
if not config.plugins.get("material/social"):
Expand Down
258 changes: 163 additions & 95 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,101 +26,169 @@ hooks:

# Plugins
plugins:
- awesome-pages
- exclude:
glob:
- "*/templates/*"
- "*.yml"
- git-authors:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_GIT_AUTHORS, false]
exclude:
- index.md
show_contribution: true
- git-committers:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_GIT_COMMITTERS, false]
repository: geotribu/website
branch: master
docs_path: content/
cache_dir:
!ENV [
MKDOCS_PLUGIN_GIT_COMMITTERS_CACHE_DIR,
.cache/plugins/git-committers/,
]
- git-revision-date-localized:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_GIT_DATES, false]
enable_creation_date: true
fallback_to_build_date: true
locale: fr
- meta:
meta_file: "content/**/.meta.yml"
- minify:
minify_css: true
css_files:
- theme/assets/stylesheets/extra.css
- theme/assets/stylesheets/homepage.css
minify_html: true
htmlmin_opts:
remove_comments: true
- search:
lang: fr
- macros:
include_dir: content/toc_nav_ignored/snippets
- tags:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_TAGS, true]
tags_file: tags.md
tags_compare: !!python/name:material.plugins.tags.casefold
tags_pages_compare: !!python/name:material.plugins.tags.page_url
- termynal
- privacy:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_PRIVACY, true]
cache_dir:
!ENV [MKDOCS_PLUGIN_PRIVACY_EXTERNAL_CACHE_DIR, .cache/plugins/privacy]
links_attr_map:
target: _blank
assets_exclude:
# mandatory - https://squidfunk.github.io/mkdocs-material/setup/ensuring-data-privacy/
- cdn.jsdelivr.net/npm/mathjax@3/*
- giscus.app/*
# geotribu
- cdn.geotribu.fr/images/*
- cdn.geotribu.fr/img/*
- geotribu.net/*
- www.geotribu.net/*
- ks356007.kimsufi.com/*
# external
- baliz-geospatial.com/images/mediatheque/2008-08/*
- cdn.jsdelivr.net/**/*/twemoji*
- cdnjs.cloudflare.com/ajax/libs/twemoji/*
- github.com/**/*.gif
- i.imgur.com/*
- raw.githubusercontent.com/*
- sondekla.com/buid/widget/*
- cdnjs.cloudflare.com/ajax/libs/twemoji/*
- twemoji.maxcdn.com/*
- upload.wikimedia.org/*
- user-images.githubusercontent.com/**/*.gif
# to remove later:
- dev.openstreetmap.org/*
- www.portailsig.org/assets/images/*
- 88.191.39.115/*
- cdn.theatlanticcities.com/img/*
- boundlessgeo.com/*
- i3.codeplex.com/*
- drfhlmcehrc34.cloudfront.net/*
- social:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_SOCIAL, true]
cache_dir: !ENV [MKDOCS_PLUGIN_SOCIAL_CACHE_DIR, .cache/plugins/social]
cards: !ENV [MKDOCS_ENABLE_PLUGIN_SOCIAL_CARDS, true]
cards_exclude:
- index.md
- toc_nav_ignored/*.md
cards_layout_options:
background_color: "#00000000"
background_image: content/theme/assets/images/geotribu/background_geotribu.png
color: "#3e93a7"
font_family: Ubuntu

# Theme
# -- MINIMAL --
- group:
enabled: true
plugins:
- awesome-pages
- exclude:
glob:
- "*/templates/*"
- "*.yml"
- macros:
include_dir: content/toc_nav_ignored/snippets

# -- COMMON --
- group:
enabled: !ENV [MKDOCS_ENABLE_THEME_COMMON, true]
plugins:
- git-authors:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_GIT_AUTHORS, false]
exclude:
- index.md
show_contribution: true
- git-revision-date-localized:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_GIT_DATES, false]
enable_creation_date: true
fallback_to_build_date: true
locale: fr
- glightbox:
auto_caption: true
caption_position: bottom
draggable: true
effect: zoom
height: auto
skip_classes:
- img-rdp-news-thumb
- emojione
- twemoji
touchNavigation: true
width: 90%
zoomable: true
- minify:
minify_css: true
css_files:
- theme/assets/stylesheets/extra.css
- theme/assets/stylesheets/homepage.css
minify_html: true
htmlmin_opts:
remove_comments: true
- rss:
abstract_chars_count: 500
categories:
- categories
- tags
comments_path: "#__comments"
date_from_meta:
as_creation: "date"
as_update: false
datetime_format: "%Y-%m-%d %H:%M"
default_timezone: Europe/Paris
default_time: "14:00"
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_RSS, false]
image: "https://cdn.geotribu.fr/img/internal/charte/geotribu_logo_64x64.png"
length: 50
match_path: "(articles|rdp)/.*"
pretty_print: false
url_parameters:
utm_source: "rss-feed"
utm_medium: "RSS"
utm_campaign: "feed-syndication"
- search:
lang: fr
- termynal

# -- FREE --
- group:
enabled: !ENV [MKDOCS_ENABLE_THEME_FREE, false]
plugins:
- social:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_SOCIAL, true]
cache_dir:
!ENV [MKDOCS_PLUGIN_SOCIAL_CACHE_DIR, .cache/plugins/social]
cards: !ENV [MKDOCS_ENABLE_PLUGIN_SOCIAL_CARDS, true]
cards_layout_options:
font_family: Ubuntu
- tags:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_TAGS, true]
tags_file: tags.md

# -- INSIDERS --
- group:
enabled: !ENV [MKDOCS_ENABLE_THEME_INSIDERS, false]
plugins:
- git-committers:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_GIT_COMMITTERS, false]
repository: geotribu/website
branch: master
docs_path: content/
cache_dir:
!ENV [
MKDOCS_PLUGIN_GIT_COMMITTERS_CACHE_DIR,
.cache/plugins/git-committers/,
]
- meta:
meta_file: "content/**/.meta.yml"
- privacy:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_PRIVACY, true]
cache_dir:
!ENV [
MKDOCS_PLUGIN_PRIVACY_EXTERNAL_CACHE_DIR,
.cache/plugins/privacy,
]
links_attr_map:
target: _blank
assets_exclude:
# mandatory - https://squidfunk.github.io/mkdocs-material/setup/ensuring-data-privacy/
- cdn.jsdelivr.net/npm/mathjax@3/*
- giscus.app/*
# geotribu
- cdn.geotribu.fr/images/*
- cdn.geotribu.fr/img/*
- geotribu.net/*
- www.geotribu.net/*
- ks356007.kimsufi.com/*
# external
- baliz-geospatial.com/images/mediatheque/2008-08/*
- cdn.jsdelivr.net/**/*/twemoji*
- cdnjs.cloudflare.com/ajax/libs/twemoji/*
- github.com/**/*.gif
- i.imgur.com/*
- raw.githubusercontent.com/*
- sondekla.com/buid/widget/*
- cdnjs.cloudflare.com/ajax/libs/twemoji/*
- twemoji.maxcdn.com/*
- upload.wikimedia.org/*
- user-images.githubusercontent.com/**/*.gif
# to remove later:
- dev.openstreetmap.org/*
- www.portailsig.org/assets/images/*
- 88.191.39.115/*
- cdn.theatlanticcities.com/img/*
- boundlessgeo.com/*
- i3.codeplex.com/*
- drfhlmcehrc34.cloudfront.net/*
- social:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_SOCIAL, true]
cache_dir:
!ENV [MKDOCS_PLUGIN_SOCIAL_CACHE_DIR, .cache/plugins/social]
cards: !ENV [MKDOCS_ENABLE_PLUGIN_SOCIAL_CARDS, true]
cards_exclude:
- index.md
- toc_nav_ignored/*.md
cards_layout_options:
background_color: "#00000000"
background_image: content/theme/assets/images/geotribu/background_geotribu.png
color: "#3e93a7"
font_family: Ubuntu
- tags:
enabled: !ENV [MKDOCS_ENABLE_PLUGIN_TAGS, true]
tags_file: tags.md
tags_compare: !!python/name:material.plugins.tags.casefold
tags_pages_compare:
!!python/name:material.plugins.tags.page_url # Theme


theme:
name: "material"
insiders_flavor: true
Expand Down