post.swig 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. {##################}
  2. {### POST BLOCK ###}
  3. {##################}
  4. <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="{{ post.lang or config.language }}">
  5. <link itemprop="mainEntityOfPage" href="{{ post.permalink }}">
  6. <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
  7. <meta itemprop="image" content="{{ url_for(theme.avatar.url or theme.images + '/avatar.gif') }}">
  8. <meta itemprop="name" content="{{ author }}">
  9. <meta itemprop="description" content="{{ description }}">
  10. </span>
  11. <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
  12. <meta itemprop="name" content="{{ title }}">
  13. </span>
  14. {%- if post.header !== false %}
  15. <header class="post-header">
  16. <{%- if is_index %}h2{% else %}h1{%- endif %} class="post-title{%- if post.direction and post.direction.toLowerCase() === 'rtl' %} rtl{%- endif %}" itemprop="name headline">
  17. {# Link posts #}
  18. {%- if post.link %}
  19. {%- if post.sticky > 0 %}
  20. <span class="post-sticky-flag" title="{{ __('post.sticky') }}">
  21. <i class="fa fa-thumbtack"></i>
  22. </span>
  23. {%- endif %}
  24. {%- set postTitleIcon = '<i class="fa fa-external-link-alt"></i>' %}
  25. {%- set postText = post.title or post.link %}
  26. {{ next_url(post.link, postText + postTitleIcon, {class: 'post-title-link post-title-link-external', itemprop: 'url'}) }}
  27. {% elif is_index %}
  28. {%- if post.sticky > 0 %}
  29. <span class="post-sticky-flag" title="{{ __('post.sticky') }}">
  30. <i class="fa fa-thumbtack"></i>
  31. </span>
  32. {%- endif %}
  33. {{ next_url(post.path, post.title or __('post.untitled'), {class: 'post-title-link', itemprop: 'url'}) }}
  34. {%- else %}
  35. {{- post.title }}
  36. {{- post_edit(post.source) }}
  37. {%- endif %}
  38. </{%- if is_index %}h2{% else %}h1{%- endif %}>
  39. <div class="post-meta">
  40. {%- set date_diff = date(post.date) != date(post.updated) %}
  41. {%- set time_diff = time(post.date) != time(post.updated) %}
  42. {%- set datetime_diff = date_diff or time_diff %}
  43. {%- if theme.post_meta.created_at %}
  44. <span class="post-meta-item">
  45. <span class="post-meta-item-icon">
  46. <i class="far fa-calendar"></i>
  47. </span>
  48. <span class="post-meta-item-text">{{ __('post.posted') }}</span>
  49. {%- if not date_diff and time_diff and theme.post_meta.updated_at.enable and theme.post_meta.updated_at.another_day %}
  50. {%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) + ' / ' + __('post.modified') + __('symbol.colon') + time(post.updated) %}
  51. {% else %}
  52. {%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) %}
  53. {%- endif %}
  54. <time title="{{ create_title }}" itemprop="dateCreated datePublished" datetime="{{ moment(post.date).format() }}">{{ date(post.date) }}</time>
  55. </span>
  56. {%- endif %}
  57. {%- if theme.post_meta.updated_at.enable and datetime_diff %}
  58. {%- set display_updated = not theme.post_meta.updated_at.another_day or theme.post_meta.updated_at.another_day and date_diff %}
  59. {%- if display_updated or not theme.post_meta.created_at %}
  60. <span class="post-meta-item">
  61. <span class="post-meta-item-icon">
  62. <i class="far fa-calendar-check"></i>
  63. </span>
  64. <span class="post-meta-item-text">{{ __('post.edited') }}</span>
  65. <time title="{{ __('post.modified') + __('symbol.colon') + full_date(post.updated) }}" itemprop="dateModified" datetime="{{ moment(post.updated).format() }}">{{ date(post.updated) }}</time>
  66. </span>
  67. {%- endif %}
  68. {%- endif %}
  69. {%- if post.categories and post.categories.length and theme.post_meta.categories %}
  70. <span class="post-meta-item">
  71. <span class="post-meta-item-icon">
  72. <i class="far fa-folder"></i>
  73. </span>
  74. <span class="post-meta-item-text">{{ __('post.in') }}</span>
  75. {%- for cat in post.categories.toArray() %}
  76. <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
  77. <a href="{{ url_for(cat.path) }}" itemprop="url" rel="index"><span itemprop="name">{{ cat.name }}</span></a>
  78. </span>
  79. {%- set cat_length = post.categories.length %}
  80. {%- if cat_length > 1 and loop.index !== cat_length %}
  81. {{ __('symbol.comma') }}
  82. {%- endif %}
  83. {%- endfor %}
  84. </span>
  85. {%- endif %}
  86. {# LeanCloud PageView #}
  87. {%- if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appid and theme.valine.appkey and theme.valine.visitor) %}
  88. <span id="{{ url_for(post.path) }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ post.title }}" title="{{ __('post.views') }}">
  89. <span class="post-meta-item-icon">
  90. <i class="fa fa-eye"></i>
  91. </span>
  92. <span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
  93. <span class="leancloud-visitors-count"></span>
  94. </span>
  95. {%- endif %}
  96. {%- if theme.firestore.enable %}
  97. <span class="post-meta-item" title="{{ __('post.views') }}">
  98. <span class="post-meta-item-icon">
  99. <i class="fa fa-users"></i>
  100. </span>
  101. <span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
  102. <span class="firestore-visitors-count"></span>
  103. </span>
  104. {%- endif %}
  105. {%- if not is_index and theme.busuanzi_count.enable and theme.busuanzi_count.post_views %}
  106. <span class="post-meta-item" title="{{ __('post.views') }}" id="busuanzi_container_page_pv" style="display: none;">
  107. <span class="post-meta-item-icon">
  108. <i class="{{ theme.busuanzi_count.post_views_icon }}"></i>
  109. </span>
  110. <span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
  111. <span id="busuanzi_value_page_pv"></span>
  112. </span>
  113. {%- endif %}
  114. {{- next_inject('postMeta') }}
  115. {%- if config.symbols_count_time.symbols %}
  116. {%- if theme.symbols_count_time.separated_meta %}<br>{%- endif %}
  117. <span class="post-meta-item" title="{{ __('symbols_count_time.count') }}">
  118. <span class="post-meta-item-icon">
  119. <i class="far fa-file-word"></i>
  120. </span>
  121. {%- if theme.symbols_count_time.item_text_post %}
  122. <span class="post-meta-item-text">{{ __('symbols_count_time.count') + __('symbol.colon') }}</span>
  123. {%- endif %}
  124. <span>{{ symbolsCount(post) }}</span>
  125. </span>
  126. {%- endif %}
  127. {%- if config.symbols_count_time.time %}
  128. <span class="post-meta-item" title="{{ __('symbols_count_time.time') }}">
  129. <span class="post-meta-item-icon">
  130. <i class="far fa-clock"></i>
  131. </span>
  132. {%- if theme.symbols_count_time.item_text_post %}
  133. <span class="post-meta-item-text">{{ __('symbols_count_time.time') }} &asymp;</span>
  134. {%- endif %}
  135. <span>{{ symbolsTime(post, config.symbols_count_time.awl, config.symbols_count_time.wpm, __('symbols_count_time.time_minutes')) }}</span>
  136. </span>
  137. {%- endif %}
  138. {%- if post.description and (not theme.excerpt_description or not is_index) %}
  139. <div class="post-description">{{ post.description }}</div>
  140. {%- endif %}
  141. </div>
  142. </header>
  143. {%- endif %}
  144. {#################}
  145. {### POST BODY ###}
  146. {#################}
  147. <div class="post-body{%- if post.direction and post.direction.toLowerCase() === 'rtl' %} rtl{%- endif %}" itemprop="articleBody">
  148. {# Gallery support #}
  149. {%- if post.photos and post.photos.length %}
  150. <div class="post-gallery" itemscope itemtype="http://schema.org/ImageGallery">
  151. {%- for photo in post.photos %}
  152. <img src="{{ url_for(photo) }}" itemprop="contentUrl">
  153. {%- endfor %}
  154. </div>
  155. {%- endif %}
  156. {%- if is_index %}
  157. {%- if post.description and theme.excerpt_description %}
  158. <p>{{ post.description }}</p>
  159. <!--noindex-->
  160. {%- if theme.read_more_btn %}
  161. <div class="post-button">
  162. <a class="btn" href="{{ url_for(post.path) }}">
  163. {{ __('post.read_more') }} &raquo;
  164. </a>
  165. </div>
  166. {%- endif %}
  167. <!--/noindex-->
  168. {% elif post.excerpt %}
  169. {{ post.excerpt }}
  170. <!--noindex-->
  171. {%- if theme.read_more_btn %}
  172. <div class="post-button">
  173. <a class="btn" href="{{ url_for(post.path) }}#more" rel="contents">
  174. {{ __('post.read_more') }} &raquo;
  175. </a>
  176. </div>
  177. {%- endif %}
  178. <!--/noindex-->
  179. {% else %}
  180. {{ post.content }}
  181. {%- endif %}
  182. {% else %}
  183. {{ post.content }}
  184. {%- endif %}
  185. </div>
  186. {#####################}
  187. {### END POST BODY ###}
  188. {#####################}
  189. {%- if theme.related_posts.enable and (theme.related_posts.display_in_home or not is_index) %}
  190. {{ partial('_partials/post/post-related.swig') }}
  191. {%- endif %}
  192. {%- if not is_index %}
  193. {{- next_inject('postBodyEnd') }}
  194. {%- if post.reward_settings.enable %}
  195. {{ partial('_partials/post/post-reward.swig') }}
  196. {%- endif %}
  197. {%- if theme.creative_commons.license and theme.creative_commons.post %}
  198. {{ partial('_partials/post/post-copyright.swig') }}
  199. {%- endif %}
  200. {%- if theme.follow_me %}
  201. {{ partial('_partials/post/post-followme.swig', {}, {cache: theme.cache.enable}) }}
  202. {%- endif %}
  203. <footer class="post-footer">
  204. {%- if post.tags and post.tags.length %}
  205. {%- if theme.tag_icon %}
  206. {%- set tag_indicate = '<i class="fa fa-tag"></i>' %}
  207. {% else %}
  208. {%- set tag_indicate = '#' %}
  209. {%- endif %}
  210. <div class="post-tags">
  211. {%- for tag in post.tags.toArray() %}
  212. <a href="{{ url_for(tag.path) }}" rel="tag">{{ tag_indicate }} {{ tag.name }}</a>
  213. {%- endfor %}
  214. </div>
  215. {%- endif %}
  216. {{ partial('_partials/post/post-footer.swig', {}, {cache: theme.cache.enable}) }}
  217. {{ post_nav(post) }}
  218. </footer>
  219. {% else %}
  220. <footer class="post-footer">
  221. <div class="post-eof"></div>
  222. </footer>
  223. {%- endif %}
  224. </article>
  225. {######################}
  226. {### END POST BLOCK ###}
  227. {######################}