mkdocs-document-dates 3.1.1__tar.gz → 3.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/PKG-INFO +21 -6
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/README.md +18 -5
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/cache_manager.py +97 -94
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/hooks/pre-commit +2 -6
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/hooks_installer.py +2 -2
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/plugin.py +23 -50
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/config/user.config.js +35 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/core/timeago-load.js +5 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/core/timeago.full.min.js +1 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/core/timeago.min.js +1 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/ar.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/de.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/en.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/es.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/fr.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/ja.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/ko.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/ru.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/zh.json +6 -0
- mkdocs_document_dates-3.1.2/mkdocs_document_dates/static/languages/zh_tw.json +6 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates.egg-info/PKG-INFO +21 -6
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates.egg-info/SOURCES.txt +3 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/setup.py +2 -1
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/ar.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/de.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/en.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/es.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/fr.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/ja.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/ko.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/ru.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/zh.json +0 -20
- mkdocs_document_dates-3.1.1/mkdocs_document_dates/static/languages/zh_tw.json +0 -20
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/LICENSE +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/__init__.py +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/config/user.config.css +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/core/core.css +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/core/core.js +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/tippy/light.css +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/tippy/material.css +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/tippy/scale.css +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates.egg-info/requires.txt +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
- {mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/setup.cfg +0 -0
@@ -1,9 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.2
|
4
4
|
Summary: An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents.
|
5
5
|
Home-page: https://github.com/jaywhj/mkdocs-document-dates
|
6
6
|
Author: Aaron Wang
|
7
|
+
License: MIT
|
7
8
|
Classifier: Programming Language :: Python :: 3
|
8
9
|
Classifier: License :: OSI Approved :: MIT License
|
9
10
|
Classifier: Operating System :: OS Independent
|
@@ -16,6 +17,7 @@ Dynamic: classifier
|
|
16
17
|
Dynamic: description
|
17
18
|
Dynamic: description-content-type
|
18
19
|
Dynamic: home-page
|
20
|
+
Dynamic: license
|
19
21
|
Dynamic: license-file
|
20
22
|
Dynamic: requires-dist
|
21
23
|
Dynamic: requires-python
|
@@ -70,7 +72,7 @@ plugins:
|
|
70
72
|
- document-dates:
|
71
73
|
position: top # Display position: top (after title) bottom (end of document), default: bottom
|
72
74
|
type: date # Date type: date datetime timeago, default: date
|
73
|
-
locale: en # Localization: zh
|
75
|
+
locale: en # Localization: zh zh_TW en es fr de ar ja ko ru, default: en
|
74
76
|
date_format: '%Y-%m-%d' # Date format, Supports all Python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
75
77
|
time_format: '%H:%M:%S' # Time format (valid only if type=datetime)
|
76
78
|
exclude: # List of excluded files
|
@@ -125,6 +127,15 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
125
127
|
- Style & Theme: `docs/assets/document_dates/user.config.css`
|
126
128
|
- Properties & Animations: `docs/assets/document_dates/user.config.js`
|
127
129
|
- Localized languages: `docs/assets/document_dates/languages/` , refer to the template file `en.json` for any additions or modifications
|
130
|
+
- timeago.js localization: `timeago.min.js` only contains English and Chinese by default, if you need to load other languages, you can configure it as below (choose one):
|
131
|
+
- In user.config.js, refer to [the demo commented out](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) at the bottom, translate it into your local language
|
132
|
+
- In mkdocs.yml, add the following two lines to configure the full version of `timeago.full.min.js` to load all languages at once
|
133
|
+
|
134
|
+
```yaml
|
135
|
+
extra_javascript:
|
136
|
+
- assets/document_dates/core/timeago.full.min.js
|
137
|
+
- assets/document_dates/core/timeago-load.js
|
138
|
+
```
|
128
139
|
|
129
140
|
## Other Tips
|
130
141
|
|
@@ -147,9 +158,13 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
147
158
|
- Method 2: You can cache the original time, and then read the cache subsequently. The cache can be in Front Matter of the source document or in a separate file, I chose the latter. Storing in Front Matter makes sense and is simple, but this will modify the source content of the document, although it doesn't have any impact on the body, but I still want to ensure the originality of the data!
|
148
159
|
- **Difficulty**:
|
149
160
|
1. When to read and store original time? This is just a plugin for mkdocs, with very limited access and permissions, mkdocs provides only build and serve, so in case a user commits directly without executing build or serve (e.g., when using a CI/CD build system), then you won't be able to retrieve the time information of the file, not to mention caching it!
|
150
|
-
- Let's take a straight shot: the Git Hooks mechanism was found, prompted by the AI, which can trigger a custom script when a specific action occurs, such as every time commit is performed
|
151
|
-
2. How
|
152
|
-
-
|
161
|
+
- Let's take a straight shot: the Git Hooks mechanism was found, prompted by the AI, which can trigger a custom script when a specific git action occurs, such as every time commit is performed
|
162
|
+
2. How to install Git Hooks automatically? When and how are they triggered? Installing packages from PyPI via pip doesn't have a standard post-install hook mechanism
|
163
|
+
- Workaround: After analyzing the flow of pip installing packages from PyPI, I found that when compiling and installing through the source package (sdist), setuptools will be called to handle it, so we can find a way to implant the installation script in the process of setuptools, i.e., we can add a custom script in setup.py
|
164
|
+
3. How to design a cross-platform hook? To execute a python script, we need to explicitly specify the python interpreter, and the user's python environment varies depending on the operating system, the way python is installed, and the configuration, so how can we ensure that it works properly in all environments?
|
165
|
+
- Solution: I considered using a shell script, but since I'd have to call back to python eventually, it's easier to use a python script. We can detect the user's python environment when the hook is installed, and then dynamically set the hook's shebang line to set the correct python interpreter
|
166
|
+
4. How can I ensure that a single cache file does not conflict when collaborating with multi-person?
|
167
|
+
- Workaround: use JSONL (JSON Lines) instead of JSON, and with the merge strategy 'merge=union'
|
153
168
|
- **Improve**:
|
154
169
|
- Since it has been re-developed, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity and personalization**
|
155
170
|
- Ease of use: don't let users do things manually if you can, e.g., auto-install Git Hooks, auto-cache, auto-commit, provide customized templates, etc
|
@@ -157,4 +172,4 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
157
172
|
- Personalization: almost everything can be customized, whether it's icons, styles, themes, or features, it's all fully customizable
|
158
173
|
- In addition, it has good compatibility and extensibility, and works well in WIN7, mobile devices, old Safari, etc
|
159
174
|
- **The Last Secret**:
|
160
|
-
-
|
175
|
+
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
@@ -47,7 +47,7 @@ plugins:
|
|
47
47
|
- document-dates:
|
48
48
|
position: top # Display position: top (after title) bottom (end of document), default: bottom
|
49
49
|
type: date # Date type: date datetime timeago, default: date
|
50
|
-
locale: en # Localization: zh
|
50
|
+
locale: en # Localization: zh zh_TW en es fr de ar ja ko ru, default: en
|
51
51
|
date_format: '%Y-%m-%d' # Date format, Supports all Python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
52
52
|
time_format: '%H:%M:%S' # Time format (valid only if type=datetime)
|
53
53
|
exclude: # List of excluded files
|
@@ -102,6 +102,15 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
102
102
|
- Style & Theme: `docs/assets/document_dates/user.config.css`
|
103
103
|
- Properties & Animations: `docs/assets/document_dates/user.config.js`
|
104
104
|
- Localized languages: `docs/assets/document_dates/languages/` , refer to the template file `en.json` for any additions or modifications
|
105
|
+
- timeago.js localization: `timeago.min.js` only contains English and Chinese by default, if you need to load other languages, you can configure it as below (choose one):
|
106
|
+
- In user.config.js, refer to [the demo commented out](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) at the bottom, translate it into your local language
|
107
|
+
- In mkdocs.yml, add the following two lines to configure the full version of `timeago.full.min.js` to load all languages at once
|
108
|
+
|
109
|
+
```yaml
|
110
|
+
extra_javascript:
|
111
|
+
- assets/document_dates/core/timeago.full.min.js
|
112
|
+
- assets/document_dates/core/timeago-load.js
|
113
|
+
```
|
105
114
|
|
106
115
|
## Other Tips
|
107
116
|
|
@@ -124,9 +133,13 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
124
133
|
- Method 2: You can cache the original time, and then read the cache subsequently. The cache can be in Front Matter of the source document or in a separate file, I chose the latter. Storing in Front Matter makes sense and is simple, but this will modify the source content of the document, although it doesn't have any impact on the body, but I still want to ensure the originality of the data!
|
125
134
|
- **Difficulty**:
|
126
135
|
1. When to read and store original time? This is just a plugin for mkdocs, with very limited access and permissions, mkdocs provides only build and serve, so in case a user commits directly without executing build or serve (e.g., when using a CI/CD build system), then you won't be able to retrieve the time information of the file, not to mention caching it!
|
127
|
-
- Let's take a straight shot: the Git Hooks mechanism was found, prompted by the AI, which can trigger a custom script when a specific action occurs, such as every time commit is performed
|
128
|
-
2. How
|
129
|
-
-
|
136
|
+
- Let's take a straight shot: the Git Hooks mechanism was found, prompted by the AI, which can trigger a custom script when a specific git action occurs, such as every time commit is performed
|
137
|
+
2. How to install Git Hooks automatically? When and how are they triggered? Installing packages from PyPI via pip doesn't have a standard post-install hook mechanism
|
138
|
+
- Workaround: After analyzing the flow of pip installing packages from PyPI, I found that when compiling and installing through the source package (sdist), setuptools will be called to handle it, so we can find a way to implant the installation script in the process of setuptools, i.e., we can add a custom script in setup.py
|
139
|
+
3. How to design a cross-platform hook? To execute a python script, we need to explicitly specify the python interpreter, and the user's python environment varies depending on the operating system, the way python is installed, and the configuration, so how can we ensure that it works properly in all environments?
|
140
|
+
- Solution: I considered using a shell script, but since I'd have to call back to python eventually, it's easier to use a python script. We can detect the user's python environment when the hook is installed, and then dynamically set the hook's shebang line to set the correct python interpreter
|
141
|
+
4. How can I ensure that a single cache file does not conflict when collaborating with multi-person?
|
142
|
+
- Workaround: use JSONL (JSON Lines) instead of JSON, and with the merge strategy 'merge=union'
|
130
143
|
- **Improve**:
|
131
144
|
- Since it has been re-developed, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity and personalization**
|
132
145
|
- Ease of use: don't let users do things manually if you can, e.g., auto-install Git Hooks, auto-cache, auto-commit, provide customized templates, etc
|
@@ -134,4 +147,4 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
134
147
|
- Personalization: almost everything can be customized, whether it's icons, styles, themes, or features, it's all fully customizable
|
135
148
|
- In addition, it has good compatibility and extensibility, and works well in WIN7, mobile devices, old Safari, etc
|
136
149
|
- **The Last Secret**:
|
137
|
-
-
|
150
|
+
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
{mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/cache_manager.py
RENAMED
@@ -1,5 +1,4 @@
|
|
1
1
|
import os
|
2
|
-
import sys
|
3
2
|
import json
|
4
3
|
import logging
|
5
4
|
import platform
|
@@ -66,29 +65,30 @@ def get_git_first_commit_time(file_path):
|
|
66
65
|
return None
|
67
66
|
|
68
67
|
def setup_gitattributes(docs_dir):
|
69
|
-
gitattributes_path = docs_dir / '.gitattributes'
|
70
|
-
union_config_line = ".dates_cache.jsonl merge=union"
|
71
68
|
updated = False
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
69
|
+
try:
|
70
|
+
gitattributes_path = docs_dir / '.gitattributes'
|
71
|
+
union_config_line = ".dates_cache.jsonl merge=union"
|
72
|
+
if gitattributes_path.exists():
|
73
|
+
with open(gitattributes_path, 'r', encoding='utf-8') as f:
|
74
|
+
content = f.read()
|
75
|
+
|
76
|
+
if union_config_line not in content:
|
77
|
+
with open(gitattributes_path, 'a', encoding='utf-8') as f:
|
78
|
+
f.write(f"\n{union_config_line}\n")
|
79
|
+
updated = True
|
80
|
+
else:
|
81
|
+
with open(gitattributes_path, 'w', encoding='utf-8') as f:
|
82
|
+
f.write(f"{union_config_line}\n")
|
80
83
|
updated = True
|
81
|
-
|
82
|
-
|
83
|
-
f.write(f"{union_config_line}\n")
|
84
|
-
updated = True
|
85
|
-
|
86
|
-
if updated:
|
87
|
-
try:
|
84
|
+
|
85
|
+
if updated:
|
88
86
|
subprocess.run(["git", "add", str(gitattributes_path)], check=True)
|
89
87
|
logging.info(f"Updated .gitattributes file: {gitattributes_path}")
|
90
|
-
|
91
|
-
|
88
|
+
except (IOError, OSError) as e:
|
89
|
+
logging.error(f"Failed to read/write .gitattributes file: {e}")
|
90
|
+
except Exception as e:
|
91
|
+
logging.error(f"Failed to add .gitattributes to git: {e}")
|
92
92
|
|
93
93
|
return updated
|
94
94
|
|
@@ -145,87 +145,90 @@ def write_jsonl_cache(jsonl_file, dates_cache, tracked_files):
|
|
145
145
|
|
146
146
|
def update_cache():
|
147
147
|
global_updated = False
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
if not docs_dir.exists():
|
153
|
-
logging.error(f"Document directory does not exist: {docs_dir}")
|
154
|
-
continue
|
155
|
-
|
156
|
-
# 设置.gitattributes文件
|
157
|
-
gitattributes_updated = setup_gitattributes(docs_dir)
|
158
|
-
if gitattributes_updated:
|
159
|
-
global_updated = True
|
148
|
+
try:
|
149
|
+
for project_dir in find_mkdocs_projects():
|
150
|
+
try:
|
151
|
+
project_updated = False
|
160
152
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
tracked_files = result.stdout.splitlines() if result.stdout else []
|
166
|
-
|
167
|
-
if not tracked_files:
|
168
|
-
logging.info(f"No tracked markdown files found in {docs_dir}")
|
169
|
-
continue
|
153
|
+
docs_dir = project_dir / 'docs'
|
154
|
+
if not docs_dir.exists():
|
155
|
+
logging.error(f"Document directory does not exist: {docs_dir}")
|
156
|
+
continue
|
170
157
|
|
171
|
-
|
172
|
-
|
173
|
-
|
158
|
+
# 设置.gitattributes文件
|
159
|
+
gitattributes_updated = setup_gitattributes(docs_dir)
|
160
|
+
if gitattributes_updated:
|
161
|
+
global_updated = True
|
174
162
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
163
|
+
# 获取docs目录下已跟踪(tracked)的markdown文件
|
164
|
+
cmd = ["git", "ls-files", "*.md"]
|
165
|
+
result = subprocess.run(cmd, cwd=docs_dir, capture_output=True, text=True, check=True)
|
166
|
+
tracked_files = result.stdout.splitlines() if result.stdout else []
|
167
|
+
|
168
|
+
if not tracked_files:
|
169
|
+
logging.info(f"No tracked markdown files found in {docs_dir}")
|
170
|
+
continue
|
171
|
+
|
172
|
+
# 读取旧的JSON缓存文件(如果存在)
|
173
|
+
json_cache_file = docs_dir / '.dates_cache.json'
|
174
|
+
json_dates_cache = read_json_cache(json_cache_file)
|
175
|
+
|
176
|
+
# 读取新的JSONL缓存文件(如果存在)
|
177
|
+
jsonl_cache_file = docs_dir / '.dates_cache.jsonl'
|
178
|
+
jsonl_dates_cache = read_jsonl_cache(jsonl_cache_file)
|
179
|
+
|
180
|
+
# 根据 git已跟踪的文件来更新
|
181
|
+
for file_path in tracked_files:
|
182
|
+
try:
|
183
|
+
rel_path = file_path
|
184
|
+
full_path = docs_dir / rel_path
|
185
|
+
|
186
|
+
# 如果文件已在JSONL缓存中,跳过
|
187
|
+
if rel_path in jsonl_dates_cache:
|
188
|
+
continue
|
189
|
+
|
190
|
+
# 处理新文件或迁移旧JSON缓存
|
191
|
+
if rel_path in json_dates_cache:
|
192
|
+
jsonl_dates_cache[rel_path] = json_dates_cache[rel_path]
|
193
|
+
project_updated = True
|
194
|
+
elif full_path.exists():
|
195
|
+
created_time = get_file_creation_time(full_path)
|
196
|
+
if not jsonl_cache_file.exists() and not json_cache_file.exists():
|
197
|
+
git_time = get_git_first_commit_time(full_path)
|
198
|
+
if git_time is not None:
|
199
|
+
created_time = min(created_time, git_time)
|
200
|
+
jsonl_dates_cache[rel_path] = {
|
201
|
+
"created": created_time.isoformat()
|
202
|
+
}
|
203
|
+
project_updated = True
|
204
|
+
except Exception as e:
|
205
|
+
logging.error(f"Error processing file {file_path}: {e}")
|
187
206
|
continue
|
188
|
-
|
189
|
-
# 处理新文件或迁移旧JSON缓存
|
190
|
-
if rel_path in json_dates_cache:
|
191
|
-
jsonl_dates_cache[rel_path] = json_dates_cache[rel_path]
|
192
|
-
project_updated = True
|
193
|
-
elif full_path.exists():
|
194
|
-
created_time = get_file_creation_time(full_path)
|
195
|
-
if not jsonl_cache_file.exists() and not json_cache_file.exists():
|
196
|
-
git_time = get_git_first_commit_time(full_path)
|
197
|
-
if git_time is not None:
|
198
|
-
created_time = min(created_time, git_time)
|
199
|
-
jsonl_dates_cache[rel_path] = {
|
200
|
-
"created": created_time.isoformat()
|
201
|
-
}
|
202
|
-
project_updated = True
|
203
|
-
except Exception as e:
|
204
|
-
logging.error(f"Error processing file {file_path}: {e}")
|
205
|
-
|
206
|
-
# 标记删除不再跟踪的文件
|
207
|
-
files_to_remove = set(jsonl_dates_cache.keys()) - set(tracked_files)
|
208
|
-
if files_to_remove:
|
209
|
-
project_updated = True
|
210
|
-
logging.info(f"Removing {len(files_to_remove)} untracked files from cache")
|
211
|
-
|
212
|
-
# 如果有更新,写入JSONL缓存文件
|
213
|
-
if project_updated or not jsonl_cache_file.exists():
|
214
|
-
if write_jsonl_cache(jsonl_cache_file, jsonl_dates_cache, tracked_files):
|
215
|
-
global_updated = True
|
216
|
-
else:
|
217
|
-
logging.info(f"No updates needed for {jsonl_cache_file}")
|
218
207
|
|
219
|
-
|
220
|
-
|
221
|
-
|
208
|
+
# 标记删除不再跟踪的文件
|
209
|
+
files_to_remove = set(jsonl_dates_cache.keys()) - set(tracked_files)
|
210
|
+
if files_to_remove:
|
211
|
+
project_updated = True
|
212
|
+
logging.info(f"Removing {len(files_to_remove)} untracked files from cache")
|
213
|
+
|
214
|
+
# 如果有更新,写入JSONL缓存文件
|
215
|
+
if project_updated or not jsonl_cache_file.exists():
|
216
|
+
if write_jsonl_cache(jsonl_cache_file, jsonl_dates_cache, tracked_files):
|
217
|
+
global_updated = True
|
218
|
+
else:
|
219
|
+
logging.info(f"No updates needed for {jsonl_cache_file}")
|
220
|
+
except subprocess.CalledProcessError as e:
|
221
|
+
logging.error(f"Failed to execute git command: {e}")
|
222
|
+
continue
|
223
|
+
except Exception as e:
|
224
|
+
logging.error(f"Error processing project directory {project_dir}: {e}")
|
225
|
+
continue
|
226
|
+
|
227
|
+
except Exception as e:
|
228
|
+
logging.error(f"Unexpected error in update_cache: {e}")
|
222
229
|
|
223
230
|
return global_updated
|
224
231
|
|
225
232
|
|
226
233
|
if __name__ == "__main__":
|
227
|
-
|
228
|
-
update_cache()
|
229
|
-
except Exception as e:
|
230
|
-
logging.error(f"Hook execution failed: {e}")
|
231
|
-
sys.exit(1)
|
234
|
+
update_cache()
|
{mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/hooks/pre-commit
RENAMED
@@ -1,16 +1,12 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
|
3
3
|
import sys
|
4
|
-
import logging
|
5
4
|
|
6
5
|
try:
|
7
6
|
from mkdocs_document_dates.cache_manager import update_cache
|
8
7
|
except ImportError:
|
8
|
+
# 正常退出(0 状态码),不影响 git 的后续动作
|
9
9
|
sys.exit(0)
|
10
10
|
|
11
11
|
if __name__ == "__main__":
|
12
|
-
|
13
|
-
update_cache()
|
14
|
-
except Exception as e:
|
15
|
-
logging.error(f"Hook execution failed: {e}")
|
16
|
-
sys.exit(1)
|
12
|
+
update_cache()
|
{mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/hooks_installer.py
RENAMED
@@ -47,7 +47,7 @@ def check_git_available():
|
|
47
47
|
try:
|
48
48
|
subprocess.run(['git', '--version'], check=True, capture_output=True, encoding='utf-8')
|
49
49
|
return True
|
50
|
-
except
|
50
|
+
except Exception:
|
51
51
|
logging.warning("Git not detected, skip hooks installation")
|
52
52
|
return False
|
53
53
|
|
@@ -95,7 +95,7 @@ def configure_git_hooks(hooks_dir):
|
|
95
95
|
)
|
96
96
|
logging.info(f"Git hooks successfully installed in: {hooks_dir}")
|
97
97
|
return True
|
98
|
-
except
|
98
|
+
except Exception as e:
|
99
99
|
logging.error(f"Failed to set git hooks path: {str(e)}")
|
100
100
|
return False
|
101
101
|
|
@@ -65,7 +65,7 @@ class DocumentDatesPlugin(BasePlugin):
|
|
65
65
|
check_git = subprocess.run(['git', 'rev-parse', '--is-inside-work-tree'], capture_output=True, text=True)
|
66
66
|
if check_git.returncode == 0:
|
67
67
|
self.is_git_repo = True
|
68
|
-
except
|
68
|
+
except Exception as e:
|
69
69
|
logging.info(f"Not a Git repository: {str(e)}")
|
70
70
|
|
71
71
|
docs_dir_path = Path(config['docs_dir'])
|
@@ -142,7 +142,14 @@ class DocumentDatesPlugin(BasePlugin):
|
|
142
142
|
target_config = dest_dir / config_file
|
143
143
|
if not target_config.exists():
|
144
144
|
shutil.copy2(source_config, target_config)
|
145
|
-
|
145
|
+
|
146
|
+
# 加载 timeago.js
|
147
|
+
# https://cdn.jsdelivr.net/npm/timeago.js@4.0.2/dist/timeago.min.js
|
148
|
+
# https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.2/timeago.full.min.js
|
149
|
+
if self.config['type'] == 'timeago':
|
150
|
+
config['extra_javascript'].insert(0, 'assets/document_dates/core/timeago.min.js')
|
151
|
+
config['extra_javascript'].insert(1, 'assets/document_dates/core/timeago-load.js')
|
152
|
+
|
146
153
|
# 加载 Tippy CSS 文件
|
147
154
|
tippy_css_dir = dest_dir / 'tippy'
|
148
155
|
for css_file in tippy_css_dir.glob('*.css'):
|
@@ -418,43 +425,9 @@ class DocumentDatesPlugin(BasePlugin):
|
|
418
425
|
return None
|
419
426
|
|
420
427
|
|
421
|
-
def
|
422
|
-
now = datetime.now()
|
423
|
-
diff = now - date
|
424
|
-
seconds = diff.total_seconds()
|
425
|
-
|
426
|
-
if seconds < 10:
|
427
|
-
return t['just_now']
|
428
|
-
elif seconds < 60:
|
429
|
-
return t['seconds_ago'].format(int(seconds))
|
430
|
-
elif seconds < 120:
|
431
|
-
return t['minute_ago']
|
432
|
-
elif seconds < 3600:
|
433
|
-
return t['minutes_ago'].format(int(seconds / 60))
|
434
|
-
elif seconds < 7200:
|
435
|
-
return t['hour_ago']
|
436
|
-
elif seconds < 86400:
|
437
|
-
return t['hours_ago'].format(int(seconds / 3600))
|
438
|
-
elif seconds < 172800:
|
439
|
-
return t['day_ago']
|
440
|
-
elif seconds < 604800:
|
441
|
-
return t['days_ago'].format(int(seconds / 86400))
|
442
|
-
elif seconds < 1209600:
|
443
|
-
return t['week_ago']
|
444
|
-
elif seconds < 2592000:
|
445
|
-
return t['weeks_ago'].format(int(seconds / 604800))
|
446
|
-
elif seconds < 5184000:
|
447
|
-
return t['month_ago']
|
448
|
-
elif seconds < 31536000:
|
449
|
-
return t['months_ago'].format(int(seconds / 2592000))
|
450
|
-
elif seconds < 63072000:
|
451
|
-
return t['year_ago']
|
452
|
-
else:
|
453
|
-
return t['years_ago'].format(int(seconds / 31536000))
|
454
|
-
|
455
|
-
def _get_formatted_date(self, date, translations):
|
428
|
+
def _get_formatted_date(self, date):
|
456
429
|
if self.config['type'] == 'timeago':
|
457
|
-
return
|
430
|
+
return ""
|
458
431
|
elif self.config['type'] == 'datetime':
|
459
432
|
return date.strftime(f"{self.config['date_format']} {self.config['time_format']}")
|
460
433
|
return date.strftime(self.config['date_format'])
|
@@ -469,14 +442,14 @@ class DocumentDatesPlugin(BasePlugin):
|
|
469
442
|
|
470
443
|
# 构建基本的日期信息 HTML
|
471
444
|
html = (
|
472
|
-
f"<div class='document-dates-plugin-wrapper {position_class}'>"
|
473
|
-
f"<div class='document-dates-plugin'>"
|
474
|
-
f"<span data-tippy-content='{t['created_time']}: {created.strftime(self.config['date_format'])}'>"
|
475
|
-
f"<span class='material-icons' data-icon='doc_created'></span>"
|
476
|
-
f"{self._get_formatted_date(created
|
477
|
-
f"<span data-tippy-content='{t['modified_time']}: {modified.strftime(self.config['date_format'])}'>"
|
478
|
-
f"<span class='material-icons' data-icon='doc_modified'></span>"
|
479
|
-
f"{self._get_formatted_date(modified
|
445
|
+
f"<div class='document-dates-plugin-wrapper {position_class}'>"
|
446
|
+
f"<div class='document-dates-plugin'>"
|
447
|
+
f"<span data-tippy-content='{t['created_time']}: {created.strftime(self.config['date_format'])}'>"
|
448
|
+
f"<span class='material-icons' data-icon='doc_created'></span>"
|
449
|
+
f"<time datetime='{created.isoformat()}' locale='{'zh_CN' if locale == 'zh' else locale}'>{self._get_formatted_date(created)}</time></span>"
|
450
|
+
f"<span data-tippy-content='{t['modified_time']}: {modified.strftime(self.config['date_format'])}'>"
|
451
|
+
f"<span class='material-icons' data-icon='doc_modified'></span>"
|
452
|
+
f"<time datetime='{modified.isoformat()}' locale='{'zh_CN' if locale == 'zh' else locale}'>{self._get_formatted_date(modified)}</time></span>"
|
480
453
|
)
|
481
454
|
|
482
455
|
# 添加作者信息
|
@@ -487,8 +460,8 @@ class DocumentDatesPlugin(BasePlugin):
|
|
487
460
|
authors_tooltip = ', '.join(f'<a href="mailto:{a.email}">{a.name}</a>' if a.email else a.name for a in author)
|
488
461
|
|
489
462
|
html += (
|
490
|
-
f"<span data-tippy-content='{t.get('authors', 'Authors')}: {authors_tooltip}'>"
|
491
|
-
f"<span class='material-icons' data-icon='doc_authors'></span>"
|
463
|
+
f"<span data-tippy-content='{t.get('authors', 'Authors')}: {authors_tooltip}'>"
|
464
|
+
f"<span class='material-icons' data-icon='doc_authors'></span>"
|
492
465
|
f"{authors_info}</span>"
|
493
466
|
# f"{authors_tooltip}</span>"
|
494
467
|
)
|
@@ -496,8 +469,8 @@ class DocumentDatesPlugin(BasePlugin):
|
|
496
469
|
# 单个作者的情况
|
497
470
|
author_tooltip = f'<a href="mailto:{author.email}">{author.name}</a>' if author.email else author.name
|
498
471
|
html += (
|
499
|
-
f"<span data-tippy-content='{t.get('author', 'Author')}: {author_tooltip}'>"
|
500
|
-
f"<span class='material-icons' data-icon='doc_author'></span>"
|
472
|
+
f"<span data-tippy-content='{t.get('author', 'Author')}: {author_tooltip}'>"
|
473
|
+
f"<span class='material-icons' data-icon='doc_author'></span>"
|
501
474
|
f"{author.name}</span>"
|
502
475
|
# f"{author_tooltip}</span>"
|
503
476
|
)
|
@@ -43,3 +43,38 @@ DocumentDates.registerHook('afterInit', async (context) => {
|
|
43
43
|
|
44
44
|
});
|
45
45
|
*/
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
/*
|
50
|
+
Demonstrates how to register a local language when using timeago.js
|
51
|
+
Simply translate the English in parentheses into your own language, nothing else needs to be changed!
|
52
|
+
*/
|
53
|
+
/*
|
54
|
+
const localeFunc = (number, index) => {
|
55
|
+
return [
|
56
|
+
['just now', 'right now'],
|
57
|
+
['%s seconds ago', 'in %s seconds'],
|
58
|
+
['1 minute ago', 'in 1 minute'],
|
59
|
+
['%s minutes ago', 'in %s minutes'],
|
60
|
+
['1 hour ago', 'in 1 hour'],
|
61
|
+
['%s hours ago', 'in %s hours'],
|
62
|
+
['1 day ago', 'in 1 day'],
|
63
|
+
['%s days ago', 'in %s days'],
|
64
|
+
['1 week ago', 'in 1 week'],
|
65
|
+
['%s weeks ago', 'in %s weeks'],
|
66
|
+
['1 month ago', 'in 1 month'],
|
67
|
+
['%s months ago', 'in %s months'],
|
68
|
+
['1 year ago', 'in 1 year'],
|
69
|
+
['%s years ago', 'in %s years']
|
70
|
+
][index];
|
71
|
+
};
|
72
|
+
const localeStr = 'whatever';
|
73
|
+
timeago.register(localeStr, localeFunc);
|
74
|
+
|
75
|
+
if (typeof timeago !== 'undefined') {
|
76
|
+
document.querySelectorAll('.document-dates-plugin time').forEach(timeElement => {
|
77
|
+
timeElement.textContent = timeago.format(timeElement.getAttribute('datetime'), localeStr);
|
78
|
+
});
|
79
|
+
}
|
80
|
+
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(s,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((s=s||self).timeago={})}(this,function(s){"use strict";var a=["second","minute","hour","day","week","month","year"];function n(s,n){if(0===n)return["just now","right now"];var e=a[Math.floor(n/2)];return 1<s&&(e+="s"),[s+" "+e+" ago","in "+s+" "+e]}var t=["秒","分钟","小时","天","周","个月","年"];function e(s,n){if(0===n)return["刚刚","片刻后"];var e=t[~~(n/2)];return[s+" "+e+"前",s+" "+e+"后"]}function u(s,n){i[s]=n}function r(s){return i[s]||i.en_US}var i={},m=[60,60,24,7,365/7/12,12];function o(s){return s instanceof Date?s:!isNaN(s)||/^\d+$/.test(s)?new Date(parseInt(s)):(s=(s||"").trim().replace(/\.\d+/,"").replace(/-/,"/").replace(/-/,"/").replace(/(\d)T(\d)/,"$1 $2").replace(/Z/," UTC").replace(/([+-]\d\d):?(\d\d)/," $1$2"),new Date(s))}function d(s,n){for(var e=s<0?1:0,a=s=Math.abs(s),t=0;s>=m[t]&&t<m.length;t++)s/=m[t];return(0===(t*=2)?9:1)<(s=Math.floor(s))&&(t+=1),n(s,t,a)[e].replace("%s",s.toString())}function c(s,n){return((n?o(n):new Date)-o(s))/1e3}var l="timeago-id";function h(s){return parseInt(s.getAttribute(l))}var g={},f=function(s){clearTimeout(s),delete g[s]};function p(s,n,e,a){f(h(s));var t=a.relativeDate,u=a.minInterval,r=c(n,t);s.innerText=d(r,e);var i,o=setTimeout(function(){p(s,n,e,a)},Math.min(1e3*Math.max(function(s){for(var n=1,e=0,a=Math.abs(s);s>=m[e]&&e<m.length;e++)s/=m[e],n*=m[e];return a=(a%=n)?n-a:n,Math.ceil(a)}(r),u||1),2147483647));g[o]=0,i=o,s.setAttribute(l,i)}u("en_US",n),u("zh_CN",e);var b=[["ثانية","ثانيتين","%s ثوان","%s ثانية"],["دقيقة","دقيقتين","%s دقائق","%s دقيقة"],["ساعة","ساعتين","%s ساعات","%s ساعة"],["يوم","يومين","%s أيام","%s يوماً"],["أسبوع","أسبوعين","%s أسابيع","%s أسبوعاً"],["شهر","شهرين","%s أشهر","%s شهراً"],["عام","عامين","%s أعوام","%s عاماً"]];function v(s,n,e,a,t){var u=t%10,r=a;return 1===t?r=s:1==u&&20<t?r=n:1<u&&u<5&&(20<t||t<10)&&(r=e),r}var y=v.bind(null,"секунду","%s секунду","%s секунды","%s секунд"),k=v.bind(null,"хвіліну","%s хвіліну","%s хвіліны","%s хвілін"),j=v.bind(null,"гадзіну","%s гадзіну","%s гадзіны","%s гадзін"),z=v.bind(null,"дзень","%s дзень","%s дні","%s дзён"),w=v.bind(null,"тыдзень","%s тыдзень","%s тыдні","%s тыдняў"),_=v.bind(null,"месяц","%s месяц","%s месяцы","%s месяцаў"),M=v.bind(null,"год","%s год","%s гады","%s гадоў");function q(s){var n=["۰","۱","۲","۳","۴","۵","۶","۷","۸","۹"];return s.toString().replace(/\d/g,function(s){return n[s]})}var S=[["w tej chwili","za chwilę"],["%s sekund temu","za %s sekund"],["1 minutę temu","za 1 minutę"],["%s minut temu","za %s minut"],["1 godzinę temu","za 1 godzinę"],["%s godzin temu","za %s godzin"],["1 dzień temu","za 1 dzień"],["%s dni temu","za %s dni"],["1 tydzień temu","za 1 tydzień"],["%s tygodni temu","za %s tygodni"],["1 miesiąc temu","za 1 miesiąc"],["%s miesięcy temu","za %s miesięcy"],["1 rok temu","za 1 rok"],["%s lat temu","za %s lat"],["%s sekundy temu","za %s sekundy"],["%s minuty temu","za %s minuty"],["%s godziny temu","za %s godziny"],["%s dni temu","za %s dni"],["%s tygodnie temu","za %s tygodnie"],["%s miesiące temu","za %s miesiące"],["%s lata temu","za %s lata"]];function T(s,n,e,a,t){var u=t%10,r=a;return 1===t?r=s:1==u&&20<t?r=n:1<u&&u<5&&(20<t||t<10)&&(r=e),r}var N=T.bind(null,"секунду","%s секунду","%s секунды","%s секунд"),x=T.bind(null,"минуту","%s минуту","%s минуты","%s минут"),D=T.bind(null,"час","%s час","%s часа","%s часов"),I=T.bind(null,"день","%s день","%s дня","%s дней"),O=T.bind(null,"неделю","%s неделю","%s недели","%s недель"),W=T.bind(null,"месяц","%s месяц","%s месяца","%s месяцев"),$=T.bind(null,"год","%s год","%s года","%s лет");function J(s,n,e,a,t){var u=t%10,r=t%100;return 1==t?s:1==u&&11!=r?n:2<=u&&u<=4&&!(12<=r&&r<=14)?e:a}var U=J.bind(null,"1 секунд","%s секунд","%s секунде","%s секунди"),A=J.bind(null,"1 минут","%s минут","%s минуте","%s минута"),C=J.bind(null,"сат времена","%s сат","%s сата","%s сати"),E=J.bind(null,"1 дан","%s дан","%s дана","%s дана"),B=J.bind(null,"недељу дана","%s недељу","%s недеље","%s недеља"),P=J.bind(null,"месец дана","%s месец","%s месеца","%s месеци"),R=J.bind(null,"годину дана","%s годину","%s године","%s година");function Z(s,n,e,a,t){var u=t%10,r=a;return 1===t?r=s:1==u&&20<t?r=n:1<u&&u<5&&(20<t||t<10)&&(r=e),r}var F=Z.bind(null,"секунду","%s секунду","%s секунди","%s секунд"),G=Z.bind(null,"хвилину","%s хвилину","%s хвилини","%s хвилин"),H=Z.bind(null,"годину","%s годину","%s години","%s годин"),K=Z.bind(null,"день","%s день","%s дні","%s днів"),L=Z.bind(null,"тиждень","%s тиждень","%s тиждні","%s тижднів"),Q=Z.bind(null,"місяць","%s місяць","%s місяці","%s місяців"),V=Z.bind(null,"рік","%s рік","%s роки","%s років");var X=Object.freeze({__proto__:null,ar:function(s,n){if(0===n)return["منذ لحظات","بعد لحظات"];var e,a,t=(e=Math.floor(n/2),(a=s)<3?b[e][a-1]:3<=a&&a<=10?b[e][2]:b[e][3]);return["منذ "+t,"بعد "+t]},be:function(s,n){switch(n){case 0:return["толькі што","праз некалькі секунд"];case 1:return[y(s)+" таму","праз "+y(s)];case 2:case 3:return[k(s)+" таму","праз "+k(s)];case 4:case 5:return[j(s)+" таму","праз "+j(s)];case 6:case 7:return[z(s)+" таму","праз "+z(s)];case 8:case 9:return[w(s)+" таму","праз "+w(s)];case 10:case 11:return[_(s)+" таму","праз "+_(s)];case 12:case 13:return[M(s)+" таму","праз "+M(s)];default:return["",""]}},bg:function(s,n){return[["току що","съвсем скоро"],["преди %s секунди","след %s секунди"],["преди 1 минута","след 1 минута"],["преди %s минути","след %s минути"],["преди 1 час","след 1 час"],["преди %s часа","след %s часа"],["преди 1 ден","след 1 ден"],["преди %s дни","след %s дни"],["преди 1 седмица","след 1 седмица"],["преди %s седмици","след %s седмици"],["преди 1 месец","след 1 месец"],["преди %s месеца","след %s месеца"],["преди 1 година","след 1 година"],["преди %s години","след %s години"]][n]},bn_IN:function(s,n){return[["এইমাত্র","একটা সময়"],["%s সেকেন্ড আগে","%s এর সেকেন্ডের মধ্যে"],["1 মিনিট আগে","1 মিনিটে"],["%s এর মিনিট আগে","%s এর মিনিটের মধ্যে"],["1 ঘন্টা আগে","1 ঘন্টা"],["%s ঘণ্টা আগে","%s এর ঘন্টার মধ্যে"],["1 দিন আগে","1 দিনের মধ্যে"],["%s এর দিন আগে","%s এর দিন"],["1 সপ্তাহ আগে","1 সপ্তাহের মধ্যে"],["%s এর সপ্তাহ আগে","%s সপ্তাহের মধ্যে"],["1 মাস আগে","1 মাসে"],["%s মাস আগে","%s মাসে"],["1 বছর আগে","1 বছরের মধ্যে"],["%s বছর আগে","%s বছরে"]][n]},ca:function(s,n){return[["fa un moment","d'aquí un moment"],["fa %s segons","d'aquí %s segons"],["fa 1 minut","d'aquí 1 minut"],["fa %s minuts","d'aquí %s minuts"],["fa 1 hora","d'aquí 1 hora"],["fa %s hores","d'aquí %s hores"],["fa 1 dia","d'aquí 1 dia"],["fa %s dies","d'aquí %s dies"],["fa 1 setmana","d'aquí 1 setmana"],["fa %s setmanes","d'aquí %s setmanes"],["fa 1 mes","d'aquí 1 mes"],["fa %s mesos","d'aquí %s mesos"],["fa 1 any","d'aquí 1 any"],["fa %s anys","d'aquí %s anys"]][n]},de:function(s,n){return[["gerade eben","vor einer Weile"],["vor %s Sekunden","in %s Sekunden"],["vor 1 Minute","in 1 Minute"],["vor %s Minuten","in %s Minuten"],["vor 1 Stunde","in 1 Stunde"],["vor %s Stunden","in %s Stunden"],["vor 1 Tag","in 1 Tag"],["vor %s Tagen","in %s Tagen"],["vor 1 Woche","in 1 Woche"],["vor %s Wochen","in %s Wochen"],["vor 1 Monat","in 1 Monat"],["vor %s Monaten","in %s Monaten"],["vor 1 Jahr","in 1 Jahr"],["vor %s Jahren","in %s Jahren"]][n]},el:function(s,n){return[["μόλις τώρα","σε λίγο"],["%s δευτερόλεπτα πριν","σε %s δευτερόλεπτα"],["1 λεπτό πριν","σε 1 λεπτό"],["%s λεπτά πριν","σε %s λεπτά"],["1 ώρα πριν","σε 1 ώρα"],["%s ώρες πριν","σε %s ώρες"],["1 μέρα πριν","σε 1 μέρα"],["%s μέρες πριν","σε %s μέρες"],["1 εβδομάδα πριν","σε 1 εβδομάδα"],["%s εβδομάδες πριν","σε %s εβδομάδες"],["1 μήνα πριν","σε 1 μήνα"],["%s μήνες πριν","σε %s μήνες"],["1 χρόνο πριν","σε 1 χρόνο"],["%s χρόνια πριν","σε %s χρόνια"]][n]},en_short:function(s,n){return[["just now","right now"],["%ss ago","in %ss"],["1m ago","in 1m"],["%sm ago","in %sm"],["1h ago","in 1h"],["%sh ago","in %sh"],["1d ago","in 1d"],["%sd ago","in %sd"],["1w ago","in 1w"],["%sw ago","in %sw"],["1mo ago","in 1mo"],["%smo ago","in %smo"],["1yr ago","in 1yr"],["%syr ago","in %syr"]][n]},en_US:n,es:function(s,n){return[["justo ahora","en un rato"],["hace %s segundos","en %s segundos"],["hace 1 minuto","en 1 minuto"],["hace %s minutos","en %s minutos"],["hace 1 hora","en 1 hora"],["hace %s horas","en %s horas"],["hace 1 día","en 1 día"],["hace %s días","en %s días"],["hace 1 semana","en 1 semana"],["hace %s semanas","en %s semanas"],["hace 1 mes","en 1 mes"],["hace %s meses","en %s meses"],["hace 1 año","en 1 año"],["hace %s años","en %s años"]][n]},eu:function(s,n){return[["orain","denbora bat barru"],["duela %s segundu","%s segundu barru"],["duela minutu 1","minutu 1 barru"],["duela %s minutu","%s minutu barru"],["duela ordu 1","ordu 1 barru"],["duela %s ordu","%s ordu barru"],["duela egun 1","egun 1 barru"],["duela %s egun","%s egun barru"],["duela aste 1","aste 1 barru"],["duela %s aste","%s aste barru"],["duela hillabete 1","hillabete 1 barru"],["duela %s hillabete","%s hillabete barru"],["duela urte 1","urte 1 barru"],["duela %s urte","%s urte barru"]][n]},fa:function(s,n){var e=[["لحظاتی پیش","همین حالا"],["%s ثانیه پیش","%s ثانیه دیگر"],["۱ دقیقه پیش","۱ دقیقه دیگر"],["%s دقیقه پیش","%s دقیقه دیگر"],["۱ ساعت پیش","۱ ساعت دیگر"],["%s ساعت پیش","%s ساعت دیگر"],["۱ روز پیش","۱ روز دیگر"],["%s روز پیش","%s روز دیگر"],["۱ هفته پیش","۱ هفته دیگر"],["%s هفته پیش","%s هفته دیگر"],["۱ ماه پیش","۱ ماه دیگر"],["%s ماه پیش","%s ماه دیگر"],["۱ سال پیش","۱ سال دیگر"],["%s سال پیش","%s سال دیگر"]][n];return[e[0].replace("%s",q(s)),e[1].replace("%s",q(s))]},fi:function(s,n){return[["juuri äsken","juuri nyt"],["%s sekuntia sitten","%s sekunnin päästä"],["minuutti sitten","minuutin päästä"],["%s minuuttia sitten","%s minuutin päästä"],["tunti sitten","tunnin päästä"],["%s tuntia sitten","%s tunnin päästä"],["päivä sitten","päivän päästä"],["%s päivää sitten","%s päivän päästä"],["viikko sitten","viikon päästä"],["%s viikkoa sitten","%s viikon päästä"],["kuukausi sitten","kuukauden päästä"],["%s kuukautta sitten","%s kuukauden päästä"],["vuosi sitten","vuoden päästä"],["%s vuotta sitten","%s vuoden päästä"]][n]},fr:function(s,n){return[["à l'instant","dans un instant"],["il y a %s secondes","dans %s secondes"],["il y a 1 minute","dans 1 minute"],["il y a %s minutes","dans %s minutes"],["il y a 1 heure","dans 1 heure"],["il y a %s heures","dans %s heures"],["il y a 1 jour","dans 1 jour"],["il y a %s jours","dans %s jours"],["il y a 1 semaine","dans 1 semaine"],["il y a %s semaines","dans %s semaines"],["il y a 1 mois","dans 1 mois"],["il y a %s mois","dans %s mois"],["il y a 1 an","dans 1 an"],["il y a %s ans","dans %s ans"]][n]},gl:function(s,n){return[["xusto agora","daquí a un pouco"],["hai %s segundos","en %s segundos"],["hai 1 minuto","nun minuto"],["hai %s minutos","en %s minutos"],["hai 1 hora","nunha hora"],["hai %s horas","en %s horas"],["hai 1 día","nun día"],["hai %s días","en %s días"],["hai 1 semana","nunha semana"],["hai %s semanas","en %s semanas"],["hai 1 mes","nun mes"],["hai %s meses","en %s meses"],["hai 1 ano","nun ano"],["hai %s anos","en %s anos"]][n]},he:function(s,n){return[["זה עתה","עכשיו"],["לפני %s שניות","בעוד %s שניות"],["לפני דקה","בעוד דקה"],["לפני %s דקות","בעוד %s דקות"],["לפני שעה","בעוד שעה"],2===s?["לפני שעתיים","בעוד שעתיים"]:["לפני %s שעות","בעוד %s שעות"],["אתמול","מחר"],2===s?["לפני יומיים","בעוד יומיים"]:["לפני %s ימים","בעוד %s ימים"],["לפני שבוע","בעוד שבוע"],2===s?["לפני שבועיים","בעוד שבועיים"]:["לפני %s שבועות","בעוד %s שבועות"],["לפני חודש","בעוד חודש"],2===s?["לפני חודשיים","בעוד חודשיים"]:["לפני %s חודשים","בעוד %s חודשים"],["לפני שנה","בעוד שנה"],2===s?["לפני שנתיים","בעוד שנתיים"]:["לפני %s שנים","בעוד %s שנים"]][n]},hi_IN:function(s,n){return[["अभी","कुछ समय"],["%s सेकंड पहले","%s सेकंड में"],["1 मिनट पहले","1 मिनट में"],["%s मिनट पहले","%s मिनट में"],["1 घंटे पहले","1 घंटे में"],["%s घंटे पहले","%s घंटे में"],["1 दिन पहले","1 दिन में"],["%s दिन पहले","%s दिनों में"],["1 सप्ताह पहले","1 सप्ताह में"],["%s हफ्ते पहले","%s हफ्तों में"],["1 महीने पहले","1 महीने में"],["%s महीने पहले","%s महीनों में"],["1 साल पहले","1 साल में"],["%s साल पहले","%s साल में"]][n]},hu:function(s,n){return[["éppen most","éppen most"],["%s másodperce","%s másodpercen belül"],["1 perce","1 percen belül"],["%s perce","%s percen belül"],["1 órája","1 órán belül"],["%s órája","%s órán belül"],["1 napja","1 napon belül"],["%s napja","%s napon belül"],["1 hete","1 héten belül"],["%s hete","%s héten belül"],["1 hónapja","1 hónapon belül"],["%s hónapja","%s hónapon belül"],["1 éve","1 éven belül"],["%s éve","%s éven belül"]][n]},id_ID:function(s,n){return[["baru saja","sebentar"],["%s detik yang lalu","dalam %s detik"],["1 menit yang lalu","dalam 1 menit"],["%s menit yang lalu","dalam %s menit"],["1 jam yang lalu","dalam 1 jam"],["%s jam yang lalu","dalam %s jam"],["1 hari yang lalu","dalam 1 hari"],["%s hari yang lalu","dalam %s hari"],["1 minggu yang lalu","dalam 1 minggu"],["%s minggu yang lalu","dalam %s minggu"],["1 bulan yang lalu","dalam 1 bulan"],["%s bulan yang lalu","dalam %s bulan"],["1 tahun yang lalu","dalam 1 tahun"],["%s tahun yang lalu","dalam %s tahun"]][n]},it:function(s,n){return[["poco fa","fra poco"],["%s secondi fa","fra %s secondi"],["un minuto fa","fra un minuto"],["%s minuti fa","fra %s minuti"],["un'ora fa","fra un'ora"],["%s ore fa","fra %s ore"],["un giorno fa","fra un giorno"],["%s giorni fa","fra %s giorni"],["una settimana fa","fra una settimana"],["%s settimane fa","fra %s settimane"],["un mese fa","fra un mese"],["%s mesi fa","fra %s mesi"],["un anno fa","fra un anno"],["%s anni fa","fra %s anni"]][n]},ja:function(s,n){return[["すこし前","すぐに"],["%s秒前","%s秒以内"],["1分前","1分以内"],["%s分前","%s分以内"],["1時間前","1時間以内"],["%s時間前","%s時間以内"],["1日前","1日以内"],["%s日前","%s日以内"],["1週間前","1週間以内"],["%s週間前","%s週間以内"],["1ヶ月前","1ヶ月以内"],["%sヶ月前","%sヶ月以内"],["1年前","1年以内"],["%s年前","%s年以内"]][n]},ko:function(s,n){return[["방금","곧"],["%s초 전","%s초 후"],["1분 전","1분 후"],["%s분 전","%s분 후"],["1시간 전","1시간 후"],["%s시간 전","%s시간 후"],["1일 전","1일 후"],["%s일 전","%s일 후"],["1주일 전","1주일 후"],["%s주일 전","%s주일 후"],["1개월 전","1개월 후"],["%s개월 전","%s개월 후"],["1년 전","1년 후"],["%s년 전","%s년 후"]][n]},ml:function(s,n){return[["ഇപ്പോള്","കുറച്ചു മുന്പ്"],["%s സെക്കന്റ്കള്ക്ക് മുന്പ്","%s സെക്കന്റില്"],["1 മിനിറ്റിനു മുന്പ്","1 മിനിറ്റില്"],["%s മിനിറ്റുകള്ക്ക് മുന്പ","%s മിനിറ്റില്"],["1 മണിക്കൂറിനു മുന്പ്","1 മണിക്കൂറില്"],["%s മണിക്കൂറുകള്ക്കു മുന്പ്","%s മണിക്കൂറില്"],["1 ഒരു ദിവസം മുന്പ്","1 ദിവസത്തില്"],["%s ദിവസങ്ങള്ക് മുന്പ്","%s ദിവസങ്ങള്ക്കുള്ളില്"],["1 ആഴ്ച മുന്പ്","1 ആഴ്ചയില്"],["%s ആഴ്ചകള്ക്ക് മുന്പ്","%s ആഴ്ചകള്ക്കുള്ളില്"],["1 മാസത്തിനു മുന്പ്","1 മാസത്തിനുള്ളില്"],["%s മാസങ്ങള്ക്ക് മുന്പ്","%s മാസങ്ങള്ക്കുള്ളില്"],["1 വര്ഷത്തിനു മുന്പ്","1 വര്ഷത്തിനുള്ളില്"],["%s വര്ഷങ്ങള്ക്കു മുന്പ്","%s വര്ഷങ്ങള്ക്കുല്ല്ളില്"]][n]},my:function(s,n){return[["ယခုအတွင်း","ယခု"],["%s စက္ကန့် အကြာက","%s စက္ကန့်အတွင်း"],["1 မိနစ် အကြာက","1 မိနစ်အတွင်း"],["%s မိနစ် အကြာက","%s မိနစ်အတွင်း"],["1 နာရီ အကြာက","1 နာရီအတွင်း"],["%s နာရီ အကြာက","%s နာရီအတွင်း"],["1 ရက် အကြာက","1 ရက်အတွင်း"],["%s ရက် အကြာက","%s ရက်အတွင်း"],["1 ပတ် အကြာက","1 ပတ်အတွင်း"],["%s ပတ် အကြာက","%s ပတ်အတွင်း"],["1 လ အကြာက","1 လအတွင်း"],["%s လ အကြာက","%s လအတွင်း"],["1 နှစ် အကြာက","1 နှစ်အတွင်း"],["%s နှစ် အကြာက","%s နှစ်အတွင်း"]][n]},nb_NO:function(s,n){return[["akkurat nå","om litt"],["%s sekunder siden","om %s sekunder"],["1 minutt siden","om 1 minutt"],["%s minutter siden","om %s minutter"],["1 time siden","om 1 time"],["%s timer siden","om %s timer"],["1 dag siden","om 1 dag"],["%s dager siden","om %s dager"],["1 uke siden","om 1 uke"],["%s uker siden","om %s uker"],["1 måned siden","om 1 måned"],["%s måneder siden","om %s måneder"],["1 år siden","om 1 år"],["%s år siden","om %s år"]][n]},nl:function(s,n){return[["recent","binnenkort"],["%s seconden geleden","binnen %s seconden"],["1 minuut geleden","binnen 1 minuut"],["%s minuten geleden","binnen %s minuten"],["1 uur geleden","binnen 1 uur"],["%s uur geleden","binnen %s uur"],["1 dag geleden","binnen 1 dag"],["%s dagen geleden","binnen %s dagen"],["1 week geleden","binnen 1 week"],["%s weken geleden","binnen %s weken"],["1 maand geleden","binnen 1 maand"],["%s maanden geleden","binnen %s maanden"],["1 jaar geleden","binnen 1 jaar"],["%s jaar geleden","binnen %s jaar"]][n]},nn_NO:function(s,n){return[["nett no","om litt"],["%s sekund sidan","om %s sekund"],["1 minutt sidan","om 1 minutt"],["%s minutt sidan","om %s minutt"],["1 time sidan","om 1 time"],["%s timar sidan","om %s timar"],["1 dag sidan","om 1 dag"],["%s dagar sidan","om %s dagar"],["1 veke sidan","om 1 veke"],["%s veker sidan","om %s veker"],["1 månad sidan","om 1 månad"],["%s månadar sidan","om %s månadar"],["1 år sidan","om 1 år"],["%s år sidan","om %s år"]][n]},pl:function(s,n){return S[1&n?4<s%10||s%10<2||1==~~(s/10)%10?n:++n/2+13:n]},pt_BR:function(s,n){return[["agora mesmo","agora"],["há %s segundos","em %s segundos"],["há um minuto","em um minuto"],["há %s minutos","em %s minutos"],["há uma hora","em uma hora"],["há %s horas","em %s horas"],["há um dia","em um dia"],["há %s dias","em %s dias"],["há uma semana","em uma semana"],["há %s semanas","em %s semanas"],["há um mês","em um mês"],["há %s meses","em %s meses"],["há um ano","em um ano"],["há %s anos","em %s anos"]][n]},ro:function(s,n){var e=[["chiar acum","chiar acum"],["acum %s secunde","peste %s secunde"],["acum un minut","peste un minut"],["acum %s minute","peste %s minute"],["acum o oră","peste o oră"],["acum %s ore","peste %s ore"],["acum o zi","peste o zi"],["acum %s zile","peste %s zile"],["acum o săptămână","peste o săptămână"],["acum %s săptămâni","peste %s săptămâni"],["acum o lună","peste o lună"],["acum %s luni","peste %s luni"],["acum un an","peste un an"],["acum %s ani","peste %s ani"]];return s<20?e[n]:[e[n][0].replace("%s","%s de"),e[n][1].replace("%s","%s de")]},ru:function(s,n){switch(n){case 0:return["только что","через несколько секунд"];case 1:return[N(s)+" назад","через "+N(s)];case 2:case 3:return[x(s)+" назад","через "+x(s)];case 4:case 5:return[D(s)+" назад","через "+D(s)];case 6:return["вчера","завтра"];case 7:return[I(s)+" назад","через "+I(s)];case 8:case 9:return[O(s)+" назад","через "+O(s)];case 10:case 11:return[W(s)+" назад","через "+W(s)];case 12:case 13:return[$(s)+" назад","через "+$(s)];default:return["",""]}},sq:function(s,n){return[["pak më parë","pas pak"],["para %s sekondash","pas %s sekondash"],["para një minute","pas një minute"],["para %s minutash","pas %s minutash"],["para një ore","pas një ore"],["para %s orësh","pas %s orësh"],["dje","nesër"],["para %s ditësh","pas %s ditësh"],["para një jave","pas një jave"],["para %s javësh","pas %s javësh"],["para një muaji","pas një muaji"],["para %s muajsh","pas %s muajsh"],["para një viti","pas një viti"],["para %s vjetësh","pas %s vjetësh"]][n]},sr:function(s,n){switch(n){case 0:return["малопре","управо сад"];case 1:return["пре "+U(s),"за "+U(s)];case 2:case 3:return["пре "+A(s),"за "+A(s)];case 4:case 5:return["пре "+C(s),"за "+C(s)];case 6:case 7:return["пре "+E(s),"за "+E(s)];case 8:case 9:return["пре "+B(s),"за "+B(s)];case 10:case 11:return["пре "+P(s),"за "+P(s)];case 12:case 13:return["пре "+R(s),"за "+R(s)];default:return["",""]}},sv:function(s,n){return[["just nu","om en stund"],["%s sekunder sedan","om %s sekunder"],["1 minut sedan","om 1 minut"],["%s minuter sedan","om %s minuter"],["1 timme sedan","om 1 timme"],["%s timmar sedan","om %s timmar"],["1 dag sedan","om 1 dag"],["%s dagar sedan","om %s dagar"],["1 vecka sedan","om 1 vecka"],["%s veckor sedan","om %s veckor"],["1 månad sedan","om 1 månad"],["%s månader sedan","om %s månader"],["1 år sedan","om 1 år"],["%s år sedan","om %s år"]][n]},ta:function(s,n){return[["இப்போது","சற்று நேரம் முன்பு"],["%s நொடிக்கு முன்","%s நொடிகளில்"],["1 நிமிடத்திற்க்கு முன்","1 நிமிடத்தில்"],["%s நிமிடத்திற்க்கு முன்","%s நிமிடங்களில்"],["1 மணி நேரத்திற்கு முன்","1 மணி நேரத்திற்குள்"],["%s மணி நேரத்திற்கு முன்","%s மணி நேரத்திற்குள்"],["1 நாளுக்கு முன்","1 நாளில்"],["%s நாட்களுக்கு முன்","%s நாட்களில்"],["1 வாரத்திற்கு முன்","1 வாரத்தில்"],["%s வாரங்களுக்கு முன்","%s வாரங்களில்"],["1 மாதத்திற்கு முன்","1 மாதத்தில்"],["%s மாதங்களுக்கு முன்","%s மாதங்களில்"],["1 வருடத்திற்கு முன்","1 வருடத்தில்"],["%s வருடங்களுக்கு முன்","%s வருடங்களில்"]][n]},th:function(s,n){return[["เมื่อสักครู่นี้","อีกสักครู่"],["%s วินาทีที่แล้ว","ใน %s วินาที"],["1 นาทีที่แล้ว","ใน 1 นาที"],["%s นาทีที่แล้ว","ใน %s นาที"],["1 ชั่วโมงที่แล้ว","ใน 1 ชั่วโมง"],["%s ชั่วโมงที่แล้ว","ใน %s ชั่วโมง"],["1 วันที่แล้ว","ใน 1 วัน"],["%s วันที่แล้ว","ใน %s วัน"],["1 อาทิตย์ที่แล้ว","ใน 1 อาทิตย์"],["%s อาทิตย์ที่แล้ว","ใน %s อาทิตย์"],["1 เดือนที่แล้ว","ใน 1 เดือน"],["%s เดือนที่แล้ว","ใน %s เดือน"],["1 ปีที่แล้ว","ใน 1 ปี"],["%s ปีที่แล้ว","ใน %s ปี"]][n]},tr:function(s,n){return[["az önce","şimdi"],["%s saniye önce","%s saniye içinde"],["1 dakika önce","1 dakika içinde"],["%s dakika önce","%s dakika içinde"],["1 saat önce","1 saat içinde"],["%s saat önce","%s saat içinde"],["1 gün önce","1 gün içinde"],["%s gün önce","%s gün içinde"],["1 hafta önce","1 hafta içinde"],["%s hafta önce","%s hafta içinde"],["1 ay önce","1 ay içinde"],["%s ay önce","%s ay içinde"],["1 yıl önce","1 yıl içinde"],["%s yıl önce","%s yıl içinde"]][n]},uk:function(s,n){switch(n){case 0:return["щойно","через декілька секунд"];case 1:return[F(s)+" тому","через "+F(s)];case 2:case 3:return[G(s)+" тому","через "+G(s)];case 4:case 5:return[H(s)+" тому","через "+H(s)];case 6:case 7:return[K(s)+" тому","через "+K(s)];case 8:case 9:return[L(s)+" тому","через "+L(s)];case 10:case 11:return[Q(s)+" тому","через "+Q(s)];case 12:case 13:return[V(s)+" тому","через "+V(s)];default:return["",""]}},vi:function(s,n){return[["vừa xong","một lúc"],["%s giây trước","trong %s giây"],["1 phút trước","trong 1 phút"],["%s phút trước","trong %s phút"],["1 giờ trước","trong 1 giờ"],["%s giờ trước","trong %s giờ"],["1 ngày trước","trong 1 ngày"],["%s ngày trước","trong %s ngày"],["1 tuần trước","trong 1 tuần"],["%s tuần trước","trong %s tuần"],["1 tháng trước","trong 1 tháng"],["%s tháng trước","trong %s tháng"],["1 năm trước","trong 1 năm"],["%s năm trước","trong %s năm"]][n]},zh_CN:e,zh_TW:function(s,n){return[["剛剛","片刻後"],["%s 秒前","%s 秒後"],["1 分鐘前","1 分鐘後"],["%s 分鐘前","%s 分鐘後"],["1 小時前","1 小時後"],["%s 小時前","%s 小時後"],["1 天前","1 天後"],["%s 天前","%s 天後"],["1 週前","1 週後"],["%s 週前","%s 週後"],["1 個月前","1 個月後"],["%s 個月前","%s 個月後"],["1 年前","1 年後"],["%s 年前","%s 年後"]][n]}});Object.keys(X).forEach(function(s){u(s,X[s])}),s.cancel=function(s){s?f(h(s)):Object.keys(g).forEach(f)},s.format=function(s,n,e){return d(c(s,e&&e.relativeDate),r(n))},s.register=u,s.render=function(s,n,e){var a=s.length?s:[s];return a.forEach(function(s){p(s,s.getAttribute("datetime"),r(n),e||{})}),a},Object.defineProperty(s,"__esModule",{value:!0})});
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).timeago={})}(this,function(e){"use strict";var r=["second","minute","hour","day","week","month","year"];var a=["秒","分钟","小时","天","周","个月","年"];function t(e,t){n[e]=t}function i(e){return n[e]||n.en_US}var n={},f=[60,60,24,7,365/7/12,12];function o(e){return e instanceof Date?e:!isNaN(e)||/^\d+$/.test(e)?new Date(parseInt(e)):(e=(e||"").trim().replace(/\.\d+/,"").replace(/-/,"/").replace(/-/,"/").replace(/(\d)T(\d)/,"$1 $2").replace(/Z/," UTC").replace(/([+-]\d\d):?(\d\d)/," $1$2"),new Date(e))}function d(e,t){for(var n=e<0?1:0,r=e=Math.abs(e),a=0;e>=f[a]&&a<f.length;a++)e/=f[a];return(0===(a*=2)?9:1)<(e=Math.floor(e))&&(a+=1),t(e,a,r)[n].replace("%s",e.toString())}function l(e,t){return((t?o(t):new Date)-o(e))/1e3}var s="timeago-id";function h(e){return parseInt(e.getAttribute(s))}var p={},v=function(e){clearTimeout(e),delete p[e]};function m(e,t,n,r){v(h(e));var a=r.relativeDate,i=r.minInterval,o=l(t,a);e.innerText=d(o,n);var u,c=setTimeout(function(){m(e,t,n,r)},Math.min(1e3*Math.max(function(e){for(var t=1,n=0,r=Math.abs(e);e>=f[n]&&n<f.length;n++)e/=f[n],t*=f[n];return r=(r%=t)?t-r:t,Math.ceil(r)}(o),i||1),2147483647));p[c]=0,u=c,e.setAttribute(s,u)}t("en_US",function(e,t){if(0===t)return["just now","right now"];var n=r[Math.floor(t/2)];return 1<e&&(n+="s"),[e+" "+n+" ago","in "+e+" "+n]}),t("zh_CN",function(e,t){if(0===t)return["刚刚","片刻后"];var n=a[~~(t/2)];return[e+" "+n+"前",e+" "+n+"后"]}),e.cancel=function(e){e?v(h(e)):Object.keys(p).forEach(v)},e.format=function(e,t,n){return d(l(e,n&&n.relativeDate),i(t))},e.register=t,e.render=function(e,t,n){var r=e.length?e:[e];return r.forEach(function(e){m(e,e.getAttribute("datetime"),i(t),n||{})}),r},Object.defineProperty(e,"__esModule",{value:!0})});
|
{mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates.egg-info/PKG-INFO
RENAMED
@@ -1,9 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mkdocs-document-dates
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.2
|
4
4
|
Summary: An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents.
|
5
5
|
Home-page: https://github.com/jaywhj/mkdocs-document-dates
|
6
6
|
Author: Aaron Wang
|
7
|
+
License: MIT
|
7
8
|
Classifier: Programming Language :: Python :: 3
|
8
9
|
Classifier: License :: OSI Approved :: MIT License
|
9
10
|
Classifier: Operating System :: OS Independent
|
@@ -16,6 +17,7 @@ Dynamic: classifier
|
|
16
17
|
Dynamic: description
|
17
18
|
Dynamic: description-content-type
|
18
19
|
Dynamic: home-page
|
20
|
+
Dynamic: license
|
19
21
|
Dynamic: license-file
|
20
22
|
Dynamic: requires-dist
|
21
23
|
Dynamic: requires-python
|
@@ -70,7 +72,7 @@ plugins:
|
|
70
72
|
- document-dates:
|
71
73
|
position: top # Display position: top (after title) bottom (end of document), default: bottom
|
72
74
|
type: date # Date type: date datetime timeago, default: date
|
73
|
-
locale: en # Localization: zh
|
75
|
+
locale: en # Localization: zh zh_TW en es fr de ar ja ko ru, default: en
|
74
76
|
date_format: '%Y-%m-%d' # Date format, Supports all Python datetime format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
|
75
77
|
time_format: '%H:%M:%S' # Time format (valid only if type=datetime)
|
76
78
|
exclude: # List of excluded files
|
@@ -125,6 +127,15 @@ The plugin supports deep customization, such as icon style, font style, theme co
|
|
125
127
|
- Style & Theme: `docs/assets/document_dates/user.config.css`
|
126
128
|
- Properties & Animations: `docs/assets/document_dates/user.config.js`
|
127
129
|
- Localized languages: `docs/assets/document_dates/languages/` , refer to the template file `en.json` for any additions or modifications
|
130
|
+
- timeago.js localization: `timeago.min.js` only contains English and Chinese by default, if you need to load other languages, you can configure it as below (choose one):
|
131
|
+
- In user.config.js, refer to [the demo commented out](https://github.com/jaywhj/mkdocs-document-dates/blob/main/mkdocs_document_dates/static/config/user.config.js) at the bottom, translate it into your local language
|
132
|
+
- In mkdocs.yml, add the following two lines to configure the full version of `timeago.full.min.js` to load all languages at once
|
133
|
+
|
134
|
+
```yaml
|
135
|
+
extra_javascript:
|
136
|
+
- assets/document_dates/core/timeago.full.min.js
|
137
|
+
- assets/document_dates/core/timeago-load.js
|
138
|
+
```
|
128
139
|
|
129
140
|
## Other Tips
|
130
141
|
|
@@ -147,9 +158,13 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
147
158
|
- Method 2: You can cache the original time, and then read the cache subsequently. The cache can be in Front Matter of the source document or in a separate file, I chose the latter. Storing in Front Matter makes sense and is simple, but this will modify the source content of the document, although it doesn't have any impact on the body, but I still want to ensure the originality of the data!
|
148
159
|
- **Difficulty**:
|
149
160
|
1. When to read and store original time? This is just a plugin for mkdocs, with very limited access and permissions, mkdocs provides only build and serve, so in case a user commits directly without executing build or serve (e.g., when using a CI/CD build system), then you won't be able to retrieve the time information of the file, not to mention caching it!
|
150
|
-
- Let's take a straight shot: the Git Hooks mechanism was found, prompted by the AI, which can trigger a custom script when a specific action occurs, such as every time commit is performed
|
151
|
-
2. How
|
152
|
-
-
|
161
|
+
- Let's take a straight shot: the Git Hooks mechanism was found, prompted by the AI, which can trigger a custom script when a specific git action occurs, such as every time commit is performed
|
162
|
+
2. How to install Git Hooks automatically? When and how are they triggered? Installing packages from PyPI via pip doesn't have a standard post-install hook mechanism
|
163
|
+
- Workaround: After analyzing the flow of pip installing packages from PyPI, I found that when compiling and installing through the source package (sdist), setuptools will be called to handle it, so we can find a way to implant the installation script in the process of setuptools, i.e., we can add a custom script in setup.py
|
164
|
+
3. How to design a cross-platform hook? To execute a python script, we need to explicitly specify the python interpreter, and the user's python environment varies depending on the operating system, the way python is installed, and the configuration, so how can we ensure that it works properly in all environments?
|
165
|
+
- Solution: I considered using a shell script, but since I'd have to call back to python eventually, it's easier to use a python script. We can detect the user's python environment when the hook is installed, and then dynamically set the hook's shebang line to set the correct python interpreter
|
166
|
+
4. How can I ensure that a single cache file does not conflict when collaborating with multi-person?
|
167
|
+
- Workaround: use JSONL (JSON Lines) instead of JSON, and with the merge strategy 'merge=union'
|
153
168
|
- **Improve**:
|
154
169
|
- Since it has been re-developed, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity and personalization**
|
155
170
|
- Ease of use: don't let users do things manually if you can, e.g., auto-install Git Hooks, auto-cache, auto-commit, provide customized templates, etc
|
@@ -157,4 +172,4 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
|
|
157
172
|
- Personalization: almost everything can be customized, whether it's icons, styles, themes, or features, it's all fully customizable
|
158
173
|
- In addition, it has good compatibility and extensibility, and works well in WIN7, mobile devices, old Safari, etc
|
159
174
|
- **The Last Secret**:
|
160
|
-
-
|
175
|
+
- Programming is a hobby, and I'm a marketer of 8 years (Feel free to leave a comment)
|
@@ -16,6 +16,9 @@ mkdocs_document_dates/static/config/user.config.css
|
|
16
16
|
mkdocs_document_dates/static/config/user.config.js
|
17
17
|
mkdocs_document_dates/static/core/core.css
|
18
18
|
mkdocs_document_dates/static/core/core.js
|
19
|
+
mkdocs_document_dates/static/core/timeago-load.js
|
20
|
+
mkdocs_document_dates/static/core/timeago.full.min.js
|
21
|
+
mkdocs_document_dates/static/core/timeago.min.js
|
19
22
|
mkdocs_document_dates/static/languages/ar.json
|
20
23
|
mkdocs_document_dates/static/languages/de.json
|
21
24
|
mkdocs_document_dates/static/languages/en.json
|
@@ -30,12 +30,13 @@ try:
|
|
30
30
|
except FileNotFoundError:
|
31
31
|
long_description = "An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents."
|
32
32
|
|
33
|
-
VERSION = '3.1.
|
33
|
+
VERSION = '3.1.2'
|
34
34
|
|
35
35
|
setup(
|
36
36
|
name="mkdocs-document-dates",
|
37
37
|
version=VERSION,
|
38
38
|
author="Aaron Wang",
|
39
|
+
license="MIT",
|
39
40
|
description="An easy-to-use, lightweight MkDocs plugin for displaying the exact creation time, last modification time and author info of markdown documents.",
|
40
41
|
long_description=long_description,
|
41
42
|
long_description_content_type="text/markdown",
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "الآن",
|
3
|
-
"seconds_ago": "منذ {} ثانية",
|
4
|
-
"minute_ago": "منذ دقيقة",
|
5
|
-
"minutes_ago": "منذ {} دقيقة",
|
6
|
-
"hour_ago": "منذ ساعة",
|
7
|
-
"hours_ago": "منذ {} ساعة",
|
8
|
-
"day_ago": "منذ يوم",
|
9
|
-
"days_ago": "منذ {} يوم",
|
10
|
-
"week_ago": "منذ أسبوع",
|
11
|
-
"weeks_ago": "منذ {} أسبوع",
|
12
|
-
"month_ago": "منذ شهر",
|
13
|
-
"months_ago": "منذ {} شهر",
|
14
|
-
"year_ago": "منذ سنة",
|
15
|
-
"years_ago": "منذ {} سنة",
|
16
|
-
"created_time": "تاريخ الإنشاء",
|
17
|
-
"modified_time": "تاريخ التعديل",
|
18
|
-
"author": "المؤلف",
|
19
|
-
"authors": "المؤلفون"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "gerade jetzt",
|
3
|
-
"seconds_ago": "vor {} Sekunden",
|
4
|
-
"minute_ago": "vor einer Minute",
|
5
|
-
"minutes_ago": "vor {} Minuten",
|
6
|
-
"hour_ago": "vor einer Stunde",
|
7
|
-
"hours_ago": "vor {} Stunden",
|
8
|
-
"day_ago": "vor einem Tag",
|
9
|
-
"days_ago": "vor {} Tagen",
|
10
|
-
"week_ago": "vor einer Woche",
|
11
|
-
"weeks_ago": "vor {} Wochen",
|
12
|
-
"month_ago": "vor einem Monat",
|
13
|
-
"months_ago": "vor {} Monaten",
|
14
|
-
"year_ago": "vor einem Jahr",
|
15
|
-
"years_ago": "vor {} Jahren",
|
16
|
-
"created_time": "Erstellungszeit",
|
17
|
-
"modified_time": "Änderungszeit",
|
18
|
-
"author": "Autor",
|
19
|
-
"authors": "Autoren"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "just now",
|
3
|
-
"seconds_ago": "{} seconds ago",
|
4
|
-
"minute_ago": "1 minute ago",
|
5
|
-
"minutes_ago": "{} minutes ago",
|
6
|
-
"hour_ago": "1 hour ago",
|
7
|
-
"hours_ago": "{} hours ago",
|
8
|
-
"day_ago": "1 day ago",
|
9
|
-
"days_ago": "{} days ago",
|
10
|
-
"week_ago": "1 week ago",
|
11
|
-
"weeks_ago": "{} weeks ago",
|
12
|
-
"month_ago": "1 month ago",
|
13
|
-
"months_ago": "{} months ago",
|
14
|
-
"year_ago": "1 year ago",
|
15
|
-
"years_ago": "{} years ago",
|
16
|
-
"created_time": "Created",
|
17
|
-
"modified_time": "Last Update",
|
18
|
-
"author": "Author",
|
19
|
-
"authors": "Authors"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "justo ahora",
|
3
|
-
"seconds_ago": "hace {} segundos",
|
4
|
-
"minute_ago": "hace un minuto",
|
5
|
-
"minutes_ago": "hace {} minutos",
|
6
|
-
"hour_ago": "hace una hora",
|
7
|
-
"hours_ago": "hace {} horas",
|
8
|
-
"day_ago": "hace un día",
|
9
|
-
"days_ago": "hace {} días",
|
10
|
-
"week_ago": "hace una semana",
|
11
|
-
"weeks_ago": "hace {} semanas",
|
12
|
-
"month_ago": "hace un mes",
|
13
|
-
"months_ago": "hace {} meses",
|
14
|
-
"year_ago": "hace un año",
|
15
|
-
"years_ago": "hace {} años",
|
16
|
-
"created_time": "Fecha de creación",
|
17
|
-
"modified_time": "Fecha de modificación",
|
18
|
-
"author": "Autor",
|
19
|
-
"authors": "Autores"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "à l'instant",
|
3
|
-
"seconds_ago": "il y a {} secondes",
|
4
|
-
"minute_ago": "il y a une minute",
|
5
|
-
"minutes_ago": "il y a {} minutes",
|
6
|
-
"hour_ago": "il y a une heure",
|
7
|
-
"hours_ago": "il y a {} heures",
|
8
|
-
"day_ago": "il y a un jour",
|
9
|
-
"days_ago": "il y a {} jours",
|
10
|
-
"week_ago": "il y a une semaine",
|
11
|
-
"weeks_ago": "il y a {} semaines",
|
12
|
-
"month_ago": "il y a un mois",
|
13
|
-
"months_ago": "il y a {} mois",
|
14
|
-
"year_ago": "il y a un an",
|
15
|
-
"years_ago": "il y a {} ans",
|
16
|
-
"created_time": "Date de création",
|
17
|
-
"modified_time": "Date de modification",
|
18
|
-
"author": "Auteur",
|
19
|
-
"authors": "Auteurs"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "たった今",
|
3
|
-
"seconds_ago": "{} 秒前",
|
4
|
-
"minute_ago": "1 分前",
|
5
|
-
"minutes_ago": "{} 分前",
|
6
|
-
"hour_ago": "1 時間前",
|
7
|
-
"hours_ago": "{} 時間前",
|
8
|
-
"day_ago": "1 日前",
|
9
|
-
"days_ago": "{} 日前",
|
10
|
-
"week_ago": "1 週間前",
|
11
|
-
"weeks_ago": "{} 週間前",
|
12
|
-
"month_ago": "1 ヶ月前",
|
13
|
-
"months_ago": "{} ヶ月前",
|
14
|
-
"year_ago": "1 年前",
|
15
|
-
"years_ago": "{} 年前",
|
16
|
-
"created_time": "作成日時",
|
17
|
-
"modified_time": "更新日時",
|
18
|
-
"author": "著者",
|
19
|
-
"authors": "著者"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "방금",
|
3
|
-
"seconds_ago": "{} 초 전",
|
4
|
-
"minute_ago": "1 분 전",
|
5
|
-
"minutes_ago": "{} 분 전",
|
6
|
-
"hour_ago": "1 시간 전",
|
7
|
-
"hours_ago": "{} 시간 전",
|
8
|
-
"day_ago": "1 일 전",
|
9
|
-
"days_ago": "{} 일 전",
|
10
|
-
"week_ago": "1 주 전",
|
11
|
-
"weeks_ago": "{} 주 전",
|
12
|
-
"month_ago": "1 개월 전",
|
13
|
-
"months_ago": "{} 개월 전",
|
14
|
-
"year_ago": "1 년 전",
|
15
|
-
"years_ago": "{} 년 전",
|
16
|
-
"created_time": "작성일",
|
17
|
-
"modified_time": "수정일",
|
18
|
-
"author": "작성자",
|
19
|
-
"authors": "작성자"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "только что",
|
3
|
-
"seconds_ago": "{} секунд назад",
|
4
|
-
"minute_ago": "минуту назад",
|
5
|
-
"minutes_ago": "{} минут назад",
|
6
|
-
"hour_ago": "час назад",
|
7
|
-
"hours_ago": "{} часов назад",
|
8
|
-
"day_ago": "день назад",
|
9
|
-
"days_ago": "{} дней назад",
|
10
|
-
"week_ago": "неделю назад",
|
11
|
-
"weeks_ago": "{} недель назад",
|
12
|
-
"month_ago": "месяц назад",
|
13
|
-
"months_ago": "{} месяцев назад",
|
14
|
-
"year_ago": "год назад",
|
15
|
-
"years_ago": "{} лет назад",
|
16
|
-
"created_time": "Дата создания",
|
17
|
-
"modified_time": "Дата изменения",
|
18
|
-
"author": "Автор",
|
19
|
-
"authors": "Авторы"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "刚刚",
|
3
|
-
"seconds_ago": "{} 秒前",
|
4
|
-
"minute_ago": "1 分钟前",
|
5
|
-
"minutes_ago": "{} 分钟前",
|
6
|
-
"hour_ago": "1 小时前",
|
7
|
-
"hours_ago": "{} 小时前",
|
8
|
-
"day_ago": "1 天前",
|
9
|
-
"days_ago": "{} 天前",
|
10
|
-
"week_ago": "1 周前",
|
11
|
-
"weeks_ago": "{} 周前",
|
12
|
-
"month_ago": "1 个月前",
|
13
|
-
"months_ago": "{} 个月前",
|
14
|
-
"year_ago": "1 年前",
|
15
|
-
"years_ago": "{} 年前",
|
16
|
-
"created_time": "创建时间",
|
17
|
-
"modified_time": "最后更新",
|
18
|
-
"author": "作者",
|
19
|
-
"authors": "作者"
|
20
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"just_now": "剛剛",
|
3
|
-
"seconds_ago": "{} 秒前",
|
4
|
-
"minute_ago": "1 分鐘前",
|
5
|
-
"minutes_ago": "{} 分鐘前",
|
6
|
-
"hour_ago": "1 小時前",
|
7
|
-
"hours_ago": "{} 小時前",
|
8
|
-
"day_ago": "1 天前",
|
9
|
-
"days_ago": "{} 天前",
|
10
|
-
"week_ago": "1 週前",
|
11
|
-
"weeks_ago": "{} 週前",
|
12
|
-
"month_ago": "1 個月前",
|
13
|
-
"months_ago": "{} 個月前",
|
14
|
-
"year_ago": "1 年前",
|
15
|
-
"years_ago": "{} 年前",
|
16
|
-
"created_time": "建立時間",
|
17
|
-
"modified_time": "修改時間",
|
18
|
-
"author": "作者",
|
19
|
-
"authors": "作者"
|
20
|
-
}
|
File without changes
|
{mkdocs_document_dates-3.1.1 → mkdocs_document_dates-3.1.2}/mkdocs_document_dates/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|