From bb5cfe650cb5de268633eb4a47ad575e37f55175 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Fri, 28 Dec 2018 13:03:29 +0100 Subject: [PATCH 1/3] Cache is not enough? Ok, let's cache sidebar, scripts and 3rd-party's. Issues: #539, #385. --- layout/_layout.swig | 41 ++++++++++++----------- layout/{_macro => _partials}/sidebar.swig | 5 ++- layout/archive.swig | 3 +- layout/category.swig | 3 +- layout/index.swig | 3 +- layout/page.swig | 3 +- layout/post.swig | 7 +--- layout/tag.swig | 3 +- 8 files changed, 29 insertions(+), 39 deletions(-) rename layout/{_macro => _partials}/sidebar.swig (98%) diff --git a/layout/_layout.swig b/layout/_layout.swig index 1198a2c4aa..4012cc9cc1 100644 --- a/layout/_layout.swig +++ b/layout/_layout.swig @@ -94,30 +94,31 @@ {% endif %} - {% include '_scripts/vendors.swig' %} - {% include '_scripts/commons.swig' %} + {{ partial('_scripts/vendors.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_scripts/commons.swig', {}, {cache: theme.cache.enable}) }} {% set scheme_script = '_scripts/schemes/' + theme.scheme | lower + '.swig' %} - {% include scheme_script %} + {{ partial(scheme_script, {}, {cache: theme.cache.enable}) }} {% block script_extra %}{% endblock %} - {% include '_scripts/boostrap.swig' %} - - {% include '_third-party/comments/index.swig' %} - {% include '_third-party/search/index.swig' %} - {% include '_third-party/analytics/lean-analytics.swig' %} - {% include '_third-party/analytics/firestore.swig' %} - {% include '_third-party/seo/baidu-push.swig' %} - {% include '_third-party/schedule.swig' %} - {% include '_third-party/math/index.swig' %} - {% include '_third-party/needsharebutton.swig' %} - {% include '_third-party/rating.swig' %} - {% include '_third-party/pangu.swig' %} - {% include '_third-party/scroll-cookie.swig' %} - {% include '_third-party/exturl.swig' %} - {% include '_third-party/bookmark.swig' %} - {% include '_third-party/copy-code.swig' %} - {% include '_third-party/pdf.swig' %} + {{ partial('_scripts/boostrap.swig', {}, {cache: theme.cache.enable}) }} + + {{ partial('_third-party/comments/index.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/search/index.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/analytics/lean-analytics.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/analytics/firestore.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/seo/baidu-push.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/schedule.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/math/index.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/needsharebutton.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/rating.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/pangu.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/scroll-cookie.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/exturl.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/bookmark.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/copy-code.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_third-party/pdf.swig', {}, {cache: theme.cache.enable}) }} + diff --git a/layout/_macro/sidebar.swig b/layout/_partials/sidebar.swig similarity index 98% rename from layout/_macro/sidebar.swig rename to layout/_partials/sidebar.swig index a83cd2f48f..a4bb9e9bd3 100644 --- a/layout/_macro/sidebar.swig +++ b/layout/_partials/sidebar.swig @@ -1,4 +1,3 @@ -{% macro render(is_post) %}