File tree Expand file tree Collapse file tree 5 files changed +34
-6
lines changed Expand file tree Collapse file tree 5 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -26,13 +26,13 @@ spec:
26
26
name : djangoblog-env
27
27
readinessProbe :
28
28
httpGet :
29
- path : /
29
+ path : /health/
30
30
port : 8000
31
31
initialDelaySeconds : 10
32
32
periodSeconds : 30
33
33
livenessProbe :
34
34
httpGet :
35
- path : /
35
+ path : /health/
36
36
port : 8000
37
37
initialDelaySeconds : 10
38
38
periodSeconds : 30
Original file line number Diff line number Diff line change 20
20
from django .urls import path , include
21
21
from django .urls import re_path
22
22
from haystack .views import search_view_factory
23
+ from django .http import JsonResponse
24
+ import time
23
25
24
26
from blog .views import EsSearchView
25
27
from djangoblog .admin_site import admin_site
40
42
handler500 = 'blog.views.server_error_view'
41
43
handle403 = 'blog.views.permission_denied_view'
42
44
45
+
46
+ def health_check (request ):
47
+ """
48
+ 健康检查接口
49
+ 简单返回服务健康状态
50
+ """
51
+ return JsonResponse ({
52
+ 'status' : 'healthy' ,
53
+ 'timestamp' : time .time ()
54
+ })
55
+
43
56
urlpatterns = [
44
57
path ('i18n/' , include ('django.conf.urls.i18n' )),
58
+ path ('health/' , health_check , name = 'health_check' ),
45
59
]
46
60
urlpatterns += i18n_patterns (
47
61
re_path (r'^admin/' , admin_site .urls ),
Original file line number Diff line number Diff line change @@ -17,7 +17,15 @@ def register_hooks(self):
17
17
def add_reading_time (self , content , * args , ** kwargs ):
18
18
"""
19
19
计算阅读时间并添加到内容开头。
20
+ 只在文章详情页显示,首页(文章列表页)不显示。
20
21
"""
22
+ # 检查是否为摘要模式(首页/文章列表页)
23
+ # 通过kwargs中的is_summary参数判断
24
+ is_summary = kwargs .get ('is_summary' , False )
25
+ if is_summary :
26
+ # 如果是摘要模式(首页),直接返回原内容,不添加阅读时间
27
+ return content
28
+
21
29
# 移除HTML标签和空白字符,以获得纯文本
22
30
clean_content = re .sub (r'<[^>]*>' , '' , content )
23
31
clean_content = clean_content .strip ()
Original file line number Diff line number Diff line change 2
2
< li class ="comment even thread-even depth-{{ depth }} parent " id ="comment-{{ comment_item.pk }} ">
3
3
< div id ="div-comment-{{ comment_item.pk }} " class ="comment-body ">
4
4
< div class ="comment-author vcard ">
5
- < img alt =""
5
+ < img alt ="{{ comment_item.author.username }}的头像 "
6
6
src ="{{ comment_item.author.email|gravatar_url:150 }} "
7
7
srcset ="{{ comment_item.author.email|gravatar_url:150 }} "
8
- class ="avatar avatar-96 photo ">
8
+ class ="avatar avatar-96 photo "
9
+ loading ="lazy "
10
+ decoding ="async "
11
+ style ="max-width:100%;height:auto; ">
9
12
< cite class ="fn ">
10
13
< a rel ="nofollow "
11
14
{% if comment_item.author.is_superuser %}
Original file line number Diff line number Diff line change 3
3
style ="margin-left: {% widthratio depth 1 3 %}rem ">
4
4
< div id ="div-comment-{{ comment_item.pk }} " class ="comment-body ">
5
5
< div class ="comment-author vcard ">
6
- < img alt =""
6
+ < img alt ="{{ comment_item.author.username }}的头像 "
7
7
src ="{{ comment_item.author.email|gravatar_url:150 }} "
8
8
srcset ="{{ comment_item.author.email|gravatar_url:150 }} "
9
- class ="avatar avatar-96 photo ">
9
+ class ="avatar avatar-96 photo "
10
+ loading ="lazy "
11
+ decoding ="async "
12
+ style ="max-width:100%;height:auto; ">
10
13
< cite class ="fn ">
11
14
< a rel ="nofollow "
12
15
{% if comment_item.author.is_superuser %}
You can’t perform that action at this time.
0 commit comments