From 6c03d3d63345da8aeaa08a0159d02c180ba341a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=C9=AA=E1=B4=8D=C9=AA?= <1119186082@qq.com> Date: Thu, 8 Aug 2019 00:39:17 +0800 Subject: [PATCH] Optimize the rendering of posts (#1075) --- layout/_macro/post.swig | 153 +++++++----------- layout/_partials/post/post-copyright.swig | 2 + layout/_partials/post/post-footer.swig | 50 ++++++ .../post/{reward.swig => post-reward.swig} | 0 layout/_partials/share/index.swig | 3 + layout/_partials/share/likely.swig | 13 -- 6 files changed, 110 insertions(+), 111 deletions(-) create mode 100644 layout/_partials/post/post-footer.swig rename layout/_partials/post/{reward.swig => post-reward.swig} (100%) diff --git a/layout/_macro/post.swig b/layout/_macro/post.swig index 106bc89200..e5987ece10 100644 --- a/layout/_macro/post.swig +++ b/layout/_macro/post.swig @@ -261,6 +261,10 @@ {%- endif %} + {#####################} + {### END POST BODY ###} + {#####################} + {%- if theme.related_posts.enable and (theme.related_posts.display_in_home or not is_index) %} {% include '../_partials/post/post-related.swig' with { post: post } %} {%- endif %} @@ -269,117 +273,70 @@ {%- for inject_item in theme.injects.postBodyEnd %} {{ partial(inject_item.layout, inject_item.locals, inject_item.options) }} {%- endfor %} - {%- endif %} - - {#####################} - {### END POST BODY ###} - {#####################} - {%- if theme.wechat_subscriber.enable and not is_index %} - {% include '../_partials/post/wechat-subscriber.swig' %} - {%- endif %} + {%- if theme.wechat_subscriber.enable %} + {{ partial('../_partials/post/wechat-subscriber.swig', {}, {cache: theme.cache.enable}) }} + {%- endif %} - {%- if post.reward === undefined and theme.reward_settings.enable %} - {%- set reward_able = true %} - {% else %} - {%- set reward_able = post.reward %} - {%- endif %} - {%- if reward_able and not is_index %} -
- {% include '../_partials/post/reward.swig' %} -
- {%- endif %} + {%- if post.reward === undefined and theme.reward_settings.enable %} + {%- set reward_able = true %} + {% else %} + {%- set reward_able = post.reward %} + {%- endif %} + {%- if reward_able %} + {{ partial('../_partials/post/post-reward.swig', {}, {cache: theme.cache.enable}) }} + {%- endif %} - {%- if theme.creative_commons.license and theme.creative_commons.post and not is_index %} -
+ {%- if theme.creative_commons.license and theme.creative_commons.post %} {% include '../_partials/post/post-copyright.swig' with { post: post } %} -
- {%- endif %} - - + {%- endif %} + + {% else %} + + {%- endif %} {######################} {### END POST BLOCK ###} diff --git a/layout/_partials/post/post-copyright.swig b/layout/_partials/post/post-copyright.swig index 6b5c958de6..17c0503c8d 100644 --- a/layout/_partials/post/post-copyright.swig +++ b/layout/_partials/post/post-copyright.swig @@ -9,6 +9,7 @@ {%- endif %} {%- set ccURL = 'https://creativecommons.org/' + ccType %} +
+
diff --git a/layout/_partials/post/post-footer.swig b/layout/_partials/post/post-footer.swig new file mode 100644 index 0000000000..897afaa404 --- /dev/null +++ b/layout/_partials/post/post-footer.swig @@ -0,0 +1,50 @@ +{%- if theme.rating.enable or (theme.vkontakte_api.enable and theme.vkontakte_api.like) or (theme.facebook_sdk.enable and theme.facebook_sdk.like_button) or theme.likely.enable or (theme.needmoreshare2.enable and theme.needmoreshare2.postbottom.enable) %} +
+ {%- if theme.rating.enable %} +
+
+
+ {%- endif %} + + {%- if (theme.vkontakte_api.enable and theme.vkontakte_api.like) or (theme.facebook_sdk.enable and theme.facebook_sdk.like_button) %} +
+ {%- if theme.vkontakte_api.enable and theme.vkontakte_api.like %} +
+ +
+ {%- endif %} + + {%- if theme.facebook_sdk.enable and theme.facebook_sdk.like_button %} +
+
+
+ {%- endif %} +
+ {%- endif %} + + {%- if theme.likely.enable or (theme.needmoreshare2.enable and theme.needmoreshare2.postbottom.enable) %} +
+ {%- if theme.likely.enable %} + {%- if theme.likely.look == 'normal' %} + {%- set likely_look = 'likely' %} + {% else %} + {%- set likely_look = 'likely likely-' + theme.likely.look %} + {%- endif %} + +
+ {%- for x in theme.likely.networks %} +
{{ x }}
+ {%- endfor %} +
+ {%- endif %} + {%- if theme.needmoreshare2.enable and theme.needmoreshare2.postbottom.enable %} +
+ + + +
+ {%- endif %} +
+ {%- endif %} +
+{%- endif %} diff --git a/layout/_partials/post/reward.swig b/layout/_partials/post/post-reward.swig similarity index 100% rename from layout/_partials/post/reward.swig rename to layout/_partials/post/post-reward.swig diff --git a/layout/_partials/share/index.swig b/layout/_partials/share/index.swig index 64a97f964a..46644a2b7a 100644 --- a/layout/_partials/share/index.swig +++ b/layout/_partials/share/index.swig @@ -1,6 +1,9 @@ {%- if theme.add_this_id %} {% include 'add-this.swig' %} {%- endif %} +{%- if theme.likely.enable %} + {% include 'likely.swig' %} +{%- endif %} {%- if theme.needmoreshare2.enable %} {% include 'needsharebutton.swig' %} {%- endif %} diff --git a/layout/_partials/share/likely.swig b/layout/_partials/share/likely.swig index ee353e525b..5e7a3ca893 100644 --- a/layout/_partials/share/likely.swig +++ b/layout/_partials/share/likely.swig @@ -1,18 +1,5 @@ -{%- if theme.likely.look == 'normal' %} - {%- set likely_look = 'likely' %} -{% else %} - {%- set likely_look = 'likely likely-' + theme.likely.look %} -{%- endif %} - -
- {%- for x in theme.likely.networks %} -
{{ x }}
- {%- endfor %} -
- {%- set likely_js_url = '//cdn.jsdelivr.net/npm/ilyabirman-likely@2/release/likely.js' %} {%- if theme.vendors.likely_js %} {%- set likely_js_url = theme.vendors.likely_js %} {%- endif %} -