diff --git a/package/hexo-theme-async/_config.yml b/package/hexo-theme-async/_config.yml index bf484f06..68e27816 100644 --- a/package/hexo-theme-async/_config.yml +++ b/package/hexo-theme-async/_config.yml @@ -1,4 +1,4 @@ -# user +# user info user: name: ThemeAsync first_name: Theme @@ -84,7 +84,7 @@ top_bars: - title: menu.archives url: /archives/ -# banner +# Banner settings banner: default: type: img @@ -108,7 +108,7 @@ banner: bannerTitle: 醉后不知天在水,
满船清梦压星河。 bannerText: About me -# sidebar +# Sidebar settings sidebar: typedTextPrefix: I`m typedText: [ 'Web Developer' ] @@ -127,7 +127,7 @@ sidebar: icon: fab fa-twitter url: https://twitter.com -# about +# About page settings about: title: 如果一切都是镜花水月,那就让这万物走向终结。如果一切皆是命中注定,那就让这世界消失殆尽。 introduction: 大家好,我是 Async,很高兴您能在浩瀚如烟的互联网世界里发现这个博客,更感谢您能够饶有兴致地浏览这个页面。建立这个 Blog 是出于兴趣爱好,我将在此分会分享一些学习笔记,可能还会分享少许图片、视频以及其他有趣东西的链接。 @@ -139,7 +139,7 @@ about: privacy: 本网站不会追踪访客行为,且不要求访客提供任何敏感信息(比如真实姓名、身份证号码、手机号等),因而也不存在任何隐私泄漏问题。访客参与评论,必须遵守法律法规和基本道德规范,文明礼貌。严禁发布任何有关淫秽、反动、暴力、博彩、恐吓、低俗的内容或违法信息,在尊重言论自由的同时请保持和平与理性。请勿对他人采取不友好的评论或其它过激行为。 -# footer +# Footer settings footer: # Hexo link (Powered by Hexo). powered: @@ -163,6 +163,18 @@ footer: archive: type: more # less more +# Creative Commons 4.0 International License. +# https://creativecommons.org/licenses/ +# Available values of license: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | zero +# You can set a language value if you prefer a translated version of CC license. +# CC licenses are available in 39 languages, where you can find the specific and correct abbreviation you need. +# Valid values of language: deed.zh, deed.en, deed.ja, etc. +creative_commons: + license: by-nc-sa + language: deed.zh + post: false + clipboard: false + # Reward (Donate) # If enable true, reward would be displayed in every posts and pages by default. # You can show or hide reward in a specific page throuth `reward: true | false` in Front Matter. diff --git a/package/hexo-theme-async/languages/en.yml b/package/hexo-theme-async/languages/en.yml index b4664bf1..e4223b4c 100644 --- a/package/hexo-theme-async/languages/en.yml +++ b/package/hexo-theme-async/languages/en.yml @@ -52,4 +52,17 @@ search: reward: comment: I'm so cute. Please give me money. +post: + read_more: READ MORE + copyright: + author: Post author + link: Post link + license_title: Copyright Notice + license_content: 'All articles in this blog are licensed under %s unless otherwise stated.' + +symbol: + comma: ', ' + period: '. ' + colon: ': ' + ieTips: For a better experience, use a browser other than Internet Explorer \ No newline at end of file diff --git a/package/hexo-theme-async/languages/zh-Hans.yml b/package/hexo-theme-async/languages/zh-Hans.yml index 0d6be928..5a4f8203 100644 --- a/package/hexo-theme-async/languages/zh-Hans.yml +++ b/package/hexo-theme-async/languages/zh-Hans.yml @@ -52,4 +52,17 @@ search: reward: comment: 我很可爱,请给我钱 +post: + more: 更多 + copyright: + author: 本文作者 + link: 本文链接 + license_title: 版权声明 + license_content: '本博客所有文章除特别声明外,均默认采用 %s 许可协议。' + +symbol: + comma: , + period: 。 + colon: : + ieTips: 为了更好的体验,请使用非IE浏览器 \ No newline at end of file diff --git a/package/hexo-theme-async/layout/_partial/page/post.ejs b/package/hexo-theme-async/layout/_partial/page/post.ejs index 4921c6df..da3f7fb7 100644 --- a/package/hexo-theme-async/layout/_partial/page/post.ejs +++ b/package/hexo-theme-async/layout/_partial/page/post.ejs @@ -2,6 +2,7 @@
<%- partial('../post/post-content') %> <%- partial('../post/reward') %> + <%- partial('../post/post-copyright') %>
<%- partial('../post/post-next-prev') %> <%- partial('../../_widget/comment',{ titleHide: false }) %> \ No newline at end of file diff --git a/package/hexo-theme-async/layout/_partial/post/post-copyright.ejs b/package/hexo-theme-async/layout/_partial/post/post-copyright.ejs new file mode 100644 index 00000000..00562838 --- /dev/null +++ b/package/hexo-theme-async/layout/_partial/post/post-copyright.ejs @@ -0,0 +1,24 @@ +<% if(theme.creative_commons.post) { + + let ccVersion = (theme.creative_commons.license == 'zero') ? '1.0' : '4.0'; + let ccPrefix = (theme.creative_commons.license == 'zero') ? 'publicdomain' : 'licenses'; + let ccURL = 'https://creativecommons.org/' + ccPrefix + '/' + theme.creative_commons.license + '/' + ccVersion + '/' + theme.creative_commons.language; + let postURL = page.url || page.permalink; +%> + + +<% } %> \ No newline at end of file diff --git a/package/hexo-theme-async/layout/_partial/post/reward.ejs b/package/hexo-theme-async/layout/_partial/post/reward.ejs index 302057b5..6ce6b642 100644 --- a/package/hexo-theme-async/layout/_partial/post/reward.ejs +++ b/package/hexo-theme-async/layout/_partial/post/reward.ejs @@ -17,6 +17,7 @@ <%- method.name %> +

