mkdocs-document-dates 3.4.6__tar.gz → 3.4.7__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.
Files changed (38) hide show
  1. {mkdocs_document_dates-3.4.6/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.4.7}/PKG-INFO +3 -2
  2. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/README.md +2 -1
  3. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/plugin.py +26 -37
  4. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/core/core.js +2 -6
  5. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7/mkdocs_document_dates.egg-info}/PKG-INFO +3 -2
  6. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/setup.py +1 -1
  7. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/LICENSE +0 -0
  8. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/MANIFEST.in +0 -0
  9. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/__init__.py +0 -0
  10. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/cache_manager.py +0 -0
  11. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/hooks/pre-commit +0 -0
  12. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/hooks_installer.py +0 -0
  13. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/config/user.config.css +0 -0
  14. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/config/user.config.js +0 -0
  15. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/core/core.css +0 -0
  16. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/core/default.config.js +0 -0
  17. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
  18. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
  19. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/core/utils.js +0 -0
  20. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/fonts/material-icons.css +0 -0
  21. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
  22. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/templates/recently_updated.html +0 -0
  23. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
  24. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/tippy/light.css +0 -0
  25. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/tippy/material.css +0 -0
  26. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
  27. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/tippy/scale.css +0 -0
  28. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
  29. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
  30. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
  31. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates/utils.py +0 -0
  32. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  33. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  34. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  35. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  36. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  37. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/pyproject.toml +0 -0
  38. {mkdocs_document_dates-3.4.6 → mkdocs_document_dates-3.4.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.4.6
3
+ Version: 3.4.7
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,6 +41,7 @@ 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
@@ -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,6 +15,7 @@ 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
@@ -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`
@@ -16,21 +16,12 @@ logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
16
16
 
17
17
 
18
18
  class Author:
19
- def __init__(self, name="", email="", avatar="", url="", desc=""):
19
+ def __init__(self, name="", email="", avatar="", url="", description="", **kwargs):
20
20
  self.name = name
21
21
  self.email = email
22
22
  self.avatar = avatar
23
23
  self.url = url
24
- self.desc = desc
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
- }
24
+ self.description = description
34
25
 
35
26
 
36
27
  class DocumentDatesPlugin(BasePlugin):
@@ -264,14 +255,7 @@ class DocumentDatesPlugin(BasePlugin):
264
255
  with open(file_path, 'r', encoding='utf-8') as f:
265
256
  data = yaml.safe_load(f)
266
257
  for key, info in (data or {}).get('authors', {}).items():
267
- author = Author(
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
258
+ self.authors_yml[key] = Author(**info)
275
259
  except Exception as e:
276
260
  logger.info(f"Error parsing .authors.yml: {e}")
277
261
 
@@ -314,9 +298,23 @@ class DocumentDatesPlugin(BasePlugin):
314
298
  if rel_path in self.dates_cache:
315
299
  authors_list = self.dates_cache[rel_path].get('authors')
316
300
  if authors_list:
317
- return [Author(**dict) for dict in authors_list]
301
+ authors = []
302
+ for dict in authors_list:
303
+ full_author = self.authors_yml.get(dict['name'])
304
+ if full_author:
305
+ authors.append(full_author)
306
+ # authors.append(Author(**{**vars(full_author), **dict}))
307
+ else:
308
+ authors.append(Author(**dict))
309
+ return authors
318
310
  # 3. site_author 或 PC username
319
- return [Author(name=config.get('site_author') or Path.home().name)]
311
+ name = config.get('site_author') or Path.home().name
312
+ full_author = self.authors_yml.get(name)
313
+ if full_author:
314
+ return [full_author]
315
+ # return [Author(**{**vars(full_author), "name": name})]
316
+ else:
317
+ return [Author(name=name)]
320
318
 
321
319
  def _process_meta_author(self, meta):
322
320
  try:
@@ -331,27 +329,18 @@ class DocumentDatesPlugin(BasePlugin):
331
329
  if author_objs:
332
330
  return author_objs
333
331
 
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
332
  # 匹配独立字段: name, email
349
333
  name = meta.get('name')
350
334
  email = meta.get('email')
351
335
  if name or email:
352
336
  if not name and email:
353
337
  name = email.partition('@')[0]
354
- return [Author(name=name, email=email)]
338
+ full_author = self.authors_yml.get(name)
339
+ if full_author:
340
+ return [full_author]
341
+ # return [Author(**{**vars(full_author), "name": name, "email": email or full_author.email})]
342
+ else:
343
+ return [Author(name=name, email=email)]
355
344
  except Exception as e:
356
345
  logger.warning(f"Error processing author meta: {e}")
357
346
  return None
@@ -422,7 +411,7 @@ class DocumentDatesPlugin(BasePlugin):
422
411
  html_parts.append(
423
412
  f"<div class='avatar-wrapper' data-name='{author.name}' data-tippy-content data-tippy-raw='{tooltip}'>"
424
413
  f"<span class='avatar-text'></span>"
425
- f"<img class='avatar' data-src='{img_url}' />"
414
+ f"<img class='avatar' src='{img_url}' onerror=\"this.style.display='none'\" />"
426
415
  f"</div>"
427
416
  )
428
417
  html_parts.append("</div>")
@@ -34,12 +34,8 @@ function generateAvatar() {
34
34
 
35
35
  const imgEl = wrapper.querySelector('img.avatar');
36
36
  if (imgEl) {
37
- // 先设置 onerror,再设置 src(设置src时就会立即触发加载)
38
- imgEl.onerror = () => imgEl.style.display = 'none';
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
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.4.6
3
+ Version: 3.4.7
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,6 +41,7 @@ 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
@@ -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`
@@ -23,7 +23,7 @@ class CustomInstallCommand(install):
23
23
  install.run(self)
24
24
 
25
25
 
26
- VERSION = '3.4.6'
26
+ VERSION = '3.4.7'
27
27
 
28
28
  setup(
29
29
  name="mkdocs-document-dates",