mkdocs-document-dates 3.4.9__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.
- {mkdocs_document_dates-3.4.9/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.5.1}/PKG-INFO +30 -19
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/README.md +28 -17
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/plugin.py +100 -97
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/config/user.config.css +32 -26
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/config/user.config.js +5 -3
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/core.css +135 -73
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/core.js +29 -1
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/default.config.js +13 -12
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/templates/recently_updated.html +4 -4
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/utils.py +80 -38
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1/mkdocs_document_dates.egg-info}/PKG-INFO +30 -19
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/setup.py +2 -2
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/LICENSE +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/MANIFEST.in +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/__init__.py +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/cache_manager.py +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/hooks/pre-commit +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/hooks_installer.py +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/core/utils.js +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/fonts/material-icons.css +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/light.css +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/material.css +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/scale.css +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/requires.txt +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/pyproject.toml +0 -0
- {mkdocs_document_dates-3.4.9 → mkdocs_document_dates-3.5.1}/setup.cfg +0 -0
{mkdocs_document_dates-3.4.9/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.5.1}/PKG-INFO
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-document-dates
|
|
3
|
-
Version: 3.
|
|
4
|
-
Summary: A new generation MkDocs plugin for displaying exact creation
|
|
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
|
|
@@ -30,28 +30,26 @@ English | [简体中文](README_zh.md)
|
|
|
30
30
|
|
|
31
31
|
<br />
|
|
32
32
|
|
|
33
|
-
A new generation MkDocs plugin for displaying exact **creation
|
|
33
|
+
A new generation MkDocs plugin for displaying exact **creation date, last updated date, authors, email** of documents
|
|
34
34
|
|
|
35
35
|

