1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--- a/themes/next/layout/_scripts/pjax.swig
+++ b/themes/next/layout/_scripts/pjax.swig
@@ -15,8 +15,8 @@ var pjax = new Pjax({
scrollTo : !CONFIG.bookmark.enable
});

-window.addEventListener('pjax:success', () => {
- document.querySelectorAll('script[pjax], script#page-configurations, #pjax script').forEach(element => {
+window.addEventListener('pjax:success', function() {
+ document.querySelectorAll('script[pjax], script#page-configurations, #pjax script').forEach(function(element) {
var code = element.text || element.textContent || element.innerHTML || '';
var parent = element.parentNode;
parent.removeChild(element);

--- a/themes/next/layout/_third-party/comments/disqus.swig
+++ b/themes/next/layout/_third-party/comments/disqus.swig
@@ -41,7 +41,7 @@
// load directly when there's no a scrollbar
window.addEventListener('load', loadComments, false);
} else {
- var disqus_scroll = () => {
+ var disqus_scroll = function() {
// offsetTop may changes because of manually resizing browser window or lazy loading images.
var offsetTop = document.getElementById('comments').offsetTop - window.innerHeight;
var scrollTop = window.scrollY;

--- a/themes/next/layout/_third-party/quicklink.swig
+++ b/themes/next/layout/_third-party/quicklink.swig
@@ -3,12 +3,12 @@
<script src="{{ quicklink_uri }}"></script>
<script>
{%- if page.quicklink.delay %}
- window.addEventListener('load', () => {
+ window.addEventListener('load', function() {
{%- endif %}
quicklink({
timeout: {{ page.quicklink.timeout }},
priority: {{ page.quicklink.priority }},
- ignores: [uri => uri.includes('#'),uri => uri == '{{ url | replace('index.html', '') }}',{{ page.quicklink.ignores }}]
+ ignores: [function(uri) { return uri.includes('#') }, function(uri) { return uri === '{{ url | replace('index.html', '') }}' }, {{ page.quicklink.ignores }}]
});
{%- if page.quicklink.delay %}
});

安装 docker 并拉取相关镜像

  • gitlab/gitlab-ce

  • gitlab/gitlab-runner

1
2
docker pull gitlab/gitlab-ce
docker pull gitlab/gitlab-runner

运行 docker 镜像

  • GitLab CE
1
2
3
4
5
6
7
8
9
10
docker run -d \
--name gitlab \
--restart always \
-p 127.0.0.1:50080:80 \
-p 127.0.0.1:50022:22 \
-m 2048m \
-v /opt/docker/gitlab/config:/etc/gitlab \
-v /opt/docker/gitlab/logs:/var/log/gitlab \
-v /opt/docker/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
1
2
3
4
5
6
7
8
docker run -d \
--name gitlab-runner \
--link gitlab:gitlab \
--restart always \
-m 1024m \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /opt/docker/gitlab-runner/config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
  • GitLab EE
1
2
3
4
5
6
7
8
9
10
11
docker run -d \
--name gitlab \
--restart always \
-p 127.0.0.1:50080:80 \
-p 127.0.0.1:50022:22 \
-m 2048m \
-v /opt/docker/gitlab/config:/etc/gitlab \
-v /opt/docker/gitlab/logs:/var/log/gitlab \
-v /opt/docker/gitlab/data:/var/opt/gitlab \
-v /opt/docker/gitlab/.license_encryption_key.pub:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub \
gitlab/gitlab-ee:latest

注册 gitlab-runner

1
2
3
docker exec -it gitlab-runner gitlab-runner register
# 之后访问地址 http://code.52xckl.cn/admin/runners 配置即可
# 配置地址可以使用 http://gitlab 内网

参考文档

  • gitlab

  • gitlab-runner

安装 npm 以及 asar

1
2
# download: https://nodejs.org/en/
npm i -g asar

解压 GitKraken 的资源文件

1
2
# 安装目录\gitkraken\app-x.x.x\resources
asar extract ./app.asar ./tmp/

修改 static/index.js 文件(注意备份)

下面是 v6.5.1 之后的版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--- static/index.js
+++ static/index.js
@@ -1,6 +1,27 @@
// Warning: You almost certainly do *not* want to edit this code -
// instead, you want to edit src/js/main.jsx instead
+
+function PatchSnapshot() {
+ const edmLiteD = snapshotResult.customRequire('@axosoft/edm-lite-d/src/d.js');
+ snapshotResult.customRequire.cache['@axosoft/edm-lite-d/src/d.js'] = {
+ exports: function() {
+ let response = JSON.parse(edmLiteD(...arguments).toString('utf8'));
+ if ('licenseExpiresAt' in response || 'licensedFeatures' in response) {
+ response = {
+ ...response,
+ availableTrialDays: null,
+ licenseExpiresAt: 8640000000000000,
+ licensedFeatures: ['pro']
+ };
+ }
+ return Buffer.from(JSON.stringify(response), 'utf8');
+ }
+ };
+}
+
(function() {
+ PatchSnapshot();
+
const Perf = snapshotResult.customRequire('./src/js/utils/Performance.js');
Perf.timeEnd('loading monaco scripts');
Perf.time('index.js pre-bootstrap');

下面是 v6.5.1 之前的版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--- static/index.js
+++ static/index.js
@@ -1,7 +1,29 @@
// Warning: You almost certainly do *not* want to edit this code -
// instead, you want to edit src/js/main.jsx instead

+function XhrPromiseReduxProxy() {
+ const xhrPromiseRedux = snapshotResult.customRequire(
+ 'xhr-promise-redux/dist/index.js'
+ );
+ xhrPromiseRedux._post = xhrPromiseRedux.post;
+ xhrPromiseRedux.post = async (url, options) => {
+ const res = await xhrPromiseRedux._post(url, options);
+ if (url.match(/https:\/\/.*api.gitkraken.com\/phone-home/)) {
+ res.body.availableTrialDays = null;
+ res.body.code = 0;
+ res.body.features = [];
+ res.body.individualAccessState = null;
+ res.body.licenseExpiresAt = 8640000000000000;
+ res.body.licensedFeatures = ['pro'];
+ res.body.proAccessState = null;
+ }
+ return res;
+ };
+}
+
(function() {
+ XhrPromiseReduxProxy();
+
const Perf = snapshotResult.customRequire('./src/js/utils/Performance.js');
Perf.timeEnd('loading monaco scripts');
Perf.time('index.js pre-bootstrap');

重新打包

1
asar pack ./tmp/ app.asar

安装

1
apt install samba

配置

新建系统用户

1
useradd -M -s /sbin/nologin ${user}

新建 samba 用户

1
smbpasswd -a ${user}

修改 samba 配置文件

在文件末尾添加如下配置:

1
2
3
4
5
6
[Samba]
comment = Samba
path = /opt/samba
guest ok = no
read only = no
browseable = yes

不要忘了授予 ${user} /opt/samba 目录权限

重启 samba 服务

1
systemctl restart smbd.service

博客使用 Hexo,搭建在 Github Pages,源代码部署在 GitLab 上,使用相关 CI 自动化部署。

自动化部署

_config.yml

1
2
3
4
5
6
7
deploy:
type: git
repo: https://${username}:${token|password}@github.com/starudream/blog.git
branch: master
message: update
name: ${name}
email: ${email}

.gitlab-ci.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
image: node:lts-alpine

github:
stage: publish
script:
- apk add --no-cache git
- git config --global user.name ${name}
- git config --global user.email ${email}
- git clone https://${name}:${token|password}@github.com/starudream/blog.git .deploy_git
- npm install && npm install hexo-cli -g && hexo clean && hexo deploy
only:
- master

stages:
- publish

cache:
paths:
- node_modules