Skip to content

Commit

Permalink
Reorganize #576, using macro (#582)
Browse files Browse the repository at this point in the history
* Reorganize #576

* update _config.yml
  • Loading branch information
stevenjoezhang authored Jan 13, 2019
1 parent 52d1e4c commit 5cb7444
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 75 deletions.
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Short description in several words here.
Issue Number(s): #xxxx.
### Files modified:
1. Short description of modified file [1]. xxxxxxx
2. Short description of modified file [2]. xxxxxxx
3. Short description of modified file [3]. xxxxxxx
1. Short description of modified file [1]. xxxxxxx
2. Short description of modified file [2]. xxxxxxx
3. Short description of modified file [3]. xxxxxxx
### Global code changes:
* ADD: `newFunction` in `utils.js`.
Expand Down
23 changes: 11 additions & 12 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,11 @@ cheers_enabled: true

# ---------------------------------------------------------------
# Font Settings
# - Find fonts on Google Fonts (https://www.google.com/fonts)
# - All fonts set here will have the following styles:
# light, light italic, normal, normal italic, bold, bold italic
# - Be aware that setting too much fonts will cause site running slowly
# - Introduced in 5.0.1
# Find fonts on Google Fonts (https://www.google.com/fonts)
# All fonts set here will have the following styles:
# light, light italic, normal, normal italic, bold, bold italic
# Be aware that setting too much fonts will cause site running slowly
# Introduced in 5.0.1
# ---------------------------------------------------------------
# CAUTION! Safari Version 10.1.2 bug: https://github.com/iissnan/hexo-theme-next/issues/1844
# To avoid space between header and sidebar in Pisces / Gemini themes recommended to use Web Safe fonts for `global` (and `logo`):
Expand Down Expand Up @@ -567,7 +567,7 @@ gitment:

# Gitalk
# Demo: https://gitalk.github.io
# Reference: https://asdfv1929.github.io/2018/01/20/gitalk/, https://liujunzhou.cn/2018/8/10/gitalk-error/#more
# Reference: https://asdfv1929.github.io/2018/01/20/gitalk/, https://liujunzhou.top/2018/8/10/gitalk-error/
gitalk:
enable: false
github_id: # Github repo owner
Expand All @@ -578,8 +578,7 @@ gitalk:
distraction_free_mode: true # Facebook-like distraction free mode

# Baidu Share
# Available values:
# button | slide
# Available values: button | slide
# Warning: Baidu Share does not support https.
#baidushare:
## type: button
Expand Down Expand Up @@ -765,8 +764,8 @@ local_search:
bookmark:
enable: false
# if auto
# - save the reading position when closing the page
# - or clicking the bookmark-icon
# - save the reading position when closing the page
# - or clicking the bookmark-icon
# if manual, only save it by clicking the bookmark-icon
save: auto

Expand Down Expand Up @@ -891,7 +890,7 @@ canvas_ribbon:
# Script Vendors.
# Set a CDN address for the vendor you want to customize.
# For example
# jquery: https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
# jquery: https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
# Be aware that you should use the same version as internal ones to avoid potential problems.
# Please use the https protocol of CDN files when you enable https on your site.
vendors:
Expand Down Expand Up @@ -929,7 +928,7 @@ vendors:
lazyload:

# Internal version: 1.2.1
# See: http://VelocityJS.org
# See: http://velocityjs.org
# Example:
# velocity: //cdn.jsdelivr.net/npm/velocity-animate@1/velocity.min.js
# velocity: //cdnjs.cloudflare.com/ajax/libs/velocity/1.2.1/velocity.min.js
Expand Down
2 changes: 0 additions & 2 deletions docs/zh-CN/MATH.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ math:
mathjax:
# Use 2.7.1 as default, jsdelivr as default CDN, works everywhere even in China
cdn: //cdn.jsdelivr.net/npm/mathjax@2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML
# For newMathJax CDN (cdnjs.cloudflare.com) with fallback to oldMathJax (cdn.mathjax.org).
#cdn: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
# For direct link to MathJax.js with CloudFlare CDN (cdnjs.cloudflare.com).
#cdn: //cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML
Expand Down
4 changes: 2 additions & 2 deletions layout/_layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

<body itemscope itemtype="http://schema.org/WebPage" lang="{{ page.lang || page.language || config.language }}">

