Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(qrcode): add support for using online api to generate post qrcode #342

Merged
merged 2 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>