Skip to content

Commit e0c25a6

Browse files
committed
Do a hard rebase.
0 parents  commit e0c25a6

File tree

156 files changed

+8028
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+8028
-0
lines changed

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Specifies intentionally untracked files to ignore when using Git
2+
# http://git-scm.com/docs/gitignore
3+
4+
*~
5+
*.sw[mnpcod]
6+
.tmp
7+
*.tmp
8+
*.tmp.*
9+
*.sublime-project
10+
*.sublime-workspace
11+
.DS_Store
12+
Thumbs.db
13+
UserInterfaceState.xcuserstate
14+
$RECYCLE.BIN/
15+
16+
*.log
17+
log.txt
18+
npm-debug.log*
19+
package-lock.json
20+
21+
/.idea
22+
/.ionic
23+
/.sass-cache
24+
/.sourcemaps
25+
/.versions
26+
/.vscode
27+
/coverage
28+
/dist
29+
/node_modules
30+
/platforms
31+
/plugins
32+
/www
33+
/src/app/*.js
34+
dist
35+
build
36+
node_modules
37+
elecrton/src/*.js

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Gitbook 阅读器
2+
3+
网上基于 Markdown 的书籍很多,通常在GitHub、GitLab、Gitee等代码托管与社会化编程网站上都能找到,其中大部分都是高质量的技术文档。本项目基于Electron、Angular、UnifiedJS等既有框架,目标是得到一个稳定、易于使用的Gitbook阅读器。
4+
5+
6+
## 开发日志
7+
8+
+ 2020-12-16
9+
10+
- 重写Electron后端,将书籍管理放入 `book.backend.ts`的类中
11+
- 将Electron的`index.ts`修改为类的形式
12+
- 给图片重新加上了`findup`方法,将`images`插件修改为异步方式
13+
- 发现`router.service.ts`中的判断 `homepage` 方法有问题,加以修改
14+
- 继续实现书籍删除、类别编辑
15+
16+
+ 2020-12-12
17+
18+
- 因为打包后无法再在 `src/assets` 中添加Git repo, 因此考虑使用Electron的`app.getPath('appDir')`文件夹来存放书籍Git repo,为了能在Angular中获取到Markdown、图片文件,故在Electron中`child_process.fork`出一个Mini web服务器
19+
- 修改Anuglar的`book`模块的`location.service.ts`服务,使得`book/markdown-elements/embed.ts`从本地服务器获取文件
20+
- 利用Electron的`session`模块,解决`CORS`报错问题
21+
- 后面尝试对 `electron/src/bookOps.ts`进行`fork`
22+
- 尚待完成书籍编辑、分类过滤、删除
23+
24+
+ 2020-12-11
25+
26+
- 重写了 `router.service.ts`,解决了多处同名文件的bug。
27+
- 尚需实现 `home.page` 的书籍类别管理、删除书籍。
28+
29+
+ 2020-12-10
30+
31+
- 重写 `loadSummary` 方法,由后端提供书籍的全部 `.md` 文件,提升加载速度。后期将 `summary-toc``search-index`在数据库中持久化,以进一步提升加载速度
32+
- 正在解决 `toc-pagination.component.ts` 不能正常显示的问题
33+
34+
35+
+ 2020-12-08(2)
36+
37+
- 解决了在Electron中打开新窗口,加载Angular的路由问题!!!
38+
- Electron 应用的协议 `electron://-/``capacitor-electron://-/`) 表示根路径,其他路径都是 `capacitor-electron://-/#/home`这样的
39+
- 要在 `app.module.ts`中使用`HashLocationStrategy`
40+
41+
42+
+ 2020-12-08
43+
44+
- 为了能在Electron的新窗口中打开Angular的路由,修改 `app-routing.module.ts``app.module.ts`,将`LocationStrategy``PathLocationStrategy`修改为`HashLocationStratedy`,以及一些其他修改
45+
- 修正了`book/services/location.service.ts`中判断是否为`shared` MD文件的方法,以及`shared`MD文件`vfile.data.gbr.url`生成的方式
46+
- 在修改了`LocationStrategy`后,由于路径中已经有了`#`符号,导致`toc`无法展开,现修改代码,解决`toc`展开的问题
47+
+ `toc`展开机制:
48+
- `sectionScrollSpy` 指令获取到当前`article`在屏幕中的那些小节,发射输出到`read.page.ts`
49+
- 两个`aside``listCollapse` 指令,从`read.page.ts`中获取到`sectionScrollSpy`生成的`active sections` 集合(`set`),对两个`aside`元素中的清单进行操作
50+
- 在变更了 `LocationStrategy` 后,原来的 `book/directives/list-collapse.directive.ts` 已经失效,需要进行修改
51+
52+
53+
+ 2020-12-07
54+
55+
- 前段界面已经优化的很不错了,阅读页面稳定,Home 页面简化成熟
56+
- 加入了NodeGit和Sqlite3两个原生模块,其中NodeGit用于克隆Markdown书籍,Sqlite3用于维护本地书籍数据
57+
- 两个原生模块都需要为当前Electron版本进行重新构建,为此要使用命令`npm i electron-rebuild --save-dev`安装`electron-rebuild`
58+
- 重新构建就是为当前特定版本的Electron重新编译模块的二进制版本,而不是使用该模块的预先构建版本
59+
- 模块的二进制发布,是一个二进制文件,包含了所有该模块的API接口,可供JavaScript, Python等语言进行调用,可以看着是一个`dll`文件
60+
- `node_module/.bin/`目录下,有很多到`node_module/xxx`模块命令的软连接(其中就有`electron`),这个目录没有加入到系统的`$PATH`环境变量,只在本地`npm`环境下有效
61+
- `electron-rebuild`命令默认将重新编译所有的原生(native)模块,可使用其命令参数`-w --which`编译指定的模块
62+
63+
+ 2020-11-30
64+
65+
- 已经支持多本书
66+
- 解决 github.io 部署时,`assets`下的 `.md` 文件 `404` 错误问题
67+
68+
+ 2020-11-21
69+
70+
- 解决了打印问题、搜索问题,阅读器完全可用
71+
- 下一步着重开发Electron部分
72+
73+
+ 2020-11-21
74+
75+
- 解决打印问题
76+
77+
+ 2020-11-20
78+
79+
- 点击页面连接,页面没有更新,`RouterService`没有传入正确的 `changes`
80+
- 目录清单没有正确展开,`list-collapse.directive`没有正确工作
81+
- `section-spy.directive`有正确传出,但`list-collapse.directive`没有正确处理
82+
83+

angular.json

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"defaultProject": "app",
5+
"newProjectRoot": "projects",
6+
"projects": {
7+
"app": {
8+
"root": "",
9+
"sourceRoot": "src",
10+
"projectType": "application",
11+
"prefix": "app",
12+
"schematics": {},
13+
"architect": {
14+
"build": {
15+
"builder": "@angular-devkit/build-angular:browser",
16+
"options": {
17+
"outputPath": "www",
18+
"index": "src/index.html",
19+
"main": "src/main.ts",
20+
"polyfills": "src/polyfills.ts",
21+
"tsConfig": "tsconfig.app.json",
22+
"assets": [
23+
{
24+
"glob": "**/*",
25+
"input": "src/assets",
26+
"output": "assets"
27+
},
28+
{
29+
"glob": "**/*.svg",
30+
"input": "node_modules/ionicons/dist/ionicons/svg",
31+
"output": "./svg"
32+
}
33+
],
34+
"styles": [
35+
"node_modules/@angular/material/prebuilt-themes/purple-green.css",
36+
"./node_modules/prismjs/themes/prism-okaidia.css",
37+
"node_modules/docsify/themes/dolphin.css",
38+
"node_modules/katex/dist/katex.min.css",
39+
"node_modules/@angular/cdk/overlay-prebuilt.css",
40+
{
41+
"input": "src/theme/variables.scss"
42+
},
43+
{
44+
"input": "src/global.scss"
45+
}
46+
],
47+
"scripts": [
48+
"node_modules/docsify/lib/plugins/zoom-image.min.js",
49+
"node_modules/prismjs/prism.js",
50+
"node_modules/prismjs/components/prism-bash.js",
51+
"node_modules/katex/dist/katex.min.js",
52+
"node_modules/docsify-copy-code/dist/docsify-copy-code.min.js"
53+
]
54+
},
55+
"configurations": {
56+
"production": {
57+
"fileReplacements": [
58+
{
59+
"replace": "src/environments/environment.ts",
60+
"with": "src/environments/environment.prod.ts"
61+
}
62+
],
63+
"optimization": true,
64+
"outputHashing": "all",
65+
"sourceMap": false,
66+
"extractCss": true,
67+
"namedChunks": false,
68+
"aot": true,
69+
"extractLicenses": true,
70+
"vendorChunk": false,
71+
"buildOptimizer": true,
72+
"budgets": [
73+
{
74+
"type": "initial",
75+
"maximumWarning": "5mb",
76+
"maximumError": "10mb"
77+
}
78+
]
79+
},
80+
"ci": {
81+
"progress": false
82+
}
83+
}
84+
},
85+
"serve": {
86+
"builder": "@angular-devkit/build-angular:dev-server",
87+
"options": {
88+
"browserTarget": "app:build"
89+
},
90+
"configurations": {
91+
"production": {
92+
"browserTarget": "app:build:production"
93+
},
94+
"ci": {
95+
"progress": false
96+
}
97+
}
98+
},
99+
"extract-i18n": {
100+
"builder": "@angular-devkit/build-angular:extract-i18n",
101+
"options": {
102+
"browserTarget": "app:build"
103+
}
104+
},
105+
"test": {
106+
"builder": "@angular-devkit/build-angular:karma",
107+
"options": {
108+
"main": "src/test.ts",
109+
"polyfills": "src/polyfills.ts",
110+
"tsConfig": "tsconfig.spec.json",
111+
"karmaConfig": "karma.conf.js",
112+
"styles": [
113+
"./node_modules/@angular/material/prebuilt-themes/purple-green.css"
114+
],
115+
"scripts": [],
116+
"assets": [
117+
{
118+
"glob": "favicon.ico",
119+
"input": "src/",
120+
"output": "/"
121+
},
122+
{
123+
"glob": "**/*",
124+
"input": "src/assets",
125+
"output": "/assets"
126+
}
127+
]
128+
},
129+
"configurations": {
130+
"ci": {
131+
"progress": false,
132+
"watch": false
133+
}
134+
}
135+
},
136+
"lint": {
137+
"builder": "@angular-devkit/build-angular:tslint",
138+
"options": {
139+
"tsConfig": [
140+
"tsconfig.app.json",
141+
"tsconfig.spec.json",
142+
"e2e/tsconfig.json"
143+
],
144+
"exclude": [
145+
"**/node_modules/**"
146+
]
147+
}
148+
},
149+
"e2e": {
150+
"builder": "@angular-devkit/build-angular:protractor",
151+
"options": {
152+
"protractorConfig": "e2e/protractor.conf.js",
153+
"devServerTarget": "app:serve"
154+
},
155+
"configurations": {
156+
"production": {
157+
"devServerTarget": "app:serve:production"
158+
},
159+
"ci": {
160+
"devServerTarget": "app:serve:ci"
161+
}
162+
}
163+
},
164+
"ionic-cordova-build": {
165+
"builder": "@ionic/angular-toolkit:cordova-build",
166+
"options": {
167+
"browserTarget": "app:build"
168+
},
169+
"configurations": {
170+
"production": {
171+
"browserTarget": "app:build:production"
172+
}
173+
}
174+
},
175+
"ionic-cordova-serve": {
176+
"builder": "@ionic/angular-toolkit:cordova-serve",
177+
"options": {
178+
"cordovaBuildTarget": "app:ionic-cordova-build",
179+
"devServerTarget": "app:serve"
180+
},
181+
"configurations": {
182+
"production": {
183+
"cordovaBuildTarget": "app:ionic-cordova-build:production",
184+
"devServerTarget": "app:serve:production"
185+
}
186+
}
187+
},
188+
"deploy": {
189+
"options": {}
190+
}
191+
}
192+
}
193+
},
194+
"cli": {
195+
"defaultCollection": "@ionic/angular-toolkit"
196+
},
197+
"schematics": {
198+
"@ionic/angular-toolkit:component": {
199+
"styleext": "scss"
200+
},
201+
"@ionic/angular-toolkit:page": {
202+
"styleext": "scss"
203+
}
204+
}
205+
}

