From b1c26e373f8be01b11b0b84796f631547909fdab Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Tue, 11 Dec 2018 03:03:43 +0100 Subject: [PATCH 1/4] Added `post_edit` option on pages & Maked some refactoring. --- _config.yml | 10 +++++----- layout/_layout.swig | 4 ++-- layout/_macro/post.swig | 11 ++++------- layout/{_third-party => _partials}/github-banner.swig | 0 layout/_partials/{ => page}/breadcrumb.swig | 0 layout/_partials/{ => page}/page-header.swig | 5 ++++- layout/_partials/post-edit.swig | 4 ++++ layout/_partials/{ => post}/post-copyright.swig | 0 layout/page.swig | 4 ++-- 9 files changed, 21 insertions(+), 17 deletions(-) rename layout/{_third-party => _partials}/github-banner.swig (100%) rename layout/_partials/{ => page}/breadcrumb.swig (100%) rename layout/_partials/{ => page}/page-header.swig (67%) create mode 100644 layout/_partials/post-edit.swig rename layout/_partials/{ => post}/post-copyright.swig (100%) diff --git a/_config.yml b/_config.yml index e07f0453b9..ac2e4ac1d9 100644 --- a/_config.yml +++ b/_config.yml @@ -95,7 +95,7 @@ footer: # ------------------------------------------------------------- # Any custom text can be defined here. - #custom_text: Hosted by Coding Pages + #custom_text: Hosted by Coding Pages # Creative Commons 4.0 International License. # https://creativecommons.org/share-your-work/licensing-types-examples @@ -350,8 +350,8 @@ related_posts: # Dependencies: https://github.com/hexojs/hexo-deployer-git post_edit: enable: false - url: https://github.com/theme-next/theme-next.org/_posts/tree/master/ # Link for view source. -# url: https://github.com/theme-next/theme-next.org/_posts/edit/master/ # Link for fork & edit. + url: https://github.com/user-name/repo-name/tree/branch-name/subdirectory-name/ # Link for view source. + #url: https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name/ # Link for fork & edit. # --------------------------------------------------------------- @@ -557,7 +557,7 @@ gitment: proxy_gateway: # Address of api proxy, See: https://github.com/aimingoo/intersect redirect_protocol: # Protocol of redirect_uri with force_redirect_protocol when mint enabled -# Gitalk +# Gitalk # Demo: https://gitalk.github.io # Reference: https://asdfv1929.github.io/2018/01/20/gitalk/, https://liujunzhou.cn/2018/8/10/gitalk-error/#more gitalk: @@ -1054,7 +1054,7 @@ vendors: # Internal version: 0.7.3 # See: https://github.com/emn178/js-md5/ - # Example: + # Example: # md5: https://cdn.jsdelivr.net/npm/js-md5@0.7.3/src/md5.min.js md5: diff --git a/layout/_layout.swig b/layout/_layout.swig index ddf0d34751..1198a2c4aa 100644 --- a/layout/_layout.swig +++ b/layout/_layout.swig @@ -37,7 +37,7 @@
{% include '_partials/header/index.swig' %}
- {{ partial('_third-party/github-banner.swig', {}, {cache: theme.cache.enable}) }} + {{ partial('_partials/github-banner.swig', {}, {cache: theme.cache.enable}) }}
@@ -80,7 +80,7 @@
{% endif %} - + {% if theme.baidushare and theme.baidushare.type === "slide" %}
{% include '_partials/share/baidushare.swig' %} diff --git a/layout/_macro/post.swig b/layout/_macro/post.swig index a2e9d1c4fe..35d33a69ea 100644 --- a/layout/_macro/post.swig +++ b/layout/_macro/post.swig @@ -59,10 +59,7 @@ {{ next_url(post.path, post.title | default(__('post.untitled')), {class: 'post-title-link', itemprop: url }) }} {% else -%} {{- post.title -}} - {% if theme.post_edit.enable -%} - {% set editIcon = '' -%} - {{ next_url(theme.post_edit.url + post.source.slice(7), editIcon, {class: 'post-edit-link', title: __('post.edit') }) }} - {%- endif %} + {% include '../_partials/post-edit.swig' %} {% endif %} {% endif %} @@ -361,9 +358,9 @@ {% endif %} {% if page.reward === undefined and theme.reward.enable %} - {% set reward_able = true %} + {% set reward_able = true %} {% else %} - {% set reward_able = page.reward %} + {% set reward_able = page.reward %} {% endif %} {% if reward_able and (theme.reward.alipay or theme.reward.wechatpay or theme.reward.bitcoin) and not is_index %}
@@ -373,7 +370,7 @@ {% if theme.creative_commons.license and theme.creative_commons.post and not is_index %}
- {% include '../_partials/post-copyright.swig' with { post: post } %} + {% include '../_partials/post/post-copyright.swig' with { post: post } %}
{% endif %} diff --git a/layout/_third-party/github-banner.swig b/layout/_partials/github-banner.swig similarity index 100% rename from layout/_third-party/github-banner.swig rename to layout/_partials/github-banner.swig diff --git a/layout/_partials/breadcrumb.swig b/layout/_partials/page/breadcrumb.swig similarity index 100% rename from layout/_partials/breadcrumb.swig rename to layout/_partials/page/breadcrumb.swig diff --git a/layout/_partials/page-header.swig b/layout/_partials/page/page-header.swig similarity index 67% rename from layout/_partials/page-header.swig rename to layout/_partials/page/page-header.swig index 8fb71c6b89..469d4bfa65 100644 --- a/layout/_partials/page-header.swig +++ b/layout/_partials/page/page-header.swig @@ -1,6 +1,9 @@
-<{% if theme.seo %}h2{% else %}h1{% endif %} class="post-title" itemprop="name headline">{{ page.title }} +<{% if theme.seo %}h2{% else %}h1{% endif %} class="post-title" itemprop="name headline"> + {{- page.title -}} + {% include '../post-edit.swig' %} + {% if theme.related_posts.enable and (theme.related_posts.display_in_home or not is_index) %} - {% include 'post-related.swig' with { post: post } %} + {% include '../partials/post/post-related.swig' with { post: post } %} {% endif %} {#####################} @@ -353,7 +353,7 @@ {% if theme.wechat_subscriber.enabled and not is_index %}
- {% include 'wechat-subscriber.swig' %} + {% include '../partials/post/wechat-subscriber.swig' %}
{% endif %} @@ -364,7 +364,7 @@ {% endif %} {% if reward_able and (theme.reward.alipay or theme.reward.wechatpay or theme.reward.bitcoin) and not is_index %}
- {% include 'reward.swig' %} + {% include '../partials/post/reward.swig' %}
{% endif %} diff --git a/layout/_macro/post-related.swig b/layout/_partials/post/post-related.swig similarity index 100% rename from layout/_macro/post-related.swig rename to layout/_partials/post/post-related.swig diff --git a/layout/_macro/reward.swig b/layout/_partials/post/reward.swig similarity index 100% rename from layout/_macro/reward.swig rename to layout/_partials/post/reward.swig diff --git a/layout/_macro/wechat-subscriber.swig b/layout/_partials/post/wechat-subscriber.swig similarity index 100% rename from layout/_macro/wechat-subscriber.swig rename to layout/_partials/post/wechat-subscriber.swig From e490f630ce9b3110b5b36a3993d4b371739298a9 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Tue, 11 Dec 2018 03:19:23 +0100 Subject: [PATCH 3/4] Fixed partials name. --- layout/_macro/post.swig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layout/_macro/post.swig b/layout/_macro/post.swig index 9caea91e29..c242d4c802 100644 --- a/layout/_macro/post.swig +++ b/layout/_macro/post.swig @@ -344,7 +344,7 @@
{% 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 } %} + {% include '../_partials/post/post-related.swig' with { post: post } %} {% endif %} {#####################} @@ -353,7 +353,7 @@ {% if theme.wechat_subscriber.enabled and not is_index %}
- {% include '../partials/post/wechat-subscriber.swig' %} + {% include '../_partials/post/wechat-subscriber.swig' %}
{% endif %} @@ -364,7 +364,7 @@ {% endif %} {% if reward_able and (theme.reward.alipay or theme.reward.wechatpay or theme.reward.bitcoin) and not is_index %}
- {% include '../partials/post/reward.swig' %} + {% include '../_partials/post/reward.swig' %}
{% endif %} From 05adab81fb1c511a9a624985de44cf039de40497 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Tue, 11 Dec 2018 03:47:03 +0100 Subject: [PATCH 4/4] Added `disable_baidu_tranformation` option. --- _config.yml | 3 +++ layout/_partials/head/head.swig | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/_config.yml b/_config.yml index ac2e4ac1d9..0f6e8084d5 100644 --- a/_config.yml +++ b/_config.yml @@ -358,6 +358,9 @@ post_edit: # Misc Theme Settings # --------------------------------------------------------------- +# Disable Baidu tranformation on mobile devices. +disable_baidu_tranformation: false + # Reduce padding / margin indents on devices with narrow width. mobile_layout_economy: false diff --git a/layout/_partials/head/head.swig b/layout/_partials/head/head.swig index 17782fd1ce..8ac99cc4f4 100644 --- a/layout/_partials/head/head.swig +++ b/layout/_partials/head/head.swig @@ -35,11 +35,10 @@ {% endif %} - -{# #238, Disable Baidu tranformation #} - - - +{% if theme.disable_baidu_tranformation %} + + +{% endif %} {% if theme.google_site_verification %}