Przeglądaj źródła

feat: 将发布时间精确到分钟

Co-authored-by: aider (deepseek/deepseek-v4-pro) <aider@aider.chat>
Your Name 3 dni temu
rodzic
commit
146cb77c3a
4 zmienionych plików z 5 dodań i 5 usunięć
  1. 2 2
      app.py
  2. 1 1
      templates/admin.html
  3. 1 1
      templates/index.html
  4. 1 1
      templates/post_template.html

+ 2 - 2
app.py

@@ -149,8 +149,8 @@ def upload():
     # 提取缩略图
     thumbnail = extract_thumbnail(html_body)
 
-    # 生成日期
-    date_iso = datetime.now(timezone.utc).isoformat()
+    # 生成日期(精确到分钟)
+    date_iso = datetime.now(timezone.utc).replace(second=0, microsecond=0).isoformat()
 
     # 生成静态页面
     generate_static_page(post_id, title, html_body, date_iso, thumbnail)

+ 1 - 1
templates/admin.html

@@ -20,7 +20,7 @@
                 <td>
                     <a href="{{ url_for('view_post', post_id=post.id) }}">{{ post.title }}</a>
                 </td>
-                <td>{{ post.date[:10] }}</td>
+                <td>{{ post.date[:16] | replace('T', ' ') }}</td>
                 <td>
                     <form method="POST" action="{{ url_for('delete_post', post_id=post.id) }}" onsubmit="return confirm('确定要删除「{{ post.title }}」吗?此操作不可恢复。');">
                         <button type="submit" class="btn btn-danger">删除</button>

+ 1 - 1
templates/index.html

@@ -16,7 +16,7 @@
                 <h2 class="card-title">
                     <a href="{{ url_for('view_post', post_id=post.id) }}">{{ post.title }}</a>
                 </h2>
-                <time class="card-date" datetime="{{ post.date }}">{{ post.date[:10] }}</time>
+                <time class="card-date" datetime="{{ post.date }}">{{ post.date[:16] | replace('T', ' ') }}</time>
                 <div class="card-summary">{{ post.content | safe }}</div>
                 <a href="{{ url_for('view_post', post_id=post.id) }}" class="card-link">阅读全文 →</a>
             </div>

+ 1 - 1
templates/post_template.html

@@ -11,7 +11,7 @@
     {% endif %}
     <div class="card-body">
         <h1 class="card-title">{{ title }}</h1>
-        <time class="card-date" datetime="{{ date }}">{{ date[:10] }}</time>
+        <time class="card-date" datetime="{{ date }}">{{ date[:16] | replace('T', ' ') }}</time>
         <div class="card-summary">
             {{ content | safe }}
         </div>