browserslist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.

capacitor.config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"appId": "com.xfoss.ccna60d",
3+
"appName": "Gitbook-Reader-CCNA60D",
4+
"bundledWebRuntime": false,
5+
"npmClient": "npm",
6+
"webDir": "www",
7+
"plugins": {
8+
"SplashScreen": {
9+
"launchShowDuration": 0
10+
}
11+
},
12+
"cordova": {}
13+
}

e2e/protractor.conf.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// @ts-check
2+
// Protractor configuration file, see link for more information
3+
// https://github.com/angular/protractor/blob/master/lib/config.ts
4+
5+
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
6+
7+
/**
8+
* @type { import("protractor").Config }
9+
*/
10+
exports.config = {
11+
allScriptsTimeout: 11000,
12+
specs: [
13+
'./src/**/*.e2e-spec.ts'
14+
],
15+
capabilities: {
16+
browserName: 'chrome'
17+
},
18+
directConnect: true,
19+
baseUrl: 'http://localhost:4200/',
20+
framework: 'jasmine',
21+
jasmineNodeOpts: {
22+
showColors: true,
23+
defaultTimeoutInterval: 30000,
24+
print: function() {}
25+
},
26+
onPrepare() {
27+
require('ts-node').register({
28+
project: require('path').join(__dirname, './tsconfig.json')
29+
});
30+
jasmine.getEnv().addReporter(new SpecReporter({
31+
spec: {
32+
displayStacktrace: StacktraceOption.PRETTY
33+
}
34+
}));
35+
}
36+
};

0 commit comments

Comments
 (0)