diff --git a/includes/helpers/site.js b/includes/helpers/site.js index 08cd226..7641295 100644 --- a/includes/helpers/site.js +++ b/includes/helpers/site.js @@ -9,9 +9,11 @@ * <%- tag_count() %> * <%- duration() %> * <%- word_count(content) %> +* <%- md5(data) %> */ const URL = require('url').URL; const moment = require('moment'); +const crypto = require('crypto'); module.exports = function (hexo) { hexo.extend.helper.register('is_same_link', function (a, b) { @@ -57,4 +59,8 @@ module.exports = function (hexo) { content = content.trim(); return content ? (content.match(/[\u00ff-\uffff]|[a-zA-Z]+/g) || []).length : 0; }); + + hexo.extend.helper.register('md5', function (data) { + return crypto.createHash('md5').update(data).digest("hex") + }); } \ No newline at end of file diff --git a/includes/specs/comment.spec.js b/includes/specs/comment.spec.js index a169a18..c844ba6 100644 --- a/includes/specs/comment.spec.js +++ b/includes/specs/comment.spec.js @@ -24,30 +24,40 @@ const DisqusSpec = { } }; -const GitmentSpec = { +const GitmentGitalkSpec = { owner: { [type]: 'string', - [doc]: 'Your GitHub ID', + [doc]: 'GitHub user ID', [required]: true, - [requires]: comment => comment.type === 'gitment' + [requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk' }, repo: { [type]: 'string', - [doc]: 'The repo to store comments', + [doc]: 'GitHub repo name to store comments', [required]: true, - [requires]: comment => comment.type === 'gitment' + [requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk' }, client_id: { [type]: 'string', - [doc]: 'Your client ID', + [doc]: 'GitHub application client ID', [required]: true, - [requires]: comment => comment.type === 'gitment' + [requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk' }, client_secret: { [type]: 'string', - [doc]: 'Your client secret', + [doc]: 'GitHub application client secret', [required]: true, - [requires]: comment => comment.type === 'gitment' + [requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk' + }, + admin: { + [type]: ['string', 'array'], + [doc]: 'GitHub repo owner and collaborators who can can initialize github issues', + [required]: true, + [requires]: comment => comment.type === 'gitalk', + '*': { + [type]: 'string', + [required]: true + } } }; @@ -112,7 +122,7 @@ module.exports = { }, ...ChangYanSpec, ...DisqusSpec, - ...GitmentSpec, + ...GitmentGitalkSpec, ...IssoSpec, ...LiveReSpec, ...ValineSpec diff --git a/layout/comment/gitalk.ejs b/layout/comment/gitalk.ejs new file mode 100644 index 0000000..e49aae9 --- /dev/null +++ b/layout/comment/gitalk.ejs @@ -0,0 +1,22 @@ +<% if (!has_config('comment.owner') || !has_config('comment.admin') || !has_config('comment.repo') || !has_config('comment.client_id') || + !has_config('comment.client_secret')) { %> +
+ You forgot to set the owner, admin, repo, client_id, or client_secret for Gittalk. + Please set it in _config.yml. +
+<% } else { %> +
+<%- _css(cdn('gitalk', '1.4.1', 'dist/gitalk.css')) %> +<%- _js(cdn('gitalk', '1.4.1', 'dist/gitalk.min.js')) %> + +<% } %> \ No newline at end of file diff --git a/layout/comment/gittalk.ejs b/layout/comment/gittalk.ejs deleted file mode 100644 index 9e7349a..0000000 --- a/layout/comment/gittalk.ejs +++ /dev/null @@ -1,23 +0,0 @@ -<% if (!has_config('comment.owner') || !has_config('comment.admin') || !has_config('comment.repo') || !has_config('comment.client_id') || - !has_config('comment.client_secret')) { %> -
- You forgot to set the owner, admin, repo, client_id, or client_secret for Gittalk. - Please set it in _config.yml. -
-<% } else { %> -
- - - - -<% } %> \ No newline at end of file diff --git a/source/js/clipboard.js b/source/js/clipboard.js index bbf658f..2e0e4d4 100644 --- a/source/js/clipboard.js +++ b/source/js/clipboard.js @@ -1,8 +1,10 @@ document.addEventListener('DOMContentLoaded', function () { - $('figure.highlight').each(function () { - var id = 'code-' + Date.now() + (Math.random() * 1000 | 0); - $(this).attr('id', id); - $(this).prepend($(``)); - }); - new ClipboardJS('.highlight .copy'); + if (typeof(ClipboardJS) !== 'undefined') { + $('figure.highlight').each(function () { + var id = 'code-' + Date.now() + (Math.random() * 1000 | 0); + $(this).attr('id', id); + $(this).prepend($(``)); + }); + new ClipboardJS('.highlight .copy'); + } }); \ No newline at end of file