Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 32f9ea74f1 | |||
| 9d1fb69fee | |||
| 24a02d862f | |||
| cfe9965d03 | |||
| d260b9d2f8 | |||
| 9ec55b3c01 | |||
| c693d96339 | |||
| 8bb6b6db66 | |||
| 849cdf2a19 | |||
| d0d3f94049 | |||
| 613e663c13 | |||
| bd10871da9 | |||
| 671a4314d7 | |||
| 1cee7094f3 | |||
| 2284d46bb5 | |||
| 7245876b07 | |||
| 7a35aec7ad | |||
| 870701b6c6 | |||
| 3be86dec58 | |||
| 48d9535007 | |||
| ae2eb52cf8 | |||
| 7e9e1e19fa | |||
| c9ef93088b | |||
| 99e4bb5c4d | |||
| dd5af2b865 | |||
| 4671253147 | |||
| add01b28fe | |||
| a27a53e238 | |||
| 6aff9b4d93 | |||
| c9f57233a4 | |||
| 90c343c752 | |||
| ff7542af70 |
@@ -1,5 +1,7 @@
|
|||||||
[](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)
|
||||||
|
[](https://lgtm.com/projects/g/Klemek/GitBlog.md/context:javascript)
|
||||||
|
[](https://lgtm.com/projects/g/Klemek/GitBlog.md/alerts/)
|
||||||
|
|
||||||
# GitBlog.md
|
# GitBlog.md
|
||||||
|
|
||||||
@@ -245,7 +247,7 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link
|
|||||||
* **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**
|
* **fa-diagrams**
|
||||||
It allows you to define SVG diagrams with Font-Awesome icons in YAML between `@startfad` and `@endfad` (more info [here](https://github.com/Klemek/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
|
||||||
@@ -260,6 +262,8 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link
|
|||||||
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)
|
||||||
the Express view engine used to render pages from templates
|
the Express view engine used to render pages from templates
|
||||||
|
* `rate_limit` (default: 100)
|
||||||
|
number of requests allowed in a time-frame of 15 minutes
|
||||||
* `access_log` (default: access.log)
|
* `access_log` (default: access.log)
|
||||||
log file where to save access requests (empty to disable)
|
log file where to save access requests (empty to disable)
|
||||||
* `error_log` (default: error.log)
|
* `error_log` (default: error.log)
|
||||||
|
|||||||
Generated
+1267
-5142
File diff suppressed because it is too large
Load Diff
+3
-5
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "gitblog.md",
|
"name": "gitblog.md",
|
||||||
"version": "1.2.6",
|
"version": "1.2.8",
|
||||||
"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",
|
|
||||||
"ejs": "^2.6.2",
|
"ejs": "^2.6.2",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"express-rate-limit": "^5.0.0",
|
||||||
"fa-diagrams": "^1.0.3",
|
"fa-diagrams": "^1.0.3",
|
||||||
"js-yaml": "^3.13.1",
|
|
||||||
"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",
|
||||||
@@ -18,8 +18,6 @@
|
|||||||
"showdown": "^1.9.0"
|
"showdown": "^1.9.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.26.0",
|
|
||||||
"babel-preset-env": "^1.7.0",
|
|
||||||
"coveralls": "^3.0.4",
|
"coveralls": "^3.0.4",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.8.0",
|
||||||
"superagent": "^5.1.0",
|
"superagent": "^5.1.0",
|
||||||
|
|||||||
@@ -257,26 +257,30 @@ express -up-> web : 5. html
|
|||||||
### Diagrams
|
### Diagrams
|
||||||
[Back to top](#top)
|
[Back to top](#top)
|
||||||
|
|
||||||
You can use [fa-diagrams](https://github.com/Klemek/fa-diagrams) with `@startfad` and `@endfad` tags and using YAML inside
|
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
|
||||||
|
|
||||||
@startuml
|
@startfad
|
||||||
nodes:
|
[[nodes]]
|
||||||
- name: node1
|
name = "node1"
|
||||||
icon: laptop-code
|
icon = "laptop-code"
|
||||||
color: '#4E342E'
|
color = "#4E342E"
|
||||||
bottom: my app
|
bottom = "my app"
|
||||||
- name: node2
|
|
||||||
icon: globe
|
[[nodes]]
|
||||||
color: '#455A64'
|
name = "node2"
|
||||||
bottom: world
|
icon = "globe"
|
||||||
links:
|
color = "#455A64"
|
||||||
- from: node1
|
bottom = "world"
|
||||||
to: node2
|
|
||||||
color: '#333333'
|
[[links]]
|
||||||
top:
|
from = "node1"
|
||||||
icon: envelope
|
to = "node2"
|
||||||
bottom: '"hello"'
|
color = "#333333"
|
||||||
@enduml
|
bottom = '"hello"'
|
||||||
|
|
||||||
|
[links.top]
|
||||||
|
icon = "envelope"
|
||||||
|
@endfad
|
||||||
|
|
||||||
### Youtube Videos
|
### Youtube Videos
|
||||||
[Back to top](#top)
|
[Back to top](#top)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const app = express();
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const pjson = require('../package.json');
|
const pjson = require('../package.json');
|
||||||
|
const rateLimit = require('express-rate-limit');
|
||||||
|
|
||||||
app.enable('trust proxy');
|
app.enable('trust proxy');
|
||||||
|
|
||||||
@@ -122,6 +123,13 @@ module.exports = (config) => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//rate limit for safer server
|
||||||
|
const limiter = rateLimit({
|
||||||
|
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||||
|
max: config['rate_limit']
|
||||||
|
});
|
||||||
|
app.use(limiter);
|
||||||
|
|
||||||
//log request at result end
|
//log request at result end
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
if (config['access_log']) {
|
if (config['access_log']) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"host": "",
|
"host": "",
|
||||||
"data_dir": "data",
|
"data_dir": "data",
|
||||||
"view_engine": "ejs",
|
"view_engine": "ejs",
|
||||||
|
"rate_limit": 100,
|
||||||
"access_log": "access.log",
|
"access_log": "access.log",
|
||||||
"error_log": "error.log",
|
"error_log": "error.log",
|
||||||
"modules": {
|
"modules": {
|
||||||
|
|||||||
+3
-3
@@ -150,10 +150,10 @@ module.exports = (config) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let faDiagrams;
|
let faDiagrams;
|
||||||
let yaml;
|
let toml;
|
||||||
if (config['modules']['fa-diagrams']) {
|
if (config['modules']['fa-diagrams']) {
|
||||||
faDiagrams = require('fa-diagrams');
|
faDiagrams = require('fa-diagrams');
|
||||||
yaml = require('js-yaml');
|
toml = require('@iarna/toml');
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderFaDiagrams = (data, cb) => {
|
const renderFaDiagrams = (data, cb) => {
|
||||||
@@ -167,7 +167,7 @@ module.exports = (config) => {
|
|||||||
const code = match[1].trim();
|
const code = match[1].trim();
|
||||||
let output;
|
let output;
|
||||||
try {
|
try {
|
||||||
const diagData = yaml.safeLoad(code);
|
const diagData = toml.parse(code);
|
||||||
const findLineBreaks = (data) => {
|
const findLineBreaks = (data) => {
|
||||||
Object.keys(data).forEach(key => {
|
Object.keys(data).forEach(key => {
|
||||||
if (typeof data[key] === 'object')
|
if (typeof data[key] === 'object')
|
||||||
|
|||||||
+11
-8
@@ -241,26 +241,29 @@ describe('Test MathJax', () => {
|
|||||||
describe('Test fa-diagrams', () => {
|
describe('Test fa-diagrams', () => {
|
||||||
test('no fa-diagrams', (done) => {
|
test('no fa-diagrams', (done) => {
|
||||||
config['modules']['fa-diagrams'] = false;
|
config['modules']['fa-diagrams'] = false;
|
||||||
renderer.renderFaDiagrams('@startfad\noptions:\n\trendering:\t\tcolor:red\n\n@endfad', (data) => {
|
renderer.renderFaDiagrams('@startfad\noptions.rendering.color=\'red\'\n@endfad', (data) => {
|
||||||
expect(data).toBe('@startfad\noptions:\n\trendering:\t\tcolor:red\n\n@endfad');
|
expect(data).toBe('@startfad\noptions.rendering.color=\'red\'\n@endfad');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('no fa-diagrams in code', (done) => {
|
test('no fa-diagrams in code', (done) => {
|
||||||
renderer.renderFaDiagrams('code:\n```\n@startfad\noptions:\n\trendering:\t\tcolor:red\n\n@endfad\n```', (data) => {
|
renderer.renderFaDiagrams('code:\n```\n@startfad\noptions.rendering.color=\'red\'\n@endfad\n```', (data) => {
|
||||||
expect(data).toBe('code:\n```\n@startfad\noptions:\n\trendering:\t\tcolor:red\n\n@endfad\n```');
|
expect(data).toBe('code:\n```\n@startfad\noptions.rendering.color=\'red\'\n@endfad\n```');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('valid fa-diagrams', (done) => {
|
test('valid fa-diagrams', (done) => {
|
||||||
renderer.renderFaDiagrams('before\n@startfad\noptions:\n rendering:\n color: red\n@endfad\nafter', (data) => {
|
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');
|
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();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('invalid yaml', (done) => {
|
test('invalid toml', (done) => {
|
||||||
renderer.renderFaDiagrams('before\n@startfad\noptions:\n@endfad\nafter', (data) => {
|
renderer.renderFaDiagrams('before\n@startfad\noptions.rendering.color=red\n@endfad\nafter', (data) => {
|
||||||
expect(data).toBe('before\n<b style="color:red">TypeError: Cannot convert undefined or null to object</b>\nafter');
|
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();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 20 KiB |
@@ -10,6 +10,7 @@ node nodejs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
package data {
|
package data {
|
||||||
|
[template.ejs]
|
||||||
package "2019/06/18" {
|
package "2019/06/18" {
|
||||||
component index [
|
component index [
|
||||||
index.md
|
index.md
|
||||||
@@ -22,6 +23,7 @@ package data {
|
|||||||
web -down-> TCP : 1. /2019/06/18/title
|
web -down-> TCP : 1. /2019/06/18/title
|
||||||
express -down-> index : 2. fetch
|
express -down-> index : 2. fetch
|
||||||
index -up-> showdown : 3. markdown
|
index -up-> showdown : 3. markdown
|
||||||
|
template.ejs -up-> express : 4
|
||||||
showdown -left-> express : 4. html
|
showdown -left-> express : 4. html
|
||||||
express -up-> web : 5. html
|
express -up-> web : 5. html
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user