{% set container_class = "container " %}
{% set container_class = 'container' %}
{% if theme.sidebar.position %}
{% set container_class = container_class + 'sidebar-position-' + theme.sidebar.position %}
{% set container_class = container_class + ' sidebar-position-' + theme.sidebar.position %}
{% endif %}

<div class="{{ container_class }} {% block page_class %}{% endblock %}">
Expand Down
43 changes: 13 additions & 30 deletions layout/_macro/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -139,69 +139,52 @@
{% endif %}

{% if post.comments %}
{% if theme.facebook_comments_plugin.enable %}
{% macro comments() %}
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
{% endmacro %}
{% if theme.facebook_comments_plugin.enable %}
{{ comments() }}
<a href="{{ url_for(post.path) }}#comments" itemprop="discussionUrl">
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span class="post-comments-count fb-comments-count" data-href="{{ post.permalink }}" itemprop="commentCount">0</span>
</a>
</span>
{% elseif theme.disqus.enable and theme.disqus.count %}
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
{{ comments() }}
<a href="{{ url_for(post.path) }}#comments" itemprop="discussionUrl">
{% if __('disqus') !== 'disqus' -%}
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span>
{% endif %}
<span class="post-comments-count disqus-comment-count"
data-disqus-identifier="{{ post.path }}" itemprop="commentCount"></span>
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span class="post-comments-count disqus-comment-count" data-disqus-identifier="{{ post.path }}" itemprop="commentCount"></span>
</a>
</span>
{% elseif theme.changyan.enable and theme.changyan.appid and theme.changyan.appkey %}
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
{{ comments() }}
{% if is_post() %}
<a href="{{ url_for(post.path) }}#SOHUCS" itemprop="discussionUrl">
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span id="changyan_count_unit" class="post-comments-count hc-comment-count" data-xid="{{ post.path }}" itemprop="commentsCount"></span>
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span id="changyan_count_unit" class="post-comments-count hc-comment-count" data-xid="{{ post.path }}" itemprop="commentCount"></span>
</a>
{% else %}
<a href="{{ url_for(post.path) }}#SOHUCS" itemprop="discussionUrl">
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span id="url::{{ post.permalink }}" class="cy_cmt_count" data-xid="{{ post.path }}" itemprop="commentsCount"></span>
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span id="url::{{ post.permalink }}" class="cy_cmt_count" data-xid="{{ post.path }}" itemprop="commentCount"></span>
</a>
{% endif %}
{% elseif is_post() and theme.gitment.enable and theme.gitment.mint and theme.gitment.count %}
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
{{ comments() }}
<a href="{{ url_for(post.path) }}#comments" itemprop="discussionUrl">
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span class="post-comments-count gitment-comments-count" data-xid="{{ url_for(post.path) }}" itemprop="commentsCount"></span>
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span class="post-comments-count gitment-comments-count" data-xid="{{ url_for(post.path) }}" itemprop="commentCount"></span>
</a>
</span>
{% elseif (is_post() or theme.valine.comment_count) and theme.valine.enable and theme.valine.appid and theme.valine.appkey %}
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
{{ comments() }}
<a href="{{ url_for(post.path) }}#comments" itemprop="discussionUrl">
<span class="post-meta-item-text">{{ __('post.comments_count') + __('symbol.colon') }}</span> <span class="post-comments-count valine-comment-count" data-xid="{{ url_for(post.path) }}" itemprop="commentCount"></span>
</a>
</span>
{% endif %}
{% endif %}

{# LeanCould PageView #}
{# LeanCloud PageView #}
{% if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appid and theme.valine.appkey and theme.valine.visitor) %}
<span id="{{ url_for(post.path) }}" class="leancloud_visitors" data-flag-title="{{ post.title }}">
<span class="post-meta-divider">|</span>
Expand Down
2 changes: 1 addition & 1 deletion layout/_partials/github-banner.swig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% if theme.github_banner %}
{% set github_banner_bg_color = theme.android_chrome_color %}
{% set github_banner_fg_color = "#fff" %}
{% set github_banner_fg_color = '#fff' %}
{% set github_URL = theme.github_banner.split('||')[0] | trim %}
{% set github_title = theme.github_banner.split('||')[1] | trim %}

