mkdocs-document-dates 3.5__tar.gz → 3.5.1__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.5/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.5.1}/PKG-INFO +15 -6
  2. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/README.md +13 -4
  3. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/plugin.py +31 -35
  4. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/config/user.config.css +29 -25
  5. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/config/user.config.js +2 -0
  6. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/core.css +133 -71
  7. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/core.js +28 -0
  8. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/default.config.js +1 -0
  9. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/utils.py +47 -4
  10. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1/mkdocs_document_dates.egg-info}/PKG-INFO +15 -6
  11. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/setup.py +2 -2
  12. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/LICENSE +0 -0
  13. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/MANIFEST.in +0 -0
  14. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/__init__.py +0 -0
  15. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/cache_manager.py +0 -0
  16. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/hooks/pre-commit +0 -0
  17. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/hooks_installer.py +0 -0
  18. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
  19. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
  20. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/utils.js +0 -0
  21. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/fonts/material-icons.css +0 -0
  22. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
  23. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/templates/recently_updated.html +0 -0
  24. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
  25. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/light.css +0 -0
  26. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/material.css +0 -0
  27. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
  28. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/scale.css +0 -0
  29. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
  30. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
  31. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
  32. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  33. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  34. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  35. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  36. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  37. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/pyproject.toml +0 -0
  38. {mkdocs_document_dates-3.5 → mkdocs_document_dates-3.5.1}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.5
4
- Summary: A new generation MkDocs plugin for displaying exact creation time, last update time, authors, email of documents
3
+ Version: 3.5.1
4
+ Summary: A new generation MkDocs plugin for displaying exact creation date, last updated date, authors, email of documents
5
5
  Home-page: https://github.com/jaywhj/mkdocs-document-dates
6
6
  Author: Aaron Wang
7
7
  Author-email: aaronwqt@gmail.com
@@ -44,9 +44,7 @@ A new generation MkDocs plugin for displaying exact **creation date, last update
44
44
  - [x] Support for manually configuring author's name, link, avatar, email, etc.
45
45
  - [x] Flexible display position (top or bottom)
46
46
  - [x] Elegant styling (fully customizable)
47
- - [x] Smart Tooltip Hover Tips
48
47
  - [x] Multi-language support, localization support, intelligent recognition of user language, automatic adaptation
49
- - [x] Cross-platform support (Windows, macOS, Linux)
50
48
  - [x] **Ultimate build efficiency**: O(1), no need to set the env var `!ENV` to distinguish runs
51
49
 
52
50
  | Build Speed Comparison: | 100 md: | 1000 md: | Time Complexity: |
@@ -94,10 +92,21 @@ In addition to the above basic configuration, the plug-in also provides a wealth
94
92
  - [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): Introduces the mechanism for obtaining document authors and methods for personalized customization, you can manually specify the author information for each document, such as name, link, avatar, email, etc.
