Skip to content

Commit 6c99bcc

Browse files
author
yucong02
committed
add theme music config
1 parent 5a22af1 commit 6c99bcc

File tree

10 files changed

+156
-31
lines changed

10 files changed

+156
-31
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
$ moka s # 开启本地服务
2525
$ moka n abc # 新建一个article
2626

27-
$ moka d # 根据 moka.config.json deploy 发布
27+
$ moka d # 根据 moka.config.json deploy 发布
28+
$ moka b # 根据 moka.config.json bak 备份所有文件
2829
```
2930

3031
3. 线上效果

THEME_README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@
7575
},
7676

7777
"articleCover": true // 是否开启文章封面, 在文章头部配置 `cover: ...` 效果请看默认文章`Linux C学习一周`
78+
},
79+
// 音乐播放器 配置
80+
// http://www.hocc.cn/wordpress-development-netease-cloud-music-player-code-single-player-playlists.html
81+
"music": {
82+
"id": "69355290",
83+
"auto": false,
84+
"style": {
85+
"left": "80px",
86+
"top": "15px",
87+
"right": "",
88+
"bottom": ""
89+
}
7890
}
7991
}
8092
```

lib/cli.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ var u = require('./util');
1111
var init = require('./init');
1212
var generate = require('./generate');
1313
var staticServer = require('./static-server');
14-
var deploy = require('./deploy');
14+
var deploy = require('./deploy_bak').deploy;
15+
var bak = require('./deploy_bak').bak;
1516
var _new = require('./new');
1617