Expand Down
5 changes: 2 additions & 3 deletions layout/_third-party/comments/changyan.swig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% if is_home() %}
<script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId={{ theme.changyan.appid }}"></script>
{% else %}
{% elif page.comments %}
<script>
(function() {
var appid = '{{ theme.changyan.appid }}';
Expand All @@ -10,8 +10,7 @@
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>');
}
else {
var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){
window.changyan.api.config({appid:appid,conf:conf})});
var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})});
}
})();
</script>
Expand Down
13 changes: 7 additions & 6 deletions layout/_third-party/comments/disqus.swig
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{% if theme.disqus.count %}
<script id="dsq-count-scr" src="https://{{ theme.disqus.shortname }}.disqus.com/count.js" async></script>
{% endif %}

{% if page.comments %}
<script>
var disqus_config = function () {
var disqus_config = function() {
this.page.url = {{ page.permalink | json }};
this.page.identifier = {{ page.path | json }};
this.page.title = '{{ page.title| addslashes }}';
this.page.title = '{{ page.title | addslashes }}';
{% if __('disqus') !== 'disqus' -%}
this.language = '{{ __('disqus') }}';
{% endif -%}
};
function loadComments () {
function loadComments() {
var d = document, s = d.createElement('script');
s.src = 'https://{{ theme.disqus.shortname }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', '' + +new Date());
(d.head || d.body).appendChild(s);
}
{% if theme.disqus.lazyload %}
$(function () {
$(function() {
var offsetTop = $('#comments').offset().top - $(window).height();
if (offsetTop <= 0) {
// load directly when there's no a scrollbar
loadComments();
} else {
$(window).on('scroll.disqus_scroll', function () {
$(window).on('scroll.disqus_scroll', function() {
// offsetTop may changes because of manually resizing browser window or lazy loading images.
var offsetTop = $('#comments').offset().top - $(window).height();
var scrollTop = $(window).scrollTop();
Expand All @@ -41,3 +41,4 @@
loadComments();
{% endif %}
</script>
{% endif %}
19 changes: 9 additions & 10 deletions layout/_third-party/comments/index.swig
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{% if theme.disqus.enable %}
{% include 'disqus.swig' %}
{% elif theme.changyan.enable and theme.changyan.appid and theme.changyan.appkey %}
{% include 'changyan.swig' %}
{% elif theme.valine.enable and theme.valine.appid and theme.valine.appkey %}
{% include 'valine.swig' %}
{% endif %}

{% if page.comments %}
{% if theme.disqus.enable %}
{% include 'disqus.swig' %}
{% elif theme.livere_uid %}
{% if theme.livere_uid %}
{% include 'livere.swig' %}
{% elif theme.changyan.enable and theme.changyan.appid and theme.changyan.appkey %}
{% include 'changyan.swig' %}
{% elif theme.gitment.enable and theme.gitment.client_id %}
{% include 'gitment.swig' %}
{% elif theme.gitalk.enable %}
{% include 'gitalk.swig' %}
{% endif %}
{% endif %}

{# Valine Comment Count #}
{% if theme.valine.enable and theme.valine.appid and theme.valine.appkey %}
{% include 'valine.swig' %}
{% endif %}
2 changes: 1 addition & 1 deletion layout/_third-party/comments/valine.swig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<script>
var GUEST = ['nick', 'mail', 'link'];
var guest = '{{ theme.valine.guest_info }}';
guest = guest.split(',').filter(function (item) {
guest = guest.split(',').filter(function(item) {
return GUEST.indexOf(item) > -1;
});
new Valine({
Expand Down
10 changes: 5 additions & 5 deletions layout/_third-party/copy-code.swig
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
}
</style>
<script>
$('.highlight').each(function (i, e) {
$('.highlight').each(function(i, e) {
var $wrap = $('<div>').addClass('highlight-wrap');
$(e).after($wrap);
$wrap.append($('<button>').addClass('copy-btn').append('{{__("post.copy_button")}}').on('click', function (e) {
var code = $(this).parent().find('.code').find('.line').map(function (i, e) {
$wrap.append($('<button>').addClass('copy-btn').append('{{__("post.copy_button")}}').on('click', function(e) {
var code = $(this).parent().find('.code').find('.line').map(function(i, e) {
return $(e).text();
}).toArray().join('\n');
var ta = document.createElement('textarea');
Expand All @@ -67,9 +67,9 @@
{% endif %}
ta.blur(); //For iOS
$(this).blur();
})).on('mouseleave', function (e) {
})).on('mouseleave', function(e) {
var $b = $(this).find('.copy-btn');
setTimeout(function () {
setTimeout(function() {
$b.text('{{__("post.copy_button")}}');
}, 300);
}).append(e);
Expand Down

0 comments on commit 5cb7444

Please sign in to comment.