|
|
|
|
@ -1,18 +1,21 @@
|
|
|
|
|
{% load blog_tags %}
|
|
|
|
|
{% load cache %}
|
|
|
|
|
{% load i18n %}
|
|
|
|
|
{% load blog_tags %} // 加载自定义博客相关的自定义模板标签库
|
|
|
|
|
{% load cache %} // 加载缓存功能相关的模板标签库
|
|
|
|
|
{% load i18n %} // 加载国际化相关的模板标签库
|
|
|
|
|
|
|
|
|
|
<article id="post-{{ article.pk }} "
|
|
|
|
|
class="post-{{ article.pk }} post type-post status-publish format-standard hentry">
|
|
|
|
|
<header class="entry-header">
|
|
|
|
|
class="post-{{ article.pk }} post type-post status-publish format-standard hentry">// 加载国际化相关的模板标签库
|
|
|
|
|
|
|
|
|
|
<header class="entry-header">// 文章头部区域,包含标题等信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h1 class="entry-title">
|
|
|
|
|
{% if isindex %}
|
|
|
|
|
{% if article.article_order > 0 %}
|
|
|
|
|
<h1 class="entry-title">// 文章标题元素
|
|
|
|
|
{% if isindex %} // 判断当前是否为索引页(文章列表页)
|
|
|
|
|
{% if article.article_order > 0 %} // 若为索引页,判断文章是否有置顶顺序(大于0表示置顶)
|
|
|
|
|
<a href="{{ article.get_absolute_url }}"
|
|
|
|
|
rel="bookmark">【{% trans 'pin to top' %}】{{ article.title }}</a>
|
|
|
|
|
rel="bookmark">【{% trans 'pin to top' %}】{{ article.title }}</a>// 显示带"置顶"标识的文章标题
|
|
|
|
|
{% else %}
|
|
|
|
|
<a href="{{ article.get_absolute_url }}"
|
|
|
|
|
rel="bookmark">{{ article.title }}</a>
|
|
|
|
|
rel="bookmark">{{ article.title }}</a>// 显示普通文章标题
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
|
{% else %}
|
|
|
|
|
@ -22,25 +25,25 @@
|
|
|
|
|
<div class="comments-link">
|
|
|
|
|
{% if article.comment_status == "o" and open_site_comment %}
|
|
|
|
|
<a href="{{ article.get_absolute_url }}#comments" class="ds-thread-count" data-thread-key="3815"
|
|
|
|
|
rel="nofollow">
|
|
|
|
|
<span class="leave-reply">
|
|
|
|
|
rel="nofollow">// 链接添加nofollow属性,告诉搜索引擎不要追踪此链接
|
|
|
|
|
<span class="leave-reply">// 评论数量显示容器
|
|
|
|
|
{% if article.comment_set and article.comment_set.count %}
|
|
|
|
|
{{ article.comment_set.count }} {% trans 'comments' %}
|
|
|
|
|
{{ article.comment_set.count }} {% trans 'comments' %}// 检查是否有评论且评论数量存在
|
|
|
|
|
{% else %}
|
|
|
|
|
{% trans 'comment' %}
|
|
|
|
|
{% trans 'comment' %}// 显示"comment"文本(国际化)
|
|
|
|
|
{% endif %}
|
|
|
|
|
</span>
|
|
|
|
|
</a>
|
|
|
|
|
{% endif %}
|
|
|
|
|
<div style="float:right">
|
|
|
|
|
{{ article.views }} views
|
|
|
|
|
<div style="float:right">// 阅读量显示容器,设置右浮动
|
|
|
|
|
{{ article.views }} views// 显示文章阅读量和"views"文本
|
|
|
|
|
</div>
|
|
|
|
|
</div><!-- .comments-link -->
|
|
|
|
|
<br/>
|
|
|
|
|
{% if article.type == 'a' %}
|
|
|
|
|
{% if not isindex %}
|
|
|
|
|
{% cache 36000 breadcrumb article.pk %}
|
|
|
|
|
{% load_breadcrumb article %}
|
|
|
|
|
{% if article.type == 'a' %} // 检查文章类型是否为文章
|
|
|
|
|
{% if not isindex %} // 如果当前不是索引页(即文章详情页)
|
|
|
|
|
{% cache 36000 breadcrumb article.pk %}// 缓存面包屑导航,有效期10小时(36000秒),以文章主键作为缓存键
|
|
|
|
|
{% load_breadcrumb article %}// 调用自定义标签加载文章的面包屑导航
|
|
|
|
|
{% endcache %}
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% endif %}
|
|
|
|
|
@ -48,27 +51,29 @@
|
|
|
|
|
|
|
|
|
|
<div class="entry-content" itemprop="articleBody">
|
|
|
|
|
{% if isindex %}
|
|
|
|
|
{{ article.body|custom_markdown|escape|truncatechars_content }}
|
|
|
|
|
{{ article.body|custom_markdown|escape|truncatechars_content }}// 显示经过markdown处理、转义并截断的文章内容
|
|
|
|
|
|
|
|
|
|
<p class='read-more'><a
|
|
|
|
|
href=' {{ article.get_absolute_url }}'>Read more</a></p>
|
|
|
|
|
{% else %}
|
|
|
|
|
|
|
|
|
|
{% if article.show_toc %}
|
|
|
|
|
{% get_markdown_toc article.body as toc %}
|
|
|
|
|
{% if article.show_toc %}// 检查文章是否设置显示目录
|
|
|
|
|
{% get_markdown_toc article.body as toc %}// 调用自定义标签获取文章内容的markdown目录,并赋值给toc变量
|
|
|
|
|
<b>{% trans 'toc' %}:</b>
|
|
|
|
|
{{ toc|safe }}
|
|
|
|
|
{{ toc|safe }}// 安全地显示目录内容(允许HTML渲染)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<hr class="break_line"/>
|
|
|
|
|
{% endif %}
|
|
|
|
|
<div class="article">
|
|
|
|
|
|
|
|
|
|
{{ article.body|custom_markdown|escape }}
|
|
|
|
|
{{ article.body|custom_markdown|escape }}// 显示经过markdown处理和转义的完整文章内容
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
|
</div><!-- .entry-content -->
|
|
|
|
|
|
|
|
|
|
{% load_article_metas article user %}
|
|
|
|
|
{% load_article_metas article user %}// 调用自定义标签加载文章的元数据(如作者、发布时间等),传入文章对象和用户对象
|
|
|
|
|
|
|
|
|
|
</article><!-- #post -->
|