Skip to content

Commit

Permalink
Merge latests changes from Insiders
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Dec 7, 2023
1 parent f855a67 commit aa62bcc
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 154 deletions.
13 changes: 0 additions & 13 deletions material/plugins/blog/plugin.py
Expand Up @@ -477,19 +477,6 @@ def _resolve_authors(self, config: MkDocsConfig):

# Validate authors and throw if errors occurred
errors, warnings = config.validate()
if not config.authors and warnings:
log.warning(
f"Action required: the format of the authors file changed.\n"
f"All authors must now be located under the 'authors' key.\n"
f"Please adjust '{file}' to match:\n"
f"\n"
f"authors:\n"
f" squidfunk:\n"
f" avatar: https://avatars.githubusercontent.com/u/932156\n"
f" description: Creator\n"
f" name: Martin Donath\n"
f"\n"
)
for _, w in warnings:
log.warning(w)
for _, e in errors:
Expand Down
4 changes: 2 additions & 2 deletions material/plugins/group/plugin.py
Expand Up @@ -53,8 +53,8 @@ def on_startup(self, *, command, dirty):
# little hacky, but has huge potential making plugin configuration easier.
# There's one little caveat: the `__init__` and `on_startup` methods of the
# plugins that are part of the group are called after all other plugins, so
# the `event_priority` decorator for `on_startup` events and is effectively
# useless. However, the `on_startup` event is only intended to set up the
# the `event_priority` decorator for `on_startup` methods is effectively
# useless. However, the `on_startup` method is only intended to set up the
# plugin and doesn't receive anything else than the invoked command and
# whether we're running a dirty build, so there should be no problems.
@event_priority(150)
Expand Down
136 changes: 80 additions & 56 deletions material/templates/partials/source-file.html
@@ -1,6 +1,82 @@
{#-
This file was automatically generated - do not edit
-#}
{% macro render_updated(date) %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.date.updated') }}">
{% include ".icons/material/clock-edit-outline.svg" %}
</span>
{{ date }}
</span>
{% endmacro %}
{% macro render_created(date) %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.date.created') }}">
{% include ".icons/material/clock-plus-outline.svg" %}
</span>
{{ date }}
</span>
{% endmacro %}
{% macro render_authors(authors) %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% if authors | length == 1 %}
{% include ".icons/material/account.svg" %}
{% else %}
{% include ".icons/material/account-group.svg" %}
{% endif %}
</span>
<nav>
{% for author in authors %}
<a href="mailto:{{ author.email }}">
{{- author.name -}}
</a>
{%- if loop.revindex > 1 %}, {% endif -%}
{% endfor %}
</nav>
</span>
{% endmacro %}
{% macro render_committers_github(title) %}
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% include ".icons/material/github.svg" %}
</span>
<span>{{ title }}</span>
{% endmacro %}
{% macro render_committers_gitlab(title) %}
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% include ".icons/material/gitlab.svg" %}
</span>
<span>{{ title }}</span>
{% endmacro %}
{% macro render_committers(authors) %}
<span class="md-source-file__fact">
{% if committers_source == "gitlab" %}
{{ render_committers_gitlab("GitLab") }}
{% else %}
{{ render_committers_github("GitHub") }}
{% endif %}
<nav>
{% for author in authors[:4] %}
<a href="{{ author.url }}" class="md-author" title="@{{ author.login }}">
{% set separator = "&" if "?" in author.avatar else "?" %}
<img src="{{ author.avatar }}{{ separator }}size=72" alt="{{ author.name or 'GitHub user' }}">
</a>
{% endfor %}
{% set more = authors[4:] | length %}
{% if more > 0 %}
{% if page.edit_url %}
<a href="{{ page.edit_url | replace('edit', 'blob') }}" class="md-author md-author--more">
+{{ more }}
</a>
{% else %}
<span class="md-author md-author--more">
+{{ more }}
</span>
{% endif %}
{% endif %}
</nav>
</span>
{% endmacro %}
{% if page.meta %}
{% if page.meta.git_revision_date_localized %}
{% set updated = page.meta.git_revision_date_localized %}
Expand All @@ -14,68 +90,16 @@
{% if updated or created or git_info or committers %}
<aside class="md-source-file">
{% if updated %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.date.updated') }}">
{% include ".icons/material/clock-edit-outline.svg" %}
</span>
{{ updated }}
</span>
{{ render_updated(updated) }}
{% endif %}
{% if created %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.date.created') }}">
{% include ".icons/material/clock-plus-outline.svg" %}
</span>
{{ created }}
</span>
{{ render_created(created) }}
{% endif %}
{% if git_info %}
{% set authors = git_info.get("page_authors") %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% if authors | length == 1 %}
{% include ".icons/material/account.svg" %}
{% else %}
{% include ".icons/material/account-group.svg" %}
{% endif %}
</span>
<nav>
{% for author in authors %}
<a href="mailto:{{ author.email }}">
{{- author.name -}}
</a>
{%- if loop.revindex > 1 %}, {% endif -%}
{% endfor %}
</nav>
</span>
{{ render_authors(git_info.get("page_authors")) }}
{% endif %}
{% if committers %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% include ".icons/material/github.svg" %}
</span>
<span>GitHub</span>
<nav>
{% for author in committers[:4] %}
<a href="{{ author.url }}" class="md-author" title="@{{ author.login }}">
{% set separator = "&" if "?" in author.avatar else "?" %}
<img src="{{ author.avatar }}{{ separator }}size=72" alt="{{ author.name or 'GitHub user' }}">
</a>
{% endfor %}
{% set more = committers[4:] | length %}
{% if more > 0 %}
{% if page.edit_url %}
<a href="{{ page.edit_url | replace('edit', 'blob') }}" class="md-author md-author--more">
+{{ more }}
</a>
{% else %}
<span class="md-author md-author--more">
+{{ more }}
</span>
{% endif %}
{% endif %}
</nav>
</span>
{{ render_committers(committers) }}
{% endif %}
</aside>
{% endif %}
13 changes: 0 additions & 13 deletions src/plugins/blog/plugin.py
Expand Up @@ -477,19 +477,6 @@ def _resolve_authors(self, config: MkDocsConfig):

# Validate authors and throw if errors occurred
errors, warnings = config.validate()
if not config.authors and warnings:
log.warning(
f"Action required: the format of the authors file changed.\n"
f"All authors must now be located under the 'authors' key.\n"
f"Please adjust '{file}' to match:\n"
f"\n"
f"authors:\n"
f" squidfunk:\n"
f" avatar: https://avatars.githubusercontent.com/u/932156\n"
f" description: Creator\n"
f" name: Martin Donath\n"
f"\n"
)
for _, w in warnings:
log.warning(w)
for _, e in errors:
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/group/plugin.py
Expand Up @@ -53,8 +53,8 @@ def on_startup(self, *, command, dirty):
# little hacky, but has huge potential making plugin configuration easier.
# There's one little caveat: the `__init__` and `on_startup` methods of the
# plugins that are part of the group are called after all other plugins, so
# the `event_priority` decorator for `on_startup` events and is effectively
# useless. However, the `on_startup` event is only intended to set up the
# the `event_priority` decorator for `on_startup` methods is effectively
# useless. However, the `on_startup` method is only intended to set up the
# plugin and doesn't receive anything else than the invoked command and
# whether we're running a dirty build, so there should be no problems.
@event_priority(150)
Expand Down

0 comments on commit aa62bcc

Please sign in to comment.