mkdocs-document-dates 3.4.6__tar.gz → 3.4.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mkdocs_document_dates-3.4.6/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.4.8}/PKG-INFO +5 -4
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/README.md +4 -3
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/cache_manager.py +6 -14
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/plugin.py +79 -78
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/core/core.js +2 -6
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/utils.py +0 -10
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8/mkdocs_document_dates.egg-info}/PKG-INFO +5 -4
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/setup.py +1 -1
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/LICENSE +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/MANIFEST.in +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/__init__.py +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/hooks/pre-commit +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/hooks_installer.py +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/config/user.config.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/config/user.config.js +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/core/core.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/core/default.config.js +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/core/utils.js +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/fonts/material-icons.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/templates/recently_updated.html +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/tippy/light.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/tippy/material.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/tippy/scale.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates.egg-info/requires.txt +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/pyproject.toml +0 -0
- {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/setup.cfg +0 -0
{mkdocs_document_dates-3.4.6/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.4.8}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-document-dates
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.8
|
|
4
4
|
Summary: A new generation MkDocs plugin for displaying exact creation time, last update time, authors, email of documents
|
|
5
5
|
Home-page: https://github.com/jaywhj/mkdocs-document-dates
|
|
6
6
|
Author: Aaron Wang
|
|
@@ -41,14 +41,15 @@ A new generation MkDocs plugin for displaying exact **creation time, last update
|
|
|
41
41
|
- [x] Support for manually specifying time and author in `Front Matter`
|
|
42
42
|
- [x] Support for multiple time formats (date, datetime, timeago)
|
|
43
43
|
- [x] Support for multiple author modes (avatar, text, hidden)
|
|
44
|
+
- [x] Support for manually configuring author's name, link, avatar, email, etc.
|
|
44
45
|
- [x] Flexible display position (top or bottom)
|
|
45
46
|
- [x] Elegant styling (fully customizable)
|
|
46
47
|
- [x] Smart Tooltip Hover Tips
|
|
47
48
|
- [x] Multi-language support, localization support, intelligent recognition of user language, automatic adaptation
|
|
48
49
|
- [x] Cross-platform support (Windows, macOS, Linux)
|
|
49
|
-
- [x] **Ultimate build efficiency**: O(1), no need to set env
|
|
50
|
+
- [x] **Ultimate build efficiency**: O(1), no need to set the env var `!ENV` to distinguish runs
|
|
50
51
|
|
|
51
|
-
|
|
|
52
|
+
| Build Speed Comparison: | 100 md: | 1000 md: | Time Complexity: |
|
|
52
53
|
| --------------------------- | :-----: | :------: | :----------: |
|
|
53
54
|
| git-revision-date-localized | > 3 s | > 30 s | O(n) |
|
|
54
55
|
| document-dates | < 0.1 s | < 0.15 s | O(1) |
|
|
@@ -88,7 +89,7 @@ plugins:
|
|
|
88
89
|
In addition to the above basic configuration, the plug-in also provides a wealth of customization options to meet a variety of individual needs:
|
|
89
90
|
|
|
90
91
|
- [Specify Datetime](https://jaywhj.netlify.app/document-dates-en#Specify-Datetime): You can manually specify the creation time and last update time for each document
|
|
91
|
-
- [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): You can manually specify the author information for each document
|
|
92
|
+
- [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): You can manually specify the author information for each document, such as name, link, avatar, email, etc.
|
|
92
93
|
- [Specify Avatar](https://jaywhj.netlify.app/document-dates-en#Specify-Avatar): You can manually specify the avatar for each author
|
|
93
94
|
- [Set Plugin Style](https://jaywhj.netlify.app/document-dates-en#Set-Plugin-Style): Such as icons, themes, colors, fonts, animations, dividing line, etc.
|
|
94
95
|
- [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
|
|
@@ -15,14 +15,15 @@ A new generation MkDocs plugin for displaying exact **creation time, last update
|
|
|
15
15
|
- [x] Support for manually specifying time and author in `Front Matter`
|
|
16
16
|
- [x] Support for multiple time formats (date, datetime, timeago)
|
|
17
17
|
- [x] Support for multiple author modes (avatar, text, hidden)
|
|
18
|
+
- [x] Support for manually configuring author's name, link, avatar, email, etc.
|
|
18
19
|
- [x] Flexible display position (top or bottom)
|
|
19
20
|
- [x] Elegant styling (fully customizable)
|
|
20
21
|
- [x] Smart Tooltip Hover Tips
|
|
21
22
|
- [x] Multi-language support, localization support, intelligent recognition of user language, automatic adaptation
|
|
22
23
|
- [x] Cross-platform support (Windows, macOS, Linux)
|
|
23
|
-
- [x] **Ultimate build efficiency**: O(1), no need to set env
|
|
24
|
+
- [x] **Ultimate build efficiency**: O(1), no need to set the env var `!ENV` to distinguish runs
|
|
24
25
|
|
|
25
|
-
|
|
|
26
|
+
| Build Speed Comparison: | 100 md: | 1000 md: | Time Complexity: |
|
|
26
27
|
| --------------------------- | :-----: | :------: | :----------: |
|
|
27
28
|
| git-revision-date-localized | > 3 s | > 30 s | O(n) |
|
|
28
29
|
| document-dates | < 0.1 s | < 0.15 s | O(1) |
|
|
@@ -62,7 +63,7 @@ plugins:
|
|
|
62
63
|
In addition to the above basic configuration, the plug-in also provides a wealth of customization options to meet a variety of individual needs:
|
|
63
64
|
|
|
64
65
|
- [Specify Datetime](https://jaywhj.netlify.app/document-dates-en#Specify-Datetime): You can manually specify the creation time and last update time for each document
|
|
65
|
-
- [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): You can manually specify the author information for each document
|
|
66
|
+
- [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): You can manually specify the author information for each document, such as name, link, avatar, email, etc.
|
|
66
67
|
- [Specify Avatar](https://jaywhj.netlify.app/document-dates-en#Specify-Avatar): You can manually specify the avatar for each author
|
|
67
68
|
- [Set Plugin Style](https://jaywhj.netlify.app/document-dates-en#Set-Plugin-Style): Such as icons, themes, colors, fonts, animations, dividing line, etc.
|
|
68
69
|
- [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
|
{mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/cache_manager.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import subprocess
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from .utils import
|
|
4
|
+
from .utils import read_jsonl_cache, write_jsonl_cache, get_file_creation_time, get_git_first_commit_time
|
|
5
5
|
|
|
6
6
|
logger = logging.getLogger("mkdocs.plugins.document_dates")
|
|
7
7
|
logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
@@ -72,29 +72,21 @@ def update_cache():
|
|
|
72
72
|
logger.info(f"No tracked markdown files found in {docs_dir}")
|
|
73
73
|
continue
|
|
74
74
|
|
|
75
|
-
#
|
|
76
|
-
json_cache_file = docs_dir / '.dates_cache.json'
|
|
77
|
-
json_dates_cache = read_json_cache(json_cache_file)
|
|
78
|
-
|
|
79
|
-
# 读取新的JSONL缓存文件(如果存在)
|
|
75
|
+
# 读取 JSONL 缓存
|
|
80
76
|
jsonl_cache_file = docs_dir / '.dates_cache.jsonl'
|
|
81
77
|
jsonl_dates_cache = read_jsonl_cache(jsonl_cache_file)
|
|
82
78
|
|
|
83
79
|
# 根据 git已跟踪的文件来更新
|
|
84
80
|
for rel_path in tracked_files:
|
|
85
81
|
try:
|
|
86
|
-
# 如果文件已在JSONL缓存中,跳过
|
|
82
|
+
# 如果文件已在 JSONL 缓存中,跳过
|
|
87
83
|
if rel_path in jsonl_dates_cache:
|
|
88
84
|
continue
|
|
89
85
|
|
|
90
86
|
full_path = docs_dir / rel_path
|
|
91
|
-
|
|
92
|
-
if rel_path in json_dates_cache:
|
|
93
|
-
jsonl_dates_cache[rel_path] = json_dates_cache[rel_path]
|
|
94
|
-
project_updated = True
|
|
95
|
-
elif full_path.exists():
|
|
87
|
+
if full_path.exists():
|
|
96
88
|
created_time = get_file_creation_time(full_path).astimezone()
|
|
97
|
-
if not jsonl_cache_file.exists()
|
|
89
|
+
if not jsonl_cache_file.exists():
|
|
98
90
|
git_time = get_git_first_commit_time(full_path)
|
|
99
91
|
if git_time:
|
|
100
92
|
created_time = min(created_time, git_time)
|
|
@@ -110,7 +102,7 @@ def update_cache():
|
|
|
110
102
|
if len(jsonl_dates_cache) > len(tracked_files):
|
|
111
103
|
project_updated = True
|
|
112
104
|
|
|
113
|
-
# 如果有更新,写入JSONL缓存文件
|
|
105
|
+
# 如果有更新,写入 JSONL 缓存文件
|
|
114
106
|
if project_updated or not jsonl_cache_file.exists():
|
|
115
107
|
global_updated = write_jsonl_cache(jsonl_cache_file, jsonl_dates_cache, tracked_files)
|
|
116
108
|
except subprocess.CalledProcessError as e:
|
|
@@ -8,6 +8,7 @@ from pathlib import Path
|
|
|
8
8
|
from mkdocs.plugins import BasePlugin
|
|
9
9
|
from mkdocs.config import config_options
|
|
10
10
|
from mkdocs.structure.pages import Page
|
|
11
|
+
from mkdocs.utils import get_relative_url
|
|
11
12
|
from urllib.parse import urlparse
|
|
12
13
|
from .utils import get_file_creation_time, load_git_cache, read_jsonl_cache,is_excluded, get_recently_updated_files
|
|
13
14
|
|
|
@@ -16,21 +17,12 @@ logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class Author:
|
|
19
|
-
def __init__(self, name="", email="", avatar="", url="",
|
|
20
|
+
def __init__(self, name="", email="", avatar="", url="", description="", **kwargs):
|
|
20
21
|
self.name = name
|
|
21
22
|
self.email = email
|
|
22
23
|
self.avatar = avatar
|
|
23
24
|
self.url = url
|
|
24
|
-
self.
|
|
25
|
-
|
|
26
|
-
def to_dict(self):
|
|
27
|
-
return {
|
|
28
|
-
'name': self.name,
|
|
29
|
-
'email': self.email,
|
|
30
|
-
'avatar': self.avatar,
|
|
31
|
-
'url': self.url,
|
|
32
|
-
'description': self.desc
|
|
33
|
-
}
|
|
25
|
+
self.description = description
|
|
34
26
|
|
|
35
27
|
|
|
36
28
|
class DocumentDatesPlugin(BasePlugin):
|
|
@@ -173,31 +165,6 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
173
165
|
|
|
174
166
|
return nav
|
|
175
167
|
|
|
176
|
-
def _render_recently_updated_html(self, docs_dir, template_path, recently_updated_data):
|
|
177
|
-
# 获取自定义模板路径
|
|
178
|
-
if template_path:
|
|
179
|
-
user_full_path = docs_dir / template_path
|
|
180
|
-
|
|
181
|
-
# 选择模板路径
|
|
182
|
-
if template_path and user_full_path.is_file():
|
|
183
|
-
template_dir = user_full_path.parent
|
|
184
|
-
template_file = user_full_path.name
|
|
185
|
-
else:
|
|
186
|
-
# 默认模板路径
|
|
187
|
-
default_template_path = Path(__file__).parent / 'static' / 'templates' / 'recently_updated.html'
|
|
188
|
-
template_dir = default_template_path.parent
|
|
189
|
-
template_file = default_template_path.name
|
|
190
|
-
|
|
191
|
-
# 加载模板
|
|
192
|
-
env = Environment(
|
|
193
|
-
loader=FileSystemLoader(str(template_dir)),
|
|
194
|
-
autoescape=select_autoescape(["html", "xml"])
|
|
195
|
-
)
|
|
196
|
-
template = env.get_template(template_file)
|
|
197
|
-
|
|
198
|
-
# 渲染模板
|
|
199
|
-
return template.render(recent_docs=recently_updated_data)
|
|
200
|
-
|
|
201
168
|
def on_page_markdown(self, markdown, page: Page, config, files):
|
|
202
169
|
# 获取相对路径,src_uri 总是以"/"分隔
|
|
203
170
|
rel_path = getattr(page.file, 'src_uri', page.file.src_path)
|
|
@@ -215,6 +182,10 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
215
182
|
|
|
216
183
|
# 获取作者信息
|
|
217
184
|
authors = self._get_author_info(rel_path, page, config)
|
|
185
|
+
if len(authors) == 1:
|
|
186
|
+
a = authors[0]
|
|
187
|
+
if not a.avatar and self.github_username:
|
|
188
|
+
a.avatar = f"https://avatars.githubusercontent.com/{self.github_username}"
|
|
218
189
|
|
|
219
190
|
# 在排除前暴露 meta 信息给前端使用
|
|
220
191
|
page.meta['document_dates_created'] = created.isoformat()
|
|
@@ -246,6 +217,7 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
246
217
|
if item.is_file():
|
|
247
218
|
shutil.copy2(item, target_dir / item.name)
|
|
248
219
|
|
|
220
|
+
|
|
249
221
|
def _extract_github_username(self, url):
|
|
250
222
|
try:
|
|
251
223
|
parsed = urlparse(url)
|
|
@@ -264,18 +236,37 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
264
236
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
265
237
|
data = yaml.safe_load(f)
|
|
266
238
|
for key, info in (data or {}).get('authors', {}).items():
|
|
267
|
-
|
|
268
|
-
name=info.get('name', ''),
|
|
269
|
-
email=info.get('email', ''),
|
|
270
|
-
avatar=info.get('avatar', ''),
|
|
271
|
-
url=info.get('url', ''),
|
|
272
|
-
desc=info.get('description', '')
|
|
273
|
-
)
|
|
274
|
-
self.authors_yml[key] = author
|
|
239
|
+
self.authors_yml[key] = Author(**info)
|
|
275
240
|
except Exception as e:
|
|
276
241
|
logger.info(f"Error parsing .authors.yml: {e}")
|
|
277
242
|
|
|
278
243
|
|
|
244
|
+
def _render_recently_updated_html(self, docs_dir, template_path, recently_updated_data):
|
|
245
|
+
# 获取自定义模板路径
|
|
246
|
+
if template_path:
|
|
247
|
+
user_full_path = docs_dir / template_path
|
|
248
|
+
|
|
249
|
+
# 选择模板路径
|
|
250
|
+
if template_path and user_full_path.is_file():
|
|
251
|
+
template_dir = user_full_path.parent
|
|
252
|
+
template_file = user_full_path.name
|
|
253
|
+
else:
|
|
254
|
+
# 默认模板路径
|
|
255
|
+
default_template_path = Path(__file__).parent / 'static' / 'templates' / 'recently_updated.html'
|
|
256
|
+
template_dir = default_template_path.parent
|
|
257
|
+
template_file = default_template_path.name
|
|
258
|
+
|
|
259
|
+
# 加载模板
|
|
260
|
+
env = Environment(
|
|
261
|
+
loader=FileSystemLoader(str(template_dir)),
|
|
262
|
+
autoescape=select_autoescape(["html", "xml"])
|
|
263
|
+
)
|
|
264
|
+
template = env.get_template(template_file)
|
|
265
|
+
|
|
266
|
+
# 渲染模板
|
|
267
|
+
return template.render(recent_docs=recently_updated_data)
|
|
268
|
+
|
|
269
|
+
|
|
279
270
|
def _find_meta_date(self, meta, field_names):
|
|
280
271
|
for field in field_names:
|
|
281
272
|
if field in meta:
|
|
@@ -307,55 +298,73 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
307
298
|
if not self.config['show_author']:
|
|
308
299
|
return None
|
|
309
300
|
# 1. meta author
|
|
310
|
-
authors = self._process_meta_author(page.meta)
|
|
301
|
+
authors = self._process_meta_author(page.meta, page.url)
|
|
311
302
|
if authors:
|
|
312
303
|
return authors
|
|
304
|
+
|
|
313
305
|
# 2. git author
|
|
314
306
|
if rel_path in self.dates_cache:
|
|
315
307
|
authors_list = self.dates_cache[rel_path].get('authors')
|
|
316
308
|
if authors_list:
|
|
317
|
-
|
|
309
|
+
authors = []
|
|
310
|
+
for data in authors_list:
|
|
311
|
+
full_author = self.authors_yml.get(data['name'])
|
|
312
|
+
if full_author:
|
|
313
|
+
authors.append(self._get_repaired_author(full_author, page.url))
|
|
314
|
+
else:
|
|
315
|
+
authors.append(Author(**data))
|
|
316
|
+
return authors
|
|
317
|
+
|
|
318
318
|
# 3. site_author 或 PC username
|
|
319
|
-
|
|
319
|
+
name = config.get('site_author') or Path.home().name
|
|
320
|
+
full_author = self.authors_yml.get(name)
|
|
321
|
+
if full_author:
|
|
322
|
+
return [self._get_repaired_author(full_author, page.url)]
|
|
323
|
+
else:
|
|
324
|
+
return [Author(name=name)]
|
|
320
325
|
|
|
321
|
-
def _process_meta_author(self, meta):
|
|
326
|
+
def _process_meta_author(self, meta, page_url):
|
|
322
327
|
try:
|
|
323
328
|
# 匹配 authors 数组
|
|
324
329
|
author_objs = []
|
|
325
330
|
authors_data = meta.get('authors')
|
|
326
331
|
for key in authors_data or []:
|
|
327
|
-
|
|
328
|
-
if
|
|
329
|
-
|
|
330
|
-
|
|
332
|
+
full_author = self.authors_yml.get(key)
|
|
333
|
+
if full_author:
|
|
334
|
+
author_objs.append(self._get_repaired_author(full_author, page_url))
|
|
335
|
+
else:
|
|
336
|
+
author_objs.append(Author(name=str(key)))
|
|
331
337
|
if author_objs:
|
|
332
338
|
return author_objs
|
|
333
339
|
|
|
334
|
-
# 匹配 author 对象,或 author 字符串
|
|
335
|
-
author_data = meta.get('author')
|
|
336
|
-
if author_data:
|
|
337
|
-
if isinstance(author_data, dict):
|
|
338
|
-
name = author_data.get('name')
|
|
339
|
-
if not name:
|
|
340
|
-
return None
|
|
341
|
-
email = author_data.get('email')
|
|
342
|
-
avatar = author_data.get('avatar')
|
|
343
|
-
url = author_data.get('url')
|
|
344
|
-
desc = author_data.get('description')
|
|
345
|
-
return [Author(name=name, email=email, avatar=avatar, url=url, desc=desc)]
|
|
346
|
-
return [Author(name=str(author_data))]
|
|
347
|
-
|
|
348
340
|
# 匹配独立字段: name, email
|
|
349
341
|
name = meta.get('name')
|
|
350
342
|
email = meta.get('email')
|
|
351
343
|
if name or email:
|
|
352
344
|
if not name and email:
|
|
353
345
|
name = email.partition('@')[0]
|
|
354
|
-
|
|
346
|
+
full_author = self.authors_yml.get(name)
|
|
347
|
+
if full_author:
|
|
348
|
+
return [self._get_repaired_author(full_author, page_url)]
|
|
349
|
+
else:
|
|
350
|
+
return [Author(name=name, email=email)]
|
|
355
351
|
except Exception as e:
|
|
356
352
|
logger.warning(f"Error processing author meta: {e}")
|
|
357
353
|
return None
|
|
358
354
|
|
|
355
|
+
def _get_repaired_author(self, author: Author, page_url: str) -> Author:
|
|
356
|
+
try:
|
|
357
|
+
if not author.avatar:
|
|
358
|
+
return author
|
|
359
|
+
parsed = urlparse(author.avatar)
|
|
360
|
+
if parsed.scheme or author.avatar.startswith('//'):
|
|
361
|
+
return author
|
|
362
|
+
# 处理本地路径(相对路径 & 绝对路径)
|
|
363
|
+
avatar = get_relative_url(author.avatar.lstrip('/'), page_url or '')
|
|
364
|
+
return Author(**{**vars(author), 'avatar': avatar})
|
|
365
|
+
except Exception:
|
|
366
|
+
return author
|
|
367
|
+
|
|
359
368
|
|
|
360
369
|
def _get_formatted_date(self, date: datetime):
|
|
361
370
|
if self.config['type'] == 'timeago':
|
|
@@ -393,13 +402,6 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
393
402
|
return f'<a href="mailto:{author.email}">{author.name}</a>'
|
|
394
403
|
return author.name
|
|
395
404
|
|
|
396
|
-
def get_avatar_img_url(author):
|
|
397
|
-
if author.avatar:
|
|
398
|
-
return author.avatar
|
|
399
|
-
elif self.github_username and len(authors) == 1:
|
|
400
|
-
return f"https://avatars.githubusercontent.com/{self.github_username}"
|
|
401
|
-
return ""
|
|
402
|
-
|
|
403
405
|
if self.config['show_author'] == 'text':
|
|
404
406
|
# 显示文本模式
|
|
405
407
|
tooltip_text = ', '.join(get_author_tooltip(author) for author in authors)
|
|
@@ -418,11 +420,10 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
418
420
|
html_parts.append("<div class='avatar-group'>")
|
|
419
421
|
for author in authors:
|
|
420
422
|
tooltip = get_author_tooltip(author)
|
|
421
|
-
img_url = get_avatar_img_url(author)
|
|
422
423
|
html_parts.append(
|
|
423
424
|
f"<div class='avatar-wrapper' data-name='{author.name}' data-tippy-content data-tippy-raw='{tooltip}'>"
|
|
424
425
|
f"<span class='avatar-text'></span>"
|
|
425
|
-
f"<img class='avatar'
|
|
426
|
+
f"<img class='avatar' src='{author.avatar}' onerror=\"this.style.display='none'\" />"
|
|
426
427
|
f"</div>"
|
|
427
428
|
)
|
|
428
429
|
html_parts.append("</div>")
|
|
@@ -437,14 +438,14 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
437
438
|
|
|
438
439
|
def _insert_date_info(self, markdown: str, date_info: str):
|
|
439
440
|
if self.config['position'] == 'top':
|
|
440
|
-
first_line, insert_pos = self.
|
|
441
|
+
first_line, insert_pos = self._find_markdown_body_start(markdown)
|
|
441
442
|
if first_line.startswith(('# ', '<h1')):
|
|
442
443
|
return markdown[:insert_pos] + '\n' + date_info + '\n' + markdown[insert_pos:]
|
|
443
444
|
else:
|
|
444
445
|
return f"{date_info}\n{markdown}"
|
|
445
446
|
return f"{markdown}\n\n{date_info}"
|
|
446
447
|
|
|
447
|
-
def
|
|
448
|
+
def _find_markdown_body_start(self, text: str):
|
|
448
449
|
pos = 0
|
|
449
450
|
length = len(text)
|
|
450
451
|
in_comment = False
|
|
@@ -34,12 +34,8 @@ function generateAvatar() {
|
|
|
34
34
|
|
|
35
35
|
const imgEl = wrapper.querySelector('img.avatar');
|
|
36
36
|
if (imgEl) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const dataSrc = (imgEl.getAttribute('data-src') || '').trim();
|
|
40
|
-
if (dataSrc) {
|
|
41
|
-
imgEl.src = dataSrc;
|
|
42
|
-
} else {
|
|
37
|
+
const src = (imgEl.getAttribute('src') || '').trim();
|
|
38
|
+
if (!src) {
|
|
43
39
|
imgEl.style.display = 'none';
|
|
44
40
|
}
|
|
45
41
|
}
|
|
@@ -171,16 +171,6 @@ def get_recently_updated_files(docs_dir_path: Path, files: Files, exclude_list:
|
|
|
171
171
|
|
|
172
172
|
return doc_mtime_map, recently_updated_results
|
|
173
173
|
|
|
174
|
-
def read_json_cache(cache_file: Path):
|
|
175
|
-
dates_cache = {}
|
|
176
|
-
if cache_file.exists():
|
|
177
|
-
try:
|
|
178
|
-
with open(cache_file, 'r', encoding='utf-8') as f:
|
|
179
|
-
dates_cache = json.load(f)
|
|
180
|
-
except (IOError, json.JSONDecodeError) as e:
|
|
181
|
-
logger.warning(f"Error reading from '.dates_cache.json': {str(e)}")
|
|
182
|
-
return dates_cache
|
|
183
|
-
|
|
184
174
|
def read_jsonl_cache(jsonl_file: Path):
|
|
185
175
|
dates_cache = {}
|
|
186
176
|
if jsonl_file.exists():
|
{mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8/mkdocs_document_dates.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-document-dates
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.8
|
|
4
4
|
Summary: A new generation MkDocs plugin for displaying exact creation time, last update time, authors, email of documents
|
|
5
5
|
Home-page: https://github.com/jaywhj/mkdocs-document-dates
|
|
6
6
|
Author: Aaron Wang
|
|
@@ -41,14 +41,15 @@ A new generation MkDocs plugin for displaying exact **creation time, last update
|
|
|
41
41
|
- [x] Support for manually specifying time and author in `Front Matter`
|
|
42
42
|
- [x] Support for multiple time formats (date, datetime, timeago)
|
|
43
43
|
- [x] Support for multiple author modes (avatar, text, hidden)
|
|
44
|
+
- [x] Support for manually configuring author's name, link, avatar, email, etc.
|
|
44
45
|
- [x] Flexible display position (top or bottom)
|
|
45
46
|
- [x] Elegant styling (fully customizable)
|
|
46
47
|
- [x] Smart Tooltip Hover Tips
|
|
47
48
|
- [x] Multi-language support, localization support, intelligent recognition of user language, automatic adaptation
|
|
48
49
|
- [x] Cross-platform support (Windows, macOS, Linux)
|
|
49
|
-
- [x] **Ultimate build efficiency**: O(1), no need to set env
|
|
50
|
+
- [x] **Ultimate build efficiency**: O(1), no need to set the env var `!ENV` to distinguish runs
|
|
50
51
|
|
|
51
|
-
|
|
|
52
|
+
| Build Speed Comparison: | 100 md: | 1000 md: | Time Complexity: |
|
|
52
53
|
| --------------------------- | :-----: | :------: | :----------: |
|
|
53
54
|
| git-revision-date-localized | > 3 s | > 30 s | O(n) |
|
|
54
55
|
| document-dates | < 0.1 s | < 0.15 s | O(1) |
|
|
@@ -88,7 +89,7 @@ plugins:
|
|
|
88
89
|
In addition to the above basic configuration, the plug-in also provides a wealth of customization options to meet a variety of individual needs:
|
|
89
90
|
|
|
90
91
|
- [Specify Datetime](https://jaywhj.netlify.app/document-dates-en#Specify-Datetime): You can manually specify the creation time and last update time for each document
|
|
91
|
-
- [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): You can manually specify the author information for each document
|
|
92
|
+
- [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): You can manually specify the author information for each document, such as name, link, avatar, email, etc.
|
|
92
93
|
- [Specify Avatar](https://jaywhj.netlify.app/document-dates-en#Specify-Avatar): You can manually specify the avatar for each author
|
|
93
94
|
- [Set Plugin Style](https://jaywhj.netlify.app/document-dates-en#Set-Plugin-Style): Such as icons, themes, colors, fonts, animations, dividing line, etc.
|
|
94
95
|
- [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
|
|
File without changes
|
|
File without changes
|
{mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/__init__.py
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/hooks/pre-commit
RENAMED
|
File without changes
|
{mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.8}/mkdocs_document_dates/hooks_installer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|