From eac243818d651281e841188481859d3e6e251cc8 Mon Sep 17 00:00:00 2001
From: dynastxu <151742029+ETOofficial@users.noreply.github.com>
Date: Sun, 9 Nov 2025 00:06:10 +0800
Subject: [PATCH] Squashed 'src/DjangoBlog/' changes from 408d19c..13ebbc8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
13ebbc8 优化代码
git-subtree-dir: src/DjangoBlog
git-subtree-split: 13ebbc80d2e3639d9271431d19b52afe889e8646
---
accounts/forms.py | 1 +
accounts/migrations/0001_initial.py | 2 +-
...s_remove_bloguser_created_time_and_more.py | 2 +-
accounts/models.py | 1 +
accounts/tests.py | 7 ++--
accounts/utils.py | 1 +
accounts/views.py | 5 ++-
blog/admin.py | 10 ++---
blog/documents.py | 14 ++++---
blog/management/commands/ping_baidu.py | 5 ++-
blog/management/commands/sync_user_avatar.py | 3 +-
blog/middleware.py | 4 +-
blog/migrations/0001_initial.py | 5 +--
...options_alter_category_options_and_more.py | 5 +--
blog/templatetags/blog_tags.py | 10 ++---
blog/tests.py | 13 ++++---
blog/views.py | 37 +++++++++----------
comments/admin.py | 4 +-
comments/migrations/0001_initial.py | 3 +-
...ns_remove_comment_created_time_and_more.py | 3 +-
comments/tests.py | 3 +-
djangoblog/blog_signals.py | 13 ++-----
djangoblog/elasticsearch_backend.py | 6 ++-
djangoblog/feeds.py | 12 ++++--
djangoblog/plugin_manage/base_plugin.py | 21 +++++++----
djangoblog/plugin_manage/loader.py | 3 +-
djangoblog/sitemap.py | 12 ++++--
djangoblog/spider_notify.py | 2 +-
djangoblog/urls.py | 7 ++--
djangoblog/utils.py | 12 +++---
djangoblog/whoosh_cn_backend.py | 30 ++++++++-------
oauth/admin.py | 3 +-
oauth/migrations/0001_initial.py | 3 +-
...ptions_alter_oauthuser_options_and_more.py | 3 +-
oauth/oauthmanager.py | 13 +++++--
oauth/tests.py | 18 +++++----
owntracks/migrations/0001_initial.py | 2 +-
owntracks/tests.py | 2 +-
plugins/article_copyright/plugin.py | 5 ++-
plugins/article_recommendation/plugin.py | 10 +++--
plugins/external_links/plugin.py | 6 ++-
plugins/image_lazy_loading/plugin.py | 16 +++++---
plugins/reading_time/plugin.py | 6 ++-
plugins/seo_optimizer/plugin.py | 18 +++++----
plugins/view_count/plugin.py | 5 ++-
servermanager/api/blogapi.py | 3 +-
servermanager/api/commonapi.py | 3 +-
servermanager/robot.py | 16 ++++----
servermanager/tests.py | 7 ++--
49 files changed, 220 insertions(+), 175 deletions(-)
diff --git a/accounts/forms.py b/accounts/forms.py
index fce4137..964466e 100644
--- a/accounts/forms.py
+++ b/accounts/forms.py
@@ -4,6 +4,7 @@ from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
from django.core.exceptions import ValidationError
from django.forms import widgets
from django.utils.translation import gettext_lazy as _
+
from . import utils
from .models import BlogUser
diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py
index d2fbcab..884428e 100644
--- a/accounts/migrations/0001_initial.py
+++ b/accounts/migrations/0001_initial.py
@@ -2,8 +2,8 @@
import django.contrib.auth.models
import django.contrib.auth.validators
-from django.db import migrations, models
import django.utils.timezone
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/accounts/migrations/0002_alter_bloguser_options_remove_bloguser_created_time_and_more.py b/accounts/migrations/0002_alter_bloguser_options_remove_bloguser_created_time_and_more.py
index 1a9f509..854d366 100644
--- a/accounts/migrations/0002_alter_bloguser_options_remove_bloguser_created_time_and_more.py
+++ b/accounts/migrations/0002_alter_bloguser_options_remove_bloguser_created_time_and_more.py
@@ -1,7 +1,7 @@
# Generated by Django 4.2.5 on 2023-09-06 13:13
-from django.db import migrations, models
import django.utils.timezone
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/accounts/models.py b/accounts/models.py
index 3baddbb..855dfc8 100644
--- a/accounts/models.py
+++ b/accounts/models.py
@@ -3,6 +3,7 @@ from django.db import models
from django.urls import reverse
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
+
from djangoblog.utils import get_current_site
diff --git a/accounts/tests.py b/accounts/tests.py
index 6893411..e962f67 100644
--- a/accounts/tests.py
+++ b/accounts/tests.py
@@ -1,7 +1,6 @@
from django.test import Client, RequestFactory, TestCase
from django.urls import reverse
from django.utils import timezone
-from django.utils.translation import gettext_lazy as _
from accounts.models import BlogUser
from blog.models import Article, Category
@@ -23,12 +22,12 @@ class AccountTest(TestCase):
self.new_test = "xxx123--="
def test_validate_account(self):
- site = get_current_site().domain
+ get_current_site().domain
user = BlogUser.objects.create_superuser(
email="liangliangyy1@gmail.com",
username="liangliangyy1",
password="qwer!@#$ggg")
- testuser = BlogUser.objects.get(username='liangliangyy1')
+ BlogUser.objects.get(username='liangliangyy1')
loginresult = self.client.login(
username='liangliangyy1',
@@ -60,7 +59,7 @@ class AccountTest(TestCase):
0, len(
BlogUser.objects.filter(
email='user123@user.com')))
- response = self.client.post(reverse('account:register'), {
+ self.client.post(reverse('account:register'), {
'username': 'user1233',
'email': 'user123@user.com',
'password1': 'password123!q@wE#R$T',
diff --git a/accounts/utils.py b/accounts/utils.py
index 4b94bdf..d416b35 100644
--- a/accounts/utils.py
+++ b/accounts/utils.py
@@ -37,6 +37,7 @@ def verify(email: str, code: str) -> typing.Optional[str]:
cache_code = get_code(email)
if cache_code != code:
return gettext("Verification code error")
+ return None
def set_code(email: str, code: str):
diff --git a/accounts/views.py b/accounts/views.py
index ae67aec..e9c188e 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -1,5 +1,5 @@
import logging
-from django.utils.translation import gettext_lazy as _
+
from django.conf import settings
from django.contrib import auth
from django.contrib.auth import REDIRECT_FIELD_NAME
@@ -191,7 +191,8 @@ class ForgetPasswordView(FormView):
class ForgetPasswordEmailCode(View):
- def post(self, request: HttpRequest):
+ @staticmethod
+ def post(request: HttpRequest):
form = ForgetPasswordCodeForm(request.POST)
if not form.is_valid():
return HttpResponse("错误的邮箱")
diff --git a/blog/admin.py b/blog/admin.py
index 69d7f8e..3207b63 100644
--- a/blog/admin.py
+++ b/blog/admin.py
@@ -6,7 +6,7 @@ from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
# Register your models here.
-from .models import Article, Category, Tag, Links, SideBar, BlogSettings
+from .models import Article
class ArticleForm(forms.ModelForm):
@@ -17,19 +17,19 @@ class ArticleForm(forms.ModelForm):
fields = '__all__'
-def makr_article_publish(modeladmin, request, queryset):
+def makr_article_publish(queryset):
queryset.update(status='p')
-def draft_article(modeladmin, request, queryset):
+def draft_article(queryset):
queryset.update(status='d')
-def close_article_commentstatus(modeladmin, request, queryset):
+def close_article_commentstatus(queryset):
queryset.update(comment_status='c')
-def open_article_commentstatus(modeladmin, request, queryset):
+def open_article_commentstatus(queryset):
queryset.update(comment_status='o')
diff --git a/blog/documents.py b/blog/documents.py
index 0f1db7b..2b0c883 100644
--- a/blog/documents.py
+++ b/blog/documents.py
@@ -164,20 +164,23 @@ class ArticleDocument(Document):
doc_type = 'Article'
-class ArticleDocumentManager():
+class ArticleDocumentManager:
def __init__(self):
self.create_index()
- def create_index(self):
+ @staticmethod
+ def create_index():
ArticleDocument.init()
- def delete_index(self):
+ @staticmethod
+ def delete_index():
from elasticsearch import Elasticsearch
es = Elasticsearch(settings.ELASTICSEARCH_DSL['default']['hosts'])
es.indices.delete(index='blog', ignore=[400, 404])
- def convert_to_doc(self, articles):
+ @staticmethod
+ def convert_to_doc(articles):
return [
ArticleDocument(
meta={
@@ -208,6 +211,7 @@ class ArticleDocumentManager():
for doc in docs:
doc.save()
- def update_docs(self, docs):
+ @staticmethod
+ def update_docs(docs):
for doc in docs:
doc.save()
diff --git a/blog/management/commands/ping_baidu.py b/blog/management/commands/ping_baidu.py
index 2c7fbdd..0063ea1 100644
--- a/blog/management/commands/ping_baidu.py
+++ b/blog/management/commands/ping_baidu.py
@@ -1,8 +1,8 @@
from django.core.management.base import BaseCommand
+from blog.models import Article, Tag, Category
from djangoblog.spider_notify import SpiderNotify
from djangoblog.utils import get_current_site
-from blog.models import Article, Tag, Category
site = get_current_site().domain
@@ -21,7 +21,8 @@ class Command(BaseCommand):
'category'],
help='article : all article,tag : all tag,category: all category,all: All of these')
- def get_full_url(self, path):
+ @staticmethod
+ def get_full_url(path):
url = "https://{site}{path}".format(site=site, path=path)
return url
diff --git a/blog/management/commands/sync_user_avatar.py b/blog/management/commands/sync_user_avatar.py
index d0f4612..bab11b4 100644
--- a/blog/management/commands/sync_user_avatar.py
+++ b/blog/management/commands/sync_user_avatar.py
@@ -10,7 +10,8 @@ from oauth.oauthmanager import get_manager_by_type
class Command(BaseCommand):
help = 'sync user avatar'
- def test_picture(self, url):
+ @staticmethod
+ def test_picture(url):
try:
if requests.get(url, timeout=2).status_code == 200:
return True
diff --git a/blog/middleware.py b/blog/middleware.py
index 94dd70c..881c347 100644
--- a/blog/middleware.py
+++ b/blog/middleware.py
@@ -15,7 +15,7 @@ class OnlineMiddleware(object):
super().__init__()
def __call__(self, request):
- ''' page render time '''
+ """ page render time """
start_time = time.time()
response = self.get_response(request)
http_user_agent = request.META.get('HTTP_USER_AGENT', '')
@@ -25,7 +25,7 @@ class OnlineMiddleware(object):
try:
cast_time = time.time() - start_time
if ELASTICSEARCH_ENABLED:
- time_taken = round((cast_time) * 1000, 2)
+ time_taken = round(cast_time * 1000, 2)
url = request.path
from django.utils import timezone
ElaspedTimeDocumentManager.create(
diff --git a/blog/migrations/0001_initial.py b/blog/migrations/0001_initial.py
index 3d391b6..525c125 100644
--- a/blog/migrations/0001_initial.py
+++ b/blog/migrations/0001_initial.py
@@ -1,10 +1,9 @@
# Generated by Django 4.1.7 on 2023-03-02 07:14
-from django.conf import settings
-from django.db import migrations, models
-import django.db.models.deletion
import django.utils.timezone
import mdeditor.fields
+from django.conf import settings
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/blog/migrations/0005_alter_article_options_alter_category_options_and_more.py b/blog/migrations/0005_alter_article_options_alter_category_options_and_more.py
index d08e853..398a9c7 100644
--- a/blog/migrations/0005_alter_article_options_alter_category_options_and_more.py
+++ b/blog/migrations/0005_alter_article_options_alter_category_options_and_more.py
@@ -1,10 +1,9 @@
# Generated by Django 4.2.5 on 2023-09-06 13:13
-from django.conf import settings
-from django.db import migrations, models
-import django.db.models.deletion
import django.utils.timezone
import mdeditor.fields
+from django.conf import settings
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/blog/templatetags/blog_tags.py b/blog/templatetags/blog_tags.py
index 024f2c8..eb0800f 100644
--- a/blog/templatetags/blog_tags.py
+++ b/blog/templatetags/blog_tags.py
@@ -1,7 +1,5 @@
-import hashlib
import logging
import random
-import urllib
from django import template
from django.conf import settings
@@ -14,11 +12,11 @@ from django.utils.safestring import mark_safe
from blog.models import Article, Category, Tag, Links, SideBar, LinkShowType
from comments.models import Comment
+from djangoblog.plugin_manage import hooks
from djangoblog.utils import CommonMarkdown, sanitize_html
from djangoblog.utils import cache
from djangoblog.utils import get_current_site
from oauth.models import OAuthUser
-from djangoblog.plugin_manage import hooks
logger = logging.getLogger(__name__)
@@ -168,7 +166,7 @@ def load_breadcrumb(article):
names = article.get_category_tree()
from djangoblog.utils import get_blog_setting
blogsetting = get_blog_setting()
- site = get_current_site().domain
+ get_current_site().domain
names.append((blogsetting.site_name, '/'))
names = names[::-1]
@@ -363,7 +361,7 @@ def load_article_detail(article, isindex, user):
# 返回用户头像URL
# 模板使用方法: {{ email|gravatar_url:150 }}
@register.filter
-def gravatar_url(email, size=40):
+def gravatar_url(email):
"""获得用户头像 - 优先使用OAuth头像,否则使用默认头像"""
cachekey = 'avatar/' + email
url = cache.get(cachekey)
@@ -400,7 +398,7 @@ def gravatar_url(email, size=40):
@register.filter
def gravatar(email, size=40):
"""获得用户头像HTML标签"""
- url = gravatar_url(email, size)
+ url = gravatar_url(email)
return mark_safe(
'' %
(url, size, size))
diff --git a/blog/tests.py b/blog/tests.py
index ee13505..a9f2147 100644
--- a/blog/tests.py
+++ b/blog/tests.py
@@ -25,7 +25,7 @@ class ArticleTest(TestCase):
self.factory = RequestFactory()
def test_validate_article(self):
- site = get_current_site().domain
+ get_current_site().domain
user = BlogUser.objects.get_or_create(
email="liangliangyy@gmail.com",
username="liangliangyy")[0]
@@ -35,8 +35,8 @@ class ArticleTest(TestCase):
user.save()
response = self.client.get(user.get_absolute_url())
self.assertEqual(response.status_code, 200)
- response = self.client.get('/admin/servermanager/emailsendlog/')
- response = self.client.get('admin/admin/logentry/')
+ self.client.get('/admin/servermanager/emailsendlog/')
+ self.client.get('admin/admin/logentry/')
s = SideBar()
s.sequence = 1
s.name = 'test'
@@ -126,8 +126,8 @@ class ArticleTest(TestCase):
SpiderNotify.baidu_notify([article.get_full_url()])
from blog.templatetags.blog_tags import gravatar_url, gravatar
- u = gravatar_url('liangliangyy@gmail.com')
- u = gravatar('liangliangyy@gmail.com')
+ gravatar_url('liangliangyy@gmail.com')
+ gravatar('liangliangyy@gmail.com')
link = Links(
sequence=1,
@@ -186,7 +186,8 @@ class ArticleTest(TestCase):
rsp = self.client.get('/eee')
self.assertEqual(rsp.status_code, 404)
- def test_commands(self):
+ @staticmethod
+ def test_commands():
user = BlogUser.objects.get_or_create(
email="liangliangyy@gmail.com",
username="liangliangyy")[0]
diff --git a/blog/views.py b/blog/views.py
index 773bb75..fd0a820 100644
--- a/blog/views.py
+++ b/blog/views.py
@@ -18,7 +18,6 @@ from haystack.views import SearchView
from blog.models import Article, Category, LinkShowType, Links, Tag
from comments.forms import CommentForm
from djangoblog.plugin_manage import hooks
-from djangoblog.plugin_manage.hook_constants import ARTICLE_CONTENT_HOOK_NAME
from djangoblog.utils import cache, get_blog_setting, get_sha256
logger = logging.getLogger(__name__)
@@ -60,11 +59,11 @@ class ArticleListView(ListView):
raise NotImplementedError()
def get_queryset_from_cache(self, cache_key):
- '''
+ """
缓存页面数据
:param cache_key: 缓存key
:return:
- '''
+ """
value = cache.get(cache_key)
if value:
logger.info('get view cache.key:{key}'.format(key=cache_key))
@@ -76,10 +75,10 @@ class ArticleListView(ListView):
return article_list
def get_queryset(self):
- '''
+ """
重写默认,从缓存获取数据
:return:
- '''
+ """
key = self.get_queryset_cache_key()
value = self.get_queryset_from_cache(key)
return value
@@ -90,9 +89,9 @@ class ArticleListView(ListView):
class IndexView(ArticleListView):
- '''
+ """
首页
- '''
+ """
# 友情链接类型
link_type = LinkShowType.I
@@ -106,9 +105,9 @@ class IndexView(ArticleListView):
class ArticleDetailView(DetailView):
- '''
+ """
文章详情页面
- '''
+ """
template_name = 'blog/article_detail.html'
model = Article
pk_url_kwarg = 'article_id'
@@ -163,9 +162,9 @@ class ArticleDetailView(DetailView):
class CategoryDetailView(ArticleListView):
- '''
+ """
分类目录列表
- '''
+ """
page_type = "分类目录归档"
def get_queryset_data(self):
@@ -202,9 +201,9 @@ class CategoryDetailView(ArticleListView):
class AuthorDetailView(ArticleListView):
- '''
+ """
作者详情页
- '''
+ """
page_type = '作者文章归档'
def get_queryset_cache_key(self):
@@ -228,9 +227,9 @@ class AuthorDetailView(ArticleListView):
class TagDetailView(ArticleListView):
- '''
+ """
标签列表页面
- '''
+ """
page_type = '分类标签归档'
def get_queryset_data(self):
@@ -260,9 +259,9 @@ class TagDetailView(ArticleListView):
class ArchivesView(ArticleListView):
- '''
+ """
文章归档页面
- '''
+ """
page_type = '文章归档'
paginate_by = None
page_kwarg = None
@@ -347,7 +346,7 @@ def page_not_found_view(
template_name='blog/error_page.html'):
if exception:
logger.error(exception)
- url = request.get_full_path()
+ request.get_full_path()
return render(request,
template_name,
{'message': _('Sorry, the page you requested is not found, please click the home page to see other?'),
@@ -375,6 +374,6 @@ def permission_denied_view(
'statuscode': '403'}, status=403)
-def clean_cache_view(request):
+def clean_cache_view():
cache.clear()
return HttpResponse('ok')
diff --git a/comments/admin.py b/comments/admin.py
index dbde14f..1e9bc73 100644
--- a/comments/admin.py
+++ b/comments/admin.py
@@ -4,11 +4,11 @@ from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
-def disable_commentstatus(modeladmin, request, queryset):
+def disable_commentstatus(queryset):
queryset.update(is_enable=False)
-def enable_commentstatus(modeladmin, request, queryset):
+def enable_commentstatus(queryset):
queryset.update(is_enable=True)
diff --git a/comments/migrations/0001_initial.py b/comments/migrations/0001_initial.py
index 61d1e53..eec9566 100644
--- a/comments/migrations/0001_initial.py
+++ b/comments/migrations/0001_initial.py
@@ -1,9 +1,8 @@
# Generated by Django 4.1.7 on 2023-03-02 07:14
+import django.utils.timezone
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
-import django.utils.timezone
class Migration(migrations.Migration):
diff --git a/comments/migrations/0003_alter_comment_options_remove_comment_created_time_and_more.py b/comments/migrations/0003_alter_comment_options_remove_comment_created_time_and_more.py
index a1ca970..6507ae1 100644
--- a/comments/migrations/0003_alter_comment_options_remove_comment_created_time_and_more.py
+++ b/comments/migrations/0003_alter_comment_options_remove_comment_created_time_and_more.py
@@ -1,9 +1,8 @@
# Generated by Django 4.2.5 on 2023-09-06 13:13
+import django.utils.timezone
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
-import django.utils.timezone
class Migration(migrations.Migration):
diff --git a/comments/tests.py b/comments/tests.py
index 2a7f55f..32d872c 100644
--- a/comments/tests.py
+++ b/comments/tests.py
@@ -24,7 +24,8 @@ class CommentsTest(TransactionTestCase):
username="liangliangyy1",
password="liangliangyy1")
- def update_article_comment_status(self, article):
+ @staticmethod
+ def update_article_comment_status(article):
comments = article.comment_set.all()
for comment in comments:
comment.is_enable = True
diff --git a/djangoblog/blog_signals.py b/djangoblog/blog_signals.py
index 779a267..d331d76 100644
--- a/djangoblog/blog_signals.py
+++ b/djangoblog/blog_signals.py
@@ -45,7 +45,7 @@ send_email_signal = django.dispatch.Signal(
@receiver(send_email_signal)
-def send_email_signal_handler(sender, **kwargs):
+def send_email_signal_handler(**kwargs):
"""`xjj`
发送邮件信号的处理函数
@@ -85,7 +85,7 @@ def send_email_signal_handler(sender, **kwargs):
@receiver(oauth_user_login_signal)
-def oauth_user_login_signal_handler(sender, **kwargs):
+def oauth_user_login_signal_handler(**kwargs):
"""`xjj`
OAuth 用户登录信号处理函数
@@ -109,13 +109,8 @@ def oauth_user_login_signal_handler(sender, **kwargs):
@receiver(post_save)
def model_post_save_callback(
- sender,
instance,
- created,
- raw,
- using,
- update_fields,
- **kwargs):
+ update_fields):
"""`xjj`
模型保存后的回调函数,用于处理缓存清理和搜索引擎通知等操作
@@ -171,7 +166,7 @@ def model_post_save_callback(
@receiver(user_logged_in)
@receiver(user_logged_out)
-def user_auth_callback(sender, request, user, **kwargs):
+def user_auth_callback(user):
if user and user.username:
logger.info(user)
delete_sidebar_cache()
diff --git a/djangoblog/elasticsearch_backend.py b/djangoblog/elasticsearch_backend.py
index f22ab2c..c049ad2 100644
--- a/djangoblog/elasticsearch_backend.py
+++ b/djangoblog/elasticsearch_backend.py
@@ -73,7 +73,8 @@ class ElasticSearchBackend(BaseSearchBackend):
docs = self._get_models(models)
self.manager.rebuild(docs)
- def _delete(self, models):
+ @staticmethod
+ def _delete(models):
"""`xjj`
删除指定模型对象。
@@ -206,7 +207,8 @@ class ElasticSearchBackend(BaseSearchBackend):
class ElasticSearchQuery(BaseSearchQuery):
- def _convert_datetime(self, date):
+ @staticmethod
+ def _convert_datetime(date):
"""`xjj`
将日期时间对象转换为字符串格式
diff --git a/djangoblog/feeds.py b/djangoblog/feeds.py
index cb5bcb3..18e2dbb 100644
--- a/djangoblog/feeds.py
+++ b/djangoblog/feeds.py
@@ -36,7 +36,8 @@ class DjangoBlogFeed(Feed):
title = "且听风吟 大巧无工,重剑无锋. "
link = "/feed/"
- def author_name(self):
+ @staticmethod
+ def author_name():
"""`xjj`
获取 RSS 订阅源的作者名称
@@ -46,7 +47,8 @@ class DjangoBlogFeed(Feed):
"""
return get_user_model().objects.first().nickname
- def author_link(self):
+ @staticmethod
+ def author_link():
"""`xjj`
获取 RSS 订阅源作者的链接地址
@@ -56,7 +58,8 @@ class DjangoBlogFeed(Feed):
"""
return get_user_model().objects.first().get_absolute_url()
- def items(self):
+ @staticmethod
+ def items():
"""`xjj`
获取 RSS 订阅源的文章列表
@@ -92,7 +95,8 @@ class DjangoBlogFeed(Feed):
"""
return CommonMarkdown.get_markdown(item.body)
- def feed_copyright(self):
+ @staticmethod
+ def feed_copyright():
"""`xjj`
获取 RSS 订阅源的版权信息
diff --git a/djangoblog/plugin_manage/base_plugin.py b/djangoblog/plugin_manage/base_plugin.py
index df1ce0b..e7e1ed6 100644
--- a/djangoblog/plugin_manage/base_plugin.py
+++ b/djangoblog/plugin_manage/base_plugin.py
@@ -112,23 +112,28 @@ class BasePlugin:
"""渲染文章底部组件"""
return None
- def render_article_top_widget(self, context, **kwargs):
+ @staticmethod
+ def render_article_top_widget():
"""渲染文章顶部组件"""
return None
- def render_header_widget(self, context, **kwargs):
+ @staticmethod
+ def render_header_widget():
"""渲染页头组件"""
return None
- def render_footer_widget(self, context, **kwargs):
+ @staticmethod
+ def render_footer_widget():
"""渲染页脚组件"""
return None
- def render_comment_before_widget(self, context, **kwargs):
+ @staticmethod
+ def render_comment_before_widget():
"""渲染评论前组件"""
return None
- def render_comment_after_widget(self, context, **kwargs):
+ @staticmethod
+ def render_comment_after_widget():
"""渲染评论后组件"""
return None
@@ -169,11 +174,13 @@ class BasePlugin:
"""获取插件JavaScript文件列表"""
return []
- def get_head_html(self, context=None):
+ @staticmethod
+ def get_head_html():
"""获取需要插入到