Merge remote-tracking branch 'origin/master'

This commit is contained in:
Klemek
2019-06-19 18:41:23 +02:00
14 changed files with 9964 additions and 14 deletions
+4 -2
View File
@@ -1,2 +1,4 @@
.idea /.idea
node_modules /node_modules
/config.json
/data
+21
View File
@@ -0,0 +1,21 @@
{
"esversion": 6,
"maxerr": 999,
"indent": true,
"camelcase": true,
"eqeqeq": true,
"forin": true,
"immed": true,
"latedef": true,
"noarg": true,
"noempty": true,
"nonew": true,
"undef": true,
"unused": true,
"varstmt": true,
"sub": true,
"quotmark": "single",
"node": true,
"globals": {
}
}
+20
View File
@@ -0,0 +1,20 @@
dist: xenial
language: node_js
node_js:
- "12"
cache:
npm: true
directories:
- node_modules
addons:
apt:
packages:
- graphviz
install:
- npm install
- npm install node-plantuml
before_script:
- npm install -g jshint
script:
- npm test
- jshint ./src
+26 -12
View File
@@ -1,6 +1,8 @@
# GitBlog.md (WIP) # GitBlog.md (WIP)
> This is a work in progress, some information written here might not be true yet. > This is a work in progress, some information written here might not be true yet.
[![Build Status](https://img.shields.io/travis/Klemek/GitBlog.md.svg?branch=master)](https://travis-ci.org/Klemek/GitBlog.md)
A static blog using Markdown pulled from your git repository. A static blog using Markdown pulled from your git repository.
## Flow ## Flow
@@ -14,9 +16,10 @@ A static blog using Markdown pulled from your git repository.
![rss](./uml/rss.png) ![rss](./uml/rss.png)
## Installation ## Installation
**1. Download the latest version from the repo** **1. Download and install the latest version from the repo**
```bash ```bash
git clone https://github.com/klemek/gitblog.md.git git clone https://github.com/klemek/gitblog.md.git
npm install
``` ```
**2. Create your config file** **2. Create your config file**
```bash ```bash
@@ -27,13 +30,13 @@ then edit the config.json file with your values :
> default values for config.json > default values for config.json
````json ````json
{ {
"node_port": 3000, "nodePort": 3000,
"data_dir": "data", "dataDir": "data",
"modules" : { "modules" : {
"plantuml" : true, "plantuml" : false,
"rss": true, "rss": true,
"webhook": true "webhook": true
}, },
"home" : { "home" : {
"index" : "index.ejs" "index" : "index.ejs"
}, },
@@ -41,16 +44,27 @@ then edit the config.json file with your values :
"index" : "index.md" "index" : "index.md"
}, },
"rss" : { "rss" : {
"endpoint" : "/rss", "endpoint" : "/rss",
"length" : 10 "length" : 10
}, },
"webhook" : { "webhook" : {
"endpoint": "/webhook", "endpoint": "/webhook",
"secret_file": "git_secret" "secretFile": "git_secret"
} }
} }
```` ````
**3. Create and init your git source**
**3. Start your server**
```bash
npm start
#or
node src/server.js
```
You might want to use something like screen to separate the process from your current terminal session.
**4. 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.
@@ -61,7 +75,7 @@ git remote add origin <url_of_your_repo.git>
git push -u origin master git push -u origin master
``` ```
**4. Refresh content with a webhook (optional)** **5. Refresh content with a webhook (optional)**
At first start, a `git_secret` file will be generated, use it to create a new webhook as following : At first start, a `git_secret` file will be generated, use it to create a new webhook as following :
@@ -70,4 +84,4 @@ At first start, a `git_secret` file will be generated, use it to create a new we
* Secret : `<content of the git_secret file>` * Secret : `<content of the git_secret file>`
* Events : Just the push event * Events : Just the push event
On GitHub, webhooks can be created in the `Settings/Webhooks` part of the repository. On GitHub, webhooks can be created in the `Settings/Webhooks` part of the repository.
+23
View File
@@ -0,0 +1,23 @@
{
"nodePort": 3000,
"dataDir": "data",
"modules" : {
"plantuml" : false,
"rss": true,
"webhook": true
},
"home" : {
"index" : "index.ejs"
},
"article" : {
"index" : "index.md"
},
"rss" : {
"endpoint" : "/rss",
"length" : 10
},
"webhook" : {
"endpoint": "/webhook",
"secretFile": "git_secret"
}
}
+9775
View File
File diff suppressed because it is too large Load Diff
+33
View File
@@ -0,0 +1,33 @@
{
"name": "gitblog.md",
"version": "1.0.0",
"description": "A static blog using Markdown pulled from your git repository.",
"main": "src/server.js",
"dependencies": {
"express": "^4.17.1",
"ncp": "^2.0.0",
"showdown": "^1.9.0",
"xml": "^1.0.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"jest": "^24.8.0",
"superagent": "^5.1.0",
"supertest": "^4.0.2"
},
"scripts": {
"test": "jest",
"install": "node src/postinstall.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/klemek/gitblog.md.git"
},
"author": "klemek",
"license": "ISC",
"bugs": {
"url": "https://github.com/klemek/gitblog.md/issues"
},
"homepage": "https://github.com/klemek/gitblog.md#readme"
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 898 KiB

+6
View File
@@ -0,0 +1,6 @@
# Welcome to your new blog
## If you see this page, that means it's working
![missing image](./birthday-cake.png)
+12
View File
@@ -0,0 +1,12 @@
const express = require('express');
const app = express();
module.exports = function(/*config*/){
app.get('/', (req,res) => {
res.status(200).send('Hello World!');
});
return app;
};
+18
View File
@@ -0,0 +1,18 @@
const fs = require('fs');
const ncp = require('ncp').ncp;
const pad0 = n => ('0'+n).substr(-2);
const datetime = new Date();
const dir = `./data/${datetime.getFullYear()}/${pad0(datetime.getMonth())}/${pad0(datetime.getDay())}/`;
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, {recursive: true});
}
ncp('./sample_data/',dir, function(err){
if(err)
console.error(err);
else
console.log(`sample data copied to ${dir}`);
});
+9
View File
@@ -0,0 +1,9 @@
const config = require('../config.json');
const app = require('./app')(config);
const port = config.nodePort|3000;
app.listen(config.nodePort|3000, () => {
console.log(`gitblog.md server listening on port ${port}`);
});
+14
View File
@@ -0,0 +1,14 @@
/* jshint -W117 */
const request = require('supertest');
const config = require('./config.test.json');
const app = require('../src/app')(config);
describe('Test root path', () => {
test('GET / 200', done => {
request(app).get('/').then(response => {
expect(response.statusCode).toBe(200);
done();
});
});
});
+3
View File
@@ -0,0 +1,3 @@
{
}