Skip to content

Commit 1d44858

Browse files
author
ppoffice
committed
Merge branch 'jitwxs-work'
2 parents 90414e8 + 6199abc commit 1d44858

23 files changed

Lines changed: 358 additions & 49 deletions

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img class="not-gallery-item" height="48" src="http://ppoffice.github.io/hexo-theme-icarus/images/logo.svg">
33
<br> A simple, delicate, and modern theme for the static site generator Hexo.
44
<br>
5-
<a href="http://ppoffice.github.io/hexo-theme-icarus/">Preview</a> |
5+
<a href="http://ppoffice.github.io/hexo-theme-icarus/">Preview</a> |
66
<a href="http://ppoffice.github.io/hexo-theme-icarus/categories/">Documentation</a> |
77
<a href="https://github.com/ppoffice/hexo-theme-icarus/archive/master.zip">Download</a>
88
<br>
@@ -51,6 +51,13 @@ Share plugins
5151
- [Share.js](http://ppoffice.github.io/hexo-theme-icarus/Plugins/Share/share-js-share-plugin/)
5252
- [ShareThis](http://ppoffice.github.io/hexo-theme-icarus/Plugins/Share/sharethis-share-plugin/)
5353

54+
Donation Buttons
55+
56+
- [Alipay](http://ppoffice.github.io/hexo-theme-icarus/Plugins/Donation/making-money-off-your-blog-with-donation-buttons/#Alipay)
57+
- [Wechat](http://ppoffice.github.io/hexo-theme-icarus/Plugins/Donation/making-money-off-your-blog-with-donation-buttons/#Wechat)
58+
- [Paypal](http://ppoffice.github.io/hexo-theme-icarus/Plugins/Donation/making-money-off-your-blog-with-donation-buttons/#Paypal)
59+
- [Patreon](http://ppoffice.github.io/hexo-theme-icarus/Plugins/Donation/making-money-off-your-blog-with-donation-buttons/#Patreon)
60+
5461
Other plugins
5562

5663
- [Hexo Tag Plugin](http://ppoffice.github.io/hexo-theme-icarus/Configuration/Posts/hexo-built-in-tag-helpers/)
@@ -60,7 +67,7 @@ Other plugins
6067

6168
**Rich Code Highlight Theme Choices**
6269

63-
Icarus directly import code highlight themes from the [highlight.js](https://highlightjs.org/) package, and makes more than
70+
Icarus directly import code highlight themes from the [highlight.js](https://highlightjs.org/) package, and makes more than
6471
70 highlight themes available to you.
6572

6673
<table>
@@ -73,7 +80,7 @@ Icarus directly import code highlight themes from the [highlight.js](https://hig
7380

7481
**Elastic Theme Configuration**
7582

76-
In addition to the minimalistic and easy-to-understand configuration design, Icarus allows you to set configurations on a
83+
In addition to the minimalistic and easy-to-understand configuration design, Icarus allows you to set configurations on a
7784
per-page basis with the ability to merge and override partial configurations.
7885

7986
<div>

includes/common/ConfigGenerator.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,28 @@ const YAML_SCHEMA = new Schema({
3232
]
3333
});
3434

35+
function appendDoc(spec, defaults) {
36+
if (defaults === null) {
37+
return null;
38+
}
39+
if (is.array(defaults) && spec.hasOwnProperty('*')) {
40+
return defaults.map(value => appendDoc(spec['*'], value));
41+
} else if (is.object(defaults)) {
42+
const _defaults = {};
43+
for (let key in defaults) {
44+
if (spec.hasOwnProperty(key) && spec[key].hasOwnProperty(doc)) {
45+
let i = 0;
46+
for (let line of spec[key][doc].split('\n')) {
47+
_defaults['#' + key + i++] = line;
48+
}
49+
}
50+
_defaults[key] = appendDoc(spec.hasOwnProperty(key) ? spec[key] : {}, defaults[key]);
51+
}
52+
return _defaults;
53+
}
54+
return defaults;
55+
}
56+
3557
function generate(spec, parentConfig = null) {
3658
if (!is.spec(spec)) {
3759
return UNDEFINED;
@@ -40,7 +62,7 @@ function generate(spec, parentConfig = null) {
4062
return UNDEFINED;
4163
}
4264
if (spec.hasOwnProperty(defaultValue)) {
43-
return spec[defaultValue];
65+
return appendDoc(spec, spec[defaultValue]);
4466
}
4567
const types = is.array(spec[type]) ? spec[type] : [spec[type]];
4668
if (types.includes('object')) {
@@ -54,16 +76,10 @@ function generate(spec, parentConfig = null) {
5476
if (defaults === UNDEFINED) {
5577
defaults = {};
5678
}
57-
if (spec[key].hasOwnProperty(doc)) {
58-
let i = 0;
59-
for (let line of spec[key][doc].split('\n')) {
60-
defaults['#' + key + i++] = line;
61-
}
62-
}
6379
defaults[key] = value;
6480
}
6581
}
66-
return defaults;
82+
return appendDoc(spec, defaults);
6783
} else if (types.includes('array') && spec.hasOwnProperty('*')) {
6884
return [generate(spec['*'], {})];
6985
}

includes/helpers/cdn.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ module.exports = function (hexo) {
4949
if (_package === 'pace-js') {
5050
_package = 'pace';
5151
}
52+
if (_package === 'clipboard') {
53+
_package = 'clipboard.js';
54+
}
5255
}
5356
if (provider !== null && cdn_providers.hasOwnProperty(provider)) {
5457
provider = cdn_providers[provider];

includes/helpers/site.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
*
44
* @example
55
* <%- is_same_link(url_a, url_b) %>
6+
* <%- get_domain(url) %>
67
* <%- post_count() %>
78
* <%- category_count() %>
89
* <%- tag_count() %>
910
* <%- duration() %>
1011
* <%- word_count(content) %>
12+
* <%- md5(data) %>
1113
*/
14+
const URL = require('url').URL;
1215
const moment = require('moment');
16+
const crypto = require('crypto');
1317

1418
module.exports = function (hexo) {
1519
hexo.extend.helper.register('is_same_link', function (a, b) {
@@ -23,6 +27,11 @@ module.exports = function (hexo) {
2327
return santize(this.url_for(a)) == santize(this.url_for(b));
2428
});
2529

30+
hexo.extend.helper.register('get_domain', function (link) {
31+
const url = new URL(link);
32+
return url.hostname;
33+
});
34+
2635
hexo.extend.helper.register('post_count', function () {
2736
return this.site.posts.length;
2837
});
@@ -50,4 +59,8 @@ module.exports = function (hexo) {
5059
content = content.trim();
5160
return content ? (content.match(/[\u00ff-\uffff]|[a-zA-Z]+/g) || []).length : 0;
5261
});
62+
63+
hexo.extend.helper.register('md5', function (data) {
64+
return crypto.createHash('md5').update(data).digest("hex")
65+
});
5366
}

includes/specs/comment.spec.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,40 @@ const DisqusSpec = {
2424
}
2525
};
2626

27-
const GitmentSpec = {
27+
const GitmentGitalkSpec = {
2828
owner: {
2929
[type]: 'string',
30-
[doc]: 'Your GitHub ID',
30+
[doc]: 'GitHub user ID',
3131
[required]: true,
32-
[requires]: comment => comment.type === 'gitment'
32+
[requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk'
3333
},
3434
repo: {
3535
[type]: 'string',
36-
[doc]: 'The repo to store comments',
36+
[doc]: 'GitHub repo name to store comments',
3737
[required]: true,
38-
[requires]: comment => comment.type === 'gitment'
38+
[requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk'
3939
},
4040
client_id: {
4141
[type]: 'string',
42-
[doc]: 'Your client ID',
42+
[doc]: 'GitHub application client ID',
4343
[required]: true,
44-
[requires]: comment => comment.type === 'gitment'
44+
[requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk'
4545
},
4646
client_secret: {
4747
[type]: 'string',
48-
[doc]: 'Your client secret',
48+
[doc]: 'GitHub application client secret',
4949
[required]: true,
50-
[requires]: comment => comment.type === 'gitment'
50+
[requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk'
51+
},
52+
admin: {
53+
[type]: ['string', 'array'],
54+
[doc]: 'GitHub repo owner and collaborators who can can initialize github issues',
55+
[required]: true,
56+
[requires]: comment => comment.type === 'gitalk',
57+
'*': {
58+
[type]: 'string',
59+
[required]: true
60+
}
5161
}
5262
};
5363

@@ -112,7 +122,7 @@ module.exports = {
112122
},
113123
...ChangYanSpec,
114124
...DisqusSpec,
115-
...GitmentSpec,
125+
...GitmentGitalkSpec,
116126
...IssoSpec,
117127
...LiveReSpec,
118128
...ValineSpec

includes/specs/config.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
article: require('./article.spec'),
1818
search: require('./search.spec'),
1919
comment: require('./comment.spec'),
20+
donate: require('./donate.spec'),
2021
share: require('./share.spec'),
2122
sidebar: require('./sidebar.spec'),
2223
widgets: require('./widgets.spec'),

includes/specs/donate.spec.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
const { doc, type, defaultValue, required, requires, format } = require('../common/utils').descriptors;
2+
3+
const DEFAULT_DONATE = [
4+
{
5+
type: 'alipay',
6+
qrcode: ''
7+
},
8+
{
9+
type: 'wechat',
10+
qrcode: ''
11+
},
12+
{
13+
type: 'paypal',
14+
business: '',
15+
currency_code: 'USD'
16+
},
17+
{
18+
type: 'patreon',
19+
url: ''
20+
}
21+
];
22+
23+
const QrcodeSpec = {
24+
qrcode: {
25+
[type]: 'string',
26+
[doc]: 'Qrcode image URL',
27+
[required]: true,
28+
[requires]: donate => donate.type === 'alipay' || donate.type === 'wechat'
29+
}
30+
};
31+
32+
const PaypalSpec = {
33+
business: {
34+
[type]: 'string',
35+
[doc]: 'Paypal business ID or email address',
36+
[required]: true,
37+
[requires]: donate => donate.type === 'paypal'
38+
},
39+
currency_code: {
40+
[type]: 'string',
41+
[doc]: 'Currency code',
42+
[required]: true,
43+
[requires]: donate => donate.type === 'paypal'
44+
}
45+
};
46+
47+
const PatreonSpec = {
48+
url: {
49+
[type]: 'string',
50+
[doc]: 'URL to the Patreon page',
51+
[required]: true,
52+
[requires]: donate => donate.type === 'patreon'
53+
}
54+
};
55+
56+
module.exports = {
57+
[type]: 'array',
58+
[doc]: 'Donation entries\nhttp://ppoffice.github.io/hexo-theme-icarus/categories/Donation/',
59+
[defaultValue]: DEFAULT_DONATE,
60+
'*': {
61+
[type]: 'object',
62+
[doc]: 'Single donation entry settings',
63+
type: {
64+
[type]: 'string',
65+
[doc]: 'Donation entry name',
66+
[required]: true
67+
},
68+
...QrcodeSpec,
69+
...PaypalSpec,
70+
...PatreonSpec
71+
}
72+
}

includes/specs/plugins.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,10 @@ module.exports = {
5959
[type]: 'boolean',
6060
[doc]: 'Show a loading progress bar at top of the page',
6161
[defaultValue]: true
62+
},
63+
clipboard: {
64+
[type]: 'boolean',
65+
[doc]: 'Show the copy button in the highlighted code area',
66+
[defaultValue]: true
6267
}
6368
};

languages/en.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ article:
2525
read: 'read'
2626
about: 'About'
2727
words: 'words'
28+
donate:
29+
title: 'Like this article? Support the author with'
30+
alipay: 'Alipay'
31+
wechat: 'Wechat'
32+
paypal: 'Paypal'
33+
patreon: 'Patreon'
2834
plugin:
2935
backtotop: 'Back to Top'
3036
search:

languages/id.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,40 @@ common:
66
one: 'Kategori'
77
other: 'Kategori'
88
tag:
9-
one: 'tag'
10-
other: 'tag'
9+
one: 'Tag'
10+
other: 'Tag'
1111
post:
12-
one: 'pos'
13-
other: 'pos'
12+
one: 'Artikel'
13+
other: 'Artikel'
1414
prev: 'Sebelumnya'
1515
next: 'Berikutnya'
1616
widget:
1717
follow: 'IKUTI'
1818
recents: 'Terbaru'
19-
links: 'tautan'
20-
tag_cloud: 'awan tag'
21-
catalogue: 'Catalogue'
19+
links: 'Tautan'
20+
tag_cloud: 'Awan tag'
21+
catalogue: 'Katalog'
2222
article:
23-
more: 'Read More'
23+
more: 'Selengkapnya'
2424
comments: 'Komentar'
25-
read: 'read'
26-
about: 'About'
27-
words: 'words'
25+
read: 'membaca'
26+
about: 'Sekitar'
27+
words: 'kata'
2828
search:
29-
search: 'Search'
29+
search: 'Pencarian'
3030
hint: 'Tulis Sesuatu..'
3131
insight:
3232
hint: 'Tulis Sesuatu..'
33-
posts: 'Pos'
33+
posts: 'Artikel'
3434
pages: 'Halaman'
3535
categories: 'Kategori'
3636
tags: 'Tag'
3737
untitled: 'Tanpa Judul'
38+
donate:
39+
title: 'Suka dengan artikel ini? Bantu penulis dengan donasi melalui'
40+
alipay: 'Alipay'
41+
wechat: 'Wechat'
42+
paypal: 'Paypal'
43+
patreon: 'Patreon'
44+
plugin:
45+
backtotop: 'Kembali ke atas'

0 commit comments

Comments
 (0)