<%- method.name %>

<% }) } %> diff --git a/package/hexo-theme-async/scripts/helper/async_config.js b/package/hexo-theme-async/scripts/helper/async_config.js index 593d9cec..e3e756f9 100644 --- a/package/hexo-theme-async/scripts/helper/async_config.js +++ b/package/hexo-theme-async/scripts/helper/async_config.js @@ -5,9 +5,10 @@ const { toI18n } = require('../utils') hexo.extend.helper.register('async_config', function () { const { config, theme, __ } = this - + let exportConfig = { hostname: url.parse(config.url).hostname || config.url, + author: config.author, root: config.root, typed_text: theme.sidebar.typedText, favicon: toI18n(theme.favicon, __), @@ -19,7 +20,12 @@ hexo.extend.helper.register('async_config', function () { empty: __('search.empty'), hits: __('search.hits'), hits_time: __('search.hits_time'), - } + author: __('post.copyright.author') + __('symbol.colon'), + copyright_link: __('post.copyright.link') + __('symbol.colon'), + copyright_license_title: __('post.copyright.license_title') + __('symbol.colon'), + copyright_license_content: __('post.copyright.license_content') + }, + creative_commons: theme.creative_commons } if (config.search) { diff --git a/package/hexo-theme-async/source/css/_components/publication.less b/package/hexo-theme-async/source/css/_components/publication.less index df5116fe..2a295fc9 100644 --- a/package/hexo-theme-async/source/css/_components/publication.less +++ b/package/hexo-theme-async/source/css/_components/publication.less @@ -204,4 +204,26 @@ .trm-publication { transform: translateY(-40px); } +} + +.trm-post-copyright { + list-style : none; + font-size : 0.9rem; + margin-top : 2rem; + padding : 0.5rem 1rem; + border-left : 4px solid @primary; + background-color: fade(@body-color, 5%); + list-style : none; + word-break : break-all; + position : relative; + overflow : hidden; + line-height : 2; + + li { + list-style: none; + } + + a { + color: @primary; + } } \ No newline at end of file diff --git a/package/hexo-theme-async/source/js/main.js b/package/hexo-theme-async/source/js/main.js index 84c2d1ff..5682406d 100644 --- a/package/hexo-theme-async/source/js/main.js +++ b/package/hexo-theme-async/source/js/main.js @@ -492,6 +492,21 @@ }) } }) + }, + InitCopyright() { + if (window.ASYNC_CONFIG.creative_commons.clipboard) { + let { author, i18n, creative_commons } = window.ASYNC_CONFIG + document.addEventListener('copy', function (event) { + const clipboardData = event.clipboardData || window.clipboardData; + if (!clipboardData) { return; } + const text = window.getSelection().toString(); + if (text) { + event.preventDefault(); + let copyrightText = `\n\n${i18n.author}${author}\n${i18n.copyright_link}${location.href}\n${i18n.copyright_license_title}${i18n.copyright_license_content.replace('undefined', 'CC' + creative_commons.license.toUpperCase() + ' ' + (creative_commons.license == 'zero' ? '1.0' : '4.0'))}` + clipboardData.setData('text/plain', text + copyrightText); + } + }); + } } } @@ -562,6 +577,9 @@ /* toc */ utils.InitToc() + + /* copyright */ + utils.InitCopyright() //#endregion //#region Re/init