|
|
36
36
|
|
|
37
37
|
## Features
|
|
38
38
|
|
|
39
|
-
- [x] Always displays **exact** meta information of the document and works in any environment (no
|
|
40
|
-
- [x] Support list display of recently updated documents (in descending order of update
|
|
41
|
-
- [x] Support for manually specifying
|
|
42
|
-
- [x] Support for multiple
|
|
39
|
+
- [x] Always displays **exact** meta information of the document and works in any environment (no-Git, Git environments, Docker, all CI/CD build systems, etc.)
|
|
40
|
+
- [x] Support list display of recently updated documents (in descending order of update date)
|
|
41
|
+
- [x] Support for manually specifying date and author in `Front Matter`
|
|
42
|
+
- [x] Support for multiple date formats (date, datetime, timeago)
|
|
43
43
|
- [x] Support for multiple author modes (avatar, text, hidden)
|
|
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: |
|
|
53
51
|
| --------------------------- | :-----: | :------: | :----------: |
|
|
54
|
-
| git-revision-date-localized |
|
|
52
|
+
| git-revision-date-localized<br />git-authors | > 3 s | > 30 s | O(n) |
|
|
55
53
|
| document-dates | < 0.1 s | < 0.15 s | O(1) |
|
|
56
54
|
|
|
57
55
|
## Installation
|
|
@@ -74,28 +72,41 @@ Or, full configuration:
|
|
|
74
72
|
```yaml
|
|
75
73
|
plugins:
|
|
76
74
|
- document-dates:
|
|
77
|
-
position: top # Display position: top(after title) bottom(end of document)
|
|
75
|
+
position: top # Display position: top(after title) bottom(end of document), default: top
|
|
78
76
|
type: date # Date type: date datetime timeago, default: date
|
|
79
77
|
exclude: # List of excluded files
|
|
80
78
|
- temp.md # Example: exclude the specified file
|
|
81
79
|
- blog/* # Example: exclude all files in blog folder, including subfolders
|
|
82
80
|
date_format: '%Y-%m-%d' # Date format strings (e.g., %Y-%m-%d, %b %d, %Y)
|
|
83
81
|
time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
|
|
84
|
-
|
|
82
|
+
show_created: true # Show creation date: true false, default: true
|
|
83
|
+
show_updated: true # Show last updated date: true false, default: true
|
|
84
|
+
show_author: true # Show author: true(avatar) text(text) false(hidden), default: true
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
## Customization Settings
|
|
88
88
|
|
|
89
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:
|
|
90
90
|
|
|
91
|
-
- [Specify Datetime](https://jaywhj.netlify.app/document-dates-en#Specify-Datetime):
|
|
92
|
-
- [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author):
|
|
93
|
-
- [Specify Avatar](https://jaywhj.netlify.app/document-dates-en#Specify-Avatar): You can manually specify the avatar for each author
|
|
94
|
-
- [Set Plugin Style](https://jaywhj.netlify.app/document-dates-en#Set-Plugin-Style):
|
|
91
|
+
- [Specify Datetime](https://jaywhj.netlify.app/document-dates-en#Specify-Datetime): Introduces the mechanism for obtaining document dates and methods for personalized customization, you can manually specify the creation date and last updated date for each document
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
95
97
|
- [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
|
|
96
|
-
- [
|
|
97
|
-
- [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 time)
|
|
98
|
-
- [Other Tips](https://jaywhj.netlify.app/document-dates-en#Other-Tips): Introduction to technical principles, caching mechanisms, and how to use it in Docker
|
|
98
|
+
- [Other Tips](https://jaywhj.netlify.app/document-dates-en#Other-Tips): Introducing the Do's of using plugin in Docker
|
|
99
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
|
|
100
100
|
|
|
101
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" />
|
|
@@ -4,28 +4,26 @@ English | [简体中文](README_zh.md)
|
|
|
4
4
|
|
|
5
5
|
<br />
|
|
6
6
|
|
|
7
|
-
A new generation MkDocs plugin for displaying exact **creation
|
|
7
|
+
A new generation MkDocs plugin for displaying exact **creation date, last updated date, authors, email** of documents
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
- [x] Always displays **exact** meta information of the document and works in any environment (no
|
|
14
|
-
- [x] Support list display of recently updated documents (in descending order of update
|
|
15
|
-
- [x] Support for manually specifying
|
|
16
|
-
- [x] Support for multiple
|
|
13
|
+
- [x] Always displays **exact** meta information of the document and works in any environment (no-Git, Git environments, Docker, all CI/CD build systems, etc.)
|
|
14
|
+
- [x] Support list display of recently updated documents (in descending order of update date)
|
|
15
|
+
- [x] Support for manually specifying date and author in `Front Matter`
|
|
16
|
+
- [x] Support for multiple date formats (date, datetime, timeago)
|
|
17
17
|
- [x] Support for multiple author modes (avatar, text, hidden)
|
|
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: |
|
|
27
25
|
| --------------------------- | :-----: | :------: | :----------: |
|
|
28
|
-
| git-revision-date-localized |
|
|
26
|
+
| git-revision-date-localized<br />git-authors | > 3 s | > 30 s | O(n) |
|
|
29
27
|
| document-dates | < 0.1 s | < 0.15 s | O(1) |
|
|
30
28
|
|
|
31
29
|
## Installation
|
|
@@ -48,28 +46,41 @@ Or, full configuration:
|
|
|
48
46
|
```yaml
|
|
49
47
|
plugins:
|
|
50
48
|
- document-dates:
|
|
51
|
-
position: top # Display position: top(after title) bottom(end of document)
|
|
49
|
+
position: top # Display position: top(after title) bottom(end of document), default: top
|
|
52
50
|
type: date # Date type: date datetime timeago, default: date
|
|
53
51
|
exclude: # List of excluded files
|
|
54
52
|
- temp.md # Example: exclude the specified file
|
|
55
53
|
- blog/* # Example: exclude all files in blog folder, including subfolders
|
|
56
54
|
date_format: '%Y-%m-%d' # Date format strings (e.g., %Y-%m-%d, %b %d, %Y)
|
|
57
55
|
time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
|
|
58
|
-
|
|
56
|
+
show_created: true # Show creation date: true false, default: true
|
|
57
|
+
show_updated: true # Show last updated date: true false, default: true
|
|
58
|
+
show_author: true # Show author: true(avatar) text(text) false(hidden), default: true
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
## Customization Settings
|
|
62
62
|
|
|
63
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:
|
|
64
64
|
|
|
65
|
-
- [Specify Datetime](https://jaywhj.netlify.app/document-dates-en#Specify-Datetime):
|
|
66
|
-
- [Specify Author](https://jaywhj.netlify.app/document-dates-en#Specify-Author):
|
|
67
|
-
- [Specify Avatar](https://jaywhj.netlify.app/document-dates-en#Specify-Avatar): You can manually specify the avatar for each author
|
|
68
|
-
- [Set Plugin Style](https://jaywhj.netlify.app/document-dates-en#Set-Plugin-Style):
|
|
65
|
+
- [Specify Datetime](https://jaywhj.netlify.app/document-dates-en#Specify-Datetime): Introduces the mechanism for obtaining document dates and methods for personalized customization, you can manually specify the creation date and last updated date for each document
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
69
71
|
- [Add Localization Language](https://jaywhj.netlify.app/document-dates-en#Add-Localization-Language): More localization languages for `timeago` and `tooltip`
|
|
70
|
-
- [
|
|
71
|
-
- [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 time)
|
|
72
|
-
- [Other Tips](https://jaywhj.netlify.app/document-dates-en#Other-Tips): Introduction to technical principles, caching mechanisms, and how to use it in Docker
|
|
72
|
+
- [Other Tips](https://jaywhj.netlify.app/document-dates-en#Other-Tips): Introducing the Do's of using plugin in Docker
|
|
73
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
|
|
74
74
|
|
|
75
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" />
|
|
@@ -10,7 +10,7 @@ from mkdocs.config import config_options
|
|
|
10
10
|
from mkdocs.structure.pages import Page
|
|
11
11
|
from mkdocs.utils import get_relative_url
|
|
12
12
|
from urllib.parse import urlparse
|
|
13
|
-
from .utils import get_file_creation_time,
|
|
13
|
+
from .utils import get_file_creation_time, load_git_metadata, load_git_last_updated_date, read_jsonl_cache,is_excluded, get_recently_updated_files
|
|
14
14
|
|
|
15
15
|
logger = logging.getLogger("mkdocs.plugins.document_dates")
|
|
16
16
|
logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
@@ -34,7 +34,9 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
34
34
|
('position', config_options.Type(str, default='top')),
|
|
35
35
|
('exclude', config_options.Type(list, default=[])),
|
|
36
36
|
('created_field_names', config_options.Type(list, default=['created', 'date'])),
|
|
37
|
-
('
|
|
37
|
+
('updated_field_names', config_options.Type(list, default=['updated', 'modified'])),
|
|
38
|
+
('show_created', config_options.Type(bool, default=True)),
|
|
39
|
+
('show_updated', config_options.Type(bool, default=True)),
|
|
38
40
|
('show_author', config_options.Choice((True, False, 'text'), default=True)),
|
|
39
41
|
('recently-updated', config_options.Type((dict, bool), default={}))
|
|
40
42
|
)
|
|
@@ -52,21 +54,19 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
52
54
|
docs_dir_path = Path(config['docs_dir'])
|
|
53
55
|
|
|
54
56
|
# 加载 author 配置
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
#
|
|
68
|
-
self.dates_cache = load_git_cache(docs_dir_path)
|
|
69
|
-
# 覆盖 jsonl 文件缓存
|
|
57
|
+
authors_file = docs_dir_path / 'authors.yml'
|
|
58
|
+
if not authors_file.exists():
|
|
59
|
+
try:
|
|
60
|
+
blog_config = config['plugins']['material/blog'].config
|
|
61
|
+
authors_file_resolved = blog_config.authors_file.format(blog=blog_config.blog_dir)
|
|
62
|
+
authors_file = docs_dir_path / authors_file_resolved
|
|
63
|
+
except Exception:
|
|
64
|
+
pass
|
|
65
|
+
self._load_authors_from_yaml(authors_file)
|
|
66
|
+
|
|
67
|
+
# 加载文档元数据
|
|
68
|
+
self.dates_cache = load_git_metadata(docs_dir_path)
|
|
69
|
+
# 覆盖 jsonl 缓存
|
|
70
70
|
jsonl_cache_file = docs_dir_path / '.dates_cache.jsonl'
|
|
71
71
|
if jsonl_cache_file.exists():
|
|
72
72
|
jsonl_cache = read_jsonl_cache(jsonl_cache_file)
|
|
@@ -74,6 +74,10 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
74
74
|
if filename in self.dates_cache:
|
|
75
75
|
self.dates_cache[filename].update(new_info)
|
|
76
76
|
|
|
77
|
+
# 加载文档最近更新时间
|
|
78
|
+
self.last_updated_dates = load_git_last_updated_date(docs_dir_path)
|
|
79
|
+
|
|
80
|
+
|
|
77
81
|
# 复制配置文件到用户目录(如果不存在)
|
|
78
82
|
dest_dir = docs_dir_path / 'assets' / 'document_dates'
|
|
79
83
|
dest_dir.mkdir(parents=True, exist_ok=True)
|
|
@@ -136,35 +140,6 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
136
140
|
|
|
137
141
|
return config
|
|
138
142
|
|
|
139
|
-
def on_nav(self, nav, config, files):
|
|
140
|
-
recently_updated_config = self.config.get('recently-updated')
|
|
141
|
-
if recently_updated_config:
|
|
142
|
-
self.recent_enable = True
|
|
143
|
-
|
|
144
|
-
# 兼容 true 配置
|
|
145
|
-
if recently_updated_config is True:
|
|
146
|
-
recently_updated_config = {}
|
|
147
|
-
|
|
148
|
-
# 获取配置
|
|
149
|
-
exclude_list = recently_updated_config.get('exclude', [])
|
|
150
|
-
limit = recently_updated_config.get('limit', 10)
|
|
151
|
-
template_path = recently_updated_config.get('template')
|
|
152
|
-
|
|
153
|
-
# 获取最近更新日期和最近更新的文档数据
|
|
154
|
-
docs_dir = Path(config['docs_dir'])
|
|
155
|
-
self.last_updated_dates, recently_updated_docs = get_recently_updated_files(docs_dir, files, exclude_list, limit, self.recent_enable)
|
|
156
|
-
|
|
157
|
-
# 将数据注入到 config['extra'] 中供全局访问
|
|
158
|
-
if 'extra' not in config:
|
|
159
|
-
config['extra'] = {}
|
|
160
|
-
config['extra']['recently_updated_docs'] = recently_updated_docs
|
|
161
|
-
|
|
162
|
-
# 渲染HTML
|
|
163
|
-
if self.recent_enable:
|
|
164
|
-
self.recent_docs_html = self._render_recently_updated_html(docs_dir, template_path, recently_updated_docs)
|
|
165
|
-
|
|
166
|
-
return nav
|
|
167
|
-
|
|
168
143
|
def on_page_markdown(self, markdown, page: Page, config, files):
|
|
169
144
|
# 获取相对路径,src_uri 总是以"/"分隔
|
|
170
145
|
rel_path = getattr(page.file, 'src_uri', page.file.src_path)
|
|
@@ -174,38 +149,65 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
174
149
|
|
|
175
150
|
# 获取时间信息
|
|
176
151
|
created = self._find_meta_date(page.meta, self.config['created_field_names'])
|
|
177
|
-
|
|
152
|
+
updated = self._find_meta_date(page.meta, self.config['updated_field_names'])
|
|
178
153
|
if not created:
|
|
179
154
|
created = self._get_file_creation_time(file_path, rel_path)
|
|
180
|
-
if not
|
|
181
|
-
|
|
155
|
+
if not updated:
|
|
156
|
+
updated = self._get_file_modification_time(file_path, rel_path)
|
|
182
157
|
|
|
183
158
|
# 获取作者信息
|
|
184
159
|
authors = self._get_author_info(rel_path, page, config)
|
|
185
|
-
if authors and 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}"
|
|
189
160
|
|
|
190
161
|
# 在排除前暴露 meta 信息给前端使用
|
|
191
162
|
page.meta['document_dates_created'] = created.isoformat()
|
|
192
|
-
page.meta['
|
|
163
|
+
page.meta['document_dates_updated'] = updated.isoformat()
|
|
193
164
|
page.meta['document_dates_authors'] = authors
|
|
194
165
|
|
|
195
|
-
# 占位符替换
|
|
196
|
-
if self.recent_enable and '\n<!-- RECENTLY_UPDATED_DOCS -->' in markdown:
|
|
197
|
-
markdown = markdown.replace('\n<!-- RECENTLY_UPDATED_DOCS -->', self.recent_docs_html or '')
|
|
198
|
-
|
|
199
166
|
# 检查是否需要排除
|
|
200
167
|
if is_excluded(rel_path, self.config['exclude']):
|
|
201
168
|
return markdown
|
|
202
169
|
|
|
203
170
|
# 生成日期和作者信息 HTML
|
|
204
|
-
info_html = self._generate_html_info(created,
|
|
171
|
+
info_html = self._generate_html_info(created, updated, authors)
|
|
205
172
|
|
|
206
173
|
# 将信息写入 markdown
|
|
207
174
|
return self._insert_date_info(markdown, info_html)
|
|
208
175
|
|
|
176
|
+
def on_env(self, env, config, files):
|
|
177
|
+
recently_updated_config = self.config.get('recently-updated')
|
|
178
|
+
if recently_updated_config:
|
|
179
|
+
self.recent_enable = True
|
|
180
|
+
|
|
181
|
+
# 兼容 true 配置
|
|
182
|
+
if recently_updated_config is True:
|
|
183
|
+
recently_updated_config = {}
|
|
184
|
+
|
|
185
|
+
# 获取配置
|
|
186
|
+
exclude_list = recently_updated_config.get('exclude', [])
|
|
187
|
+
limit = recently_updated_config.get('limit', 10)
|
|
188
|
+
template_path = recently_updated_config.get('template')
|
|
189
|
+
|
|
190
|
+
# 获取最近更新的文档数据
|
|
191
|
+
recently_updated_docs = get_recently_updated_files(self.last_updated_dates, files, exclude_list, limit, self.recent_enable)
|
|
192
|
+
|
|
193
|
+
# 将数据注入到 config['extra'] 中供全局访问
|
|
194
|
+
if 'extra' not in config:
|
|
195
|
+
config['extra'] = {}
|
|
196
|
+
config['extra']['recently_updated_docs'] = recently_updated_docs
|
|
197
|
+
|
|
198
|
+
# 渲染HTML
|
|
199
|
+
if self.recent_enable:
|
|
200
|
+
docs_dir = Path(config['docs_dir'])
|
|
201
|
+
self.recent_docs_html = self._render_recently_updated_html(docs_dir, template_path, recently_updated_docs)
|
|
202
|
+
|
|
203
|
+
return env
|
|
204
|
+
|
|
205
|
+
def on_post_page(self, output, page, config):
|
|
206
|
+
if self.recent_enable and '\n<!-- RECENTLY_UPDATED_DOCS -->' in output:
|
|
207
|
+
output = output.replace('\n<!-- RECENTLY_UPDATED_DOCS -->', self.recent_docs_html or '')
|
|
208
|
+
|
|
209
|
+
return output
|
|
210
|
+
|
|
209
211
|
def on_post_build(self, config):
|
|
210
212
|
site_dest_dir = Path(config['site_dir']) / 'assets' / 'document_dates'
|
|
211
213
|
for dir_name in ['tippy', 'core', 'fonts']:
|
|
@@ -218,17 +220,6 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
218
220
|
shutil.copy2(item, target_dir / item.name)
|
|
219
221
|
|
|
220
222
|
|
|
221
|
-
def _extract_github_username(self, url):
|
|
222
|
-
try:
|
|
223
|
-
parsed = urlparse(url)
|
|
224
|
-
if parsed.netloc != 'github.com':
|
|
225
|
-
return
|
|
226
|
-
path_parts = [p for p in parsed.path.split('/') if p]
|
|
227
|
-
if path_parts:
|
|
228
|
-
self.github_username = path_parts[0]
|
|
229
|
-
except Exception as e:
|
|
230
|
-
logger.info(f"Error parsing URL: {e}")
|
|
231
|
-
|
|
232
223
|
def _load_authors_from_yaml(self, file_path: Path):
|
|
233
224
|
if not file_path.exists():
|
|
234
225
|
return
|
|
@@ -258,8 +249,8 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
258
249
|
|
|
259
250
|
# 加载模板
|
|
260
251
|
env = Environment(
|
|
261
|
-
loader=FileSystemLoader(str(template_dir)),
|
|
262
|
-
autoescape=select_autoescape(["html", "xml"])
|
|
252
|
+
loader = FileSystemLoader(str(template_dir)),
|
|
253
|
+
autoescape = select_autoescape(["html", "xml"])
|
|
263
254
|
)
|
|
264
255
|
template = env.get_template(template_file)
|
|
265
256
|
|
|
@@ -295,9 +286,6 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
295
286
|
|
|
296
287
|
|
|
297
288
|
def _get_author_info(self, rel_path, page, config):
|
|
298
|
-
if not self.config['show_author']:
|
|
299
|
-
return None
|
|
300
|
-
|
|
301
289
|
# 1. meta author
|
|
302
290
|
authors = self._process_meta_author(page.meta, page.url)
|
|
303
291
|
if authors:
|
|
@@ -374,9 +362,14 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
374
362
|
return date.strftime(f"{self.config['date_format']} {self.config['time_format']}")
|
|
375
363
|
return date.strftime(self.config['date_format'])
|
|
376
364
|
|
|
377
|
-
def _generate_html_info(self, created: datetime,
|
|
365
|
+
def _generate_html_info(self, created: datetime, updated: datetime, authors=None):
|
|
378
366
|
try:
|
|
379
|
-
|
|
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
|
|
380
373
|
html_parts = []
|
|
381
374
|
position_class = 'document-dates-top' if self.config['position'] == 'top' else 'document-dates-bottom'
|
|
382
375
|
html_parts.append(f"<div class='document-dates-plugin-wrapper {position_class}'>")
|
|
@@ -385,16 +378,23 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
385
378
|
def build_time_icon(time_obj: datetime, icon: str):
|
|
386
379
|
formatted = time_obj.strftime(self.config['date_format'])
|
|
387
380
|
return (
|
|
388
|
-
f"<span data-tippy-content data-tippy-raw='{formatted}'>"
|
|
381
|
+
f"<span class='dd-item' data-tippy-content data-tippy-raw='{formatted}'>"
|
|
389
382
|
f"<span class='material-icons' data-icon='{icon}'></span>"
|
|
390
|
-
f"<time datetime='{time_obj.isoformat()}'>"
|
|
391
|
-
f"
|
|
383
|
+
f"<time datetime='{time_obj.isoformat()}'>{self._get_formatted_date(time_obj)}</time>"
|
|
384
|
+
f"</span>"
|
|
392
385
|
)
|
|
393
386
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
387
|
+
# 构建日期
|
|
388
|
+
if show_dates:
|
|
389
|
+
html_parts.append("<div class='dd-left'>")
|
|
390
|
+
if self.config['show_created']:
|
|
391
|
+
html_parts.append(build_time_icon(created, 'doc_created'))
|
|
392
|
+
if self.config['show_updated']:
|
|
393
|
+
html_parts.append(build_time_icon(updated, 'doc_updated'))
|
|
394
|
+
if show_dates:
|
|
395
|
+
html_parts.append("</div>")
|
|
396
|
+
|
|
397
|
+
# 构建作者
|
|
398
398
|
if self.config['show_author'] and authors:
|
|
399
399
|
def get_author_tooltip(author):
|
|
400
400
|
if author.url:
|
|
@@ -403,22 +403,22 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
403
403
|
return f'<a href="mailto:{author.email}">{author.name}</a>'
|
|
404
404
|
return author.name
|
|
405
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'>")
|
|
406
413
|
if self.config['show_author'] == 'text':
|
|
407
414
|
# 显示文本模式
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
f"<span data-tippy-content data-tippy-raw='{
|
|
413
|
-
f"<span class='material-icons' data-icon='{icon}'></span>"
|
|
414
|
-
f"{author_text}"
|
|
415
|
-
f"</span>"
|
|
416
|
-
)
|
|
415
|
+
for index, author in enumerate(authors):
|
|
416
|
+
if index > 0:
|
|
417
|
+
html_parts.append(", ")
|
|
418
|
+
tooltip = get_author_tooltip(author)
|
|
419
|
+
html_parts.append(f"<span class='text-wrapper' data-tippy-content data-tippy-raw='{ tooltip }'>{ tooltip }</span>")
|
|
417
420
|
else:
|
|
418
421
|
# 显示头像模式(默认)
|
|
419
|
-
icon = 'doc_author' if len(authors) == 1 else 'doc_authors'
|
|
420
|
-
html_parts.append(f"<span class='material-icons' data-icon='{icon}'></span>")
|
|
421
|
-
html_parts.append("<div class='avatar-group'>")
|
|
422
422
|
for author in authors:
|
|
423
423
|
tooltip = get_author_tooltip(author)
|
|
424
424
|
html_parts.append(
|
|
@@ -427,7 +427,8 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
427
427
|
f"<img class='avatar' src='{author.avatar}' onerror=\"this.style.display='none'\" />"
|
|
428
428
|
f"</div>"
|
|
429
429
|
)
|
|
430
|
-
|
|
430
|
+
html_parts.append("</div>")
|
|
431
|
+
html_parts.append("</div>")
|
|
431
432
|
|
|
432
433
|
html_parts.append("</div></div>")
|
|
433
434
|
return ''.join(html_parts)
|
|
@@ -438,6 +439,8 @@ class DocumentDatesPlugin(BasePlugin):
|
|
|
438
439
|
|
|
439
440
|
|
|
440
441
|
def _insert_date_info(self, markdown: str, date_info: str):
|
|
442
|
+
if not date_info:
|
|
443
|
+
return markdown
|
|
441
444
|
if self.config['position'] == 'top':
|
|
442
445
|
first_line, insert_pos = self._find_markdown_body_start(markdown)
|
|
443
446
|
if first_line.startswith(('# ', '<h1')):
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
/* 1. Plug-in styles
|
|
2
|
-
including
|
|
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;
|
|
@@ -14,14 +27,15 @@
|
|
|
14
27
|
Google Fonts Icons (2500+): https://fonts.google.com/icons
|
|
15
28
|
|
|
16
29
|
doc_created: add_circle, add_circle, note_add, more_time
|
|
17
|
-
|
|
30
|
+
doc_updated: update, check_circle, task, refresh
|
|
18
31
|
doc_author: person, account_circle
|
|
19
32
|
doc_authors: group, groups */
|
|
20
|
-
|
|
33
|
+
|
|
34
|
+
/*
|
|
21
35
|
.document-dates-plugin .material-icons[data-icon="doc_created"]::before {
|
|
22
36
|
content: "more_time";
|
|
23
37
|
}
|
|
24
|
-
.document-dates-plugin .material-icons[data-icon="
|
|
38
|
+
.document-dates-plugin .material-icons[data-icon="doc_updated"]::before {
|
|
25
39
|
content: "refresh";
|
|
26
40
|
}
|
|
27
41
|
.document-dates-plugin .material-icons[data-icon="doc_author"]::before {
|
|
@@ -33,22 +47,28 @@
|
|
|
33
47
|
|
|
34
48
|
|
|
35
49
|
|
|
36
|
-
/*
|
|
37
|
-
|
|
50
|
+
/* 3. Author Avatar styles
|
|
51
|
+
e.g. shape, hover scale, grayscale mode
|
|
38
52
|
*/
|
|
39
|
-
/* Remove the divider line: */
|
|
40
53
|
/*
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
.avatar-wrapper {
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
filter: grayscale(0%);
|
|
57
|
+
}
|
|
58
|
+
.avatar-wrapper:hover {
|
|
59
|
+
transform: scale(1.08);
|
|
44
60
|
} */
|
|
45
61
|
|
|
46
62
|
|
|
47
63
|
|
|
48
|
-
/*
|
|
64
|
+
/* 4. Tooltip styles
|
|
49
65
|
including theme, arrow, font, color, background color, etc
|
|
50
66
|
*/
|
|
51
67
|
|
|
68
|
+
/* .tippy-box {
|
|
69
|
+
font-size: 12px;
|
|
70
|
+
} */
|
|
71
|
+
|
|
52
72
|
/* Demo of the custom theme 'sorrel' and 'sublime', you can configure it in user.config.js (optional) */
|
|
53
73
|
/*
|
|
54
74
|
.tippy-box[data-theme~='sorrel'] {
|
|
@@ -66,17 +86,3 @@
|
|
|
66
86
|
.tippy-box[data-theme~='sublime'] > .tippy-arrow::before {
|
|
67
87
|
color: #474747;
|
|
68
88
|
} */
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/* 4. Author Avatar styles
|
|
73
|
-
e.g. shape, hover scale, grayscale mode
|
|
74
|
-
*/
|
|
75
|
-
/*
|
|
76
|
-
.avatar-wrapper {
|
|
77
|
-
border-radius: 4px;
|
|
78
|
-
filter: grayscale(0%);
|
|
79
|
-
}
|
|
80
|
-
.avatar-wrapper:hover {
|
|
81
|
-
transform: scale(1.08);
|
|
82
|
-
} */
|
|
@@ -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
|
|
@@ -70,7 +72,7 @@ Part 3:
|
|
|
70
72
|
// Way 1: User-defined one language
|
|
71
73
|
TooltipLanguage.register('en', {
|
|
72
74
|
created_time: "Custom Created",
|
|
73
|
-
|
|
75
|
+
updated_time: "Custom Last Update",
|
|
74
76
|
author: "Custom Author",
|
|
75
77
|
authors: "Custom Authors"
|
|
76
78
|
});
|
|
@@ -79,13 +81,13 @@ TooltipLanguage.register('en', {
|
|
|
79
81
|
const userLanguages = {
|
|
80
82
|
en: {
|
|
81
83
|
created_time: "Created",
|
|
82
|
-
|
|
84
|
+
updated_time: "Last Update",
|
|
83
85
|
author: "Author",
|
|
84
86
|
authors: "Authors"
|
|
85
87
|
},
|
|
86
88
|
zh: {
|
|
87
89
|
created_time: "创建时间",
|
|
88
|
-
|
|
90
|
+
updated_time: "最后更新",
|
|
89
91
|
author: "作者",
|
|
90
92
|
authors: "作者"
|
|
91
93
|
}
|