Skip to content

Commit 5c66675

Browse files
authored
✨ feat: implement export post to pdf (#26)
* ✨ feat: implement export post to pdf * chore: use github action to check code format * fix: diable export-post-to-pdf command if unauthorized * fix: fix puppeteer.launch undefined exception at runtime * ui: tweak export-post-to-pdf position * fix: fix chromium configuration not work * fix(export-pdf): report errors to user if there failures * fix(export-pdf): fix chromium download progress report * docs: update readme
1 parent b636735 commit 5c66675

25 files changed

+4489
-1837
lines changed

.github/workflows/build-check.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build and check the code format
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
env:
8+
GITLAB_NPM_TOKEN: ${{secrets.GITLAB_NPM_TOKEN}}
9+
jobs:
10+
build-check:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [16.x]
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
cache: 'npm'
22+
- run: npm ci
23+
- run: npm run format-check
24+
- run: npm run vscode:prepublish

.github/workflows/marketplace-publish.yml

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,43 @@
44
name: Publish extension to vscode extension marketplace
55

66
on:
7-
push:
8-
tags:
9-
- v*.*.*
7+
push:
8+
tags:
9+
- v*.*.*
1010

11-
jobs:
12-
build:
11+
env:
12+
GITLAB_NPM_TOKEN: ${{secrets.GITLAB_NPM_TOKEN}}
1313

14-
runs-on: ubuntu-latest
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
1517

16-
strategy:
17-
matrix:
18-
node-version: [14.x]
19-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
18+
strategy:
19+
matrix:
20+
node-version: [16.x]
21+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2022

21-
steps:
22-
- uses: actions/checkout@v2
23-
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v2
25-
with:
26-
node-version: ${{ matrix.node-version }}
27-
cache: 'npm'
28-
- run: echo "VERSION=${GITHUB_REF#refs/*/}"
29-
# add tag value to env
30-
- run: echo "VERSION=${GITHUB_REF#refs/*/}" | sed 's/v//' >> $GITHUB_ENV
31-
- run: echo "version:\ ${{ env.VERSION }}"
32-
# globally install vsce
33-
- run: npm i -g vsce
34-
# replace client_id
35-
- run: sed -i "s/clientId:\ 'vscode-cnb'/clientId:\ '${{ secrets.OAUTHCLIENTID }}'/" src/models/config.ts
36-
# replace client_secret
37-
- run: sed -i "s/clientSecret:\ ''/clientSecret:\ '${{ secrets.OAUTHCLIENTSECRET }}'/" src/models/config.ts
38-
- run: echo "src/models/config.ts\n" && cat src/models/config.ts
39-
# use env.VERSION to replace version property in package.json
40-
- run: sed -i 's/\"version\":\ \"[0-9]\.[0-9]\.[0-9]\"/\"version\":\ \"${{ env.VERSION }}\"/' package.json
41-
- run: echo "package.json\n" && cat package.json
42-
- run: npm ci
43-
# publish to vscode extension marketplace
44-
- run: vsce publish -p ${{ secrets.VSCETOKEN }}
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Use Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v2
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
30+
- run: echo "VERSION=${GITHUB_REF#refs/*/}"
31+
# add tag value to env
32+
- run: echo "VERSION=${GITHUB_REF#refs/*/}" | sed 's/v//' >> $GITHUB_ENV
33+
- run: echo "version:\ ${{ env.VERSION }}"
34+
# globally install vsce
35+
- run: npm i -g vsce
36+
# replace client_id
37+
- run: sed -i "s/clientId:\ 'vscode-cnb'/clientId:\ '${{ secrets.OAUTHCLIENTID }}'/" src/models/config.ts
38+
# replace client_secret
39+
- run: sed -i "s/clientSecret:\ ''/clientSecret:\ '${{ secrets.OAUTHCLIENTSECRET }}'/" src/models/config.ts
40+
- run: echo "src/models/config.ts\n" && cat src/models/config.ts
41+
# use env.VERSION to replace version property in package.json
42+
- run: sed -i 's/\"version\":\ \"[0-9]\.[0-9]\.[0-9]\"/\"version\":\ \"${{ env.VERSION }}\"/' package.json
43+
- run: echo "package.json\n" && cat package.json
44+
- run: npm ci
45+
# publish to vscode extension marketplace
46+
- run: vsce publish -p ${{ secrets.VSCETOKEN }}

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//gitlab.cnblogs.com/api/v4/projects/371/packages/npm/:_authToken=${GITLAB_NPM_TOKEN}
2+
@cnblogs-gitlab:registry=https://gitlab.cnblogs.com/api/v4/projects/371/packages/npm/

.prettierignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ node_modules
22
*.html
33
*.md
44
package-lock.json
5-
dist
5+
dist
6+
.vscode-test
7+
out

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
1212
"typescript.tsc.autoDetect": "off",
1313
"editor.formatOnSave": true
14-
}
14+
}

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [将本地文件关联到博客园博文](#将本地文件关联到博客园博文)
99
- [图片上传](#图片上传)
1010
- [博文分类管理](#博文分类管理)
11+
- [导出pdf](#导出pdf)
1112
- [vscode版本要求](#vscode版本要求)
1213
- [插件设置](#插件设置)
1314

@@ -55,12 +56,26 @@
5556

5657
![](https://img2020.cnblogs.com/blog/1596066/202112/1596066-20211228130552877-1788018336.png)
5758

59+
### 导出pdf
60+
61+
支持将博文导出为pdf格式的文件到本地, 此功能依赖于[Chromium](https://www.chromium.org/chromium-projects/), vscode-cnb默认会先从本地寻找是否有已安装的Chrome或基于Chromium的Edge浏览器, 若有的话则会直接使用本地的Chrome或基于Chromium的Edge; 若未找到, 那么会提示用户手动选择本地的Chromium或其他基于Chromium的浏览器
62+
63+
![image](https://img2022.cnblogs.com/blog/1596066/202203/1596066-20220323135717910-1090211493.png)
64+
65+
也可以在vscode的设置中手动配置**Chromium或其他基于Chromium的浏览器的可执行文件路径**, 这个路径针对windows和macos是不同的两个配置, 可以根据自己使用的系统进行配置
66+
67+
![image](https://img2022.cnblogs.com/blog/1596066/202203/1596066-20220323135918858-1619509502.png)
68+
69+
支持多选
70+
71+
![image](https://img2022.cnblogs.com/blog/1596066/202203/1596066-20220323140426961-1518402131.png)
72+
5873
## vscode版本要求
5974

6075
\>=1.62.0
6176

6277
## 插件设置
6378

64-
* `vscode-cnb.workspace`: `vscode-cnb`需要用到的一个工作空间, `vscode-cnb`只有检测到vscode处于此目录下才会生效, 默认会使用`~/Documents/Cnblogs`作为工作空间
79+
* `workspace`: `vscode-cnb`需要用到的一个工作空间, `vscode-cnb`只有检测到vscode处于此目录下才会生效, 默认会使用`~/Documents/Cnblogs`作为工作空间
6580

6681
![img](https://img2020.cnblogs.com/blog/3/202112/3-20211227183958436-462553661.png)

0 commit comments

Comments
 (0)