diff --git a/layout/comment/changyan.jsx b/layout/comment/changyan.jsx index adcbcfd..2470d92 100644 --- a/layout/comment/changyan.jsx +++ b/layout/comment/changyan.jsx @@ -7,7 +7,7 @@ class ChangeYan extends Component { render() { const { appId, conf, path } = this.props; if (!appId || !conf) { - return
+ return
You forgot to set the appid or conf for Changyan. Please set it in _config.yml.
; diff --git a/layout/comment/disqus.jsx b/layout/comment/disqus.jsx index b90f676..78b1e0d 100644 --- a/layout/comment/disqus.jsx +++ b/layout/comment/disqus.jsx @@ -7,7 +7,7 @@ class Disqus extends Component { render() { const { shortname, disqusId, path, permalink } = this.props; if (!shortname) { - return
+ return
You forgot to set the shortname for Disqus. Please set it in _config.yml.
; diff --git a/layout/comment/facebook.jsx b/layout/comment/facebook.jsx index 218b20e..849f3fc 100644 --- a/layout/comment/facebook.jsx +++ b/layout/comment/facebook.jsx @@ -14,7 +14,7 @@ class Facebook extends Component { fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));`; return -
+
; } diff --git a/layout/comment/gitalk.jsx b/layout/comment/gitalk.jsx index d942ed7..76ab074 100644 --- a/layout/comment/gitalk.jsx +++ b/layout/comment/gitalk.jsx @@ -20,7 +20,7 @@ class Gitalk extends Component { } = this.props; if (!id || !repo || !owner || !admin || !clientId || !clientSecret) { - return
+ return
You forgot to set the owner, admin, repo, client_id, or client_secret for Gittalk. Please set it in _config.yml. diff --git a/layout/comment/gitment.jsx b/layout/comment/gitment.jsx index 0e0046d..70e1f7a 100644 --- a/layout/comment/gitment.jsx +++ b/layout/comment/gitment.jsx @@ -15,7 +15,7 @@ class Gitment extends Component { } = this.props; if (!id || !repo || !owner || !clientId || !clientSecret) { - return
+ return
You forgot to set the owner, repo, client_id, or client_secret for Gitment. Please set it in _config.yml. diff --git a/layout/comment/isso.jsx b/layout/comment/isso.jsx index 116b096..431896b 100644 --- a/layout/comment/isso.jsx +++ b/layout/comment/isso.jsx @@ -7,7 +7,7 @@ class Isso extends Component { render() { const { url } = this.props; if (!url) { - return
+ return
You forgot to set the url for Isso. Please set it in _config.yml.
; diff --git a/layout/comment/livere.jsx b/layout/comment/livere.jsx index 7bfd8ca..d8e5670 100644 --- a/layout/comment/livere.jsx +++ b/layout/comment/livere.jsx @@ -7,7 +7,7 @@ class LiveRe extends Component { render() { const { uid } = this.props; if (!uid) { - return
+ return
You forgot to set the uid for LiveRe. Please set it in _config.yml.
; diff --git a/layout/comment/valine.jsx b/layout/comment/valine.jsx index 736a096..7ca05c3 100644 --- a/layout/comment/valine.jsx +++ b/layout/comment/valine.jsx @@ -7,7 +7,7 @@ class Valine extends Component { render() { const { appId, appKey, notify, verify, placeholder } = this.props; if (!appId || !appKey) { - return
+ return
You forgot to set the app_id or app_key for Valine. Please set it in _config.yml.
; @@ -21,7 +21,7 @@ class Valine extends Component { placeholder: '${placeholder}' });`; return -
+
diff --git a/layout/donate/alipay.jsx b/layout/donate/alipay.jsx index 04092b7..01cd92c 100644 --- a/layout/donate/alipay.jsx +++ b/layout/donate/alipay.jsx @@ -7,17 +7,17 @@ class Alipay extends Component { render() { const { type, qrcode, __, url_for } = this.props; if (!qrcode) { - return
+ return
You forgot to set the qrcode for Alipay. Please set it in _config.yml.
; } - return + + {__('donate.' + type)} - {__('donate.' + {__('donate.' ; } } diff --git a/layout/donate/patreon.jsx b/layout/donate/patreon.jsx index ee8d833..ff391e5 100644 --- a/layout/donate/patreon.jsx +++ b/layout/donate/patreon.jsx @@ -7,14 +7,14 @@ class Patreon extends Component { render() { const { type, url, __, url_for } = this.props; if (!url) { - return
+ return
You forgot to set the url Patreon. Please set it in _config.yml.
; } - return + + {__('donate.' + type)} ; diff --git a/layout/donate/paypal.jsx b/layout/donate/paypal.jsx index 2958824..1b85cf0 100644 --- a/layout/donate/paypal.jsx +++ b/layout/donate/paypal.jsx @@ -7,15 +7,15 @@ class Paypal extends Component { render() { const { type, business, currencyCode, __ } = this.props; if (!business || !currencyCode) { - return
+ return
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.
; } return - + + {__('donate.' + type)} diff --git a/layout/donate/wechat.jsx b/layout/donate/wechat.jsx index 290030e..7a24447 100644 --- a/layout/donate/wechat.jsx +++ b/layout/donate/wechat.jsx @@ -7,17 +7,17 @@ class Wechat extends Component { render() { const { type, qrcode, __, url_for } = this.props; if (!qrcode) { - return
+ return
You forgot to set the qrcode for Wechat. Please set it in _config.yml.
; } - return + + {__('donate.' + type)} - {__('donate.' + {__('donate.' ; } } diff --git a/layout/search/baidu.ejs b/layout/search/baidu.ejs deleted file mode 100644 index 3cc40aa..0000000 --- a/layout/search/baidu.ejs +++ /dev/null @@ -1,29 +0,0 @@ -<%- _css('css/search') %> - - \ No newline at end of file diff --git a/layout/search/baidu.jsx b/layout/search/baidu.jsx new file mode 100644 index 0000000..77097f2 --- /dev/null +++ b/layout/search/baidu.jsx @@ -0,0 +1,50 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class Baidu extends Component { + render() { + const { url, __, url_for } = this.props; + + const js = `(function ($) { + $('.search-form').on('submit', function (e) { + var keyword = $('.searchbox-input[name="wd"]').val(); + window.location = 'https://www.baidu.com/s?wd=site:${url.replace(/http(s)*:\/\//, '')} ' + keyword; + return false; + }); + })(jQuery); + (function (document, $) { + $(document).on('click', '.navbar-main .search', function () { + $('.searchbox').toggleClass('show'); + }).on('click', '.searchbox .searchbox-mask', function () { + $('.searchbox').removeClass('show'); + }).on('click', '.searchbox-close', function () { + $('.searchbox').removeClass('show'); + }); + })(document, jQuery);`; + + return + +
+
+
+
+ + +
+
+
+
+ +
; + } +} + +module.exports = cacheComponent(Baidu, 'search.baidu', props => { + return { + url: props.config.url, + __: props.__, + url_for: props.url_for + }; +}); diff --git a/layout/search/baidu.locals.js b/layout/search/baidu.locals.js deleted file mode 100644 index bec3126..0000000 --- a/layout/search/baidu.locals.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = (ctx, locals) => { - return locals; -} \ No newline at end of file diff --git a/layout/search/google-cse.ejs b/layout/search/google-cse.ejs deleted file mode 100644 index 9126f9a..0000000 --- a/layout/search/google-cse.ejs +++ /dev/null @@ -1,67 +0,0 @@ -<%- _css('css/search') %> - - \ No newline at end of file diff --git a/layout/search/google-cse.jsx b/layout/search/google-cse.jsx new file mode 100644 index 0000000..3ba0b17 --- /dev/null +++ b/layout/search/google-cse.jsx @@ -0,0 +1,88 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class Google extends Component { + render() { + const { cx, __, url_for } = this.props; + + const js1 = `(function() { + var cx = '${cx}'; + var gcse = document.createElement('script'); + gcse.type = 'text/javascript'; + gcse.async = true; + gcse.src = 'https://cse.google.com/cse.js?cx=' + cx; + var s = document.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(gcse, s); + })();`; + + const js2 = `(function (document, $) { + function debounce(func, wait, immediate) { + var timeout; + return function() { + var context = this, args = arguments; + var later = function() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; + }; + + $(document).on('click', '.navbar-main .search', function () { + $('.searchbox').toggleClass('show'); + }).on('click', '.searchbox .searchbox-mask', function () { + $('.searchbox').removeClass('show'); + }).on('click', '.searchbox-close', function () { + $('.searchbox').removeClass('show'); + }).on('keydown', '.searchbox-input', debounce(function () { + var value = $(this).val(); + try { + var element = google.search.cse.element.getElement('searchresults-only0'); + if (value.trim() === '') { + element.clearAllResults(); + } else { + element.execute(value); + } + } catch (e) {} + }, 300)); + })(document, jQuery);`; + + return + +
+
+
+ + +
+ {(() => { + if (cx) { + const innerHtml = ''; + return
; + } + return
+ It seems that you forget to set the cx value for the Google CSE. + Please set it in _config.yml. +
; + + })()} +
+ {cx ? : null} +
+ +
; + } +} + +module.exports = cacheComponent(Google, 'search.google', props => { + return { + cx: props.cx, + __: props.__, + url_for: props.url_for + }; +}); diff --git a/layout/search/google-cse.locals.js b/layout/search/google-cse.locals.js deleted file mode 100644 index bec3126..0000000 --- a/layout/search/google-cse.locals.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = (ctx, locals) => { - return locals; -} \ No newline at end of file diff --git a/layout/search/insight.ejs b/layout/search/insight.ejs deleted file mode 100644 index b522b62..0000000 --- a/layout/search/insight.ejs +++ /dev/null @@ -1,29 +0,0 @@ - - -<%- _js('js/insight', true) %> -<%- _css('css/search') %> -<%- _css('css/insight') %> \ No newline at end of file diff --git a/layout/search/insight.jsx b/layout/search/insight.jsx new file mode 100644 index 0000000..757510a --- /dev/null +++ b/layout/search/insight.jsx @@ -0,0 +1,49 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class Insight extends Component { + render() { + const { __, url_for } = this.props; + + const js = `(function (window) { + var INSIGHT_CONFIG = { + TRANSLATION: { + POSTS: '${__('insight.posts')}', + PAGES: '${__('insight.pages')}', + CATEGORIES: '${__('insight.categories')}', + TAGS: '${__('insight.tags')}', + UNTITLED: '${__('insight.untitled')}', + }, + CONTENT_URL: '${url_for('/content.json')}', + }; + window.INSIGHT_CONFIG = INSIGHT_CONFIG; + })(window);`; + + return + + +
+
+
+ + +
+
+
+
+
+
+ + +
; + } +} + +module.exports = cacheComponent(Insight, 'search.insight', props => { + return { + __: props.__, + url_for: props.url_for + }; +}); diff --git a/layout/search/insight.locals.js b/layout/search/insight.locals.js deleted file mode 100644 index bec3126..0000000 --- a/layout/search/insight.locals.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = (ctx, locals) => { - return locals; -} \ No newline at end of file diff --git a/layout/share/addthis.ejs b/layout/share/addthis.ejs deleted file mode 100644 index cd21118..0000000 --- a/layout/share/addthis.ejs +++ /dev/null @@ -1,8 +0,0 @@ -<% if (!has_config('share.install_url')) { %> -
- You need to set install_url to use AddThis. Please set it in _config.yml. -
-<% } else { %> -
- -<% } %> \ No newline at end of file diff --git a/layout/share/addthis.jsx b/layout/share/addthis.jsx new file mode 100644 index 0000000..224057e --- /dev/null +++ b/layout/share/addthis.jsx @@ -0,0 +1,26 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class AddThis extends Component { + render() { + const { installUrl } = this.props; + if (!installUrl) { + return
+ You need to set install_url to use AddThis. + Please set it in _config.yml. +
; + } + return +
+ +
; + } +} + +module.exports = cacheComponent(AddThis, 'share.addthis', props => { + return { + installUrl: props.install_url + }; +}); diff --git a/layout/share/addthis.locals.js b/layout/share/addthis.locals.js deleted file mode 100644 index bec3126..0000000 --- a/layout/share/addthis.locals.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = (ctx, locals) => { - return locals; -} \ No newline at end of file diff --git a/layout/share/addtoany.ejs b/layout/share/addtoany.ejs deleted file mode 100644 index 8ec37a2..0000000 --- a/layout/share/addtoany.ejs +++ /dev/null @@ -1,11 +0,0 @@ - -
- - - - - - -
- - diff --git a/layout/share/addtoany.jsx b/layout/share/addtoany.jsx new file mode 100644 index 0000000..e91a182 --- /dev/null +++ b/layout/share/addtoany.jsx @@ -0,0 +1,24 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class AddToAny extends Component { + render() { + return +
+ + + + + + +
+ +
; + } +} + +module.exports = cacheComponent(AddToAny, 'share.addtoany', props => { + return {}; +}); diff --git a/layout/share/addtoany.locals.js b/layout/share/addtoany.locals.js deleted file mode 100644 index bec3126..0000000 --- a/layout/share/addtoany.locals.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = (ctx, locals) => { - return locals; -} \ No newline at end of file diff --git a/layout/share/bdshare.ejs b/layout/share/bdshare.ejs deleted file mode 100644 index efaa5e6..0000000 --- a/layout/share/bdshare.ejs +++ /dev/null @@ -1,9 +0,0 @@ -
- - - - - - -
- \ No newline at end of file diff --git a/layout/share/bdshare.jsx b/layout/share/bdshare.jsx new file mode 100644 index 0000000..0d9a07a --- /dev/null +++ b/layout/share/bdshare.jsx @@ -0,0 +1,25 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class BdShare extends Component { + render() { + const js = `window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];`; + return +
+ + + + + + +
+ +
; + } +} + +module.exports = cacheComponent(BdShare, 'share.bdshare', props => { + return {}; +}); diff --git a/layout/share/bdshare.locals.js b/layout/share/bdshare.locals.js deleted file mode 100644 index bec3126..0000000 --- a/layout/share/bdshare.locals.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = (ctx, locals) => { - return locals; -} \ No newline at end of file diff --git a/layout/share/sharejs.ejs b/layout/share/sharejs.ejs deleted file mode 100644 index 35d141c..0000000 --- a/layout/share/sharejs.ejs +++ /dev/null @@ -1,3 +0,0 @@ - -<%- _css(cdn('social-share.js', '1.0.16', 'dist/css/share.min.css')) %> -<%- _js(cdn('social-share.js', '1.0.16', 'dist/js/social-share.min.js')) %> \ No newline at end of file diff --git a/layout/share/sharejs.jsx b/layout/share/sharejs.jsx new file mode 100644 index 0000000..e6a2e37 --- /dev/null +++ b/layout/share/sharejs.jsx @@ -0,0 +1,23 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class ShareJs extends Component { + render() { + const { cdn } = this.props; + return + + + + ; + } +} + +module.exports = cacheComponent(ShareJs, 'share.sharejs', props => { + return { + cdn: props.cdn, + // for cache purpose only + _providers: props.providers.cdn + }; +}); diff --git a/layout/share/sharejs.locals.js b/layout/share/sharejs.locals.js deleted file mode 100644 index 705fadb..0000000 --- a/layout/share/sharejs.locals.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = (ctx, locals) => { - const { get_config } = ctx; - return Object.assign(locals, { - // just for diff detection - _providers: { - _cdn: get_config('providers.cdn') - } - }); -} \ No newline at end of file diff --git a/layout/share/sharethis.ejs b/layout/share/sharethis.ejs deleted file mode 100644 index 6a77c57..0000000 --- a/layout/share/sharethis.ejs +++ /dev/null @@ -1,8 +0,0 @@ -<% if (!has_config('share.install_url')) { %> -
- You need to set install_url to use ShareThis. Please set it in _config.yml. -
-<% } else { %> -
- -<% } %> \ No newline at end of file diff --git a/layout/share/sharethis.jsx b/layout/share/sharethis.jsx new file mode 100644 index 0000000..66c7aaf --- /dev/null +++ b/layout/share/sharethis.jsx @@ -0,0 +1,26 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class ShareThis extends Component { + render() { + const { installUrl } = this.props; + if (!installUrl) { + return
+ You need to set install_url to use ShareThis. + Please set it in _config.yml. +
; + } + return +
+ +
; + } +} + +module.exports = cacheComponent(ShareThis, 'share.sharethis', props => { + return { + installUrl: props.install_url + }; +}); diff --git a/layout/share/sharethis.locals.js b/layout/share/sharethis.locals.js deleted file mode 100644 index bec3126..0000000 --- a/layout/share/sharethis.locals.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = (ctx, locals) => { - return locals; -} \ No newline at end of file