Skip to content

Commit

Permalink
feat(qrcode): add support for using online api to generate post qrcode
Browse files Browse the repository at this point in the history
Merge pull request #342 from viosey/feat/qrcode
  • Loading branch information
neoFelhz authored May 10, 2017
2 parents 36d8737 + 1bcfbf2 commit 6de4267
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
8 changes: 7 additions & 1 deletion _config.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ card_elevation: 2
copyright_since:

# Qrcode for redirect at other device
qrcode: false
# use: choose which method to generate the qrcode for each posts.
# Available value of "use": plugin | online
# - When use "plugin", you need to install the hexo-helper-qrcode.
# - When use "online", the qrcode will be generated by 'pan.baidu.com' in China.
qrcode:
enable: false
use: plugin


# ---------------------------------------------------------------
Expand Down
13 changes: 2 additions & 11 deletions layout/_partial/Paradox-post-info.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,8 @@
-->

<!-- Qrcode -->
<% if(theme.qrcode === true) { %>
<button id="article-functions-qrcode-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon">
<i class="material-icons" role="presentation">devices other</i>
<span class="visuallyhidden">devices other</span>
</button>
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="article-functions-qrcode-button">
<li class="mdl-menu__item"><%= __('post.qrcode') %></li>
<img src="<%- qrcode(url, {
margin: 2
}) %>">
</ul>
<% if(theme.qrcode.enable === true) { %>
<%- partial('_widget/qrcode') %>
<% } %>

<!-- Tags (bookmark) -->
Expand Down
3 changes: 3 additions & 0 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<% if(theme.fonts.host === "baomitu") { %>
<link rel="dns-prefetch" href="https://lib.baomitu.com"/>
<% } %>
<% if(theme.qrcode.use === "online" && theme.qrcode.enable === "true") { %>
<link rel="dns-prefetch" href="https://pan.baidu.com"/>
<% } %>

<!-- Meta & Info -->
<meta http-equiv="X-UA-Compatible">
Expand Down
14 changes: 14 additions & 0 deletions layout/_widget/qrcode.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<button id="article-functions-qrcode-button" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon">
<i class="material-icons" role="presentation">devices other</i>
<span class="visuallyhidden">devices other</span>
</button>
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="article-functions-qrcode-button">
<li class="mdl-menu__item"><%= __('post.qrcode') %></li>
<% if(theme.qrcode.use === "plugin") { %>
<img src="<%- qrcode(url, {
margin: 2
}) %>">
<% } else if(theme.qrcode.use === "online") { %>
<img src="https://pan.baidu.com/share/qrcode?w=246&h=246&url=<%= page.permalink %>">
<% } %>
</ul>

0 comments on commit 6de4267

Please sign in to comment.