Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4671253147 | |||
| add01b28fe | |||
| a27a53e238 | |||
| 6aff9b4d93 | |||
| c9f57233a4 | |||
| 7d72e94aa3 | |||
| 3d6a0b4306 | |||
| babc533efc | |||
| 36908134e6 | |||
| d426b41368 | |||
| 1836a414eb | |||
| ca49a29dd9 | |||
| 02a768a6af | |||
| bbc4d7c270 | |||
| bfa1521f85 | |||
| a05d380fcf | |||
| 4a32995ca1 | |||
| 53e1fe7201 | |||
| 2e8ff1be92 | |||
| e14f9fc4af | |||
| 896f302bcf | |||
| cc0bd1cf49 | |||
| 7a1d9cbbd6 | |||
| 34e8d4cb6f | |||
| 4a9b70ac68 | |||
| 889258c874 | |||
| de26feb05c | |||
| 8bb455b576 | |||
| 378ed438b6 | |||
| 3b07b6b9c5 | |||
| b6afcd4992 | |||
| 35fcdc7320 | |||
| dfb93b6764 | |||
| 6af4012522 | |||
| 1b91002c03 | |||
| bedd6a2953 | |||
| 52d37d56cd | |||
| fc7bc63c46 | |||
| 4397a76d9b | |||
| ddf964eb27 | |||
| 4b47276484 | |||
| a7fedb149f |
+2
-1
@@ -11,5 +11,6 @@ install:
|
|||||||
before_script:
|
before_script:
|
||||||
- npm install -g jshint
|
- npm install -g jshint
|
||||||
script:
|
script:
|
||||||
- jest --silent --coverage --coverageReporters=text-lcov | coveralls
|
- jest --coverage --silent
|
||||||
- jshint ./src
|
- jshint ./src
|
||||||
|
- cat ./coverage/lcov.info | coveralls
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
# GitBlog.md
|
|
||||||
|
|
||||||
|
|
||||||
[](https://travis-ci.org/Klemek/GitBlog.md)
|
[](https://travis-ci.org/Klemek/GitBlog.md)
|
||||||
[](https://coveralls.io/github/Klemek/GitBlog.md?branch=master)
|
[](https://coveralls.io/github/Klemek/GitBlog.md?branch=master)
|
||||||
|
|
||||||
|
# GitBlog.md
|
||||||
|
|
||||||
A static blog using Markdown pulled from your git repository.
|
A static blog using Markdown pulled from your git repository.
|
||||||
|
|
||||||
> Step 1 : ```$ vi 2019/06/21/index.md```
|
> Step 1 : ```$ vi 2019/06/21/index.md```
|
||||||
@@ -125,6 +124,34 @@ Resources are located on the `data` folder and can be referenced as the root of
|
|||||||
/styles/main.css => data/styles/main.css
|
/styles/main.css => data/styles/main.css
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In your template, the following data is sent :
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>details (click)</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
* `info` (every pages)
|
||||||
|
* `title` : the blog's title as in the config
|
||||||
|
* `description` the blog's description as in the config
|
||||||
|
* `host` : the specified or guessed host with the protocol
|
||||||
|
* `version` : the GitBlog.md current running version
|
||||||
|
* `request` : the Express request object
|
||||||
|
* `config` : the content of the config
|
||||||
|
* `article` (article pages only)
|
||||||
|
* `title` : the full title
|
||||||
|
* `thumbnail` the URL path of the thumbnail
|
||||||
|
* `url` : the URL path for this article (with the title)
|
||||||
|
* `date` : a JS date
|
||||||
|
* `year`
|
||||||
|
* `month`
|
||||||
|
* `day`
|
||||||
|
* `path` : the URL path for the folder of the article (without the title)
|
||||||
|
* `realPath` : the system's path for the folder
|
||||||
|
* `escapedTitle` : the code with alphanumeric and underscore characters only
|
||||||
|
* `error` (error pages only) : the error code
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
#### 5. Create and init your git source
|
#### 5. Create and init your git source
|
||||||
|
|
||||||
You need to [create a new repository](https://github.com/new) on your favorite Git service.
|
You need to [create a new repository](https://github.com/new) on your favorite Git service.
|
||||||
@@ -168,6 +195,14 @@ Here are the steps for Github, if you use another platform adapt it your way (he
|
|||||||
* Update your webhook on github to include the secret
|
* Update your webhook on github to include the secret
|
||||||
* Check if Github successfully reached the endpoint
|
* Check if Github successfully reached the endpoint
|
||||||
|
|
||||||
|
#### 8. Keep your server always up and running (optionnal)
|
||||||
|
|
||||||
|
This project `package.json` comes with a [nodemon](https://github.com/remy/nodemon) config.
|
||||||
|
|
||||||
|
After installing (`npm i -g nodemon`) you can then run the app with juste the `nodemon` command in the working directory.
|
||||||
|
|
||||||
|
With this method, you can do a simple `git pull` to update your server.
|
||||||
|
|
||||||
## Writing an article
|
## Writing an article
|
||||||
[back to top](#gitblog-md)
|
[back to top](#gitblog-md)
|
||||||
|
|
||||||
@@ -209,12 +244,18 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link
|
|||||||
It allows you to add math equations to your articles by simply writing LaTeX between `$$` for full size (and between $ for inline) (more info [here](https://www.mathjax.org/))
|
It allows you to add math equations to your articles by simply writing LaTeX between `$$` for full size (and between $ for inline) (more info [here](https://www.mathjax.org/))
|
||||||
* **PlantUML**
|
* **PlantUML**
|
||||||
It allows you to add UML diagrams with PlantUML Syntax between `@startuml` and `@enduml` (more info [here](http://www.plantuml.com))
|
It allows you to add UML diagrams with PlantUML Syntax between `@startuml` and `@enduml` (more info [here](http://www.plantuml.com))
|
||||||
|
* **fa-diagrams**
|
||||||
|
It allows you to define SVG diagrams with Font-Awesome icons in [TOML](https://github.com/toml-lang/toml) between `@startfad` and `@endfad` (more info [here](https://github.com/Klemek/fa-diagrams))
|
||||||
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
[back to top](#gitblog-md)
|
[back to top](#gitblog-md)
|
||||||
|
|
||||||
* `node_port` (default: 3000)
|
* `node_port` (default: 3000)
|
||||||
the port the server is listening to
|
the port the server is listening to
|
||||||
|
* `host` (default: none)
|
||||||
|
if set (like `https://mywebsite.com`, it will be used as reference for creating links
|
||||||
|
by default, host is guessed based on first request
|
||||||
* `data_dir` (default: data)
|
* `data_dir` (default: data)
|
||||||
the directory where will be located the git repo with templates and articles
|
the directory where will be located the git repo with templates and articles
|
||||||
* `view_engine` (default: ejs)
|
* `view_engine` (default: ejs)
|
||||||
@@ -234,6 +275,8 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link
|
|||||||
activate MathJax equations formatting
|
activate MathJax equations formatting
|
||||||
* `plantuml` (default: true)
|
* `plantuml` (default: true)
|
||||||
activate PlantUML diagram rendering
|
activate PlantUML diagram rendering
|
||||||
|
* `fa-diagrams` (default: true)
|
||||||
|
activate fa-diagrams rendering
|
||||||
* `home`
|
* `home`
|
||||||
* `title` (default: GitBlog.md)
|
* `title` (default: GitBlog.md)
|
||||||
the title of your blog, **strongly advised to be changed**
|
the title of your blog, **strongly advised to be changed**
|
||||||
@@ -247,11 +290,13 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link
|
|||||||
* `error` (default: error.ejs)
|
* `error` (default: error.ejs)
|
||||||
the name of the error page template on the data directory
|
the name of the error page template on the data directory
|
||||||
it will receive `error`, the error code
|
it will receive `error`, the error code
|
||||||
* `hidden` (default: `[.ejs]`)
|
* `hidden` (default: `[*.ejs,/.git*]`)
|
||||||
file extensions to be returned 404 when reached
|
path matches to be returned 404 when reached
|
||||||
* `article`
|
* `article`
|
||||||
* `index` (default: index.md)
|
* `index` (default: index.md)
|
||||||
the name of the Markdown page of the article on the `/year/month/day/` directory
|
the name of the Markdown page of the article on the `/year/month/day/` directory
|
||||||
|
* `draft` (default: draft.md)
|
||||||
|
the name of the Markdown page of an article not shown on the list
|
||||||
* `template` (default: template.ejs)
|
* `template` (default: template.ejs)
|
||||||
the name of the article page template on the data directory
|
the name of the article page template on the data directory
|
||||||
* `thumbnail_tag`: (default: thumbnail)
|
* `thumbnail_tag`: (default: thumbnail)
|
||||||
|
|||||||
Generated
+92
-69
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitblog.md",
|
"name": "gitblog.md",
|
||||||
"version": "1.0.3",
|
"version": "1.2.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -285,6 +285,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@iarna/toml": {
|
||||||
|
"version": "2.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.3.tgz",
|
||||||
|
"integrity": "sha512-FmuxfCuolpLl0AnQ2NHSzoUKWEJDFl63qXjzdoWBVyFCXzMGm1spBzk7LeHNoVCiWCF7mRVms9e6jEV9+MoPbg=="
|
||||||
|
},
|
||||||
"@jest/console": {
|
"@jest/console": {
|
||||||
"version": "24.7.1",
|
"version": "24.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/@jest/console/-/console-24.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/@jest/console/-/console-24.7.1.tgz",
|
||||||
@@ -2687,16 +2692,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cross-spawn": {
|
|
||||||
"version": "5.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
|
|
||||||
"integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=",
|
|
||||||
"requires": {
|
|
||||||
"lru-cache": "^4.0.1",
|
|
||||||
"shebang-command": "^1.2.0",
|
|
||||||
"which": "^1.2.9"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"crypto": {
|
"crypto": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
|
||||||
@@ -3011,20 +3006,6 @@
|
|||||||
"integrity": "sha512-9sLAvzhI5nc8TpuQUh4ahMdCrWT00wPWz7j47/emR5+2qEfoZP5zzUXvx+vdx+H6ohhnsYC31iX04QLYJK8zTg==",
|
"integrity": "sha512-9sLAvzhI5nc8TpuQUh4ahMdCrWT00wPWz7j47/emR5+2qEfoZP5zzUXvx+vdx+H6ohhnsYC31iX04QLYJK8zTg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"execa": {
|
|
||||||
"version": "0.7.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz",
|
|
||||||
"integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=",
|
|
||||||
"requires": {
|
|
||||||
"cross-spawn": "^5.0.1",
|
|
||||||
"get-stream": "^3.0.0",
|
|
||||||
"is-stream": "^1.1.0",
|
|
||||||
"npm-run-path": "^2.0.0",
|
|
||||||
"p-finally": "^1.0.0",
|
|
||||||
"signal-exit": "^3.0.0",
|
|
||||||
"strip-eof": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"exit": {
|
"exit": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz",
|
||||||
@@ -3190,6 +3171,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
|
||||||
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
|
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
|
||||||
},
|
},
|
||||||
|
"fa-diagrams": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/fa-diagrams/-/fa-diagrams-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-z9pFYYnc6s1sUs4lq+DY2m5ddLCKN3jdo5O6hv450WwjiQ7otk1RoGQsvpMcwSU1kMEzPJUI6AeTVvzyIElhwQ==",
|
||||||
|
"requires": {
|
||||||
|
"xml-js": "^1.6.11"
|
||||||
|
}
|
||||||
|
},
|
||||||
"fast-deep-equal": {
|
"fast-deep-equal": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
|
||||||
@@ -3876,11 +3865,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
|
||||||
"integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w=="
|
"integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w=="
|
||||||
},
|
},
|
||||||
"get-stream": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
|
|
||||||
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
|
|
||||||
},
|
|
||||||
"get-value": {
|
"get-value": {
|
||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz",
|
||||||
@@ -4189,11 +4173,6 @@
|
|||||||
"loose-envify": "^1.0.0"
|
"loose-envify": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"invert-kv": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY="
|
|
||||||
},
|
|
||||||
"ipaddr.js": {
|
"ipaddr.js": {
|
||||||
"version": "1.9.0",
|
"version": "1.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
|
||||||
@@ -6728,14 +6707,6 @@
|
|||||||
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
|
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"lcid": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=",
|
|
||||||
"requires": {
|
|
||||||
"invert-kv": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lcov-parse": {
|
"lcov-parse": {
|
||||||
"version": "0.0.10",
|
"version": "0.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz",
|
||||||
@@ -6784,9 +6755,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lodash": {
|
"lodash": {
|
||||||
"version": "4.17.11",
|
"version": "4.17.15",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
||||||
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
|
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
|
||||||
},
|
},
|
||||||
"lodash.sortby": {
|
"lodash.sortby": {
|
||||||
"version": "4.7.0",
|
"version": "4.7.0",
|
||||||
@@ -6895,14 +6866,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||||
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
|
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
|
||||||
},
|
},
|
||||||
"mem": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz",
|
|
||||||
"integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=",
|
|
||||||
"requires": {
|
|
||||||
"mimic-fn": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"merge-descriptors": {
|
"merge-descriptors": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
|
||||||
@@ -6976,11 +6939,6 @@
|
|||||||
"mime-db": "1.40.0"
|
"mime-db": "1.40.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mimic-fn": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ=="
|
|
||||||
},
|
|
||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
@@ -7345,16 +7303,6 @@
|
|||||||
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
|
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"os-locale": {
|
|
||||||
"version": "2.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz",
|
|
||||||
"integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==",
|
|
||||||
"requires": {
|
|
||||||
"execa": "^0.7.0",
|
|
||||||
"lcid": "^1.0.0",
|
|
||||||
"mem": "^1.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"os-tmpdir": {
|
"os-tmpdir": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
||||||
@@ -9777,6 +9725,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
|
||||||
"integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU="
|
"integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU="
|
||||||
},
|
},
|
||||||
|
"xml-js": {
|
||||||
|
"version": "1.6.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
|
||||||
|
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
||||||
|
"requires": {
|
||||||
|
"sax": "^1.2.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"xml-name-validator": {
|
"xml-name-validator": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
||||||
@@ -9809,6 +9765,73 @@
|
|||||||
"which-module": "^2.0.0",
|
"which-module": "^2.0.0",
|
||||||
"y18n": "^3.2.1",
|
"y18n": "^3.2.1",
|
||||||
"yargs-parser": "^8.1.0"
|
"yargs-parser": "^8.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"cross-spawn": {
|
||||||
|
"version": "5.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
|
||||||
|
"integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=",
|
||||||
|
"requires": {
|
||||||
|
"lru-cache": "^4.0.1",
|
||||||
|
"shebang-command": "^1.2.0",
|
||||||
|
"which": "^1.2.9"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"execa": {
|
||||||
|
"version": "0.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz",
|
||||||
|
"integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=",
|
||||||
|
"requires": {
|
||||||
|
"cross-spawn": "^5.0.1",
|
||||||
|
"get-stream": "^3.0.0",
|
||||||
|
"is-stream": "^1.1.0",
|
||||||
|
"npm-run-path": "^2.0.0",
|
||||||
|
"p-finally": "^1.0.0",
|
||||||
|
"signal-exit": "^3.0.0",
|
||||||
|
"strip-eof": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"get-stream": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
|
||||||
|
},
|
||||||
|
"invert-kv": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY="
|
||||||
|
},
|
||||||
|
"lcid": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=",
|
||||||
|
"requires": {
|
||||||
|
"invert-kv": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mem": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz",
|
||||||
|
"integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=",
|
||||||
|
"requires": {
|
||||||
|
"mimic-fn": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mimic-fn": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ=="
|
||||||
|
},
|
||||||
|
"os-locale": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==",
|
||||||
|
"requires": {
|
||||||
|
"execa": "^0.7.0",
|
||||||
|
"lcid": "^1.0.0",
|
||||||
|
"mem": "^1.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"yargs-parser": {
|
"yargs-parser": {
|
||||||
|
|||||||
+14
-1
@@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "gitblog.md",
|
"name": "gitblog.md",
|
||||||
"version": "1.2.0",
|
"version": "1.2.7",
|
||||||
"description": "A static blog using Markdown pulled from your git repository.",
|
"description": "A static blog using Markdown pulled from your git repository.",
|
||||||
"main": "src/server.js",
|
"main": "src/server.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@iarna/toml": "^2.2.3",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
"ejs": "^2.6.2",
|
"ejs": "^2.6.2",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"fa-diagrams": "^1.0.3",
|
||||||
"mathjax-node": "^2.1.1",
|
"mathjax-node": "^2.1.1",
|
||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
"node-prismjs": "^0.1.2",
|
"node-prismjs": "^0.1.2",
|
||||||
@@ -46,5 +48,16 @@
|
|||||||
"!src/postinstall.js",
|
"!src/postinstall.js",
|
||||||
"!src/lib/*.js"
|
"!src/lib/*.js"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"nodemonConfig": {
|
||||||
|
"verbose": true,
|
||||||
|
"ignore": [
|
||||||
|
"test/*",
|
||||||
|
"sample_data/*",
|
||||||
|
"data/*",
|
||||||
|
"uml/*",
|
||||||
|
"*.log",
|
||||||
|
"README.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ If you see this page, that means it's working
|
|||||||
* [Spoilers](#spoilers)
|
* [Spoilers](#spoilers)
|
||||||
* [Math Equations](#mathequations)
|
* [Math Equations](#mathequations)
|
||||||
* [UML](#uml)
|
* [UML](#uml)
|
||||||
|
* [Diagrams](#diagrams)
|
||||||
* [Youtube Videos](#youtubevideos)
|
* [Youtube Videos](#youtubevideos)
|
||||||
|
|
||||||
### Headers
|
### Headers
|
||||||
@@ -253,6 +254,34 @@ showdown -left-> express : 4. html
|
|||||||
express -up-> web : 5. html
|
express -up-> web : 5. html
|
||||||
@enduml
|
@enduml
|
||||||
|
|
||||||
|
### Diagrams
|
||||||
|
[Back to top](#top)
|
||||||
|
|
||||||
|
You can use [fa-diagrams](https://github.com/Klemek/fa-diagrams) with `@startfad` and `@endfad` tags and using [TOML](https://github.com/toml-lang/toml) inside
|
||||||
|
|
||||||
|
@startfad
|
||||||
|
[[nodes]]
|
||||||
|
name = "node1"
|
||||||
|
icon = "laptop-code"
|
||||||
|
color = "#4E342E"
|
||||||
|
bottom = "my app"
|
||||||
|
|
||||||
|
[[nodes]]
|
||||||
|
name = "node2"
|
||||||
|
icon = "globe"
|
||||||
|
color = "#455A64"
|
||||||
|
bottom = "world"
|
||||||
|
|
||||||
|
[[links]]
|
||||||
|
from = "node1"
|
||||||
|
to = "node2"
|
||||||
|
color = "#333333"
|
||||||
|
bottom = '"hello"'
|
||||||
|
|
||||||
|
[links.top]
|
||||||
|
icon = "envelope"
|
||||||
|
@endfad
|
||||||
|
|
||||||
### Youtube Videos
|
### Youtube Videos
|
||||||
[Back to top](#top)
|
[Back to top](#top)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title><%= info.title %> - Error <%= error %></title>
|
|
||||||
<%- include('head'); %>
|
<%- include('head'); %>
|
||||||
|
<title><%= info.title %> - Error <%= error %></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
|
|||||||
@@ -1,21 +1,26 @@
|
|||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
|
||||||
|
<META NAME="ROBOTS" CONTENT="INDEX, FOLLOW">
|
||||||
|
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
<% if(locals.article){ %>
|
|
||||||
<%- `<meta property="og:title" content="${info.title} - ${article.title}">` %>
|
|
||||||
<%- `<meta property="twitter:title" content="${info.title} - ${article.title}">` %>
|
|
||||||
<%- `<meta property="og:description" content="${info.description}">` %>
|
<%- `<meta property="og:description" content="${info.description}">` %>
|
||||||
<%- `<meta property="twitter:description" content="${info.description}">` %>
|
<%- `<meta property="twitter:description" content="${info.description}">` %>
|
||||||
|
<% if(locals.article){ %>
|
||||||
<%- `<meta property="org:url" content="${info.host + article.url}">` %>
|
<%- `<meta property="org:url" content="${info.host + article.url}">` %>
|
||||||
|
<%- `<meta property="og:title" content="${info.title} - ${article.title}">` %>
|
||||||
|
<%- `<meta property="twitter:title" content="${info.title} - ${article.title}">` %>
|
||||||
<% if (article.thumbnail) { %>
|
<% if (article.thumbnail) { %>
|
||||||
<%- `<meta property="og:image" content="${info.host}/${article.thumbnail}">` %>
|
<%- `<meta property="og:image" content="${info.host}/${article.thumbnail}">` %>
|
||||||
<%- `<meta property="twitter:image" content="${info.host}/${article.thumbnail}">` %>
|
<%- `<meta property="twitter:image" content="${info.host}/${article.thumbnail}">` %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<link rel="stylesheet" type="text/css" href="/prism.css">
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="/css/prism.css">
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
|
<%- `<meta property="org:url" content="${info.host}/">` %>
|
||||||
<%- `<meta property="og:title" content="${info.title} - Home">` %>
|
<%- `<meta property="og:title" content="${info.title} - Home">` %>
|
||||||
<%- `<meta property="twitter:title" content="${info.title} - Home">` %>
|
<%- `<meta property="twitter:title" content="${info.title} - Home">` %>
|
||||||
<%- `<meta property="og:description" content="${info.description}">` %>
|
|
||||||
<%- `<meta property="twitter:description" content="${info.description}">` %>
|
<%- `<meta property="description" content="${info.description}">` %>
|
||||||
<%- `<meta property="org:url" content="${info.host}/">` %>
|
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<link rel="alternate" type="application/rss+xml" title="RSS feed" href="/rss"/>
|
<link rel="alternate" type="application/rss+xml" title="RSS feed" href="/rss"/>
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title><%= info.title %> - Home</title>
|
|
||||||
<%- include('head'); %>
|
<%- include('head'); %>
|
||||||
|
<title><%= info.title %> - Home</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<h1><%= info.title %></h1>
|
<h1 class="title"><%= info.title %></h1>
|
||||||
<%= info.description %>
|
<%= info.description %>
|
||||||
<h2>Articles in this blog :</h2>
|
<h2>Articles in this blog :</h2>
|
||||||
<% articles.forEach((article) => { %>
|
<% articles.forEach((article) => { %>
|
||||||
<div class="article">
|
<div class="article">
|
||||||
<h3><%- `<a href="${article.url}">${article.title}</a>` %></h3>
|
<%- `<a href="${article.url}">` %>
|
||||||
<span class="time"><span>Published on</span> <%= article.year + '-' + article.month + '-' + article.day %></span>
|
<h3><%- `${article.title}` %></h3>
|
||||||
|
<span class="time"><span>Published on</span> <%= article.year + '-' + ('0' + article.month).slice(-2) + '-' + ('0' + article.day).slice(-2) %></span>
|
||||||
<% if(article.thumbnail){ %>
|
<% if(article.thumbnail){ %>
|
||||||
<%- `<img alt="thumbnail" src=${article.thumbnail}>` %>
|
<%- `<img alt="thumbnail" src=${article.thumbnail}>` %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<%- `</a>` %>
|
||||||
</div>
|
</div>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<%- include('footer'); %>
|
<%- include('footer'); %>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
max-width: 42rem;
|
max-width: 45rem;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background-color: #F0F0F0;
|
background-color: #F0F0F0;
|
||||||
@@ -54,6 +54,13 @@ pre {
|
|||||||
padding: 10px 16px;
|
padding: 10px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:not(pre) > code {
|
||||||
|
padding: 0.25em 0.5em;
|
||||||
|
border-radius: 0.25em;
|
||||||
|
background: #DDD;
|
||||||
|
font-size: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
blockquote {
|
blockquote {
|
||||||
border-left: 0.5em solid #ccc;
|
border-left: 0.5em solid #ccc;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
@@ -108,10 +115,11 @@ main.article div.header a.link-home {
|
|||||||
line-height: 2.4;
|
line-height: 2.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
main.article div.header h1, main.article div.header h2 {
|
main.article div.header h1, main.article div.header h2, .title {
|
||||||
margin-top: 0.85em;
|
margin-top: 0.85em;
|
||||||
margin-bottom: 0.25em;
|
margin-bottom: 0.25em;
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
main.article div.header h1 a, main.article div.header h2 a, div.article h3 a {
|
main.article div.header h1 a, main.article div.header h2 a, div.article h3 a {
|
||||||
@@ -129,6 +137,12 @@ div.article {
|
|||||||
div.article h3 {
|
div.article h3 {
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
margin:0;
|
margin:0;
|
||||||
|
color: #3C3CA1;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.article a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.article img{
|
div.article img{
|
||||||
@@ -138,6 +152,15 @@ div.article img{
|
|||||||
margin-top:0.25em;
|
margin-top:0.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.article:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.article:active {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#text {
|
#text {
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
hyphens: auto;
|
hyphens: auto;
|
||||||
@@ -147,7 +170,7 @@ div.article img{
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
#text img {
|
#text img, #text svg {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title><%= info.title %> - <%= article.title %></title>
|
|
||||||
<%- include('head'); %>
|
<%- include('head'); %>
|
||||||
|
<title><%= info.title %> - <%= article.title %></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="article">
|
<main class="article">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<a class="link-home" href="/">↑</a>
|
<a class="link-home" href="/">↑</a>
|
||||||
<h1><%= article.title %></h1>
|
<h1><%= article.title %></h1>
|
||||||
<span class="time"><span>Published on</span> <%= article.year + '-' + article.month + '-' + article.day %></span>
|
<span class="time"><span><%= article.draft ? 'Drafted on' : 'Published on' %></span> <%= article.year + '-' + ('0' + article.month).slice(-2) + '-' + ('0' + article.day).slice(-2) %></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="text"><%- article.content %></div>
|
<div id="text"><%- article.content %></div>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
+57
-44
@@ -26,6 +26,28 @@ const cons = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = (config) => {
|
module.exports = (config) => {
|
||||||
|
/**
|
||||||
|
* Fetch articles from the data folder and send success as a response
|
||||||
|
* @param success
|
||||||
|
* @param error
|
||||||
|
*/
|
||||||
|
let reload;
|
||||||
|
/**
|
||||||
|
* Render the page with the view engine and catch errors
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
* @param vPath - path of the view
|
||||||
|
* @param data - data to pass to the view
|
||||||
|
* @param code - code to send along the page
|
||||||
|
*/
|
||||||
|
let render;
|
||||||
|
/**
|
||||||
|
* Show an error with the correct page
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
* @param code - error code
|
||||||
|
*/
|
||||||
|
let showError;
|
||||||
const fw = require('./file_walker')(config);
|
const fw = require('./file_walker')(config);
|
||||||
const renderer = require('./renderer')(config);
|
const renderer = require('./renderer')(config);
|
||||||
|
|
||||||
@@ -36,14 +58,9 @@ module.exports = (config) => {
|
|||||||
|
|
||||||
const articles = {};
|
const articles = {};
|
||||||
let lastRSS = '';
|
let lastRSS = '';
|
||||||
let host;
|
let host = config['host'];
|
||||||
|
|
||||||
/**
|
reload = (success, error) => {
|
||||||
* Fetch articles from the data folder and send success as a response
|
|
||||||
* @param success
|
|
||||||
* @param error
|
|
||||||
*/
|
|
||||||
const reload = (success, error) => {
|
|
||||||
fw.fetchArticles((err, dict) => {
|
fw.fetchArticles((err, dict) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(cons.error, 'error loading articles : ' + err);
|
console.error(cons.error, 'error loading articles : ' + err);
|
||||||
@@ -52,8 +69,9 @@ module.exports = (config) => {
|
|||||||
Object.keys(articles).forEach((key) => delete articles[key]);
|
Object.keys(articles).forEach((key) => delete articles[key]);
|
||||||
Object.keys(dict).forEach((key) => articles[key] = dict[key]);
|
Object.keys(dict).forEach((key) => articles[key] = dict[key]);
|
||||||
const nb = Object.keys(articles).length;
|
const nb = Object.keys(articles).length;
|
||||||
|
const dnb = Object.values(articles).filter(a => a.draft).length;
|
||||||
if (nb > 0)
|
if (nb > 0)
|
||||||
console.log(cons.ok, `loaded ${nb} article${nb > 1 ? 's' : ''}`);
|
console.log(cons.ok, `loaded ${nb} article${nb > 1 ? 's' : ''} (${dnb} drafted)`);
|
||||||
else
|
else
|
||||||
console.log(cons.warn, `no articles loaded, check your configuration`);
|
console.log(cons.warn, `no articles loaded, check your configuration`);
|
||||||
|
|
||||||
@@ -65,42 +83,34 @@ module.exports = (config) => {
|
|||||||
if (config['test'])
|
if (config['test'])
|
||||||
app.reload = reload;
|
app.reload = reload;
|
||||||
|
|
||||||
/**
|
render = (req, res, vPath, data, code = 200) => {
|
||||||
* Render the page with the view engine and catch errors
|
|
||||||
* @param res
|
|
||||||
* @param vPath - path of the view
|
|
||||||
* @param data - data to pass to the view
|
|
||||||
* @param code - code to send along the page
|
|
||||||
*/
|
|
||||||
const render = (res, vPath, data, code = 200) => {
|
|
||||||
data.info = {
|
data.info = {
|
||||||
title: config['home']['title'],
|
title: config['home']['title'],
|
||||||
description: config['home']['description'],
|
description: config['home']['description'],
|
||||||
host: host,
|
host: host,
|
||||||
version: pjson.version
|
version: pjson.version,
|
||||||
|
request: req,
|
||||||
|
config: config
|
||||||
};
|
};
|
||||||
res.render(vPath, data, (err, html) => {
|
res.render(vPath, data, (err, html) => {
|
||||||
if (err) {
|
if (err && vPath !== path.join(config['data_dir'], config['home']['error'])) {
|
||||||
|
console.log(cons.error, `failed to render page ${vPath} : ${err}`);
|
||||||
|
showError(req, res, 500);
|
||||||
|
} else if (err) {
|
||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
console.log(cons.error, `failed to render ${vPath} : ${err}`);
|
console.log(cons.error, `failed to render error page : ${err}`);
|
||||||
} else
|
} else
|
||||||
res.status(code).send(html);
|
res.status(code).send(html);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
showError = (req, res, code) => {
|
||||||
* Show an error with the correct page
|
|
||||||
* @param resPath - the page of the original error
|
|
||||||
* @param code - error code
|
|
||||||
* @param res
|
|
||||||
*/
|
|
||||||
const showError = (resPath, code, res) => {
|
|
||||||
const errorPath = path.join(config['data_dir'], config['home']['error']);
|
const errorPath = path.join(config['data_dir'], config['home']['error']);
|
||||||
fs.access(errorPath, fs.constants.R_OK, (err) => {
|
fs.access(errorPath, fs.constants.R_OK, (err) => {
|
||||||
if (err)
|
if (err)
|
||||||
res.sendStatus(code);
|
res.sendStatus(code);
|
||||||
else
|
else
|
||||||
render(res, errorPath, {error: code, path: resPath}, code);
|
render(req, res, errorPath, {error: code}, code);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -133,9 +143,13 @@ module.exports = (config) => {
|
|||||||
const homePath = path.join(config['data_dir'], config['home']['index']);
|
const homePath = path.join(config['data_dir'], config['home']['index']);
|
||||||
fs.access(homePath, fs.constants.R_OK, (err) => {
|
fs.access(homePath, fs.constants.R_OK, (err) => {
|
||||||
if (err)
|
if (err)
|
||||||
showError(req.path, 404, res);
|
showError(req, res, 404);
|
||||||
else
|
else
|
||||||
render(res, homePath, {articles: Object.values(articles).sort((a, b) => ('' + b.path).localeCompare(a.path))});
|
render(req, res, homePath,
|
||||||
|
{
|
||||||
|
articles: Object.values(articles)
|
||||||
|
.filter(d => !d.draft).sort((a, b) => ('' + b.path).localeCompare(a.path))
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -146,15 +160,15 @@ module.exports = (config) => {
|
|||||||
const feed = new Rss({
|
const feed = new Rss({
|
||||||
'title': config['rss']['title'],
|
'title': config['rss']['title'],
|
||||||
'description': config['rss']['description'],
|
'description': config['rss']['description'],
|
||||||
'feed_url': 'http://' + req.headers.host + req.url,
|
'feed_url': host + req.url,
|
||||||
'site_url': 'http://' + req.headers.host
|
'site_url': host
|
||||||
});
|
});
|
||||||
Object.values(articles)
|
Object.values(articles)
|
||||||
.slice(0, config['rss']['length'])
|
.slice(0, config['rss']['length'])
|
||||||
.forEach((article) => {
|
.forEach((article) => {
|
||||||
feed.item({
|
feed.item({
|
||||||
title: article.title,
|
title: article.title,
|
||||||
url: 'http://' + req.headers.host + article.url,
|
url: host + article.url,
|
||||||
date: article.date
|
date: article.date
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -162,7 +176,7 @@ module.exports = (config) => {
|
|||||||
}
|
}
|
||||||
res.type(req.headers['user-agent'].match(/Mozilla/) ? 'text/xml' : 'rss').send(lastRSS);
|
res.type(req.headers['user-agent'].match(/Mozilla/) ? 'text/xml' : 'rss').send(lastRSS);
|
||||||
} else {
|
} else {
|
||||||
showError(req.path, 404, res);
|
showError(req, res, 404);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -205,21 +219,21 @@ module.exports = (config) => {
|
|||||||
const articlePath = req.path.substr(1, 10);
|
const articlePath = req.path.substr(1, 10);
|
||||||
const article = articles[articlePath];
|
const article = articles[articlePath];
|
||||||
if (!article)
|
if (!article)
|
||||||
showError(req.path, 404, res);
|
showError(req, res, 404);
|
||||||
else {
|
else {
|
||||||
renderer.render(path.join(article.realPath, config['article']['index']), (err, html) => {
|
renderer.render(article.realPath, (err, html) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(cons.error, `failed to render article ${req.path} : ${err}`);
|
console.log(cons.error, `failed to render article ${req.path} : ${err}`);
|
||||||
return showError(req.path, 500, res);
|
return showError(req, res, 500);
|
||||||
}
|
}
|
||||||
article.content = html;
|
article.content = html;
|
||||||
const templatePath = path.join(config['data_dir'], config['article']['template']);
|
const templatePath = path.join(config['data_dir'], config['article']['template']);
|
||||||
fs.access(templatePath, fs.constants.R_OK, (err) => {
|
fs.access(templatePath, fs.constants.R_OK, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(cons.error, `no template found at ${templatePath}`);
|
console.log(cons.error, `no template found at ${templatePath}`);
|
||||||
showError(req.path, 500, res);
|
showError(req, res, 500);
|
||||||
} else
|
} else
|
||||||
render(res, templatePath, {article: article});
|
render(req, res, templatePath, {article: article});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -229,18 +243,17 @@ module.exports = (config) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// catch all hidden file type and return 404
|
// catch all hidden file type and return 404
|
||||||
app.get('*', (req, res, next) => {
|
config['home']['hidden'].forEach(pathMatcher => {
|
||||||
if (config['home']['hidden'].includes(path.extname(req.path)))
|
app.get(pathMatcher, (req, res) => {
|
||||||
showError(req.path, 404, res);
|
showError(req, res, 404);
|
||||||
else
|
});
|
||||||
next();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// serve all static files via get
|
// serve all static files via get
|
||||||
app.get('*', express.static(path.join(__dirname, '..', config['data_dir'])));
|
app.get('*', express.static(path.join(__dirname, '..', config['data_dir'])));
|
||||||
// catch express.static errors (mostly not found) by displaying 404
|
// catch express.static errors (mostly not found) by displaying 404
|
||||||
app.get('*', (req, res) => {
|
app.get('*', (req, res) => {
|
||||||
showError(req.path, 404, res);
|
showError(req, res, 404);
|
||||||
});
|
});
|
||||||
|
|
||||||
// catch all other methods and return 400
|
// catch all other methods and return 400
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"node_port": 3000,
|
"node_port": 3000,
|
||||||
|
"host": "",
|
||||||
"data_dir": "data",
|
"data_dir": "data",
|
||||||
"view_engine": "ejs",
|
"view_engine": "ejs",
|
||||||
"access_log": "access.log",
|
"access_log": "access.log",
|
||||||
@@ -9,7 +10,8 @@
|
|||||||
"webhook": true,
|
"webhook": true,
|
||||||
"prism": true,
|
"prism": true,
|
||||||
"mathjax": true,
|
"mathjax": true,
|
||||||
"plantuml": true
|
"plantuml": true,
|
||||||
|
"fa-diagrams": true
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "GitBlog.md",
|
"title": "GitBlog.md",
|
||||||
@@ -17,11 +19,13 @@
|
|||||||
"index": "index.ejs",
|
"index": "index.ejs",
|
||||||
"error": "error.ejs",
|
"error": "error.ejs",
|
||||||
"hidden": [
|
"hidden": [
|
||||||
".ejs"
|
"*.ejs",
|
||||||
|
"/.git*"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"article": {
|
"article": {
|
||||||
"index": "index.md",
|
"index": "index.md",
|
||||||
|
"draft": "draft.md",
|
||||||
"template": "template.ejs",
|
"template": "template.ejs",
|
||||||
"thumbnail_tag": "thumbnail",
|
"thumbnail_tag": "thumbnail",
|
||||||
"default_title": "Untitled",
|
"default_title": "Untitled",
|
||||||
|
|||||||
+5
-3
@@ -72,7 +72,7 @@ module.exports = (config) => {
|
|||||||
return cb(err);
|
return cb(err);
|
||||||
const paths = fileList
|
const paths = fileList
|
||||||
.map((p) => p.substr(config['data_dir'].length + 1).split(path.sep))
|
.map((p) => p.substr(config['data_dir'].length + 1).split(path.sep))
|
||||||
.filter((p) => p.length === 4 && p[3] === config['article']['index'] &&
|
.filter((p) => p.length === 4 && (p[3] === config['article']['index'] || p[3] === config['article']['draft']) &&
|
||||||
/^\d{4}$/.test(p[0]) && /^\d{2}$/.test(p[1]) && /^\d{2}$/.test(p[2]));
|
/^\d{4}$/.test(p[0]) && /^\d{2}$/.test(p[1]) && /^\d{2}$/.test(p[2]));
|
||||||
if (paths.length === 0)
|
if (paths.length === 0)
|
||||||
cb(null, {});
|
cb(null, {});
|
||||||
@@ -81,7 +81,8 @@ module.exports = (config) => {
|
|||||||
paths.forEach((p) => {
|
paths.forEach((p) => {
|
||||||
const article = {
|
const article = {
|
||||||
path: joinUrl(p[0], p[1], p[2]),
|
path: joinUrl(p[0], p[1], p[2]),
|
||||||
realPath: path.join(config['data_dir'], p[0], p[1], p[2]),
|
draft: p[3] === config['article']['draft'],
|
||||||
|
realPath: path.join(config['data_dir'], p[0], p[1], p[2], p[3]),
|
||||||
year: parseInt(p[0]),
|
year: parseInt(p[0]),
|
||||||
month: parseInt(p[1]),
|
month: parseInt(p[1]),
|
||||||
day: parseInt(p[2])
|
day: parseInt(p[2])
|
||||||
@@ -89,13 +90,14 @@ module.exports = (config) => {
|
|||||||
article.date = new Date(article.year, article.month, article.day);
|
article.date = new Date(article.year, article.month, article.day);
|
||||||
article.date.setUTCHours(0);
|
article.date.setUTCHours(0);
|
||||||
remaining++;
|
remaining++;
|
||||||
readIndexFile(path.join(article.realPath, config['article']['index']), config['article']['thumbnail_tag'], (err, info) => {
|
readIndexFile(article.realPath, config['article']['thumbnail_tag'], (err, info) => {
|
||||||
if (err)
|
if (err)
|
||||||
return cb(err);
|
return cb(err);
|
||||||
article.title = info.title || config['article']['default_title'];
|
article.title = info.title || config['article']['default_title'];
|
||||||
article.thumbnail = info.thumbnail ? joinUrl(article.path, info.thumbnail) : config['article']['default_thumbnail'];
|
article.thumbnail = info.thumbnail ? joinUrl(article.path, info.thumbnail) : config['article']['default_thumbnail'];
|
||||||
article.escapedTitle = article.title.toLowerCase().replace(/[^\w]/gm, ' ').trim().replace(/ /gm, '_');
|
article.escapedTitle = article.title.toLowerCase().replace(/[^\w]/gm, ' ').trim().replace(/ /gm, '_');
|
||||||
article.url = '/' + joinUrl(article.path, article.escapedTitle) + '/';
|
article.url = '/' + joinUrl(article.path, article.escapedTitle) + '/';
|
||||||
|
if (!articles[article.path] || !article.draft)
|
||||||
articles[article.path] = article;
|
articles[article.path] = article;
|
||||||
remaining--;
|
remaining--;
|
||||||
if (remaining === 0)
|
if (remaining === 0)
|
||||||
|
|||||||
+109
-11
@@ -5,6 +5,54 @@ const showdown = require('showdown');
|
|||||||
module.exports = (config) => {
|
module.exports = (config) => {
|
||||||
const converter = new showdown.Converter(config['showdown']);
|
const converter = new showdown.Converter(config['showdown']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get parts outside of codes/scripts
|
||||||
|
* @param {string} data
|
||||||
|
* @returns {{index:number, end:number, text:string}[]} parts
|
||||||
|
*/
|
||||||
|
const getParts = (data) => {
|
||||||
|
let parts = [];
|
||||||
|
let match;
|
||||||
|
let i = 0;
|
||||||
|
while ((match = /```/m.exec(data.slice(i)))) {
|
||||||
|
parts.push({
|
||||||
|
index: i,
|
||||||
|
text: data.slice(i, i + match.index),
|
||||||
|
});
|
||||||
|
i += match.index + match[0].length;
|
||||||
|
}
|
||||||
|
if (i < data.length)
|
||||||
|
parts.push({
|
||||||
|
index: i,
|
||||||
|
text: data.slice(i, data.length),
|
||||||
|
});
|
||||||
|
|
||||||
|
parts = parts.filter((p, i) => i % 2 === 0); //filter out code parts
|
||||||
|
|
||||||
|
// detect scripts outside of code
|
||||||
|
parts.forEach((p, pi) => {
|
||||||
|
let i = 0;
|
||||||
|
const subParts = [];
|
||||||
|
while ((match = /(<script>((?:(?!<\/script>)[\s\S])*)<\/script>)/gm.exec(p.text.slice(i)))) {
|
||||||
|
subParts.push({
|
||||||
|
index: p.index + i,
|
||||||
|
text: p.text.slice(i, i + match.index),
|
||||||
|
});
|
||||||
|
i += match.index + match[0].length;
|
||||||
|
}
|
||||||
|
if (i < p.text.length)
|
||||||
|
subParts.push({
|
||||||
|
index: p.index + i,
|
||||||
|
text: p.text.slice(i, p.text.length),
|
||||||
|
});
|
||||||
|
parts.splice(pi, 1, ...subParts);
|
||||||
|
});
|
||||||
|
|
||||||
|
parts.forEach(part => part.end = part.index + part.text.length);
|
||||||
|
|
||||||
|
return parts;
|
||||||
|
};
|
||||||
|
|
||||||
const renderShowDown = (data, cb) => {
|
const renderShowDown = (data, cb) => {
|
||||||
const html = converter.makeHtml(data);
|
const html = converter.makeHtml(data);
|
||||||
cb(html);
|
cb(html);
|
||||||
@@ -35,15 +83,19 @@ module.exports = (config) => {
|
|||||||
const renderPlantUML = (data, cb) => {
|
const renderPlantUML = (data, cb) => {
|
||||||
if (!config['modules']['plantuml'])
|
if (!config['modules']['plantuml'])
|
||||||
return cb(data);
|
return cb(data);
|
||||||
|
const parts = getParts(data);
|
||||||
const umlRegex = /@startuml\r?\n((?:(?!@enduml)[\s\S])*)\r?\n@enduml/m;
|
const umlRegex = /@startuml\r?\n((?:(?!@enduml)[\s\S])*)\r?\n@enduml/m;
|
||||||
let match;
|
let match;
|
||||||
while ((match = umlRegex.exec(data))) {
|
parts.forEach(part => {
|
||||||
|
while ((match = umlRegex.exec(part.text))) {
|
||||||
const code = match[1].trim();
|
const code = match[1].trim();
|
||||||
const s = unescape(encodeURIComponent(code)); // jshint ignore:line
|
const s = unescape(encodeURIComponent(code)); // jshint ignore:line
|
||||||
const compressed = global['zip_deflate'](s);
|
const compressed = global['zip_deflate'](s);
|
||||||
const url = `http://www.plantuml.com/plantuml/${config['plantuml']['output_format']}/${encode64(compressed)}`;// jshint ignore:line
|
const url = `http://www.plantuml.com/plantuml/${config['plantuml']['output_format']}/${encode64(compressed)}`;// jshint ignore:line
|
||||||
data = data.slice(0, match.index) + `<img alt="generated PlantUML diagram" src="${url}">` + data.slice(match.index + match[0].length);
|
part.text = part.text.slice(0, match.index) + `<img alt="generated PlantUML diagram" src="${url}">` + part.text.slice(match.index + match[0].length);
|
||||||
}
|
}
|
||||||
|
data = data.slice(0, part.index) + part.text + data.slice(part.end);
|
||||||
|
});
|
||||||
cb(data);
|
cb(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,7 +116,9 @@ module.exports = (config) => {
|
|||||||
if (!config['modules']['mathjax'])
|
if (!config['modules']['mathjax'])
|
||||||
return cb(data);
|
return cb(data);
|
||||||
|
|
||||||
const doMJ = (match, format) => {
|
const parts = getParts(data);
|
||||||
|
|
||||||
|
const doMJ = (match, format, i) => {
|
||||||
const eq = match[1].trim();
|
const eq = match[1].trim();
|
||||||
const output = config['mathjax']['output_format'];
|
const output = config['mathjax']['output_format'];
|
||||||
const mjConf = {
|
const mjConf = {
|
||||||
@@ -74,7 +128,7 @@ module.exports = (config) => {
|
|||||||
};
|
};
|
||||||
mjConf[output] = true;
|
mjConf[output] = true;
|
||||||
mjAPI.typeset(mjConf, (res) => {
|
mjAPI.typeset(mjConf, (res) => {
|
||||||
data = data.slice(0, match.index) + res[output] + data.slice(match.index + match[0].length);
|
data = data.slice(0, parts[i].index + match.index) + res[output] + data.slice(parts[i].index + match.index + match[0].length);
|
||||||
renderMathJax(data, (data2) => {
|
renderMathJax(data, (data2) => {
|
||||||
cb(data2);
|
cb(data2);
|
||||||
});
|
});
|
||||||
@@ -84,29 +138,72 @@ module.exports = (config) => {
|
|||||||
const eqRegex = /\$\$((?:(?!\$\$)[\s\S])*)\$\$/m;
|
const eqRegex = /\$\$((?:(?!\$\$)[\s\S])*)\$\$/m;
|
||||||
const inlineEqRegex = /\$([^$\n]*)\$/;
|
const inlineEqRegex = /\$([^$\n]*)\$/;
|
||||||
|
|
||||||
|
for (let i = 0; i < parts.length; i++) {
|
||||||
let match;
|
let match;
|
||||||
if ((match = eqRegex.exec(data))) {
|
if ((match = eqRegex.exec(parts[i].text))) {
|
||||||
doMJ(match, 'TeX');
|
return doMJ(match, 'TeX', i);
|
||||||
} else if ((match = inlineEqRegex.exec(data))) {
|
} else if ((match = inlineEqRegex.exec(parts[i].text))) {
|
||||||
doMJ(match, 'inline-TeX');
|
return doMJ(match, 'inline-TeX', i);
|
||||||
} else {
|
|
||||||
cb(data);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
cb(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
let faDiagrams;
|
||||||
|
let toml;
|
||||||
|
if (config['modules']['fa-diagrams']) {
|
||||||
|
faDiagrams = require('fa-diagrams');
|
||||||
|
toml = require('@iarna/toml');
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderFaDiagrams = (data, cb) => {
|
||||||
|
if (!config['modules']['fa-diagrams'])
|
||||||
|
return cb(data);
|
||||||
|
const parts = getParts(data);
|
||||||
|
const diagramsRegex = /@startfad\r?\n((?:(?!@endfad)[\s\S])*)\r?\n@endfad/m;
|
||||||
|
let match;
|
||||||
|
parts.forEach(part => {
|
||||||
|
while ((match = diagramsRegex.exec(part.text))) {
|
||||||
|
const code = match[1].trim();
|
||||||
|
let output;
|
||||||
|
try {
|
||||||
|
const diagData = toml.parse(code);
|
||||||
|
const findLineBreaks = (data) => {
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
|
if (typeof data[key] === 'object')
|
||||||
|
findLineBreaks(data[key]);
|
||||||
|
else if (typeof data[key] === 'string')
|
||||||
|
data[key] = data[key].replace(/\\n/gm, '\n');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
findLineBreaks(diagData);
|
||||||
|
output = faDiagrams.compute(diagData);
|
||||||
|
} catch (err) {
|
||||||
|
output = `<b style="color:red">${err.toString()}</b>`;
|
||||||
|
}
|
||||||
|
part.text = part.text.slice(0, match.index) + output + part.text.slice(match.index + match[0].length);
|
||||||
|
}
|
||||||
|
data = data.slice(0, part.index) + part.text + data.slice(part.end);
|
||||||
|
});
|
||||||
|
cb(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
getParts: config['test'] ? getParts : undefined,
|
||||||
renderShowDown: config['test'] ? renderShowDown : undefined,
|
renderShowDown: config['test'] ? renderShowDown : undefined,
|
||||||
renderPrism: config['test'] ? renderPrism : undefined,
|
renderPrism: config['test'] ? renderPrism : undefined,
|
||||||
renderPlantUML: config['test'] ? renderPlantUML : undefined,
|
renderPlantUML: config['test'] ? renderPlantUML : undefined,
|
||||||
renderMathJax: config['test'] ? renderMathJax : undefined,
|
renderMathJax: config['test'] ? renderMathJax : undefined,
|
||||||
|
renderFaDiagrams: config['test'] ? renderFaDiagrams : undefined,
|
||||||
render: (file, cb) => {
|
render: (file, cb) => {
|
||||||
fs.readFile(file, {encoding: 'UTF-8'}, (err, data) => {
|
fs.readFile(file, {encoding: 'UTF-8'}, (err, data) => {
|
||||||
if (err)
|
if (err)
|
||||||
return cb(err);
|
return cb(err);
|
||||||
|
|
||||||
renderPrism(data, (data) => {
|
|
||||||
renderPlantUML(data, (data) => {
|
renderPlantUML(data, (data) => {
|
||||||
|
renderFaDiagrams(data, (data) => {
|
||||||
renderMathJax(data, (data) => {
|
renderMathJax(data, (data) => {
|
||||||
|
renderPrism(data, (data) => {
|
||||||
renderShowDown(data, (html) => {
|
renderShowDown(data, (html) => {
|
||||||
cb(null, html);
|
cb(null, html);
|
||||||
});
|
});
|
||||||
@@ -114,6 +211,7 @@ module.exports = (config) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+60
-20
@@ -16,16 +16,15 @@ config['data_dir'] = dataDir;
|
|||||||
config['webhook']['endpoint'] = '/webhooktest';
|
config['webhook']['endpoint'] = '/webhooktest';
|
||||||
config['rss']['endpoint'] = '/rsstest';
|
config['rss']['endpoint'] = '/rsstest';
|
||||||
config['rss']['length'] = 2;
|
config['rss']['length'] = 2;
|
||||||
config['home']['index'] = testIndex;
|
|
||||||
config['home']['error'] = testError;
|
config['home']['error'] = testError;
|
||||||
config['article']['template'] = testTemplate;
|
config['article']['template'] = testTemplate;
|
||||||
|
|
||||||
const app = require('../src/app')(config);
|
const app = require('../src/app')(config);
|
||||||
|
|
||||||
beforeEach((done, fail) => {
|
beforeEach((done, fail) => {
|
||||||
|
config['home']['index'] = testIndex;
|
||||||
config['data_dir'] = dataDir;
|
config['data_dir'] = dataDir;
|
||||||
config['article']['index'] = 'index.md';
|
config['article']['index'] = 'index.md';
|
||||||
config['home']['hidden'] = ['.ejs', '.test'];
|
|
||||||
config['access_log'] = '';
|
config['access_log'] = '';
|
||||||
config['error_log'] = '';
|
config['error_log'] = '';
|
||||||
config['modules']['rss'] = true;
|
config['modules']['rss'] = true;
|
||||||
@@ -93,20 +92,20 @@ describe('Test request logging', () => {
|
|||||||
|
|
||||||
describe('Test error logging', () => {
|
describe('Test error logging', () => {
|
||||||
test('test no log', (done) => {
|
test('test no log', (done) => {
|
||||||
config['home']['hidden'] = null;
|
config['home']['index'] = null;
|
||||||
request(app).get('/somefile.txt').then(() => {
|
request(app).get('/').then(() => {
|
||||||
expect(fs.existsSync(path.join(dataDir, 'error.log'))).toBe(false);
|
expect(fs.existsSync(path.join(dataDir, 'error.log'))).toBe(false);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('test null error ', (done) => {
|
test('test null error ', (done) => {
|
||||||
config['home']['hidden'] = null;
|
config['home']['index'] = null;
|
||||||
config['error_log'] = path.join(dataDir, 'error.log');
|
config['error_log'] = path.join(dataDir, 'error.log');
|
||||||
request(app).get('/somefile.txt').then(() => {
|
request(app).get('/').then(() => {
|
||||||
fs.readFile(path.join(dataDir, 'error.log'), {encoding: 'UTF-8'}, (err, data) => {
|
fs.readFile(path.join(dataDir, 'error.log'), {encoding: 'UTF-8'}, (err, data) => {
|
||||||
expect(err).toBeNull();
|
expect(err).toBeNull();
|
||||||
const start = data.split('\n').slice(0, 2).join('\n');
|
const start = data.split('\n').slice(0, 2).join('\n');
|
||||||
const expected = '500 GET /somefile.txt ' + new Date().toUTCString() + ' ::ffff:127.0.0.1\nTypeError: Cannot read property \'includes\' of null';
|
const expected = '500 GET / ' + new Date().toUTCString() + ' ::ffff:127.0.0.1\nTypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object';
|
||||||
expect(start).toBe(expected);
|
expect(start).toBe(expected);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -122,10 +121,10 @@ describe('Test root path', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('404 no index but error page', (done) => {
|
test('404 no index but error page', (done) => {
|
||||||
fs.writeFileSync(path.join(dataDir, testError), 'error <%= error %> at <%= path %>');
|
fs.writeFileSync(path.join(dataDir, testError), 'error <%= error %>');
|
||||||
request(app).get('/').then((response) => {
|
request(app).get('/').then((response) => {
|
||||||
expect(response.statusCode).toBe(404);
|
expect(response.statusCode).toBe(404);
|
||||||
expect(response.text).toBe('error 404 at /');
|
expect(response.text).toBe('error 404');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -136,6 +135,23 @@ describe('Test root path', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
test('500 render error with page', (done) => {
|
||||||
|
fs.writeFileSync(path.join(dataDir, testIndex), 'articles <%= null.length %>');
|
||||||
|
fs.writeFileSync(path.join(dataDir, testError), 'error <%= error %>');
|
||||||
|
request(app).get('/').then((response) => {
|
||||||
|
expect(response.statusCode).toBe(500);
|
||||||
|
expect(response.text).toBe('error 500');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('500 render error with failing page', (done) => {
|
||||||
|
fs.writeFileSync(path.join(dataDir, testIndex), 'articles <%= null.length %>');
|
||||||
|
fs.writeFileSync(path.join(dataDir, testError), 'error <%= null.error %>');
|
||||||
|
request(app).get('/').then((response) => {
|
||||||
|
expect(response.statusCode).toBe(500);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
test('200 no articles', (done) => {
|
test('200 no articles', (done) => {
|
||||||
fs.writeFileSync(path.join(dataDir, testIndex), 'articles <%= articles.length %>');
|
fs.writeFileSync(path.join(dataDir, testIndex), 'articles <%= articles.length %>');
|
||||||
request(app).get('/').then((response) => {
|
request(app).get('/').then((response) => {
|
||||||
@@ -144,14 +160,17 @@ describe('Test root path', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('200 2 articles', (done, fail) => {
|
test('200 2 articles 1 drafted', (done, fail) => {
|
||||||
utils.createEmptyDirs([
|
utils.createEmptyDirs([
|
||||||
path.join(dataDir, '2019', '05', '05'),
|
path.join(dataDir, '2019', '05', '05'),
|
||||||
path.join(dataDir, '2018', '05', '05')
|
path.join(dataDir, '2018', '05', '05'),
|
||||||
|
path.join(dataDir, '2017', '05', '05')
|
||||||
]);
|
]);
|
||||||
utils.createEmptyFiles([
|
utils.createEmptyFiles([
|
||||||
path.join(dataDir, '2019', '05', '05', 'index.md'),
|
path.join(dataDir, '2019', '05', '05', 'draft.md'),
|
||||||
path.join(dataDir, '2018', '05', '05', 'index.md')
|
path.join(dataDir, '2018', '05', '05', 'index.md'),
|
||||||
|
path.join(dataDir, '2018', '05', '05', 'draft.md'),
|
||||||
|
path.join(dataDir, '2017', '05', '05', 'index.md'),
|
||||||
]);
|
]);
|
||||||
fs.writeFileSync(path.join(dataDir, testIndex), 'articles <%= articles.length %>');
|
fs.writeFileSync(path.join(dataDir, testIndex), 'articles <%= articles.length %>');
|
||||||
app.reload(() => {
|
app.reload(() => {
|
||||||
@@ -303,12 +322,11 @@ describe('Test articles rendering', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('500 no index', (done, fail) => {
|
test('500 fail to render', (done, fail) => {
|
||||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||||
fs.writeFileSync(path.join(dataDir, '2019', '05', '05', 'index.md'), '# Hello');
|
fs.writeFileSync(path.join(dataDir, '2019', '05', '05', 'index.md'), '# Hello');
|
||||||
fs.writeFileSync(path.join(dataDir, testTemplate), '<%- article.content %><%- `<a href="${article.url}">reload</a>` %>');
|
fs.writeFileSync(path.join(dataDir, testTemplate), '<%- articl.content %><%- `<a href="${article.url}">reload</a>` %>');
|
||||||
app.reload(() => {
|
app.reload(() => {
|
||||||
config['article']['index'] = 'invalid.md';
|
|
||||||
request(app).get('/2019/05/05/hello/').then((response) => {
|
request(app).get('/2019/05/05/hello/').then((response) => {
|
||||||
expect(response.statusCode).toBe(500);
|
expect(response.statusCode).toBe(500);
|
||||||
done();
|
done();
|
||||||
@@ -340,6 +358,19 @@ describe('Test articles rendering', () => {
|
|||||||
}, fail);
|
}, fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('200 rendered draft', (done, fail) => {
|
||||||
|
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||||
|
fs.writeFileSync(path.join(dataDir, '2019', '05', '05', 'draft.md'), '# Hello');
|
||||||
|
fs.writeFileSync(path.join(dataDir, testTemplate), '<%- article.content %><%- `<a href="${article.url}">reload</a>` %>');
|
||||||
|
app.reload(() => {
|
||||||
|
request(app).get('/2019/05/05/hello/').then((response) => {
|
||||||
|
expect(response.statusCode).toBe(200);
|
||||||
|
expect(response.text).toBe('<h1 id="hello">Hello</h1><a href="/2019/05/05/hello/">reload</a>');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}, fail);
|
||||||
|
});
|
||||||
|
|
||||||
test('200 other url', (done, fail) => {
|
test('200 other url', (done, fail) => {
|
||||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||||
utils.createEmptyFiles([
|
utils.createEmptyFiles([
|
||||||
@@ -378,16 +409,25 @@ describe('Test static files', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('404 invalid file but error page', (done) => {
|
test('404 invalid file but error page', (done) => {
|
||||||
fs.writeFileSync(path.join(dataDir, testError), 'error <%= error %> at <%= path %>');
|
fs.writeFileSync(path.join(dataDir, testError), 'error <%= error %>');
|
||||||
request(app).get('/somefile.txt').then((response) => {
|
request(app).get('/somefile.txt').then((response) => {
|
||||||
expect(response.statusCode).toBe(404);
|
expect(response.statusCode).toBe(404);
|
||||||
expect(response.text).toBe('error 404 at /somefile.txt');
|
expect(response.text).toBe('error 404');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('404 hidden file', (done) => {
|
test('404 hidden file', (done) => {
|
||||||
fs.writeFileSync(path.join(dataDir, 'somefile.test'), '');
|
utils.createEmptyDirs([path.join(dataDir, 'tmp')]);
|
||||||
request(app).get('/somefile.test').then((response) => {
|
fs.writeFileSync(path.join(dataDir, 'tmp', 'somefile.ejs'), '');
|
||||||
|
request(app).get('/tmp/somefile.ejs').then((response) => {
|
||||||
|
expect(response.statusCode).toBe(404);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('404 hidden folder', (done) => {
|
||||||
|
utils.createEmptyDirs([path.join(dataDir, '.git')]);
|
||||||
|
fs.writeFileSync(path.join(dataDir, '.git', 'file.txt'), '');
|
||||||
|
request(app).get('/.git/file.txt').then((response) => {
|
||||||
expect(response.statusCode).toBe(404);
|
expect(response.statusCode).toBe(404);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -77,5 +77,5 @@ test('array fix', () => {
|
|||||||
fs.writeFileSync(configFile, '{"home":{"hidden":{}}}');
|
fs.writeFileSync(configFile, '{"home":{"hidden":{}}}');
|
||||||
const config = require('../src/config')();
|
const config = require('../src/config')();
|
||||||
expect(config).toBeDefined();
|
expect(config).toBeDefined();
|
||||||
expect(config['home']['hidden']).toEqual(['.ejs']);
|
expect(config['home']['hidden']).toEqual(['*.ejs', '/.git*']);
|
||||||
});
|
});
|
||||||
@@ -13,6 +13,7 @@ const config = {
|
|||||||
'data_dir': dataDir,
|
'data_dir': dataDir,
|
||||||
'article': {
|
'article': {
|
||||||
'index': testIndex,
|
'index': testIndex,
|
||||||
|
'draft': 'draft.md',
|
||||||
'default_title': 'Untitled',
|
'default_title': 'Untitled',
|
||||||
'default_thumbnail': 'default.png',
|
'default_thumbnail': 'default.png',
|
||||||
'thumbnail_tag': 'thumbnail'
|
'thumbnail_tag': 'thumbnail'
|
||||||
@@ -235,9 +236,10 @@ describe('Test article fetching', () => {
|
|||||||
expect(Object.keys(dict).length).toBe(1);
|
expect(Object.keys(dict).length).toBe(1);
|
||||||
expect(dict[joinUrl('2019', '05', '05')]).toEqual({
|
expect(dict[joinUrl('2019', '05', '05')]).toEqual({
|
||||||
path: joinUrl('2019', '05', '05'),
|
path: joinUrl('2019', '05', '05'),
|
||||||
realPath: dir,
|
realPath: file,
|
||||||
year: 2019,
|
year: 2019,
|
||||||
month: 5,
|
month: 5,
|
||||||
|
draft: false,
|
||||||
day: 5,
|
day: 5,
|
||||||
date: date,
|
date: date,
|
||||||
title: 'Untitled',
|
title: 'Untitled',
|
||||||
@@ -265,10 +267,11 @@ describe('Test article fetching', () => {
|
|||||||
expect(Object.keys(dict).length).toBe(1);
|
expect(Object.keys(dict).length).toBe(1);
|
||||||
expect(dict[joinUrl('2019', '05', '05')]).toEqual({
|
expect(dict[joinUrl('2019', '05', '05')]).toEqual({
|
||||||
path: joinUrl('2019', '05', '05'),
|
path: joinUrl('2019', '05', '05'),
|
||||||
realPath: dir,
|
realPath: file,
|
||||||
year: 2019,
|
year: 2019,
|
||||||
month: 5,
|
month: 5,
|
||||||
day: 5,
|
day: 5,
|
||||||
|
draft: false,
|
||||||
date: date,
|
date: date,
|
||||||
title: 'Title with : info !',
|
title: 'Title with : info !',
|
||||||
thumbnail: joinUrl('2019', '05', '05', './thumbnail.jpg'),
|
thumbnail: joinUrl('2019', '05', '05', './thumbnail.jpg'),
|
||||||
@@ -278,5 +281,64 @@ describe('Test article fetching', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
test('correct draft file', (done) => {
|
||||||
|
const dir = path.join(dataDir, '2019', '05', '05');
|
||||||
|
const file = path.join(dir, 'draft.md');
|
||||||
|
utils.createEmptyDirs([dir]);
|
||||||
|
fs.writeFileSync(file, `
|
||||||
|
# Title with : info !
|
||||||
|

|
||||||
|
this is some text
|
||||||
|
`);
|
||||||
|
const date = new Date(2019, 5, 5);
|
||||||
|
date.setUTCHours(0);
|
||||||
|
fw.fetchArticles((err, dict) => {
|
||||||
|
expect(err).toBeNull();
|
||||||
|
expect(dict).toBeDefined();
|
||||||
|
expect(Object.keys(dict).length).toBe(1);
|
||||||
|
expect(dict[joinUrl('2019', '05', '05')]).toEqual({
|
||||||
|
path: joinUrl('2019', '05', '05'),
|
||||||
|
realPath: file,
|
||||||
|
year: 2019,
|
||||||
|
month: 5,
|
||||||
|
day: 5,
|
||||||
|
draft: true,
|
||||||
|
date: date,
|
||||||
|
title: 'Title with : info !',
|
||||||
|
thumbnail: joinUrl('2019', '05', '05', './thumbnail.jpg'),
|
||||||
|
escapedTitle: 'title_with___info',
|
||||||
|
url: '/' + joinUrl('2019', '05', '05', 'title_with___info') + '/',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('index file override draft', (done) => {
|
||||||
|
const dir = path.join(dataDir, '2019', '05', '05');
|
||||||
|
const file = path.join(dir, testIndex);
|
||||||
|
const file2 = path.join(dir, 'draft.md');
|
||||||
|
utils.createEmptyDirs([dir]);
|
||||||
|
utils.createEmptyFiles([file, file2]);
|
||||||
|
const date = new Date(2019, 5, 5);
|
||||||
|
date.setUTCHours(0);
|
||||||
|
fw.fetchArticles((err, dict) => {
|
||||||
|
expect(err).toBeNull();
|
||||||
|
expect(dict).toBeDefined();
|
||||||
|
expect(Object.keys(dict).length).toBe(1);
|
||||||
|
expect(dict[joinUrl('2019', '05', '05')]).toEqual({
|
||||||
|
path: joinUrl('2019', '05', '05'),
|
||||||
|
realPath: file,
|
||||||
|
year: 2019,
|
||||||
|
month: 5,
|
||||||
|
draft: false,
|
||||||
|
day: 5,
|
||||||
|
date: date,
|
||||||
|
title: 'Untitled',
|
||||||
|
thumbnail: 'default.png',
|
||||||
|
escapedTitle: 'untitled',
|
||||||
|
url: '/' + joinUrl('2019', '05', '05', 'untitled') + '/',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+88
-1
@@ -11,7 +11,8 @@ const config = {
|
|||||||
'modules': {
|
'modules': {
|
||||||
'prism': true,
|
'prism': true,
|
||||||
'mathjax': true,
|
'mathjax': true,
|
||||||
'plantuml': true
|
'plantuml': true,
|
||||||
|
'fa-diagrams': true,
|
||||||
},
|
},
|
||||||
'showdown': {
|
'showdown': {
|
||||||
'simplifiedAutoLink': true,
|
'simplifiedAutoLink': true,
|
||||||
@@ -32,6 +33,7 @@ beforeEach(() => {
|
|||||||
config['modules']['prism'] = true;
|
config['modules']['prism'] = true;
|
||||||
config['modules']['mathjax'] = true;
|
config['modules']['mathjax'] = true;
|
||||||
config['modules']['plantuml'] = true;
|
config['modules']['plantuml'] = true;
|
||||||
|
config['modules']['fa-diagrams'] = true;
|
||||||
utils.deleteFolderSync(dataDir);
|
utils.deleteFolderSync(dataDir);
|
||||||
fs.mkdirSync(dataDir);
|
fs.mkdirSync(dataDir);
|
||||||
});
|
});
|
||||||
@@ -42,6 +44,47 @@ afterAll(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('get parts', () => {
|
||||||
|
test('normal', () => {
|
||||||
|
const data = 'Hello\nthere\ngeneral\nkenobi';
|
||||||
|
const parts = renderer.getParts(data);
|
||||||
|
expect(parts.map(p => p.text)).toEqual([
|
||||||
|
'Hello\nthere\ngeneral\nkenobi'
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
test('lot of stuff', () => {
|
||||||
|
const data = 'Hello\nthere\n```code```\ngeneral<script>script</script>\n<script>script2</script>\n```<script>script3</script>```kenobi';
|
||||||
|
const parts = renderer.getParts(data);
|
||||||
|
expect(parts).toEqual([
|
||||||
|
{
|
||||||
|
index: 0,
|
||||||
|
end: 12,
|
||||||
|
text: 'Hello\nthere\n'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 22,
|
||||||
|
end: 30,
|
||||||
|
text: '\ngeneral'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 53,
|
||||||
|
end: 54,
|
||||||
|
text: '\n'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 78,
|
||||||
|
end: 79,
|
||||||
|
text: '\n'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 109,
|
||||||
|
end: 115,
|
||||||
|
text: 'kenobi'
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Test Showdown', () => {
|
describe('Test Showdown', () => {
|
||||||
test('normal', (done) => {
|
test('normal', (done) => {
|
||||||
renderer.renderShowDown('# Hello', (html) => {
|
renderer.renderShowDown('# Hello', (html) => {
|
||||||
@@ -112,6 +155,13 @@ describe('Test PlantUML', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('plantuml ignored in code', (done) => {
|
||||||
|
renderer.renderPlantUML('code:\n```@startuml\nBob -> Alice : hello\n@enduml```\n ```@startuml``` @enduml', (data) => {
|
||||||
|
expect(data).toBe('code:\n```@startuml\nBob -> Alice : hello\n@enduml```\n ```@startuml``` @enduml');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('plantuml multiple uml', (done) => {
|
test('plantuml multiple uml', (done) => {
|
||||||
renderer.renderPlantUML('@startuml\nBob -> Alice : hello\n@enduml\n@startuml\nBob -> Alice : hello\n@enduml', (data) => {
|
renderer.renderPlantUML('@startuml\nBob -> Alice : hello\n@enduml\n@startuml\nBob -> Alice : hello\n@enduml', (data) => {
|
||||||
expect(data).toBe('<img alt="generated PlantUML diagram" src="http://www.plantuml.com/plantuml/svg/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000">\n<img alt="generated PlantUML diagram" src="http://www.plantuml.com/plantuml/svg/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000">');
|
expect(data).toBe('<img alt="generated PlantUML diagram" src="http://www.plantuml.com/plantuml/svg/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000">\n<img alt="generated PlantUML diagram" src="http://www.plantuml.com/plantuml/svg/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000">');
|
||||||
@@ -157,6 +207,12 @@ describe('Test MathJax', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
test('no eq in code / script', (done) => {
|
||||||
|
renderer.renderMathJax('this code is ```start $a$ end $$hello$$``` beautiful <script>$A$</script>\n```$no eq$```', (data) => {
|
||||||
|
expect(data).toBe('this code is ```start $a$ end $$hello$$``` beautiful <script>$A$</script>\n```$no eq$```');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
test('multiple eq', (done) => {
|
test('multiple eq', (done) => {
|
||||||
renderer.renderMathJax('$$\n\nA\n\n$$\nstart $a$ end\n$$\n\nA\n\n$$', (data) => {
|
renderer.renderMathJax('$$\n\nA\n\n$$\nstart $a$ end\n$$\n\nA\n\n$$', (data) => {
|
||||||
expect(data).toBe('' +
|
expect(data).toBe('' +
|
||||||
@@ -182,6 +238,37 @@ describe('Test MathJax', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Test fa-diagrams', () => {
|
||||||
|
test('no fa-diagrams', (done) => {
|
||||||
|
config['modules']['fa-diagrams'] = false;
|
||||||
|
renderer.renderFaDiagrams('@startfad\noptions.rendering.color=\'red\'\n@endfad', (data) => {
|
||||||
|
expect(data).toBe('@startfad\noptions.rendering.color=\'red\'\n@endfad');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('no fa-diagrams in code', (done) => {
|
||||||
|
renderer.renderFaDiagrams('code:\n```\n@startfad\noptions.rendering.color=\'red\'\n@endfad\n```', (data) => {
|
||||||
|
expect(data).toBe('code:\n```\n@startfad\noptions.rendering.color=\'red\'\n@endfad\n```');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('valid fa-diagrams', (done) => {
|
||||||
|
renderer.renderFaDiagrams('before\n@startfad\noptions.rendering.color=\'red\'\n@endfad\nafter', (data) => {
|
||||||
|
expect(data).toBe('before\n<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 0 0" width="0" height="0" font-family="Arial" font-size="15" fill="red" stroke-width="0"></svg>\nafter');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('invalid toml', (done) => {
|
||||||
|
renderer.renderFaDiagrams('before\n@startfad\noptions.rendering.color=red\n@endfad\nafter', (data) => {
|
||||||
|
expect(data).toBe('before\n<b style="color:red">TomlError: Unexpected character, expecting string, number, datetime, boolean, inline array or inline table at row 1, col 26, pos 25:\n' +
|
||||||
|
'1> options.rendering.color=red\n' +
|
||||||
|
' ^\n' +
|
||||||
|
'\n</b>\nafter');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Test render', () => {
|
describe('Test render', () => {
|
||||||
test('invalid file', (done) => {
|
test('invalid file', (done) => {
|
||||||
renderer.render('invalid file', (err, html) => {
|
renderer.render('invalid file', (err, html) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user