mkdocs-document-dates 3.3.4__tar.gz → 3.4__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.3.4/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.4}/PKG-INFO +34 -19
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/README.md +34 -19
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/plugin.py +30 -19
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/default.config.js +13 -1
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/fonts/material-icons.css +3 -1
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/utils.py +63 -11
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4/mkdocs_document_dates.egg-info}/PKG-INFO +34 -19
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -1
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/setup.py +2 -7
- mkdocs_document_dates-3.3.4/mkdocs_document_dates/static/fonts/materialicons.ttf +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/LICENSE +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/MANIFEST.in +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/__init__.py +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/cache_manager.py +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/hooks/pre-commit +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/hooks_installer.py +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/config/user.config.css +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/config/user.config.js +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/core.css +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/core.js +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/utils.js +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/fonts/materialicons.woff2 +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/tippy/light.css +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/tippy/material.css +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/tippy/scale.css +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates.egg-info/requires.txt +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
- {mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/setup.cfg +0 -0
{mkdocs_document_dates-3.3.4/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.4}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.4
|
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
|
@@ -51,8 +51,9 @@ A new generation MkDocs plugin for displaying exact **creation time, last update
|
|
51
51
|
| git-revision-date-localized | > 3 s | > 30 s | O(n) |
|
52
52
|
| document-dates | < 0.1 s | < 0.15 s | O(1) |
|
53
53
|
|
54
|
+
- Supports display of recently updated documents in an overall list
|
54
55
|
|
55
|
-
##
|
56
|
+
## Preview
|
56
57
|
|
57
58
|

|
58
59
|
|
@@ -83,14 +84,16 @@ plugins:
|
|
83
84
|
- drafts/* # Exclude all files in drafts folder, including subfolders
|
84
85
|
date_format: '%Y-%m-%d' # Date format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
85
86
|
time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
|
87
|
+
show_author: true # Show author or not, default: true
|
86
88
|
```
|
87
89
|
|
88
90
|
## Specify time manually
|
89
91
|
|
90
|
-
|
92
|
+
The plugin will **automatically** get the exact time of the document, and will automatically cache the creation time, without manual intervention
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
+
**Priority**: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
|
95
|
+
|
96
|
+
- If need to customize it, you can specify it manually in Front Matter:
|
94
97
|
```markdown
|
95
98
|
---
|
96
99
|
created: 2023-01-01
|
@@ -103,10 +106,11 @@ By default, the plugin will **automatically** get the exact time of the document
|
|
103
106
|
|
104
107
|
## Configure Author
|
105
108
|
|
106
|
-
|
109
|
+
The plugin will **automatically** get the author of the document, and will automatically parse the email and then do the link, without manual intervention
|
110
|
+
|
111
|
+
**Priority**: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
|
107
112
|
|
108
|
-
-
|
109
|
-
- If you want to customize it, you can configure an author in Front Matter with the field `name`:
|
113
|
+
- If need to customize it, you can configure an author in Front Matter with the field `name`:
|
110
114
|
```markdown
|
111
115
|
---
|
112
116
|
name: any-name
|
@@ -117,7 +121,7 @@ By default, the plugin will **automatically** get the author of the document, an
|
|
117
121
|
|
118
122
|
## Configure Avatar
|
119
123
|
|
120
|
-
|
124
|
+
The plugin will **automatically** loads the author avatar, without manual intervention
|
121
125
|
|
122
126
|
**Priority**: `Custom Avatar` > `GitHub Avatar` > `Character Avatar`
|
123
127
|
|
@@ -144,12 +148,13 @@ By default, the plugin will **automatically** loads the author avatar, without m
|
|
144
148
|
|
145
149
|
---
|
146
150
|
```
|
147
|
-
|
151
|
+
|
152
|
+
- If you want to configure complete information for multiple authors, you can create a separate configuration file `authors.yml` in the `docs/` folder, see the [authors.yml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/authors.yml) for its format
|
148
153
|
- If the URL avatar fails to load, it automatically falls back to the character avatar
|
149
154
|
|
150
155
|
## Customization
|
151
156
|
|
152
|
-
The plugin supports full customization, such as **icon
|
157
|
+
The plugin supports full customization, such as **icon, theme, color, font, animation, dividing line** etc, and the entrance has been preset, you just need to find the file below and uncomment it:
|
153
158
|
|
154
159
|
| Category: | Location: |
|
155
160
|
| :----------------------: | ---------------------------------------- |
|
@@ -160,15 +165,15 @@ The plugin supports full customization, such as **icon style, theme color, font,
|
|
160
165
|
|
161
166
|
## Localization
|
162
167
|
|
163
|
-
-
|
164
|
-
- If
|
165
|
-
- The original configuration
|
166
|
-
-
|
167
|
-
- In `user.config.js`, refer to [Part 2](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js),
|
168
|
+
- <mark>tooltip</mark>: built-in languages: `en zh zh_TW es fr de ar ja ko ru nl pt`, **no need to manually configure**, intelligent recognition, automatic switching
|
169
|
+
- If there is any missing language or inaccurate built-in language, you can refer to [Part 3](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) in `user.config.js` to add it by registering yourself, or submit PR for built-in
|
170
|
+
- The original configuration item `locale` has been retained, but manual configuration is no longer recommended
|
171
|
+
- <mark>timeago</mark>: when `type: timeago` is set, timeago.js is enabled to render dynamic time, `timeago.min.js` only contains English and Chinese by default, if need to load other languages, you can configure it as below (choose one):
|
172
|
+
- In `user.config.js`, refer to [Part 2](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js), add it by registering yourself
|
168
173
|
- In `mkdocs.yml`, configure the full version of `timeago.full.min.js` to reload all languages at once
|
169
174
|
```yaml
|
170
175
|
extra_javascript:
|
171
|
-
|
176
|
+
- assets/document_dates/core/timeago.full.min.js
|
172
177
|
```
|
173
178
|
|
174
179
|
## Template Variables
|
@@ -178,12 +183,22 @@ You can access the meta-info of a document in a template using the following var
|
|
178
183
|
- page.meta.document_dates_created
|
179
184
|
- page.meta.document_dates_modified
|
180
185
|
- page.meta.document_dates_authors
|
186
|
+
- config.extra.recently_updated_docs
|
181
187
|
|
182
188
|
Usage examples:
|
183
189
|
|
184
190
|
- **Example 1**: Set the correct `lastmod` for your site's `sitemap.xml` so that search engines can better handle SEO and thus increase your site's exposure (download [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/sitemap.xml) and override this path: `docs/overrides/sitemap.xml`)
|
185
191
|
- **Example 2**: Using the template to re-customize the plugin, you have full control over the rendering logic and the plugin is only responsible for providing the data (download [source-file.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/source-file.html) and override this path: `docs/overrides/partials/source-file.html`)
|
186
192
|
|
193
|
+
## Recently updated module
|
194
|
+
|
195
|
+
You can get the recently updated document data use `config.extra.recently_updated_docs` in any template, then customize the rendering logic yourself, or use the preset template examples directly:
|
196
|
+
|
197
|
+
- **Example 1**: Add the recently updated module to the navigation of the sidebar (download [nav.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/nav.html) and override this path: `docs/overrides/partials/nav.html`)
|
198
|
+
- **Example 2**: Add this feature anywhere in any md document, you can install the plugin [mkdocs-recently-updated-docs](https://github.com/jaywhj/mkdocs-recently-updated-docs), which is also based on the data capabilities provided by this plugin and provides more template examples, making it easier to use
|
199
|
+
|
200
|
+

|
201
|
+
|
187
202
|
## Other Tips
|
188
203
|
|
189
204
|
- In order to always get the exact creation time, a separate cache file is used to store the creation time of the document, located in the docs folder (hidden by default), please don't remove it:
|
@@ -216,10 +231,10 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
216
231
|
- Solution: Reduce the number of I/Os + Use caching + Replace less efficient system functions
|
217
232
|
- **Improve**:
|
218
233
|
- Since it's a newly developed plugin, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity, personalization, intelligence**
|
219
|
-
- **Ease of use**:
|
234
|
+
- **Ease of use**: no complex configuration, only 2-3 commonly used configuration items, in addition to providing the reference template for personalized configurations
|
220
235
|
- **Simplicity**: no unnecessary configuration, no Git dependencies, no CI/CD configuration dependencies, no other package dependencies
|
221
236
|
- **Personalization**: fully customizable and full control over the rendering logic, the plugin is only responsible for providing the data
|
222
|
-
- **Intelligence**:
|
237
|
+
- **Intelligence**: Intelligent parsing of document time, author, avatar, intelligent recognition of the user's language and automatic adaptation, in addition, there are auto-install Git Hooks, auto-cache, auto-commit
|
223
238
|
- **Compatibility**: works well on older operating systems and browsers, such as WIN7, MacOS 10.11, iOS 12, Chrome 63.0.3239
|
224
239
|
- **The Last Secret**:
|
225
240
|
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
@@ -25,8 +25,9 @@ A new generation MkDocs plugin for displaying exact **creation time, last update
|
|
25
25
|
| git-revision-date-localized | > 3 s | > 30 s | O(n) |
|
26
26
|
| document-dates | < 0.1 s | < 0.15 s | O(1) |
|
27
27
|
|
28
|
+
- Supports display of recently updated documents in an overall list
|
28
29
|
|
29
|
-
##
|
30
|
+
## Preview
|
30
31
|
|
31
32
|

|
32
33
|
|
@@ -57,14 +58,16 @@ plugins:
|
|
57
58
|
- drafts/* # Exclude all files in drafts folder, including subfolders
|
58
59
|
date_format: '%Y-%m-%d' # Date format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
59
60
|
time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
|
61
|
+
show_author: true # Show author or not, default: true
|
60
62
|
```
|
61
63
|
|
62
64
|
## Specify time manually
|
63
65
|
|
64
|
-
|
66
|
+
The plugin will **automatically** get the exact time of the document, and will automatically cache the creation time, without manual intervention
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
+
**Priority**: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
|
69
|
+
|
70
|
+
- If need to customize it, you can specify it manually in Front Matter:
|
68
71
|
```markdown
|
69
72
|
---
|
70
73
|
created: 2023-01-01
|
@@ -77,10 +80,11 @@ By default, the plugin will **automatically** get the exact time of the document
|
|
77
80
|
|
78
81
|
## Configure Author
|
79
82
|
|
80
|
-
|
83
|
+
The plugin will **automatically** get the author of the document, and will automatically parse the email and then do the link, without manual intervention
|
84
|
+
|
85
|
+
**Priority**: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
|
81
86
|
|
82
|
-
-
|
83
|
-
- If you want to customize it, you can configure an author in Front Matter with the field `name`:
|
87
|
+
- If need to customize it, you can configure an author in Front Matter with the field `name`:
|
84
88
|
```markdown
|
85
89
|
---
|
86
90
|
name: any-name
|
@@ -91,7 +95,7 @@ By default, the plugin will **automatically** get the author of the document, an
|
|
91
95
|
|
92
96
|
## Configure Avatar
|
93
97
|
|
94
|
-
|
98
|
+
The plugin will **automatically** loads the author avatar, without manual intervention
|
95
99
|
|
96
100
|
**Priority**: `Custom Avatar` > `GitHub Avatar` > `Character Avatar`
|
97
101
|
|
@@ -118,12 +122,13 @@ By default, the plugin will **automatically** loads the author avatar, without m
|
|
118
122
|
|
119
123
|
---
|
120
124
|
```
|
121
|
-
|
125
|
+
|
126
|
+
- If you want to configure complete information for multiple authors, you can create a separate configuration file `authors.yml` in the `docs/` folder, see the [authors.yml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/authors.yml) for its format
|
122
127
|
- If the URL avatar fails to load, it automatically falls back to the character avatar
|
123
128
|
|
124
129
|
## Customization
|
125
130
|
|
126
|
-
The plugin supports full customization, such as **icon
|
131
|
+
The plugin supports full customization, such as **icon, theme, color, font, animation, dividing line** etc, and the entrance has been preset, you just need to find the file below and uncomment it:
|
127
132
|
|
128
133
|
| Category: | Location: |
|
129
134
|
| :----------------------: | ---------------------------------------- |
|
@@ -134,15 +139,15 @@ The plugin supports full customization, such as **icon style, theme color, font,
|
|
134
139
|
|
135
140
|
## Localization
|
136
141
|
|
137
|
-
-
|
138
|
-
- If
|
139
|
-
- The original configuration
|
140
|
-
-
|
141
|
-
- In `user.config.js`, refer to [Part 2](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js),
|
142
|
+
- <mark>tooltip</mark>: built-in languages: `en zh zh_TW es fr de ar ja ko ru nl pt`, **no need to manually configure**, intelligent recognition, automatic switching
|
143
|
+
- If there is any missing language or inaccurate built-in language, you can refer to [Part 3](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) in `user.config.js` to add it by registering yourself, or submit PR for built-in
|
144
|
+
- The original configuration item `locale` has been retained, but manual configuration is no longer recommended
|
145
|
+
- <mark>timeago</mark>: when `type: timeago` is set, timeago.js is enabled to render dynamic time, `timeago.min.js` only contains English and Chinese by default, if need to load other languages, you can configure it as below (choose one):
|
146
|
+
- In `user.config.js`, refer to [Part 2](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js), add it by registering yourself
|
142
147
|
- In `mkdocs.yml`, configure the full version of `timeago.full.min.js` to reload all languages at once
|
143
148
|
```yaml
|
144
149
|
extra_javascript:
|
145
|
-
|
150
|
+
- assets/document_dates/core/timeago.full.min.js
|
146
151
|
```
|
147
152
|
|
148
153
|
## Template Variables
|
@@ -152,12 +157,22 @@ You can access the meta-info of a document in a template using the following var
|
|
152
157
|
- page.meta.document_dates_created
|
153
158
|
- page.meta.document_dates_modified
|
154
159
|
- page.meta.document_dates_authors
|
160
|
+
- config.extra.recently_updated_docs
|
155
161
|
|
156
162
|
Usage examples:
|
157
163
|
|
158
164
|
- **Example 1**: Set the correct `lastmod` for your site's `sitemap.xml` so that search engines can better handle SEO and thus increase your site's exposure (download [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/sitemap.xml) and override this path: `docs/overrides/sitemap.xml`)
|
159
165
|
- **Example 2**: Using the template to re-customize the plugin, you have full control over the rendering logic and the plugin is only responsible for providing the data (download [source-file.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/source-file.html) and override this path: `docs/overrides/partials/source-file.html`)
|
160
166
|
|
167
|
+
## Recently updated module
|
168
|
+
|
169
|
+
You can get the recently updated document data use `config.extra.recently_updated_docs` in any template, then customize the rendering logic yourself, or use the preset template examples directly:
|
170
|
+
|
171
|
+
- **Example 1**: Add the recently updated module to the navigation of the sidebar (download [nav.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/nav.html) and override this path: `docs/overrides/partials/nav.html`)
|
172
|
+
- **Example 2**: Add this feature anywhere in any md document, you can install the plugin [mkdocs-recently-updated-docs](https://github.com/jaywhj/mkdocs-recently-updated-docs), which is also based on the data capabilities provided by this plugin and provides more template examples, making it easier to use
|
173
|
+
|
174
|
+

|
175
|
+
|
161
176
|
## Other Tips
|
162
177
|
|
163
178
|
- In order to always get the exact creation time, a separate cache file is used to store the creation time of the document, located in the docs folder (hidden by default), please don't remove it:
|
@@ -190,10 +205,10 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
190
205
|
- Solution: Reduce the number of I/Os + Use caching + Replace less efficient system functions
|
191
206
|
- **Improve**:
|
192
207
|
- Since it's a newly developed plugin, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity, personalization, intelligence**
|
193
|
-
- **Ease of use**:
|
208
|
+
- **Ease of use**: no complex configuration, only 2-3 commonly used configuration items, in addition to providing the reference template for personalized configurations
|
194
209
|
- **Simplicity**: no unnecessary configuration, no Git dependencies, no CI/CD configuration dependencies, no other package dependencies
|
195
210
|
- **Personalization**: fully customizable and full control over the rendering logic, the plugin is only responsible for providing the data
|
196
|
-
- **Intelligence**:
|
211
|
+
- **Intelligence**: Intelligent parsing of document time, author, avatar, intelligent recognition of the user's language and automatic adaptation, in addition, there are auto-install Git Hooks, auto-cache, auto-commit
|
197
212
|
- **Compatibility**: works well on older operating systems and browsers, such as WIN7, MacOS 10.11, iOS 12, Chrome 63.0.3239
|
198
213
|
- **The Last Secret**:
|
199
|
-
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
214
|
+
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
@@ -8,7 +8,7 @@ from mkdocs.plugins import BasePlugin
|
|
8
8
|
from mkdocs.config import config_options
|
9
9
|
from mkdocs.structure.pages import Page
|
10
10
|
from urllib.parse import urlparse
|
11
|
-
from .utils import get_file_creation_time, load_git_cache, read_jsonl_cache
|
11
|
+
from .utils import get_file_creation_time, load_git_cache, read_jsonl_cache,is_excluded, get_recently_modified_files
|
12
12
|
|
13
13
|
logger = logging.getLogger("mkdocs.plugins.document_dates")
|
14
14
|
logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
@@ -42,7 +42,8 @@ class DocumentDatesPlugin(BasePlugin):
|
|
42
42
|
('exclude', config_options.Type(list, default=[])),
|
43
43
|
('created_field_names', config_options.Type(list, default=['created', 'date', 'creation'])),
|
44
44
|
('modified_field_names', config_options.Type(list, default=['modified', 'updated', 'last_modified', 'last_updated'])),
|
45
|
-
('show_author', config_options.Type(bool, default=True))
|
45
|
+
('show_author', config_options.Type(bool, default=True)),
|
46
|
+
('recently-updated', config_options.Type((dict, bool), default={}))
|
46
47
|
)
|
47
48
|
|
48
49
|
def __init__(self):
|
@@ -151,13 +152,34 @@ class DocumentDatesPlugin(BasePlugin):
|
|
151
152
|
|
152
153
|
return config
|
153
154
|
|
155
|
+
def on_nav(self, nav, config, files):
|
156
|
+
recently_updated_config = self.config.get('recently-updated')
|
157
|
+
if not recently_updated_config:
|
158
|
+
return nav
|
159
|
+
|
160
|
+
# 兼容 true 配置
|
161
|
+
if recently_updated_config is True:
|
162
|
+
recently_updated_config = {}
|
163
|
+
|
164
|
+
# 获取配置
|
165
|
+
exclude_list = recently_updated_config.get('exclude', [])
|
166
|
+
limit = recently_updated_config.get('limit', 10)
|
167
|
+
|
168
|
+
# 获取 docs 目录下最近更新的文档
|
169
|
+
recently_modified_files = get_recently_modified_files(files, exclude_list, limit)
|
170
|
+
|
171
|
+
# 将数据注入到 config['extra'] 中供全局访问
|
172
|
+
if 'extra' not in config:
|
173
|
+
config['extra'] = {}
|
174
|
+
config['extra']['recently_updated_docs'] = recently_modified_files
|
175
|
+
|
176
|
+
return nav
|
177
|
+
|
154
178
|
def on_page_markdown(self, markdown, page: Page, config, files):
|
155
179
|
# 获取相对路径,src_uri 总是以"/"分隔
|
156
|
-
rel_path = getattr(page.file, 'src_uri',
|
157
|
-
if
|
158
|
-
rel_path =
|
159
|
-
if os.sep != '/':
|
160
|
-
rel_path = rel_path.replace(os.sep, '/')
|
180
|
+
rel_path = getattr(page.file, 'src_uri', page.file.src_path)
|
181
|
+
if os.sep != '/':
|
182
|
+
rel_path = rel_path.replace(os.sep, '/')
|
161
183
|
file_path = page.file.abs_src_path
|
162
184
|
|
163
185
|
# 获取时间信息
|
@@ -177,7 +199,7 @@ class DocumentDatesPlugin(BasePlugin):
|
|
177
199
|
page.meta['document_dates_authors'] = authors
|
178
200
|
|
179
201
|
# 检查是否需要排除
|
180
|
-
if self.
|
202
|
+
if is_excluded(rel_path, self.config['exclude']):
|
181
203
|
return markdown
|
182
204
|
|
183
205
|
# 生成日期和作者信息 HTML
|
@@ -217,17 +239,6 @@ class DocumentDatesPlugin(BasePlugin):
|
|
217
239
|
logger.info(f"Error parsing .authors.yml: {e}")
|
218
240
|
|
219
241
|
|
220
|
-
def _is_excluded(self, rel_path):
|
221
|
-
for pattern in self.config['exclude']:
|
222
|
-
if pattern.endswith('*'):
|
223
|
-
if rel_path.startswith(pattern.partition('*')[0]):
|
224
|
-
return True
|
225
|
-
else:
|
226
|
-
if rel_path == pattern:
|
227
|
-
return True
|
228
|
-
return False
|
229
|
-
|
230
|
-
|
231
242
|
def _find_meta_date(self, meta, field_names):
|
232
243
|
for field in field_names:
|
233
244
|
if field in meta:
|
@@ -126,6 +126,18 @@ window.TooltipLanguage = (function () {
|
|
126
126
|
author: "작성자",
|
127
127
|
authors: "작성자"
|
128
128
|
},
|
129
|
+
nl: {
|
130
|
+
created_time: "Gecreëerd",
|
131
|
+
modified_time: "Laatst geüpdatet",
|
132
|
+
author: "Auteur",
|
133
|
+
authors: "Auteurs"
|
134
|
+
},
|
135
|
+
pt: {
|
136
|
+
created_time: "Criado em",
|
137
|
+
modified_time: "Última atualização",
|
138
|
+
author: "Autor",
|
139
|
+
authors: "Autores"
|
140
|
+
},
|
129
141
|
ru: {
|
130
142
|
created_time: "Дата создания",
|
131
143
|
modified_time: "Дата изменения",
|
@@ -150,4 +162,4 @@ window.TooltipLanguage = (function () {
|
|
150
162
|
Object.entries(defaultLanguages).forEach(([locale, data]) => {
|
151
163
|
TooltipLanguage.register(locale, data);
|
152
164
|
});
|
153
|
-
})();
|
165
|
+
})();
|
@@ -3,7 +3,9 @@
|
|
3
3
|
font-style: normal;
|
4
4
|
font-weight: 400;
|
5
5
|
src: url(./materialicons.woff2) format('woff2'),
|
6
|
-
url(
|
6
|
+
url(https://fonts.gstatic.com/s/materialicons/v140/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2'),
|
7
|
+
url(https://fonts.gstatic.com/s/materialicons/v140/flUhRq6tzZclQEJ-Vdg-IuiaDsNa.woff) format('woff'),
|
8
|
+
url(https://fonts.gstatic.com/s/materialicons/v140/flUhRq6tzZclQEJ-Vdg-IuiaDsNZ.ttf) format('truetype');
|
7
9
|
}
|
8
10
|
|
9
11
|
.material-icons {
|
@@ -11,6 +11,18 @@ logger = logging.getLogger("mkdocs.plugins.document_dates")
|
|
11
11
|
logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
12
12
|
|
13
13
|
|
14
|
+
def is_excluded(path, exclude_list):
|
15
|
+
if not exclude_list:
|
16
|
+
return False
|
17
|
+
for pattern in exclude_list:
|
18
|
+
if pattern.endswith('*'):
|
19
|
+
if path.startswith(pattern.partition('*')[0]):
|
20
|
+
return True
|
21
|
+
else:
|
22
|
+
if path == pattern:
|
23
|
+
return True
|
24
|
+
return False
|
25
|
+
|
14
26
|
def get_git_first_commit_time(file_path):
|
15
27
|
try:
|
16
28
|
# git log --reverse --format="%aI" -- {file_path} | head -n 1
|
@@ -35,8 +47,10 @@ def load_git_cache(docs_dir_path: Path):
|
|
35
47
|
text=True, encoding='utf-8'
|
36
48
|
).strip())
|
37
49
|
docs_prefix = docs_dir_path.relative_to(git_root).as_posix()
|
50
|
+
docs_prefix_with_slash = docs_prefix + '/'
|
51
|
+
prefix_len = len(docs_prefix_with_slash)
|
38
52
|
|
39
|
-
authors_dict = defaultdict(
|
53
|
+
authors_dict = defaultdict(dict)
|
40
54
|
first_commit = {}
|
41
55
|
current_commit = None
|
42
56
|
|
@@ -46,21 +60,27 @@ def load_git_cache(docs_dir_path: Path):
|
|
46
60
|
continue
|
47
61
|
if '|' in line:
|
48
62
|
name, email, created = line.split('|', 2)
|
49
|
-
|
63
|
+
# 使用元组,更轻量
|
64
|
+
current_commit = (name, email, created)
|
50
65
|
elif line.endswith('.md') and current_commit:
|
51
|
-
if line.startswith(
|
52
|
-
line = line[
|
53
|
-
|
66
|
+
if line.startswith(docs_prefix_with_slash):
|
67
|
+
line = line[prefix_len:]
|
68
|
+
# 解构元组,避免字典查找
|
69
|
+
name, email, created = current_commit
|
70
|
+
# 使用有序去重结构,保持作者首次出现顺序
|
71
|
+
authors_dict[line].setdefault((name, email), None)
|
54
72
|
if line not in first_commit:
|
55
|
-
first_commit[line] =
|
73
|
+
first_commit[line] = created
|
56
74
|
|
57
|
-
|
75
|
+
# 构建最终的缓存数据
|
76
|
+
for file_path in first_commit:
|
77
|
+
authors_list = [
|
78
|
+
{'name': name, 'email': email}
|
79
|
+
for name, email in authors_dict[file_path].keys()
|
80
|
+
]
|
58
81
|
dates_cache[file_path] = {
|
59
82
|
'created': first_commit[file_path],
|
60
|
-
'authors':
|
61
|
-
{'name': name, 'email': email}
|
62
|
-
for name, email in sorted(authors_dict[file_path])
|
63
|
-
]
|
83
|
+
'authors': authors_list
|
64
84
|
}
|
65
85
|
except Exception as e:
|
66
86
|
logger.info(f"Error getting git info in {docs_dir_path}: {e}")
|
@@ -83,6 +103,38 @@ def get_file_creation_time(file_path):
|
|
83
103
|
logger.error(f"Failed to get file creation time for {file_path}: {e}")
|
84
104
|
return datetime.now()
|
85
105
|
|
106
|
+
def get_recently_modified_files(files, exclude_list: list, limit: int = 10):
|
107
|
+
if not files:
|
108
|
+
return []
|
109
|
+
temp_results = []
|
110
|
+
for file in files:
|
111
|
+
if not file.src_path.endswith('.md'):
|
112
|
+
continue
|
113
|
+
rel_path = getattr(file, 'src_uri', file.src_path)
|
114
|
+
if os.sep != '/':
|
115
|
+
rel_path = rel_path.replace(os.sep, '/')
|
116
|
+
if is_excluded(rel_path, exclude_list):
|
117
|
+
continue
|
118
|
+
|
119
|
+
# 过滤没有配置进导航里的文档
|
120
|
+
if file.page:
|
121
|
+
if not file.page.title:
|
122
|
+
continue
|
123
|
+
title, url = file.page.title, file.page.url
|
124
|
+
else:
|
125
|
+
title, url = file.name, file.url
|
126
|
+
|
127
|
+
mtime = os.path.getmtime(file.abs_src_path)
|
128
|
+
temp_results.append((mtime, rel_path, title, url))
|
129
|
+
|
130
|
+
# 按修改时间倒序
|
131
|
+
temp_results.sort(key=lambda x: x[0], reverse=True)
|
132
|
+
results = [
|
133
|
+
(datetime.fromtimestamp(mtime).strftime("%Y-%m-%d %H:%M:%S"), *rest)
|
134
|
+
for mtime, *rest in temp_results
|
135
|
+
]
|
136
|
+
return results[:limit]
|
137
|
+
|
86
138
|
def read_json_cache(cache_file: Path):
|
87
139
|
dates_cache = {}
|
88
140
|
if cache_file.exists():
|
{mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4/mkdocs_document_dates.egg-info}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.4
|
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
|
@@ -51,8 +51,9 @@ A new generation MkDocs plugin for displaying exact **creation time, last update
|
|
51
51
|
| git-revision-date-localized | > 3 s | > 30 s | O(n) |
|
52
52
|
| document-dates | < 0.1 s | < 0.15 s | O(1) |
|
53
53
|
|
54
|
+
- Supports display of recently updated documents in an overall list
|
54
55
|
|
55
|
-
##
|
56
|
+
## Preview
|
56
57
|
|
57
58
|

|
58
59
|
|
@@ -83,14 +84,16 @@ plugins:
|
|
83
84
|
- drafts/* # Exclude all files in drafts folder, including subfolders
|
84
85
|
date_format: '%Y-%m-%d' # Date format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
85
86
|
time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
|
87
|
+
show_author: true # Show author or not, default: true
|
86
88
|
```
|
87
89
|
|
88
90
|
## Specify time manually
|
89
91
|
|
90
|
-
|
92
|
+
The plugin will **automatically** get the exact time of the document, and will automatically cache the creation time, without manual intervention
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
+
**Priority**: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
|
95
|
+
|
96
|
+
- If need to customize it, you can specify it manually in Front Matter:
|
94
97
|
```markdown
|
95
98
|
---
|
96
99
|
created: 2023-01-01
|
@@ -103,10 +106,11 @@ By default, the plugin will **automatically** get the exact time of the document
|
|
103
106
|
|
104
107
|
## Configure Author
|
105
108
|
|
106
|
-
|
109
|
+
The plugin will **automatically** get the author of the document, and will automatically parse the email and then do the link, without manual intervention
|
110
|
+
|
111
|
+
**Priority**: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
|
107
112
|
|
108
|
-
-
|
109
|
-
- If you want to customize it, you can configure an author in Front Matter with the field `name`:
|
113
|
+
- If need to customize it, you can configure an author in Front Matter with the field `name`:
|
110
114
|
```markdown
|
111
115
|
---
|
112
116
|
name: any-name
|
@@ -117,7 +121,7 @@ By default, the plugin will **automatically** get the author of the document, an
|
|
117
121
|
|
118
122
|
## Configure Avatar
|
119
123
|
|
120
|
-
|
124
|
+
The plugin will **automatically** loads the author avatar, without manual intervention
|
121
125
|
|
122
126
|
**Priority**: `Custom Avatar` > `GitHub Avatar` > `Character Avatar`
|
123
127
|
|
@@ -144,12 +148,13 @@ By default, the plugin will **automatically** loads the author avatar, without m
|
|
144
148
|
|
145
149
|
---
|
146
150
|
```
|
147
|
-
|
151
|
+
|
152
|
+
- If you want to configure complete information for multiple authors, you can create a separate configuration file `authors.yml` in the `docs/` folder, see the [authors.yml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/authors.yml) for its format
|
148
153
|
- If the URL avatar fails to load, it automatically falls back to the character avatar
|
149
154
|
|
150
155
|
## Customization
|
151
156
|
|
152
|
-
The plugin supports full customization, such as **icon
|
157
|
+
The plugin supports full customization, such as **icon, theme, color, font, animation, dividing line** etc, and the entrance has been preset, you just need to find the file below and uncomment it:
|
153
158
|
|
154
159
|
| Category: | Location: |
|
155
160
|
| :----------------------: | ---------------------------------------- |
|
@@ -160,15 +165,15 @@ The plugin supports full customization, such as **icon style, theme color, font,
|
|
160
165
|
|
161
166
|
## Localization
|
162
167
|
|
163
|
-
-
|
164
|
-
- If
|
165
|
-
- The original configuration
|
166
|
-
-
|
167
|
-
- In `user.config.js`, refer to [Part 2](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js),
|
168
|
+
- <mark>tooltip</mark>: built-in languages: `en zh zh_TW es fr de ar ja ko ru nl pt`, **no need to manually configure**, intelligent recognition, automatic switching
|
169
|
+
- If there is any missing language or inaccurate built-in language, you can refer to [Part 3](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) in `user.config.js` to add it by registering yourself, or submit PR for built-in
|
170
|
+
- The original configuration item `locale` has been retained, but manual configuration is no longer recommended
|
171
|
+
- <mark>timeago</mark>: when `type: timeago` is set, timeago.js is enabled to render dynamic time, `timeago.min.js` only contains English and Chinese by default, if need to load other languages, you can configure it as below (choose one):
|
172
|
+
- In `user.config.js`, refer to [Part 2](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js), add it by registering yourself
|
168
173
|
- In `mkdocs.yml`, configure the full version of `timeago.full.min.js` to reload all languages at once
|
169
174
|
```yaml
|
170
175
|
extra_javascript:
|
171
|
-
|
176
|
+
- assets/document_dates/core/timeago.full.min.js
|
172
177
|
```
|
173
178
|
|
174
179
|
## Template Variables
|
@@ -178,12 +183,22 @@ You can access the meta-info of a document in a template using the following var
|
|
178
183
|
- page.meta.document_dates_created
|
179
184
|
- page.meta.document_dates_modified
|
180
185
|
- page.meta.document_dates_authors
|
186
|
+
- config.extra.recently_updated_docs
|
181
187
|
|
182
188
|
Usage examples:
|
183
189
|
|
184
190
|
- **Example 1**: Set the correct `lastmod` for your site's `sitemap.xml` so that search engines can better handle SEO and thus increase your site's exposure (download [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/sitemap.xml) and override this path: `docs/overrides/sitemap.xml`)
|
185
191
|
- **Example 2**: Using the template to re-customize the plugin, you have full control over the rendering logic and the plugin is only responsible for providing the data (download [source-file.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/source-file.html) and override this path: `docs/overrides/partials/source-file.html`)
|
186
192
|
|
193
|
+
## Recently updated module
|
194
|
+
|
195
|
+
You can get the recently updated document data use `config.extra.recently_updated_docs` in any template, then customize the rendering logic yourself, or use the preset template examples directly:
|
196
|
+
|
197
|
+
- **Example 1**: Add the recently updated module to the navigation of the sidebar (download [nav.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/nav.html) and override this path: `docs/overrides/partials/nav.html`)
|
198
|
+
- **Example 2**: Add this feature anywhere in any md document, you can install the plugin [mkdocs-recently-updated-docs](https://github.com/jaywhj/mkdocs-recently-updated-docs), which is also based on the data capabilities provided by this plugin and provides more template examples, making it easier to use
|
199
|
+
|
200
|
+

|
201
|
+
|
187
202
|
## Other Tips
|
188
203
|
|
189
204
|
- In order to always get the exact creation time, a separate cache file is used to store the creation time of the document, located in the docs folder (hidden by default), please don't remove it:
|
@@ -216,10 +231,10 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
216
231
|
- Solution: Reduce the number of I/Os + Use caching + Replace less efficient system functions
|
217
232
|
- **Improve**:
|
218
233
|
- Since it's a newly developed plugin, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity, personalization, intelligence**
|
219
|
-
- **Ease of use**:
|
234
|
+
- **Ease of use**: no complex configuration, only 2-3 commonly used configuration items, in addition to providing the reference template for personalized configurations
|
220
235
|
- **Simplicity**: no unnecessary configuration, no Git dependencies, no CI/CD configuration dependencies, no other package dependencies
|
221
236
|
- **Personalization**: fully customizable and full control over the rendering logic, the plugin is only responsible for providing the data
|
222
|
-
- **Intelligence**:
|
237
|
+
- **Intelligence**: Intelligent parsing of document time, author, avatar, intelligent recognition of the user's language and automatic adaptation, in addition, there are auto-install Git Hooks, auto-cache, auto-commit
|
223
238
|
- **Compatibility**: works well on older operating systems and browsers, such as WIN7, MacOS 10.11, iOS 12, Chrome 63.0.3239
|
224
239
|
- **The Last Secret**:
|
225
240
|
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
{mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates.egg-info/SOURCES.txt
RENAMED
@@ -23,7 +23,6 @@ mkdocs_document_dates/static/core/timeago.full.min.js
|
|
23
23
|
mkdocs_document_dates/static/core/timeago.min.js
|
24
24
|
mkdocs_document_dates/static/core/utils.js
|
25
25
|
mkdocs_document_dates/static/fonts/material-icons.css
|
26
|
-
mkdocs_document_dates/static/fonts/materialicons.ttf
|
27
26
|
mkdocs_document_dates/static/fonts/materialicons.woff2
|
28
27
|
mkdocs_document_dates/static/tippy/backdrop.css
|
29
28
|
mkdocs_document_dates/static/tippy/light.css
|
@@ -22,13 +22,8 @@ class CustomInstallCommand(install):
|
|
22
22
|
atexit.register(trigger_hook_install)
|
23
23
|
install.run(self)
|
24
24
|
|
25
|
-
try:
|
26
|
-
with open("README.md", "r", encoding="utf-8") as fh:
|
27
|
-
long_description = fh.read()
|
28
|
-
except FileNotFoundError:
|
29
|
-
long_description = "A new generation MkDocs plugin for displaying exact creation time, last update time, authors, email of documents"
|
30
25
|
|
31
|
-
VERSION = '3.
|
26
|
+
VERSION = '3.4'
|
32
27
|
|
33
28
|
setup(
|
34
29
|
name="mkdocs-document-dates",
|
@@ -37,7 +32,7 @@ setup(
|
|
37
32
|
author_email="aaronwqt@gmail.com",
|
38
33
|
license="MIT",
|
39
34
|
description="A new generation MkDocs plugin for displaying exact creation time, last update time, authors, email of documents",
|
40
|
-
long_description=
|
35
|
+
long_description=open("README.md", encoding="utf-8").read(),
|
41
36
|
long_description_content_type="text/markdown",
|
42
37
|
url="https://github.com/jaywhj/mkdocs-document-dates",
|
43
38
|
packages=find_packages(),
|
Binary file
|
File without changes
|
File without changes
|
File without changes
|
{mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/cache_manager.py
RENAMED
File without changes
|
{mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/hooks/pre-commit
RENAMED
File without changes
|
{mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/hooks_installer.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/core.css
RENAMED
File without changes
|
{mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/core.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
{mkdocs_document_dates-3.3.4 → mkdocs_document_dates-3.4}/mkdocs_document_dates/static/core/utils.js
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
|