From bc55f40389a3dedff5f910f7de5d6910c8de4b19 Mon Sep 17 00:00:00 2001 From: bloodtox3710 Date: Sat, 1 Jul 2017 20:08:24 +0800 Subject: [PATCH 1/2] fix/refactor(path): fix subdir error & refactor url concatenation - Use "url_for(path)" instead of "config.root + path" (ref: https://hexo.io/docs/helpers.html ). - Fix 404 error when site is in a subdirectory. Closes #420 --- layout/_partial/Isolation-post_entry.ejs | 4 ++-- layout/_partial/Paradox-post-info.ejs | 2 +- layout/_partial/Paradox-post-thumbnail.ejs | 2 +- .../_partial/Paradox-post_entry-thumbnail.ejs | 2 +- layout/_partial/Paradox-post_entry.ejs | 2 +- layout/_partial/blog_info.ejs | 16 ++++++------- layout/_partial/config_font.ejs | 6 ++--- layout/_partial/daily_pic.ejs | 4 ++-- layout/_partial/head.ejs | 24 +++++++++---------- layout/_partial/import_js.ejs | 8 +++---- layout/_partial/post-header.ejs | 4 ++-- layout/_partial/post-info-share.ejs | 2 +- layout/_partial/post-nav.ejs | 4 ++-- layout/_partial/sidebar-footer_image.ejs | 4 ++-- layout/_partial/sidebar-header.ejs | 4 ++-- layout/_widget/mathjax.ejs | 4 ++-- layout/_widget/nprogress.ejs | 2 +- layout/_widget/page-gallery.ejs | 10 ++++---- 18 files changed, 52 insertions(+), 52 deletions(-) mode change 100644 => 100755 layout/_partial/Isolation-post_entry.ejs mode change 100644 => 100755 layout/_partial/Paradox-post-info.ejs mode change 100644 => 100755 layout/_partial/Paradox-post-thumbnail.ejs mode change 100644 => 100755 layout/_partial/Paradox-post_entry-thumbnail.ejs mode change 100644 => 100755 layout/_partial/Paradox-post_entry.ejs mode change 100644 => 100755 layout/_partial/blog_info.ejs mode change 100644 => 100755 layout/_partial/config_font.ejs mode change 100644 => 100755 layout/_partial/daily_pic.ejs mode change 100644 => 100755 layout/_partial/head.ejs mode change 100644 => 100755 layout/_partial/import_js.ejs mode change 100644 => 100755 layout/_partial/post-header.ejs mode change 100644 => 100755 layout/_partial/post-info-share.ejs mode change 100644 => 100755 layout/_partial/post-nav.ejs mode change 100644 => 100755 layout/_partial/sidebar-footer_image.ejs mode change 100644 => 100755 layout/_partial/sidebar-header.ejs mode change 100644 => 100755 layout/_widget/mathjax.ejs mode change 100644 => 100755 layout/_widget/nprogress.ejs mode change 100644 => 100755 layout/_widget/page-gallery.ejs diff --git a/layout/_partial/Isolation-post_entry.ejs b/layout/_partial/Isolation-post_entry.ejs old mode 100644 new mode 100755 index a0996dcf0..8a728b20e --- a/layout/_partial/Isolation-post_entry.ejs +++ b/layout/_partial/Isolation-post_entry.ejs @@ -4,7 +4,7 @@
- <%= config.author %>'s avatar + <%= config.author %>'s avatar <%= config.author %>
@@ -14,7 +14,7 @@
- <%= config.author %>'s avatar + <%= config.author %>'s avatar <%= config.author %>
diff --git a/layout/_partial/Paradox-post-info.ejs b/layout/_partial/Paradox-post-info.ejs old mode 100644 new mode 100755 index dc99dab7f..3b314e754 --- a/layout/_partial/Paradox-post-info.ejs +++ b/layout/_partial/Paradox-post-info.ejs @@ -2,7 +2,7 @@
- Author Avatar + Author Avatar
diff --git a/layout/_partial/Paradox-post-thumbnail.ejs b/layout/_partial/Paradox-post-thumbnail.ejs old mode 100644 new mode 100755 index 1eefb8183..f2cd556a0 --- a/layout/_partial/Paradox-post-thumbnail.ejs +++ b/layout/_partial/Paradox-post-thumbnail.ejs @@ -1,6 +1,6 @@ diff --git a/layout/_partial/Paradox-post_entry-thumbnail.ejs b/layout/_partial/Paradox-post_entry-thumbnail.ejs old mode 100644 new mode 100755 index ae631a385..99c7fde73 --- a/layout/_partial/Paradox-post_entry-thumbnail.ejs +++ b/layout/_partial/Paradox-post_entry-thumbnail.ejs @@ -6,7 +6,7 @@ randomNum = Math.floor(Math.random() * <%= theme.thumbnail.random_amount %> + 1); locatePost.children('.post_thumbnail-random').attr('id', 'random_thumbnail-'+randomNum); - locatePost.children('.post_thumbnail-random').attr('data-original', '<%= theme.img.random_thumbnail %>' + randomNum + '.png'); + locatePost.children('.post_thumbnail-random').attr('data-original', '<%= url_for(theme.img.random_thumbnail) %>' + randomNum + '.png'); $('.post_thumbnail-random').addClass('lazy'); locatePost = locatePost.next(); diff --git a/layout/_partial/Paradox-post_entry.ejs b/layout/_partial/Paradox-post_entry.ejs old mode 100644 new mode 100755 index 2318987d4..a2fee1772 --- a/layout/_partial/Paradox-post_entry.ejs +++ b/layout/_partial/Paradox-post_entry.ejs @@ -34,7 +34,7 @@
- <%= config.author %>'s avatar + <%= config.author %>'s avatar
<%= config.author %> diff --git a/layout/_partial/blog_info.ejs b/layout/_partial/blog_info.ejs old mode 100644 new mode 100755 index 3a7bdffbf..c46256248 --- a/layout/_partial/blog_info.ejs +++ b/layout/_partial/blog_info.ejs @@ -7,7 +7,7 @@ @@ -60,7 +60,7 @@ <% } %> <% if(theme.sns_share.weibo === true) { %> - +
  • <%= __('share.toWeibo') %>
  • @@ -68,7 +68,7 @@ <% } %> <% if(theme.sns_share.twitter === true) { %> -
    +
  • <%= __('share.toTwitter') %>
  • @@ -76,7 +76,7 @@ <% } %> <% if(theme.sns_share.facebook === true) { %> -
    +
  • <%= __('share.toFacebook') %>
  • @@ -84,7 +84,7 @@ <% } %> <% if(theme.sns_share.googleplus === true) { %> -
    +
  • <%= __('share.toGplus') %>
  • @@ -92,7 +92,7 @@ <% } %> <% if(theme.sns_share.linkedin === true) { %> -
    +
  • <%= __('share.toLinkedIn') %>
  • @@ -100,7 +100,7 @@ <% } %> <% if(theme.sns_share.qq === true) { %> -
    +
  • <%= __('share.toQQ') %>
  • @@ -108,7 +108,7 @@ <% } %> <% if(theme.sns_share.telegram === true) { %> -
    +
  • <%= __('share.toTelegram') %>
  • diff --git a/layout/_partial/config_font.ejs b/layout/_partial/config_font.ejs old mode 100644 new mode 100755 index cbf210100..e8decc4de --- a/layout/_partial/config_font.ejs +++ b/layout/_partial/config_font.ejs @@ -44,9 +44,9 @@ font-weight: 400; src: local('Material Icons'), local('MaterialIcons-Regular'), - url(<%- config.root %>fonts/MaterialIcons-Regular.woff2) format('woff2'), - url(<%- config.root %>fonts/MaterialIcons-Regular.woff) format('woff'), - url(<%- config.root %>fonts/MaterialIcons-Regular.ttf) format('truetype'); + url(<%- url_for('fonts/MaterialIcons-Regular.woff2') %>) format('woff2'), + url(<%- url_for('fonts/MaterialIcons-Regular.woff') %>) format('woff'), + url(<%- url_for('fonts/MaterialIcons-Regular.ttf') %>) format('truetype'); } <% } %> diff --git a/layout/_partial/daily_pic.ejs b/layout/_partial/daily_pic.ejs old mode 100644 new mode 100755 index 08a744571..51f257d16 --- a/layout/_partial/daily_pic.ejs +++ b/layout/_partial/daily_pic.ejs @@ -2,7 +2,7 @@
    -
    +

    <% if(theme.uiux.slogan) { %> <% if(Array.isArray(theme.uiux.slogan)) { %> @@ -18,7 +18,7 @@

    - avatar + avatar
    <%= config.author %> diff --git a/layout/_partial/head.ejs b/layout/_partial/head.ejs old mode 100644 new mode 100755 index 84b78c923..6d923037a --- a/layout/_partial/head.ejs +++ b/layout/_partial/head.ejs @@ -61,9 +61,9 @@ - - - + + + @@ -93,7 +93,7 @@ <% } else { %> <% } %> <% } %> - + - + <% if(page.tags && page.tags.each) { page.tags.each(function(tag){ %> <% })} %> @@ -166,7 +166,7 @@ - + diff --git a/layout/_partial/import_js.ejs b/layout/_partial/import_js.ejs old mode 100644 new mode 100755 index d829c9217..c9db536e5 --- a/layout/_partial/import_js.ejs +++ b/layout/_partial/import_js.ejs @@ -2,13 +2,13 @@ <% if(theme.vendors.materialcdn) { %> <%- jsLsload({path:(theme.vendors.materialcdn + '/js/lazyload.min.js'),key:'lazyload_js'}) %> <% } else { %> - <%- jsLsload({path:(config.root + 'js/lazyload.min.js'),key:'lazyload_js'}) %> + <%- jsLsload({path:('js/lazyload.min.js'),key:'lazyload_js'}) %> <% } %> <% if(theme.vendors.materialcdn) { %> <%- jsLsload({path:(theme.vendors.materialcdn + '/js/js.min.js'),key:'js_js'}) %> <% } else { %> - <%- jsLsload({path:(config.root + 'js/js.min.js'),key:'js_js'}) %> + <%- jsLsload({path:('js/js.min.js'),key:'js_js'}) %> <% } %> <%- partial('_widget/nprogress') %> @@ -17,7 +17,7 @@ <% if(theme.vendors.materialcdn) { %> <%- jsLsload({path:(theme.vendors.materialcdn + '/js/smoothscroll.js'),key:'sm_js'}) %> <% } else { %> - <%- jsLsload({path:(config.root + 'js/smoothscroll.js'),key:'sm_js'}) %> + <%- jsLsload({path:('js/smoothscroll.js'),key:'sm_js'}) %> <% } %> <% } %> @@ -64,7 +64,7 @@ <% if(theme.vendors.prettify) { %> <%- jsLsload({path:(theme.vendors.prettify),key:'prettify_js'}) %> <% } else { %> - <%- jsLsload({path:(config.root + 'js/prettify.min.js'),key:'prettify_js'}) %> + <%- jsLsload({path:('js/prettify.min.js'),key:'prettify_js'}) %> <% } %> <% } %> <% } %> diff --git a/layout/_partial/post-header.ejs b/layout/_partial/post-header.ejs old mode 100644 new mode 100755 index 8d3c9c23b..3fa0ecf9d --- a/layout/_partial/post-header.ejs +++ b/layout/_partial/post-header.ejs @@ -26,7 +26,7 @@
    - <%= config.author %>'s avatar + <%= config.author %>'s avatar <%= config.author %>
    @@ -36,7 +36,7 @@
    - <%= config.author %>'s avatar + <%= config.author %>'s avatar <%= config.author %>
    diff --git a/layout/_partial/post-info-share.ejs b/layout/_partial/post-info-share.ejs old mode 100644 new mode 100755 index 245779e74..2f51e71c9 --- a/layout/_partial/post-info-share.ejs +++ b/layout/_partial/post-info-share.ejs @@ -27,7 +27,7 @@ <% if(theme.sns_share.weibo === true) { %> -
    +
  • <%= __('share.toWeibo') %>
  • diff --git a/layout/_partial/post-nav.ejs b/layout/_partial/post-nav.ejs old mode 100644 new mode 100755 index 9c8f711f4..b059312aa --- a/layout/_partial/post-nav.ejs +++ b/layout/_partial/post-nav.ejs @@ -1,7 +1,7 @@