1718
program
@@ -41,23 +42,40 @@ program
4142
program
4243
.command('generate')
4344
.alias('g')
45+
.option('-s, --server', 'boolean')
4446
.description('generate static pages here.')
45-
.action(function() {
47+
.action(function(op) {
4648
u.info(`generate static pages here.`);
4749
generate({debug: true, dir: '.'});
50+
if(op.server) {
51+
staticServer({debug: true, dir: '.', port: 9999});
52+
}
4853
});
4954

5055
program
5156
.command('deploy')
5257
.alias('d')
5358
.option('-g, --generate', 'boolean')
54-
.description('deploy static pages here.')
59+
.option('-b, --bak', 'boolean')
60+
.description('deploy static pages here according to deploy config.')
5561
.action(function(op) {
5662
if(op.generate) {
5763
generate({debug: true, dir: '.'});
5864
}
5965
u.info(`deploy static pages here.`);
6066
deploy({debug: true, dir: '.'});
67+
if(op.bak) {
68+
bak({debug: true, dir: '.'});
69+
}
70+
});
71+
72+
program
73+
.command('bak')
74+
.alias('b')
75+
.description('bak all fils here according to bak config.')
76+
.action(function(op) {
77+
u.info(`bak all fils here.`);
78+
bak({debug: true, dir: '.'});
6179
});
6280

6381
program

lib/deploy.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

lib/deploy_bak.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
// https://github.com/moyuyc/moyuyc.github.io
3+
4+
var push = require('git-push');
5+
var util = require('./util');
6+
var path = require('path');
7+
8+
9+
module.exports = {
10+
deploy: function(options) {
11+
var deb = options.debug;
12+
var dir = options.dir;
13+
var config = require(path.resolve(dir, 'moka.config.json'));
14+
var deploy = config.deploy;
15+
16+
if(!deploy) {
17+
deb && util.pError("Don't Have deploy config.");
18+
return false;
19+
}
20+
21+
push('static', deploy, function() {
22+
deb && util.info(deploy);
23+
util.info('Deploy Done!');
24+
});
25+
},
26+
bak: function(options) {
27+
var deb = options.debug;
28+
var dir = options.dir;
29+
var config = require(path.resolve(dir, 'moka.config.json'));
30+
var bak = config.bak;
31+
32+
if(!bak) {
33+
deb && util.pError("Don't Have bak config.");
34+
return false;
35+
}
36+
bak.name = 'mokaBak';
37+
push(dir, bak, function() {
38+
deb && util.info(bak);
39+
util.info('Bak Done!');
40+
});
41+
}
42+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "moka-cli",
3-
"version": "1.0.10",
3+
"version": "1.0.11",
44
"dependencies": {
55
"cheerio": "^0.22.0",
66
"colors": "^1.1.2",

tpl/moka.config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
"type": "git",
1111
"url": "https://github.com/moyuyc/moyuyc.github.io.git",
1212
"branch": "master"
13+
},
14+
"bak": {
15+
"type": "git",
16+
"url": "https://github.com/moyuyc/blogsource.git",
17+
"branch": "master"
1318
}
1419
}

tpl/themes/moka/build/app.main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12366,6 +12366,7 @@
1236612366
return u.themeConfig = t, t
1236712367
})
1236812368
};
12369+
window.__moka_c = u;
1236912370
u.isCached = function() {
1237012371
return !!u.mokaConfig && !!u.themeConfig && !!u.DB
1237112372
}, e["default"] = {

tpl/themes/moka/build/index.html

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,69 @@
44
<meta charset="UTF-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
7-
<title>Title</title>
7+
<title>Moyu Blog</title>
8+
<meta name="description" content="moyu Blog">
9+
<meta property="og:type" content="blog">
10+
<meta property="og:site_name" content="site">
11+
<script src="moka.inject.js?v=1.0.10"></script>
12+
<link rel="icon" href="/head.jpg?v=1476676248393">
13+
<style>
14+
#musicBox {
15+
display: none;
16+
position: absolute;
17+
left: 80px;
18+
top: 15px;
19+
z-index: 1;
20+
/*transform: translateX(-100%);*/
21+
}
22+
</style>
823
</head>
924
<body>
1025
<div id="app"></div>
26+
<iframe id="musicBox" frameborder="no" border="0" marginwidth="0" marginheight="0" width="230" height="52"></iframe>
1127
<script src="app.main.js?v=0.0.1"></script>
28+
<script>
29+
// 源码丢失, 新功能 音乐配置 dev
30+
(function (doc, win, musicBox) {
31+
doc.addEventListener('DOMContentLoaded',function () {
32+
function work(cache) {
33+
var db = cache.DB,
34+
tc = cache.themeConfig,
35+
mc = cache.mokaConfig;
36+
37+
var music = tc.music;
38+
if(music) {
39+
var id = music.id,
40+
auto = !!music.auto?1:0,
41+
type = music.type || 0,
42+
style= music.style;
43+
44+
45+
musicBox.src = "http://music.163.com/outchain/player?type=0&"
46+
+"id="+id+"&auto="+auto+"&height=32";
47+
48+
for(var k in style) {
49+
musicBox.style[k] = style[k];
50+
}
51+
musicBox.style.display = 'block';
52+
}
53+
54+
}
55+
56+
var t;
57+
if(!window.__moka_c || !window.__moka_c.isCached()) {
58+
t = setInterval(function () {
59+
if(!!window.__moka_c && window.__moka_c.isCached()) {
60+
clearInterval(t);
61+
work(window.__moka_c);
62+
}
63+
}, 20);
64+
} else {
65+
work(window.__moka_c)
66+
}
67+
68+
})
69+
})(document, window, document.getElementById('musicBox'))
70+
</script>
1271
</body>
1372
</html>

tpl/themes/moka/theme.config.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"github": "https://github.com/moyuyc"
5555
},
5656
{
57-
"envelop-o": "mailto:492899414@qq.com"
57+
"envelope-o": "mailto:492899414@qq.com"
5858
}
5959
],
6060

@@ -72,5 +72,16 @@
7272
]
7373
},
7474
"articleCover": true
75+
},
76+
77+
"music": {
78+
"id": "69355290",
79+
"auto": false,
80+
"style": {
81+
"left": "80px",
82+
"top": "15px",
83+
"right": "",
84+
"bottom": ""
85+
}
7586
}
7687
}

0 commit comments

Comments
 (0)