forked from mirror/MrDoc
优化文集列表文集简介文本显示
This commit is contained in:
parent
59ef79e445
commit
63d4d3ee10
@ -3,6 +3,8 @@
|
||||
from app_doc.models import *
|
||||
from django import template
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.html import strip_tags
|
||||
import markdown
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@ -58,4 +60,10 @@ def get_project_collaborator_cnt(value):
|
||||
@register.filter(name='tag_doc_cnt')
|
||||
def get_img_group_cnt(value):
|
||||
cnt = DocTag.objects.filter(tag=value).count()
|
||||
return cnt
|
||||
return cnt
|
||||
|
||||
# 获取文集简介的纯文本
|
||||
@register.filter(name='project_desc')
|
||||
def get_project_desc(value):
|
||||
value = strip_tags(markdown.markdown(value))[:201]
|
||||
return value
|
@ -168,8 +168,8 @@
|
||||
{% if p.intro == "" %}
|
||||
<span class="">{% trans "此文集没有填写简介" %}</span>
|
||||
{% else %}
|
||||
<span class="">{{ p.intro | slice:'20' }}…</span>
|
||||
<span class="tooltip-content clearfix">{{ p.intro | slice:'100' }}</span>
|
||||
<span class="">{{ p.intro | project_desc | slice:'20' }}…</span>
|
||||
<span class="tooltip-content clearfix">{{ p.intro | project_desc | slice:'100' }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% for new_doc in p.id|get_new_doc %}
|
||||
|
Loading…
Reference in New Issue
Block a user