diff --git a/.gitignore b/.gitignore
index d60caaf..32b7f43 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,10 @@
/.idea
/node_modules
/config.json
-/data
\ No newline at end of file
+/config.example.json
+/data
+/data/*
+/test_data
+/access.log
+/error.log
+/coverage
\ No newline at end of file
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..4453f2b
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,2 @@
+/node_modules
+/src/lib
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index aa98b10..c6968f7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,15 +6,11 @@ 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
+ - jest --coverage --silent
- jshint ./src
+ - cat ./coverage/lcov.info | coveralls
diff --git a/README.md b/README.md
index 5d3d913..f24e25b 100644
--- a/README.md
+++ b/README.md
@@ -1,87 +1,333 @@
-# GitBlog.md (WIP)
-> This is a work in progress, some information written here might not be true yet.
-
[](https://travis-ci.org/Klemek/GitBlog.md)
+[](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
A static blog using Markdown pulled from your git repository.
-## Flow
+> Step 1 : ```$ vi 2019/06/21/index.md```
+> Step 2 : ```$ git add . && git commit -m "new article" && git push origin master```
+> Step 3 : That's it
+> Step 4 : No seriously you're done, go check your updated blog
+
+* **[How it works](#how-it-works)**
+* **[Installation](#installation)**
+* **[Writing an article](#writing-an-article)**
+* **[Modules](#modules)**
+* **[Configuration](#configuration)**
+
+## How it works
+[back to top](#gitblog-md)
+
+There are 4 majors features of this project :
+
+#### 1. Home page
+
+
+diagram (click)
+

+
+
+
+When you access the root url of your blog, the app will fetch the template and inject the list of currently available articles.
+
+
+#### 2. Article page
+
+
+diagram (click)
+

+
+
+
+As you access an article link, the server will fetch it's `index.md` Markdown file and render it in plain HTML using Showdown.
+
+
+#### 3. Git webhook
+
+
+diagram (click)
+

+
+
+
+As you configured your data repository, when you push any data, it will trigger the webhook that will perform a `git pull` then refresh the article list.
+
+
+#### 4. RSS feed
+
+
+diagram (click)
+

+
+
+
+On the `/rss` endpoint, the servers gives you a RSS feed based on the list of articles which you can bookmark.
+
+
## Installation
-**1. Download and install the latest version from the repo**
+[back to top](#gitblog-md)
+
+#### 1. Download and install the latest version from the repo
```bash
git clone https://github.com/klemek/gitblog.md.git
-npm install
+npm install --production
```
-**2. Create your config file**
+#### 2. Create your config file
```bash
cd gitblog.md
cp config.example.json config.json
```
-then edit the config.json file with your values :
-> default values for config.json
-````json
-{
- "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"
- }
-}
-````
+then edit the config.json file with your custom values.
+For example, you might want to change the app's port with :
-**3. Start your server**
+```json
+{
+ "node_port": 3030
+}
+```
+
+See [Configuration](#configuration) for more info.
+
+#### 3. Start your server
```bash
-npm start
+npm run
#or
node src/server.js
```
+You can check that it's up and running at [http://localhost:3000/](http://localhost:3000/)
+
You might want to use something like screen to separate the process from your current terminal session.
-**4. Create and init your git source**
+#### 4. Customize the blog's style
+
+At `npm install` a first article will be created for the current date.
+You can see it as an example of rendering of your blog.
+Use it to edit your templates and styles located on the `data` folder.
+
+At first, home page and articles are rendered using EJS engine but you can customize that into the configuration.
+
+Resources are located on the `data` folder and can be referenced as the root of your blog.
+
+```
+/styles/main.css => data/styles/main.css
+```
+
+In your template, the following data is sent :
+
+
+details (click)
+
+
+* `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
+
+
+### Horizontal Rule
+[Back to top](#top)
+
+Three or more...
+
+---
+
+Hyphens
+
+***
+
+Asterisks
+
+___
+
+Underscores
+
+### Line Breaks
+[Back to top](#top)
+
+Here's a line for us to start with.
+
+This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
+
+This line is also a separate paragraph, but...
+This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
+
+### Check Boxes
+[Back to top](#top)
+
+* [x] Task completed
+* [] Task to do
+
+### Spoilers
+[Back to top](#top)
+
+Title of the spoiler (click)
+Content of the spoiler
+
+On several lines
+
+
+### Math Equations
+[Back to top](#top)
+
+You can use LaTeX equations with MathJax for full equations and inline ones (based on the number of $) :
+
+$$
+\large{\beta=\sum_{i}^{\alpha }\frac{x^{i}}{\alpha}}
+$$
+
+
+Where $\alpha$ is cool
+
+### UML
+[Back to top](#top)
+
+You can use PlantUML diagrams with `@startuml` and `@enduml` tags :
+
+@startuml
+title Article
+cloud web
+node nodejs {
+ TCP -right- [express]
+ [showdown]
+}
+package data {
+ package "2019/06/18" {
+ component index [
+ index.md
+ image.png
+ ...
+ ]
+ }
+}
+web -down-> TCP : 1. /2019/06/18/title
+express -down-> index : 2. fetch
+index -up-> showdown : 3. markdown
+showdown -left-> express : 4. html
+express -up-> web : 5. html
+@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
+[Back to top](#top)
+
+Just use the "embedded" export on Youtube with dimensions of 535x300 for best results
+
+
\ No newline at end of file
diff --git a/sample_data/birthday-cake.png b/sample_data/birthday-cake.png
deleted file mode 100644
index c5d5d9f..0000000
Binary files a/sample_data/birthday-cake.png and /dev/null differ
diff --git a/sample_data/home/error.ejs b/sample_data/home/error.ejs
new file mode 100644
index 0000000..3bbcdd4
--- /dev/null
+++ b/sample_data/home/error.ejs
@@ -0,0 +1,18 @@
+
+
+
+ <%- include('head'); %>
+ <%= info.title %> - Error <%= error %>
+
+
+
+
Somehing went wrong
+ (Error <%= error %>)
+
+ It means the resource you're trying to access is unavailable right now.
+ We're terribly sorry that you encountered this error.
+ Back to home
+ <%- include('footer'); %>
+
+
+
\ No newline at end of file
diff --git a/sample_data/home/footer.ejs b/sample_data/home/footer.ejs
new file mode 100644
index 0000000..4695f3c
--- /dev/null
+++ b/sample_data/home/footer.ejs
@@ -0,0 +1,6 @@
+
+
diff --git a/sample_data/home/head.ejs b/sample_data/home/head.ejs
new file mode 100644
index 0000000..be46678
--- /dev/null
+++ b/sample_data/home/head.ejs
@@ -0,0 +1,30 @@
+
+
+
+
+
+<%- `` %>
+<%- `` %>
+<% if(locals.article){ %>
+ <%- `` %>
+ <%- `` %>
+ <%- `` %>
+ <% if (article.thumbnail) { %>
+ <%- `` %>
+ <%- `` %>
+ <% } %>
+
+
+<% } else { %>
+ <%- `` %>
+ <%- `` %>
+ <%- `` %>
+
+ <%- `` %>
+<% } %>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample_data/home/index.ejs b/sample_data/home/index.ejs
new file mode 100644
index 0000000..aeb4bc4
--- /dev/null
+++ b/sample_data/home/index.ejs
@@ -0,0 +1,26 @@
+
+
+
+ <%- include('head'); %>
+ <%= info.title %> - Home
+
+
+
+