95
93
  - [Specify Avatar](https://jaywhj.netlify.app/document-dates-en#Specify-Avatar): You can manually specify the avatar for each author, support local file path and URL path
96
94
  - [Set Plugin Style](https://jaywhj.netlify.app/document-dates-en#Set-Plugin-Style): You can quickly set the plugin styles through preset entrances, such as icons, themes, colors, fonts, animations, dividing line and so on
97
- - [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
98
- - [Use Template Variables](https://jaywhj.netlify.app/document-dates-en#Use-Template-Variables): Can be used to optimize `sitemap.xml` for site SEO, can be used to re-customize plug-ins, etc.
95
+ - [Use Template Variables](https://jaywhj.netlify.app/document-dates-en#Use-Template-Variables): Can be used to optimize `sitemap.xml` for site SEO; Can be used to re-customize plug-ins, etc.
99
96
  - [Add Recently Updated Module](https://jaywhj.netlify.app/document-dates-en#Add-Recently-Updated-Module): Enable list of recently updated documents (in descending order of update date), this is ideal for sites with a large number of documents, so that readers can quickly see what's new
97
+ - [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
100
98
  - [Other Tips](https://jaywhj.netlify.app/document-dates-en#Other-Tips): Introducing the Do's of using plugin in Docker
101
99
  - [Development Stories](https://jaywhj.netlify.app/document-dates-en#Development-Stories): Describes the origin of the plug-in, the difficulties and solutions encountered in development, and the principles and directions of product design
102
100
 
103
101
  See the documentation for details: https://jaywhj.netlify.app/document-dates-en
102
+
103
+
104
+ <br />
105
+
106
+ ## Chat Group
107
+
108
+ **Discord**: https://discord.gg/cvTfge4AUy
109
+
110
+ **Wechat**:
111
+
112
+ <img src="wechat-group.jpg" width="140" />
@@ -18,9 +18,7 @@ A new generation MkDocs plugin for displaying exact **creation date, last update
18
18
  - [x] Support for manually configuring author's name, link, avatar, email, etc.
19
19
  - [x] Flexible display position (top or bottom)
20
20
  - [x] Elegant styling (fully customizable)
21
- - [x] Smart Tooltip Hover Tips
22
21
  - [x] Multi-language support, localization support, intelligent recognition of user language, automatic adaptation
23
- - [x] Cross-platform support (Windows, macOS, Linux)
24
22
  - [x] **Ultimate build efficiency**: O(1), no need to set the env var `!ENV` to distinguish runs
25
23
 
26
24
  | Build Speed Comparison: | 100 md: | 1000 md: | Time Complexity: |
@@ -68,10 +66,21 @@ In addition to the above basic configuration, the plug-in also provides a wealth
68
66
  - [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): Introduces the mechanism for obtaining document authors and methods for personalized customization, you can manually specify the author information for each document, such as name, link, avatar, email, etc.
69
67
  - [Specify Avatar](https://jaywhj.netlify.app/document-dates-en#Specify-Avatar): You can manually specify the avatar for each author, support local file path and URL path
70
68
  - [Set Plugin Style](https://jaywhj.netlify.app/document-dates-en#Set-Plugin-Style): You can quickly set the plugin styles through preset entrances, such as icons, themes, colors, fonts, animations, dividing line and so on
71
- - [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
72
- - [Use Template Variables](https://jaywhj.netlify.app/document-dates-en#Use-Template-Variables): Can be used to optimize `sitemap.xml` for site SEO, can be used to re-customize plug-ins, etc.
69
+ - [Use Template Variables](https://jaywhj.netlify.app/document-dates-en#Use-Template-Variables): Can be used to optimize `sitemap.xml` for site SEO; Can be used to re-customize plug-ins, etc.
73
70
  - [Add Recently Updated Module](https://jaywhj.netlify.app/document-dates-en#Add-Recently-Updated-Module): Enable list of recently updated documents (in descending order of update date), this is ideal for sites with a large number of documents, so that readers can quickly see what's new
71
+ - [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
74
72
  - [Other Tips](https://jaywhj.netlify.app/document-dates-en#Other-Tips): Introducing the Do's of using plugin in Docker
75
73
  - [Development Stories](https://jaywhj.netlify.app/document-dates-en#Development-Stories): Describes the origin of the plug-in, the difficulties and solutions encountered in development, and the principles and directions of product design
76
74
 
77
75
  See the documentation for details: https://jaywhj.netlify.app/document-dates-en
76
+
77
+
78
+ <br />
79
+
80
+ ## Chat Group
81
+
82
+ **Discord**: https://discord.gg/cvTfge4AUy
83
+
84
+ **Wechat**:
85
+
86
+ <img src="wechat-group.jpg" width="140" />
@@ -54,7 +54,6 @@ class DocumentDatesPlugin(BasePlugin):
54
54
  docs_dir_path = Path(config['docs_dir'])
55
55
 
56
56
  # 加载 author 配置
57
- self._extract_github_username(config.get('repo_url'))
58
57
  authors_file = docs_dir_path / 'authors.yml'
59
58
  if not authors_file.exists():
60
59
  try:
@@ -158,10 +157,6 @@ class DocumentDatesPlugin(BasePlugin):
158
157
 
159
158
  # 获取作者信息
160
159
  authors = self._get_author_info(rel_path, page, config)
161
- if authors and len(authors) == 1:
162
- a = authors[0]
163
- if not a.avatar and self.github_username:
164
- a.avatar = f"https://avatars.githubusercontent.com/{self.github_username}"
165
160
 
166
161
  # 在排除前暴露 meta 信息给前端使用
167
162
  page.meta['document_dates_created'] = created.isoformat()
@@ -225,17 +220,6 @@ class DocumentDatesPlugin(BasePlugin):
225
220
  shutil.copy2(item, target_dir / item.name)
226
221
 
227
222
 
228
- def _extract_github_username(self, url):
229
- try:
230
- parsed = urlparse(url)
231
- if parsed.netloc != 'github.com':
232
- return
233
- path_parts = [p for p in parsed.path.split('/') if p]
234
- if path_parts:
235
- self.github_username = path_parts[0]
236
- except Exception as e:
237
- logger.info(f"Error parsing URL: {e}")
238
-
239
223
  def _load_authors_from_yaml(self, file_path: Path):
240
224
  if not file_path.exists():
241
225
  return
@@ -380,7 +364,12 @@ class DocumentDatesPlugin(BasePlugin):
380
364
 
381
365
  def _generate_html_info(self, created: datetime, updated: datetime, authors=None):
382
366
  try:
383
- # 构建基本的日期信息 HTML
367
+ show_dates = self.config['show_created'] or self.config['show_updated']
368
+ show_plugin = show_dates or self.config['show_author']
369
+ if not show_plugin:
370
+ return ""
371
+
372
+ # 构建插件骨架 HTML
384
373
  html_parts = []
385
374
  position_class = 'document-dates-top' if self.config['position'] == 'top' else 'document-dates-bottom'
386
375
  html_parts.append(f"<div class='document-dates-plugin-wrapper {position_class}'>")
@@ -389,18 +378,23 @@ class DocumentDatesPlugin(BasePlugin):
389
378
  def build_time_icon(time_obj: datetime, icon: str):
390
379
  formatted = time_obj.strftime(self.config['date_format'])
391
380
  return (
392
- f"<span data-tippy-content data-tippy-raw='{formatted}'>"
381
+ f"<span class='dd-item' data-tippy-content data-tippy-raw='{formatted}'>"
393
382
  f"<span class='material-icons' data-icon='{icon}'></span>"
394
- f"<time datetime='{time_obj.isoformat()}'>"
395
- f"{self._get_formatted_date(time_obj)}</time></span>"
383
+ f"<time datetime='{time_obj.isoformat()}'>{self._get_formatted_date(time_obj)}</time>"
384
+ f"</span>"
396
385
  )
397
386
 
387
+ # 构建日期
388
+ if show_dates:
389
+ html_parts.append("<div class='dd-left'>")
398
390
  if self.config['show_created']:
399
391
  html_parts.append(build_time_icon(created, 'doc_created'))
400
392
  if self.config['show_updated']:
401
393
  html_parts.append(build_time_icon(updated, 'doc_updated'))
394
+ if show_dates:
395
+ html_parts.append("</div>")
402
396
 
403
- # 添加作者信息
397
+ # 构建作者
404
398
  if self.config['show_author'] and authors:
405
399
  def get_author_tooltip(author):
406
400
  if author.url:
@@ -409,23 +403,22 @@ class DocumentDatesPlugin(BasePlugin):
409
403
  return f'<a href="mailto:{author.email}">{author.name}</a>'
410
404
  return author.name
411
405
 
406
+ if show_dates:
407
+ html_parts.append("<div class='dd-right'>")
408
+ else:
409
+ html_parts.append("<div class='dd-right dd-right-start'>")
410
+ icon = 'doc_author' if len(authors) == 1 else 'doc_authors'
411
+ html_parts.append(f"<span class='material-icons' data-icon='{icon}'></span>")
412
+ html_parts.append("<div class='author-group'>")
412
413
  if self.config['show_author'] == 'text':
413
414
  # 显示文本模式
414
- tooltip_text = ',&nbsp;'.join(get_author_tooltip(author) for author in authors)
415
- # author_text = ', '.join(author.name for author in authors)
416
- icon = 'doc_author' if len(authors) == 1 else 'doc_authors'
417
- html_parts.append(
418
- f"<span data-tippy-content data-tippy-raw='{tooltip_text}'>"
419
- f"<span class='material-icons' data-icon='{icon}'></span>"
420
- f"{tooltip_text}"
421
- # f"{author_text}"
422
- f"</span>"
423
- )
415
+ for index, author in enumerate(authors):
416
+ if index > 0:
417
+ html_parts.append(",&nbsp;&nbsp;")
418
+ tooltip = get_author_tooltip(author)
419
+ html_parts.append(f"<span class='text-wrapper' data-tippy-content data-tippy-raw='{ tooltip }'>{ tooltip }</span>")
424
420
  else:
425
421
  # 显示头像模式(默认)
426
- icon = 'doc_author' if len(authors) == 1 else 'doc_authors'
427
- html_parts.append(f"<span class='material-icons' data-icon='{icon}'></span>")
428
- html_parts.append("<div class='avatar-group'>")
429
422
  for author in authors:
430
423
  tooltip = get_author_tooltip(author)
431
424
  html_parts.append(
@@ -434,7 +427,8 @@ class DocumentDatesPlugin(BasePlugin):
434
427
  f"<img class='avatar' src='{author.avatar}' onerror=\"this.style.display='none'\" />"
435
428
  f"</div>"
436
429
  )
437
- html_parts.append("</div>")
430
+ html_parts.append("</div>")
431
+ html_parts.append("</div>")
438
432
 
439
433
  html_parts.append("</div></div>")
440
434
  return ''.join(html_parts)
@@ -445,6 +439,8 @@ class DocumentDatesPlugin(BasePlugin):
445
439
 
446
440
 
447
441
  def _insert_date_info(self, markdown: str, date_info: str):
442
+ if not date_info:
443
+ return markdown
448
444
  if self.config['position'] == 'top':
449
445
  first_line, insert_pos = self._find_markdown_body_start(markdown)
450
446
  if first_line.startswith(('# ', '<h1')):
@@ -1,7 +1,20 @@
1
- /* 1. Plug-in styles
2
- including icons, fonts, colors, etc
1
+ /* 1. Plug-in wrapper styles
2
+ including divider line, margin, padding, and the hiding of this plugin, etc
3
3
  */
4
+
5
+ /* Remove the divider line: */
4
6
  /*
7
+ .document-dates-plugin-wrapper.document-dates-top,
8
+ .document-dates-plugin-wrapper.document-dates-bottom {
9
+ border-bottom: none;
10
+ } */
11
+
12
+
13
+
14
+ /* 2. Plug-in styles
15
+ including icons, fonts, colors, etc
16
+ */
17
+ /*
5
18
  .md-main .document-dates-plugin {
6
19
  color: rgba(109, 157, 204, 0.7);
7
20
  font-size: 0.75rem;
@@ -18,7 +31,7 @@
18
31
  doc_author: person, account_circle
19
32
  doc_authors: group, groups */
20
33
 
21
- /*
34
+ /*
22
35
  .document-dates-plugin .material-icons[data-icon="doc_created"]::before {
23
36
  content: "more_time";
24
37
  }
@@ -34,23 +47,28 @@
34
47
 
35
48
 
36
49
 
37
- /* 2. Plug-in wrapper styles
38
- including divider line, margin, padding, and the hiding of this plugin, etc
50
+ /* 3. Author Avatar styles
51
+ e.g. shape, hover scale, grayscale mode
39
52
  */
40
-
41
- /* Remove the divider line: */
42
53
  /*
43
- .document-dates-plugin-wrapper.document-dates-top,
44
- .document-dates-plugin-wrapper.document-dates-bottom {
45
- border-bottom: none;
54
+ .avatar-wrapper {
55
+ border-radius: 4px;
56
+ filter: grayscale(0%);
57
+ }
58
+ .avatar-wrapper:hover {
59
+ transform: scale(1.08);
46
60
  } */
47
61
 
48
62
 
49
63
 
50
- /* 3. Tooltip styles
64
+ /* 4. Tooltip styles
51
65
  including theme, arrow, font, color, background color, etc
52
66
  */
53
67
 
68
+ /* .tippy-box {
69
+ font-size: 12px;
70
+ } */
71
+
54
72
  /* Demo of the custom theme 'sorrel' and 'sublime', you can configure it in user.config.js (optional) */
55
73
  /*
56
74
  .tippy-box[data-theme~='sorrel'] {
@@ -68,17 +86,3 @@
68
86
  .tippy-box[data-theme~='sublime'] > .tippy-arrow::before {
69
87
  color: #474747;
70
88
  } */
71
-
72
-
73
-
74
- /* 4. Author Avatar styles
75
- e.g. shape, hover scale, grayscale mode
76
- */
77
- /*
78
- .avatar-wrapper {
79
- border-radius: 4px;
80
- filter: grayscale(0%);
81
- }
82
- .avatar-wrapper:hover {
83
- transform: scale(1.08);
84
- } */
@@ -8,6 +8,7 @@ Part 1:
8
8
  // tooltip_config.theme.light = 'tomato';
9
9
  // tooltip_config.placement = 'top';
10
10
  // tooltip_config.arrow = false;
11
+ // tooltip_config.zIndex = 2;
11
12
 
12
13
  /* Or, override all configuration items: */
13
14
  /*
@@ -23,6 +24,7 @@ TooltipConfig.setConfig({
23
24
  interactive: true, // content in Tooltip is interactive
24
25
  animation: 'scale', // animation type: scale shift-away
25
26
  inertia: true, // animation inertia
27
+ // zIndex: 2, // control the display layer(z-index) of the tooltip element
26
28
  // arrow: false, // whether to allow arrows
27
29
  // animateFill: true, // determines if the background fill color should be animated
28
30
  // delay: [400, null], // delay: [show, hide]: show is 400ms, and hide is null for the default value
@@ -1,12 +1,31 @@
1
+ /* ==========================================================================
2
+ 1. Plug-in wrapper styles
3
+ ========================================================================== */
4
+ .document-dates-plugin-wrapper.document-dates-top,
5
+ .document-dates-plugin-wrapper.document-dates-bottom {
6
+ margin: 1rem 0;
7
+ border-bottom: 1px solid rgba(142, 142, 142, 0.1);
8
+ }
9
+ .md-main .document-dates-plugin-wrapper.document-dates-top {
10
+ margin: -1rem 0 1rem 0;
11
+ }
1
12
 
2
- /* 1. Plug-in styles
3
- including icons, fonts, colors, etc
4
- */
13
+ /* Hide the footnote divider immediately following the date information with the CSS adjacent sibling selector */
14
+ .document-dates-plugin-wrapper + .footnote hr {
15
+ display: none;
16
+ }
17
+
18
+
19
+ /* ==========================================================================
20
+ 2. Plug-in Layout & Fonts
21
+ ========================================================================== */
5
22
  .document-dates-plugin {
6
23
  color: #666;
7
24
  font-size: 0.9rem;
8
25
  display: flex;
26
+ /* flex-wrap: nowrap; */
9
27
  align-items: center;
28
+ justify-content: space-between;
10
29
  padding: 0.2rem 0;
11
30
  margin-bottom: 0.6rem;
12
31
  }
@@ -14,17 +33,14 @@
14
33
  color: rgba(142, 142, 142, 0.7);
15
34
  font-size: 0.75rem;
16
35
  }
17
- .document-dates-plugin > span {
18
- display: inline-flex;
19
- align-items: center;
20
- }
21
- .document-dates-plugin > span:not(:first-child) {
22
- margin-left: 1.5rem;
23
- }
36
+
24
37
  .document-dates-plugin .material-icons {
25
38
  font-size: 1rem;
26
39
  opacity: 0.85;
27
40
  margin-right: 0.3rem;
41
+ display: inline-flex;
42
+ align-items: center;
43
+ line-height: 1;
28
44
  }
29
45
  .md-main .document-dates-plugin .material-icons {
30
46
  font-size: 0.9rem;
@@ -51,92 +67,79 @@
51
67
  content: "group";
52
68
  }
53
69
 
54
-
55
-
56
- /* 2. Plug-in wrapper styles
57
- including divider, margin, padding, etc
58
- */
59
- .document-dates-plugin-wrapper.document-dates-top,
60
- .document-dates-plugin-wrapper.document-dates-bottom {
61
- margin: 1rem 0;
62
- border-bottom: 1px solid rgba(142, 142, 142, 0.1);
70
+ .dd-left {
71
+ display: flex;
72
+ align-items: center;
73
+ margin-right: 1.5rem;
63
74
  }
64
- .md-main .document-dates-plugin-wrapper.document-dates-top {
65
- margin: -1rem 0 1rem 0;
75
+ .dd-item {
76
+ display: inline-flex;
77
+ align-items: center;
78
+ white-space: nowrap;
79
+ flex-shrink: 0;
80
+ line-height: 1;
81
+ }
82
+ .dd-left > .dd-item + .dd-item {
83
+ margin-left: 1.5rem;
66
84
  }
67
85
 
68
- /* Hide the footnote divider immediately following the date information with the CSS adjacent sibling selector */
69
- .document-dates-plugin-wrapper + .footnote hr {
70
- display: none;
86
+ .dd-right {
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: flex-end;
90
+ flex: 1 1 auto;
91
+ min-width: 110px;
71
92
  }
72
93
 
94
+ .dd-right.dd-right-start {
95
+ justify-content: flex-start;
96
+ }
73
97
 
98
+ /* ==========================================================================
99
+ 3. Author Avatar styles
100
+ ========================================================================== */
101
+ .author-group {
102
+ display: flex;
103
+ align-items: center;
104
+ flex-wrap: nowrap;
74
105
 
75
- /* 3. Tooltip styles
76
- including theme, arrow, font, color, background color, etc
77
- */
106
+ overflow-x: auto;
107
+ overflow-y: hidden;
78
108
 
79
- /* .tippy-box {
80
- font-size: 12px;
81
- } */
109
+ /* Prevent overflow of child elements when scaling */
110
+ padding: 0.15rem 0.15rem 0.15rem 0;
82
111
 
83
- /* Demo of the custom theme 'tomato' (optional) */
84
- .tippy-box[data-theme~='tomato'] {
85
- background-color: tomato;
86
- color: white;
87
- }
88
- /* Customize the arrow corresponding to the theme tomato */
89
- .tippy-box[data-theme~='tomato'] > .tippy-arrow::before {
90
- color: tomato;
91
- }
92
- /*
93
- Recommended Colors:
94
- tomato: rgb(241, 112, 91);
95
- mung_bean: rgb(122, 145, 109);
96
- cloisonné: rgb(15, 89, 164);
97
- soft_blue: rgb(16, 104, 152);
98
- */
112
+ margin-right: 10px;
99
113
 
100
- /* Customize arrows, resize */
101
- .tippy-arrow::before {
102
- -webkit-transform: scale(0.75);
103
- -ms-transform: scale(0.75);
104
- transform: scale(0.75);
114
+ scrollbar-width: none;
115
+ -ms-overflow-style: none;
105
116
  }
106
-
107
-
108
-
109
- /* 4. Author Avatar styles */
110
- .avatar-group {
111
- display: flex;
112
- align-items: center;
113
- flex-wrap: wrap;
114
- margin: -0.15rem;
115
- padding-left: 0.15rem;
117
+ .author-group::-webkit-scrollbar {
118
+ display: none;
116
119
  }
120
+
117
121
  .avatar-wrapper {
118
- margin: 0.15rem;
122
+ margin-left: 0.3rem;
119
123
  position: relative;
120
- width: 30px;
121
- height: 30px;
124
+ width: 32px;
125
+ height: 32px;
122
126
  border-radius: 50%;
123
127
  overflow: hidden;
124
128
  flex-shrink: 0;
125
- opacity: 0.7;
129
+ opacity: 0.85;
126
130
  filter: grayscale(90%);
127
131
  transition: transform 0.2s ease, filter 0.2s ease;
132
+ display: block;
133
+
134
+ /* Fix bug in Safari: rounded corners may blink to show square corners */
135
+ will-change: transform;
136
+ transform: translateZ(0);
128
137
  }
129
138
  .avatar-wrapper:hover {
130
139
  transform: scale(1.08);
131
140
  filter: grayscale(0%);
132
141
  cursor: pointer;
133
142
  }
134
- .avatar-wrapper img.avatar {
135
- position: absolute;
136
- width: 100%;
137
- height: 100%;
138
- object-fit: cover;
139
- }
140
143
  .avatar-wrapper .avatar-text {
141
144
  position: absolute;
142
145
  width: 100%;
@@ -150,3 +153,62 @@ Recommended Colors:
150
153
  justify-content: center;
151
154
  text-transform: capitalize;
152
155
  }
156
+ .avatar-wrapper img.avatar {
157
+ position: absolute;
158
+ width: 100%;
159
+ height: 100%;
160
+ object-fit: cover;
161
+ }
162
+
163
+ /* Show authors in text mode */
164
+ .author-group .text-wrapper {
165
+ display: inline-flex;
166
+ align-items: center;
167
+ white-space: nowrap;
168
+ flex-shrink: 0;
169
+ }
170
+
171
+ /* Optimize the experience with line breaks on very narrow screens */
172
+ @media screen and (max-width: 359px) {
173
+ .document-dates-plugin {
174
+ flex-wrap: wrap;
175
+ }
176
+ .dd-right {
177
+ justify-content: flex-start;
178
+ width: 100%;
179
+ margin: 10px 0 0 0;
180
+ }
181
+ }
182
+
183
+
184
+ /* ==========================================================================
185
+ 4. Tooltip styles, including theme, arrow, font, color, background color, etc
186
+ ========================================================================== */
187
+
188
+ /* .tippy-box {
189
+ font-size: 12px;
190
+ } */
191
+
192
+ /* Demo of the custom theme 'tomato' (optional) */
193
+ .tippy-box[data-theme~='tomato'] {
194
+ background-color: tomato;
195
+ color: white;
196
+ }
197
+ /* Customize the arrow corresponding to the theme tomato */
198
+ .tippy-box[data-theme~='tomato'] > .tippy-arrow::before {
199
+ color: tomato;
200
+ }
201
+ /*
202
+ Recommended Colors:
203
+ tomato: rgb(241, 112, 91);
204
+ mung_bean: rgb(122, 145, 109);
205
+ cloisonné: rgb(15, 89, 164);
206
+ soft_blue: rgb(16, 104, 152);
207
+ */
208
+
209
+ /* Customize arrows, resize */
210
+ .tippy-arrow::before {
211
+ -webkit-transform: scale(0.75);
212
+ -ms-transform: scale(0.75);
213
+ transform: scale(0.75);
214
+ }
@@ -145,6 +145,33 @@ function initTippy() {
145
145
  return context;
146
146
  }
147
147
 
148
+ // 在滚动时隐藏 author-group 的 tooltip
149
+ function initAuthorGroupTippyGuard() {
150
+ document.querySelectorAll('.author-group').forEach(groupEl => {
151
+ if (groupEl._ddTippyGuardAbortController) {
152
+ groupEl._ddTippyGuardAbortController.abort();
153
+ }
154
+ const controller = new AbortController();
155
+ groupEl._ddTippyGuardAbortController = controller;
156
+
157
+ const getInstances = () => {
158
+ return Array.from(groupEl.querySelectorAll('[data-tippy-content]'))
159
+ .map(el => el._tippy)
160
+ .filter(Boolean);
161
+ };
162
+ const hideNow = () => {
163
+ const instances = getInstances();
164
+ instances.forEach(instance => {
165
+ instance.hide();
166
+ });
167
+ };
168
+
169
+ const opts = { passive: true, signal: controller.signal };
170
+ groupEl.addEventListener('scroll', hideNow, opts);
171
+ groupEl.addEventListener('touchmove', hideNow, opts);
172
+ });
173
+ }
174
+
148
175
  // 通过 IIFE(立即执行的函数表达式)创建 tippyManager
149
176
  const tippyManager = (() => {
150
177
  let tippyInstances = [];
@@ -174,6 +201,7 @@ const tippyManager = (() => {
174
201
  if (context && context.observer) {
175
202
  observer = context.observer;
176
203
  }
204
+ initAuthorGroupTippyGuard();
177
205
  }
178
206
  };
179
207
  })();
@@ -13,6 +13,7 @@ const ttDefaultConfig = {
13
13
  interactive: true, // 是否允许内容交互
14
14
  animation: 'scale', // 动画类型: scale shift-away
15
15
  inertia: true, // 是否允许动画惯性
16
+ zIndex: 2, // 控制 tooltip 元素的显示层级(z-index)
16
17
  // arrow: false, // 是否允许箭头
17
18
  // animateFill: true, // 背景填充颜色是否应为动画效果
18
19
  // delay: [400, null], // 动画延迟: [show, hide]: show 为 400 毫秒, hide 为 null 表示默认值
@@ -3,6 +3,8 @@ import platform
3
3
  import json
4
4
  import heapq
5
5
  import logging
6
+ import hashlib
7
+ import requests
6
8
  import subprocess
7
9
  from pathlib import Path
8
10
  from datetime import datetime
@@ -66,10 +68,11 @@ def load_git_metadata(docs_dir_path: Path):
66
68
  cmd = ['git', 'log', '--reverse', '--no-merges', '--use-mailmap', '--name-only', '--format=%aN|%aE|%aI', f'--relative={rel_docs_path}', '--', '*.md']
67
69
  process = subprocess.run(cmd, cwd=docs_dir_path, capture_output=True, encoding='utf-8')
68
70
  if process.returncode == 0:
71
+ init_avatar_provider()
72
+
69
73
  authors_dict = defaultdict(dict)
70
74
  first_commit = {}
71
75
  current_commit = None
72
-
73
76
  for line in process.stdout.splitlines():
74
77
  line = line.strip()
75
78
  if not line:
@@ -82,14 +85,14 @@ def load_git_metadata(docs_dir_path: Path):
82
85
  # 使用 defaultdict(dict)结构,处理有序与去重
83
86
  # a.巧用 Python 字典的 setdefault 特性来去重(setdefault 为不存在的键提供初始值,不会覆盖已有值)
84
87
  # b.巧用 Python 字典的插入顺序特性来保留内容插入顺序(Python 3.7+ 字典会保持插入顺序)
85
- authors_dict[line].setdefault((name, email), None)
88
+ authors_dict[line].setdefault((name, email, get_avatar_url(email)), None)
86
89
  first_commit.setdefault(line, created)
87
90
 
88
91
  # 构建最终的缓存数据
89
92
  for file_path in first_commit:
90
93
  authors_list = [
91
- {'name': name, 'email': email}
92
- for name, email in authors_dict[file_path].keys() # 这里的 keys() 是有序的
94
+ {'name': name, 'email': email, 'avatar': avatar}
95
+ for name, email, avatar in authors_dict[file_path].keys() # 这里的 keys() 是有序的
93
96
  ]
94
97
  dates_cache[file_path] = {
95
98
  'created': first_commit[file_path],
@@ -209,3 +212,43 @@ def write_jsonl_cache(jsonl_file: Path, dates_cache, tracked_files):
209
212
  except Exception as e:
210
213
  logger.warning(f"Failed to add JSONL cache file to git: {e}")
211
214
  return False
215
+
216
+
217
+ _GRAVATAR = "https://www.gravatar.com/avatar" # Gravatar 头像,全球通用头像服务商,国内访问不稳定 ✓
218
+ _WEAVATAR = "https://weavatar.com/avatar" # Gravatar 国内镜像,实测发现国内外访问都正常,数据跟 Gravatar 一致 ✓
219
+ _CRAVATAR = "https://cravatar.cn/avatar" # 国内头像服务商,有国际 CDN,很多开源项目在用,实测发现只包含部分 Gravatar 数据
220
+ _BASE: str = None
221
+
222
+ def get_avatar_url(email: str, size: int = 64, default: str = "404") -> str:
223
+ """
224
+ Generate a avatar URL from an email address.
225
+
226
+ :param email: Author email
227
+ :param size: Avatar size in pixels (1~2048)
228
+ :param default: Default avatar style when no avatar exists
229
+ options: '404' 'wavatar' 'retro' 'identicon' 'mp' 'monsterid' 'robohash' 'blank'
230
+ :return: Avatar URL
231
+ """
232
+
233
+ if not _BASE or not email:
234
+ return ""
235
+
236
+ email_hash = hashlib.md5(email.strip().lower().encode("utf-8")).hexdigest()
237
+ return f"{_BASE}/{email_hash}?d={default}&s={size}"
238
+
239
+ def init_avatar_provider(timeout: float = 0.5) -> None:
240
+ global _BASE
241
+
242
+ if _BASE is not None:
243
+ return
244
+
245
+ for base in (_GRAVATAR, _WEAVATAR):
246
+ try:
247
+ r = requests.head(f"{base}/", timeout=timeout, allow_redirects=True)
248
+ if r.status_code < 500:
249
+ _BASE = base
250
+ return
251
+ except requests.RequestException:
252
+ continue
253
+
254
+ _BASE = ""
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.5
4
- Summary: A new generation MkDocs plugin for displaying exact creation time, last update time, authors, email of documents
3
+ Version: 3.5.1
4
+ Summary: A new generation MkDocs plugin for displaying exact creation date, last updated date, authors, email of documents
5
5
  Home-page: https://github.com/jaywhj/mkdocs-document-dates
6
6
  Author: Aaron Wang
7
7
  Author-email: aaronwqt@gmail.com
@@ -44,9 +44,7 @@ A new generation MkDocs plugin for displaying exact **creation date, last update
44
44
  - [x] Support for manually configuring author's name, link, avatar, email, etc.
45
45
  - [x] Flexible display position (top or bottom)
46
46
  - [x] Elegant styling (fully customizable)
47
- - [x] Smart Tooltip Hover Tips
48
47
  - [x] Multi-language support, localization support, intelligent recognition of user language, automatic adaptation
49
- - [x] Cross-platform support (Windows, macOS, Linux)
50
48
  - [x] **Ultimate build efficiency**: O(1), no need to set the env var `!ENV` to distinguish runs
51
49
 
52
50
  | Build Speed Comparison: | 100 md: | 1000 md: | Time Complexity: |
@@ -94,10 +92,21 @@ In addition to the above basic configuration, the plug-in also provides a wealth
94
92
  - [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author): Introduces the mechanism for obtaining document authors and methods for personalized customization, you can manually specify the author information for each document, such as name, link, avatar, email, etc.
95
93
  - [Specify Avatar](https://jaywhj.netlify.app/document-dates-en#Specify-Avatar): You can manually specify the avatar for each author, support local file path and URL path
96
94
  - [Set Plugin Style](https://jaywhj.netlify.app/document-dates-en#Set-Plugin-Style): You can quickly set the plugin styles through preset entrances, such as icons, themes, colors, fonts, animations, dividing line and so on
97
- - [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
98
- - [Use Template Variables](https://jaywhj.netlify.app/document-dates-en#Use-Template-Variables): Can be used to optimize `sitemap.xml` for site SEO, can be used to re-customize plug-ins, etc.
95
+ - [Use Template Variables](https://jaywhj.netlify.app/document-dates-en#Use-Template-Variables): Can be used to optimize `sitemap.xml` for site SEO; Can be used to re-customize plug-ins, etc.
99
96
  - [Add Recently Updated Module](https://jaywhj.netlify.app/document-dates-en#Add-Recently-Updated-Module): Enable list of recently updated documents (in descending order of update date), this is ideal for sites with a large number of documents, so that readers can quickly see what's new
97
+ - [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
100
98
  - [Other Tips](https://jaywhj.netlify.app/document-dates-en#Other-Tips): Introducing the Do's of using plugin in Docker
101
99
  - [Development Stories](https://jaywhj.netlify.app/document-dates-en#Development-Stories): Describes the origin of the plug-in, the difficulties and solutions encountered in development, and the principles and directions of product design
102
100
 
103
101
  See the documentation for details: https://jaywhj.netlify.app/document-dates-en
102
+
103
+
104
+ <br />
105
+
106
+ ## Chat Group
107
+
108
+ **Discord**: https://discord.gg/cvTfge4AUy
109
+
110
+ **Wechat**:
111
+
112
+ <img src="wechat-group.jpg" width="140" />
@@ -23,7 +23,7 @@ class CustomInstallCommand(install):
23
23
  install.run(self)
24
24
 
25
25
 
26
- VERSION = '3.5'
26
+ VERSION = '3.5.1'
27
27
 
28
28
  setup(
29
29
  name="mkdocs-document-dates",
@@ -31,7 +31,7 @@ setup(
31
31
  author="Aaron Wang",
32
32
  author_email="aaronwqt@gmail.com",
33
33
  license="MIT",
34
- description="A new generation MkDocs plugin for displaying exact creation time, last update time, authors, email of documents",
34
+ description="A new generation MkDocs plugin for displaying exact creation date, last updated date, authors, email of documents",
35
35
  long_description=open("README.md", encoding="utf-8").read(),
36
36
  long_description_content_type="text/markdown",
37
37
  url="https://github.com/jaywhj/mkdocs-document-dates",