mkdocs-document-dates 3.1.2__tar.gz → 3.1.3__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.1.2 → mkdocs_document_dates-3.1.3}/PKG-INFO +9 -8
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/README.md +6 -7
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/cache_manager.py +3 -4
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/hooks/pre-commit +2 -3
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/hooks_installer.py +1 -1
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/plugin.py +104 -109
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates.egg-info/PKG-INFO +9 -8
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates.egg-info/SOURCES.txt +1 -1
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/setup.py +2 -1
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/LICENSE +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/__init__.py +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/config/user.config.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/config/user.config.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/core/core.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/core/core.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/core/timeago-load.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/ar.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/de.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/en.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/es.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/fr.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/ja.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/ko.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/ru.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/languages/zh.json +0 -0
- /mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/zh_tw.json → /mkdocs_document_dates-3.1.3/mkdocs_document_dates/static/languages/zh_TW.json +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/tippy/light.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/tippy/material.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/tippy/scale.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates.egg-info/requires.txt +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
- {mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/setup.cfg +0 -0
@@ -1,9 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.3
|
4
4
|
Summary: An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents.
|
5
5
|
Home-page: https://github.com/jaywhj/mkdocs-document-dates
|
6
6
|
Author: Aaron Wang
|
7
|
+
Author-email: aaronwqt@gmail.com
|
7
8
|
License: MIT
|
8
9
|
Classifier: Programming Language :: Python :: 3
|
9
10
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -13,6 +14,7 @@ Description-Content-Type: text/markdown
|
|
13
14
|
License-File: LICENSE
|
14
15
|
Requires-Dist: mkdocs>=1.0.0
|
15
16
|
Dynamic: author
|
17
|
+
Dynamic: author-email
|
16
18
|
Dynamic: classifier
|
17
19
|
Dynamic: description
|
18
20
|
Dynamic: description-content-type
|
@@ -73,14 +75,14 @@ plugins:
|
|
73
75
|
position: top # Display position: top (after title) bottom (end of document), default: bottom
|
74
76
|
type: date # Date type: date datetime timeago, default: date
|
75
77
|
locale: en # Localization: zh zh_TW en es fr de ar ja ko ru, default: en
|
76
|
-
date_format: '%Y-%m-%d' # Date format,
|
78
|
+
date_format: '%Y-%m-%d' # Date format, supports all python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
77
79
|
time_format: '%H:%M:%S' # Time format (valid only if type=datetime)
|
78
80
|
exclude: # List of excluded files
|
79
81
|
- temp.md # Exclude specific file
|
80
82
|
- private/* # Exclude all files in private directory, including subdirectories
|
81
83
|
- drafts/*.md # Exclude all markdown files in the current directory drafts, but not subdirectories
|
82
84
|
|
83
|
-
show_author: true #
|
85
|
+
show_author: true # Show author or not: true false, default: true
|
84
86
|
|
85
87
|
```
|
86
88
|
|
@@ -128,9 +130,8 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
128
130
|
- Properties & Animations: `docs/assets/document_dates/user.config.js`
|
129
131
|
- Localized languages: `docs/assets/document_dates/languages/` , refer to the template file `en.json` for any additions or modifications
|
130
132
|
- timeago.js localization: `timeago.min.js` only contains English and Chinese by default, if you need to load other languages, you can configure it as below (choose one):
|
131
|
-
- In user.config.js
|
132
|
-
- In mkdocs.yml
|
133
|
-
|
133
|
+
- In `user.config.js`, refer to [the demo commented out](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) at the bottom, translate it into your local language
|
134
|
+
- In `mkdocs.yml`, add the following two lines to configure the full version of `timeago.full.min.js` to load all languages at once
|
134
135
|
```yaml
|
135
136
|
extra_javascript:
|
136
137
|
- assets/document_dates/core/timeago.full.min.js
|
@@ -141,8 +142,8 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
141
142
|
|
142
143
|
- In order to get the exact creation time, a separate cache file is used to store the creation time of the file, located in the doc folder (hidden by default), please don't delete it:
|
143
144
|
- `docs/.dates_cache.jsonl`, cache file
|
144
|
-
- `docs/.gitattributes`, merge mechanism for cache file
|
145
|
-
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (
|
145
|
+
- `docs/.gitattributes`, merge mechanism for cache file
|
146
|
+
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (on each git commit), and the cached file is automatically committed along with it. In addition, the installation of Git Hooks is automatically triggered when the plugin is installed, without any manual intervention!
|
146
147
|
|
147
148
|
<br />
|
148
149
|
|
@@ -48,14 +48,14 @@ plugins:
|
|
48
48
|
position: top # Display position: top (after title) bottom (end of document), default: bottom
|
49
49
|
type: date # Date type: date datetime timeago, default: date
|
50
50
|
locale: en # Localization: zh zh_TW en es fr de ar ja ko ru, default: en
|
51
|
-
date_format: '%Y-%m-%d' # Date format,
|
51
|
+
date_format: '%Y-%m-%d' # Date format, supports all python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
52
52
|
time_format: '%H:%M:%S' # Time format (valid only if type=datetime)
|
53
53
|
exclude: # List of excluded files
|
54
54
|
- temp.md # Exclude specific file
|
55
55
|
- private/* # Exclude all files in private directory, including subdirectories
|
56
56
|
- drafts/*.md # Exclude all markdown files in the current directory drafts, but not subdirectories
|
57
57
|
|
58
|
-
show_author: true #
|
58
|
+
show_author: true # Show author or not: true false, default: true
|
59
59
|
|
60
60
|
```
|
61
61
|
|
@@ -103,9 +103,8 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
103
103
|
- Properties & Animations: `docs/assets/document_dates/user.config.js`
|
104
104
|
- Localized languages: `docs/assets/document_dates/languages/` , refer to the template file `en.json` for any additions or modifications
|
105
105
|
- timeago.js localization: `timeago.min.js` only contains English and Chinese by default, if you need to load other languages, you can configure it as below (choose one):
|
106
|
-
- In user.config.js
|
107
|
-
- In mkdocs.yml
|
108
|
-
|
106
|
+
- In `user.config.js`, refer to [the demo commented out](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) at the bottom, translate it into your local language
|
107
|
+
- In `mkdocs.yml`, add the following two lines to configure the full version of `timeago.full.min.js` to load all languages at once
|
109
108
|
```yaml
|
110
109
|
extra_javascript:
|
111
110
|
- assets/document_dates/core/timeago.full.min.js
|
@@ -116,8 +115,8 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
116
115
|
|
117
116
|
- In order to get the exact creation time, a separate cache file is used to store the creation time of the file, located in the doc folder (hidden by default), please don't delete it:
|
118
117
|
- `docs/.dates_cache.jsonl`, cache file
|
119
|
-
- `docs/.gitattributes`, merge mechanism for cache file
|
120
|
-
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (
|
118
|
+
- `docs/.gitattributes`, merge mechanism for cache file
|
119
|
+
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (on each git commit), and the cached file is automatically committed along with it. In addition, the installation of Git Hooks is automatically triggered when the plugin is installed, without any manual intervention!
|
121
120
|
|
122
121
|
<br />
|
123
122
|
|
{mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/cache_manager.py
RENAMED
@@ -13,13 +13,13 @@ logging.basicConfig(
|
|
13
13
|
)
|
14
14
|
|
15
15
|
def find_mkdocs_projects():
|
16
|
+
projects = []
|
16
17
|
try:
|
17
18
|
git_root = Path(subprocess.check_output(
|
18
19
|
['git', 'rev-parse', '--show-toplevel'],
|
19
20
|
text=True, encoding='utf-8'
|
20
21
|
).strip())
|
21
22
|
|
22
|
-
projects = []
|
23
23
|
# 遍历 git_root 及子目录, 寻找 mkdocs.yml 文件
|
24
24
|
for config_file in git_root.rglob('mkdocs.y*ml'):
|
25
25
|
if config_file.name.lower() in ('mkdocs.yml', 'mkdocs.yaml'):
|
@@ -27,13 +27,12 @@ def find_mkdocs_projects():
|
|
27
27
|
|
28
28
|
if not projects:
|
29
29
|
logging.info("No MkDocs projects found in the repository")
|
30
|
-
return projects
|
31
30
|
except subprocess.CalledProcessError as e:
|
32
31
|
logging.error(f"Failed to find the Git repository root: {e}")
|
33
|
-
return []
|
34
32
|
except Exception as e:
|
35
33
|
logging.error(f"Unexpected error while searching for MkDocs projects: {e}")
|
36
|
-
|
34
|
+
|
35
|
+
return projects
|
37
36
|
|
38
37
|
def get_file_creation_time(file_path):
|
39
38
|
try:
|
{mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/hooks_installer.py
RENAMED
@@ -23,7 +23,7 @@ def check_python_version(interpreter):
|
|
23
23
|
[interpreter, "-c", "import sys; print(sys.version_info >= (3, 7))"],
|
24
24
|
capture_output=True, text=True, check=False
|
25
25
|
)
|
26
|
-
if result.returncode == 0 and result.stdout.strip() == '
|
26
|
+
if result.returncode == 0 and result.stdout.strip().lower() == 'true':
|
27
27
|
return True
|
28
28
|
else:
|
29
29
|
logging.warning(f"Low python version, requires python_requires >=3.7")
|
@@ -54,7 +54,7 @@ class DocumentDatesPlugin(BasePlugin):
|
|
54
54
|
|
55
55
|
def __init__(self):
|
56
56
|
super().__init__()
|
57
|
-
self.
|
57
|
+
self.translation = {}
|
58
58
|
self.dates_cache = {}
|
59
59
|
self.is_git_repo = False
|
60
60
|
|
@@ -71,7 +71,7 @@ class DocumentDatesPlugin(BasePlugin):
|
|
71
71
|
docs_dir_path = Path(config['docs_dir'])
|
72
72
|
|
73
73
|
# 加载 json 语言文件
|
74
|
-
self.
|
74
|
+
self._load_translation(docs_dir_path)
|
75
75
|
|
76
76
|
# 加载日期缓存
|
77
77
|
jsonl_cache_file = docs_dir_path / '.dates_cache.jsonl'
|
@@ -208,36 +208,36 @@ class DocumentDatesPlugin(BasePlugin):
|
|
208
208
|
return self._insert_date_info(markdown, info_html)
|
209
209
|
|
210
210
|
|
211
|
-
def
|
211
|
+
def _load_translation(self, docs_dir_path):
|
212
212
|
# 内置语言文件目录
|
213
213
|
builtin_dir = Path(__file__).parent / 'static' / 'languages'
|
214
214
|
# 用户自定义语言文件目录
|
215
215
|
custom_dir = docs_dir_path / 'assets' / 'document_dates' / 'languages'
|
216
|
-
|
216
|
+
|
217
|
+
# 加载语言文件
|
218
|
+
self._load_lang_file(builtin_dir)
|
219
|
+
self._load_lang_file(custom_dir)
|
220
|
+
if not self.translation:
|
221
|
+
self.config['locale'] = 'en'
|
222
|
+
self._load_lang_file(builtin_dir)
|
223
|
+
|
217
224
|
# 复制 en.json 到用户目录作为自定义参考
|
218
225
|
custom_en_json = custom_dir / 'en.json'
|
219
226
|
if not custom_en_json.exists():
|
220
227
|
custom_dir.mkdir(parents=True, exist_ok=True)
|
221
228
|
en_json = builtin_dir / 'en.json'
|
222
229
|
shutil.copy2(en_json, custom_en_json)
|
223
|
-
|
224
|
-
return [builtin_dir, custom_dir]
|
225
|
-
|
226
|
-
def _load_translations(self, docs_dir_path):
|
227
|
-
translations = {}
|
228
|
-
|
229
|
-
for trans_dir in self._get_translation_dirs(docs_dir_path):
|
230
|
-
for lang_file in trans_dir.glob('*.json'):
|
231
|
-
try:
|
232
|
-
with lang_file.open('r', encoding='utf-8') as f:
|
233
|
-
lang_data = json.load(f)
|
234
|
-
translations[lang_file.stem] = lang_data
|
235
|
-
except json.JSONDecodeError as e:
|
236
|
-
logging.error(f"Invalid JSON format in language file {lang_file}: {str(e)}")
|
237
|
-
except Exception as e:
|
238
|
-
logging.error(f"Error loading language file {lang_file}: {str(e)}")
|
239
230
|
|
240
|
-
|
231
|
+
def _load_lang_file(self, lang_dir):
|
232
|
+
try:
|
233
|
+
locale_file = lang_dir / f"{self.config['locale']}.json"
|
234
|
+
if locale_file.exists():
|
235
|
+
with locale_file.open('r', encoding='utf-8') as f:
|
236
|
+
self.translation = json.load(f)
|
237
|
+
except json.JSONDecodeError as e:
|
238
|
+
logging.error(f"Invalid JSON format in language file {locale_file}: {str(e)}")
|
239
|
+
except Exception as e:
|
240
|
+
logging.error(f"Error loading language file {locale_file}: {str(e)}")
|
241
241
|
|
242
242
|
|
243
243
|
def _is_excluded(self, rel_path) -> bool:
|
@@ -277,7 +277,7 @@ class DocumentDatesPlugin(BasePlugin):
|
|
277
277
|
# 移除首尾可能存在的单双引号和时区信息
|
278
278
|
date_str = str(meta[field]).strip("'\"")
|
279
279
|
return datetime.fromisoformat(date_str).replace(tzinfo=None)
|
280
|
-
except
|
280
|
+
except Exception:
|
281
281
|
continue
|
282
282
|
return None
|
283
283
|
|
@@ -291,7 +291,7 @@ class DocumentDatesPlugin(BasePlugin):
|
|
291
291
|
if commits and commits[0]:
|
292
292
|
return datetime.fromisoformat(commits[0]).replace(tzinfo=None)
|
293
293
|
except Exception as e:
|
294
|
-
logging.
|
294
|
+
logging.warning(f"Error getting git first commit time for {file_path}: {e}")
|
295
295
|
return None
|
296
296
|
|
297
297
|
def _get_file_creation_time(self, file_path, rel_path):
|
@@ -342,45 +342,46 @@ class DocumentDatesPlugin(BasePlugin):
|
|
342
342
|
|
343
343
|
|
344
344
|
def _process_meta_author(self, meta):
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
if
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
if
|
375
|
-
name
|
376
|
-
|
377
|
-
|
345
|
+
try:
|
346
|
+
# 1. 处理 author 对象,或 author 字符串
|
347
|
+
author_data = meta.get('author')
|
348
|
+
if author_data:
|
349
|
+
if isinstance(author_data, dict):
|
350
|
+
name = str(author_data.get('name', ''))
|
351
|
+
if not name:
|
352
|
+
return None
|
353
|
+
email = str(author_data.get('email', ''))
|
354
|
+
# 提取扩展属性
|
355
|
+
extra_attrs = {k: str(v) for k, v in author_data.items()
|
356
|
+
if k not in ['name', 'email']}
|
357
|
+
return Author(name=name, email=email, **extra_attrs)
|
358
|
+
return Author(name=str(author_data))
|
359
|
+
|
360
|
+
# 2. 处理独立字段,匹配 author_field_mapping 配置
|
361
|
+
name = ''
|
362
|
+
email = ''
|
363
|
+
|
364
|
+
for name_field in self.config['author_field_mapping']['name']:
|
365
|
+
if name_field in meta:
|
366
|
+
name = str(meta[name_field])
|
367
|
+
break
|
368
|
+
|
369
|
+
for email_field in self.config['author_field_mapping']['email']:
|
370
|
+
if email_field in meta:
|
371
|
+
email = str(meta[email_field])
|
372
|
+
break
|
373
|
+
|
374
|
+
if name or email:
|
375
|
+
if not name and email:
|
376
|
+
name = email.split('@')[0]
|
377
|
+
return Author(name=name, email=email)
|
378
|
+
except Exception as e:
|
379
|
+
logging.warning(f"Error processing author meta: {e}")
|
378
380
|
return None
|
379
381
|
|
380
382
|
def _get_git_authors(self, file_path: str) -> Union[Author, List[Author], None]:
|
381
383
|
if not self.is_git_repo:
|
382
384
|
return None
|
383
|
-
|
384
385
|
try:
|
385
386
|
# # 检查文件是否在 Git 中
|
386
387
|
# check_file = subprocess.run(f'git ls-files --error-unmatch {file_path}',
|
@@ -398,11 +399,9 @@ class DocumentDatesPlugin(BasePlugin):
|
|
398
399
|
|
399
400
|
authors = []
|
400
401
|
unique_entries = set()
|
401
|
-
|
402
402
|
for line in git_log_result.stdout.strip().splitlines():
|
403
403
|
if not line or line in unique_entries:
|
404
404
|
continue
|
405
|
-
|
406
405
|
unique_entries.add(line)
|
407
406
|
name, email = line.split('|')
|
408
407
|
authors.append(Author(name=name, email=email))
|
@@ -411,18 +410,13 @@ class DocumentDatesPlugin(BasePlugin):
|
|
411
410
|
return None
|
412
411
|
|
413
412
|
return authors[0] if len(authors) == 1 else authors
|
414
|
-
|
415
413
|
except Exception as e:
|
416
414
|
logging.warning(f"Failed to get git author info: {str(e)}")
|
417
|
-
|
415
|
+
return None
|
418
416
|
|
419
417
|
def _get_local_author(self):
|
420
|
-
|
421
|
-
|
422
|
-
return Author(name=username)
|
423
|
-
except Exception as e:
|
424
|
-
logging.warning(f"Failed to get local author info: {str(e)}")
|
425
|
-
return None
|
418
|
+
username = Path.home().name
|
419
|
+
return Author(name=username)
|
426
420
|
|
427
421
|
|
428
422
|
def _get_formatted_date(self, date):
|
@@ -433,49 +427,50 @@ class DocumentDatesPlugin(BasePlugin):
|
|
433
427
|
return date.strftime(self.config['date_format'])
|
434
428
|
|
435
429
|
def _generate_html_info(self, created, modified, author=None):
|
436
|
-
|
437
|
-
|
438
|
-
locale = '
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
430
|
+
html = ""
|
431
|
+
try:
|
432
|
+
locale = 'zh_CN' if self.config['locale'] == 'zh' else self.config['locale']
|
433
|
+
position_class = 'document-dates-top' if self.config['position'] == 'top' else 'document-dates-bottom'
|
434
|
+
|
435
|
+
# 构建基本的日期信息 HTML
|
436
|
+
html += (
|
437
|
+
f"<div class='document-dates-plugin-wrapper {position_class}'>"
|
438
|
+
f"<div class='document-dates-plugin'>"
|
439
|
+
f"<span data-tippy-content='{self.translation.get('created_time', 'Created')}: {created.strftime(self.config['date_format'])}'>"
|
440
|
+
f"<span class='material-icons' data-icon='doc_created'></span>"
|
441
|
+
f"<time datetime='{created.isoformat()}' locale='{locale}'>{self._get_formatted_date(created)}</time></span>"
|
442
|
+
f"<span data-tippy-content='{self.translation.get('modified_time', 'Last Update')}: {modified.strftime(self.config['date_format'])}'>"
|
443
|
+
f"<span class='material-icons' data-icon='doc_modified'></span>"
|
444
|
+
f"<time datetime='{modified.isoformat()}' locale='{locale}'>{self._get_formatted_date(modified)}</time></span>"
|
445
|
+
)
|
446
|
+
|
447
|
+
# 添加作者信息
|
448
|
+
if self.config['show_author'] and author:
|
449
|
+
if isinstance(author, list):
|
450
|
+
# 多个作者的情况
|
451
|
+
authors_info = ', '.join(a.name for a in author if a.name)
|
452
|
+
authors_tooltip = ', '.join(f'<a href="mailto:{a.email}">{a.name}</a>' if a.email else a.name for a in author)
|
453
|
+
|
454
|
+
html += (
|
455
|
+
f"<span data-tippy-content='{self.translation.get('authors', 'Authors')}: {authors_tooltip}'>"
|
456
|
+
f"<span class='material-icons' data-icon='doc_authors'></span>"
|
457
|
+
f"{authors_info}</span>"
|
458
|
+
# f"{authors_tooltip}</span>"
|
459
|
+
)
|
460
|
+
else:
|
461
|
+
# 单个作者的情况
|
462
|
+
author_tooltip = f'<a href="mailto:{author.email}">{author.name}</a>' if author.email else author.name
|
463
|
+
html += (
|
464
|
+
f"<span data-tippy-content='{self.translation.get('author', 'Author')}: {author_tooltip}'>"
|
465
|
+
f"<span class='material-icons' data-icon='doc_author'></span>"
|
466
|
+
f"{author.name}</span>"
|
467
|
+
# f"{author_tooltip}</span>"
|
468
|
+
)
|
469
|
+
|
470
|
+
html += f"</div></div>"
|
477
471
|
|
478
|
-
|
472
|
+
except Exception as e:
|
473
|
+
logging.warning(f"Error generating HTML info: {e}")
|
479
474
|
return html
|
480
475
|
|
481
476
|
|
{mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates.egg-info/PKG-INFO
RENAMED
@@ -1,9 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.3
|
4
4
|
Summary: An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents.
|
5
5
|
Home-page: https://github.com/jaywhj/mkdocs-document-dates
|
6
6
|
Author: Aaron Wang
|
7
|
+
Author-email: aaronwqt@gmail.com
|
7
8
|
License: MIT
|
8
9
|
Classifier: Programming Language :: Python :: 3
|
9
10
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -13,6 +14,7 @@ Description-Content-Type: text/markdown
|
|
13
14
|
License-File: LICENSE
|
14
15
|
Requires-Dist: mkdocs>=1.0.0
|
15
16
|
Dynamic: author
|
17
|
+
Dynamic: author-email
|
16
18
|
Dynamic: classifier
|
17
19
|
Dynamic: description
|
18
20
|
Dynamic: description-content-type
|
@@ -73,14 +75,14 @@ plugins:
|
|
73
75
|
position: top # Display position: top (after title) bottom (end of document), default: bottom
|
74
76
|
type: date # Date type: date datetime timeago, default: date
|
75
77
|
locale: en # Localization: zh zh_TW en es fr de ar ja ko ru, default: en
|
76
|
-
date_format: '%Y-%m-%d' # Date format,
|
78
|
+
date_format: '%Y-%m-%d' # Date format, supports all python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
77
79
|
time_format: '%H:%M:%S' # Time format (valid only if type=datetime)
|
78
80
|
exclude: # List of excluded files
|
79
81
|
- temp.md # Exclude specific file
|
80
82
|
- private/* # Exclude all files in private directory, including subdirectories
|
81
83
|
- drafts/*.md # Exclude all markdown files in the current directory drafts, but not subdirectories
|
82
84
|
|
83
|
-
show_author: true #
|
85
|
+
show_author: true # Show author or not: true false, default: true
|
84
86
|
|
85
87
|
```
|
86
88
|
|
@@ -128,9 +130,8 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
128
130
|
- Properties & Animations: `docs/assets/document_dates/user.config.js`
|
129
131
|
- Localized languages: `docs/assets/document_dates/languages/` , refer to the template file `en.json` for any additions or modifications
|
130
132
|
- timeago.js localization: `timeago.min.js` only contains English and Chinese by default, if you need to load other languages, you can configure it as below (choose one):
|
131
|
-
- In user.config.js
|
132
|
-
- In mkdocs.yml
|
133
|
-
|
133
|
+
- In `user.config.js`, refer to [the demo commented out](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) at the bottom, translate it into your local language
|
134
|
+
- In `mkdocs.yml`, add the following two lines to configure the full version of `timeago.full.min.js` to load all languages at once
|
134
135
|
```yaml
|
135
136
|
extra_javascript:
|
136
137
|
- assets/document_dates/core/timeago.full.min.js
|
@@ -141,8 +142,8 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
141
142
|
|
142
143
|
- In order to get the exact creation time, a separate cache file is used to store the creation time of the file, located in the doc folder (hidden by default), please don't delete it:
|
143
144
|
- `docs/.dates_cache.jsonl`, cache file
|
144
|
-
- `docs/.gitattributes`, merge mechanism for cache file
|
145
|
-
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (
|
145
|
+
- `docs/.gitattributes`, merge mechanism for cache file
|
146
|
+
- The Git Hooks mechanism is used to automatically trigger the storing of the cache (on each git commit), and the cached file is automatically committed along with it. In addition, the installation of Git Hooks is automatically triggered when the plugin is installed, without any manual intervention!
|
146
147
|
|
147
148
|
<br />
|
148
149
|
|
@@ -28,7 +28,7 @@ mkdocs_document_dates/static/languages/ja.json
|
|
28
28
|
mkdocs_document_dates/static/languages/ko.json
|
29
29
|
mkdocs_document_dates/static/languages/ru.json
|
30
30
|
mkdocs_document_dates/static/languages/zh.json
|
31
|
-
mkdocs_document_dates/static/languages/
|
31
|
+
mkdocs_document_dates/static/languages/zh_TW.json
|
32
32
|
mkdocs_document_dates/static/tippy/backdrop.css
|
33
33
|
mkdocs_document_dates/static/tippy/light.css
|
34
34
|
mkdocs_document_dates/static/tippy/material.css
|
@@ -30,12 +30,13 @@ try:
|
|
30
30
|
except FileNotFoundError:
|
31
31
|
long_description = "An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents."
|
32
32
|
|
33
|
-
VERSION = '3.1.
|
33
|
+
VERSION = '3.1.3'
|
34
34
|
|
35
35
|
setup(
|
36
36
|
name="mkdocs-document-dates",
|
37
37
|
version=VERSION,
|
38
38
|
author="Aaron Wang",
|
39
|
+
author_email="aaronwqt@gmail.com",
|
39
40
|
license="MIT",
|
40
41
|
description="An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents.",
|
41
42
|
long_description=long_description,
|
File without changes
|
{mkdocs_document_dates-3.1.2 → mkdocs_document_dates-3.1.3}/mkdocs_document_dates/__init__.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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|