From 989bcdf1304868edf33099fecb3d3873f3d32622 Mon Sep 17 00:00:00 2001 From: Klemek Date: Sun, 23 Jun 2019 15:02:33 +0200 Subject: [PATCH 1/4] Pages metadata by default --- package.json | 2 +- sample_data/home/index.ejs | 14 +++++++++++--- sample_data/home/template.ejs | 14 +++++++++++++- src/app.js | 12 ++++++++++++ src/config.default.json | 2 ++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2dac4ab..81423c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitblog.md", - "version": "1.1.3", + "version": "1.1.4", "description": "A static blog using Markdown pulled from your git repository.", "main": "src/server.js", "dependencies": { diff --git a/sample_data/home/index.ejs b/sample_data/home/index.ejs index 4c48df3..3813e90 100644 --- a/sample_data/home/index.ejs +++ b/sample_data/home/index.ejs @@ -2,13 +2,21 @@ - GitBlog.md - Home + <%= info.title %> - Home + + + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> +
-

GitBlog.md

- A static blog using Markdown pulled from your git repository +

<%= info.title %>

+ <%= info.description %>

Articles in this blog :

<% articles.forEach((article) => { %>
diff --git a/sample_data/home/template.ejs b/sample_data/home/template.ejs index 6acc674..872322c 100644 --- a/sample_data/home/template.ejs +++ b/sample_data/home/template.ejs @@ -2,7 +2,19 @@ - GitBlog.md - <%= article.title %> + <%= info.title %> - <%= article.title %> + + + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + <% if (article.thumbnail) { %> + <%= `` %> + <%= `` %> + <% } %> + diff --git a/src/app.js b/src/app.js index 2dd6093..e0bb3cb 100644 --- a/src/app.js +++ b/src/app.js @@ -36,6 +36,7 @@ module.exports = (config) => { const articles = {}; let lastRSS = ''; + let host; /** * Fetch articles from the data folder and send success as a response @@ -73,6 +74,9 @@ module.exports = (config) => { */ const render = (res, vPath, data, code = 200) => { data.info = { + title: config['home']['title'], + description: config['home']['description'], + host: host, version: pjson.version }; res.render(vPath, data, (err, html) => { @@ -100,6 +104,14 @@ module.exports = (config) => { }); }; + app.use((req, res, next) => { + if (!host) { + host = 'http://' + req.headers.host; + console.log(cons.ok, 'Currently hosted on ' + host); + } + next(); + }); + //log request at result end app.use((req, res, next) => { if (config['access_log']) { diff --git a/src/config.default.json b/src/config.default.json index d5e5518..687ef07 100644 --- a/src/config.default.json +++ b/src/config.default.json @@ -12,6 +12,8 @@ "plantuml": true }, "home": { + "title": "GitBlog.md", + "description": "A static blog using Markdown pulled from your git repository", "index": "index.ejs", "error": "error.ejs", "hidden": [ From fa6d91db20a7bc1df8f802ae07005757a6b9eebe Mon Sep 17 00:00:00 2001 From: Klemek Date: Sun, 23 Jun 2019 15:04:15 +0200 Subject: [PATCH 2/4] updated README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2c256c1..8f70641 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,12 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link * `plantuml` (default: true) activate PlantUML diagram rendering * `home` + * `title` (default: GitBlog.md) + the title of your blog, **strongly advised to be changed** + given to the template to complete page title and metadata + * `description` (default: A static blog using Markdown pulled from your git repository) + the description of your blog, **strongly advised to be changed** + given to the template to complete page title and metadata * `index` (default: index.ejs) the name of the home page template on the data directory it will receive `articles`, a list of articles for rendering From 576948acee3251e4554c20176379c85831eee133 Mon Sep 17 00:00:00 2001 From: Klemek Date: Sun, 23 Jun 2019 15:05:06 +0200 Subject: [PATCH 3/4] ViewPort property --- sample_data/home/error.ejs | 3 +++ sample_data/home/index.ejs | 2 ++ sample_data/home/template.ejs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/sample_data/home/error.ejs b/sample_data/home/error.ejs index 9593025..c348a4b 100644 --- a/sample_data/home/error.ejs +++ b/sample_data/home/error.ejs @@ -3,6 +3,9 @@ Error <%= error %> + + + diff --git a/sample_data/home/index.ejs b/sample_data/home/index.ejs index 3813e90..c429cda 100644 --- a/sample_data/home/index.ejs +++ b/sample_data/home/index.ejs @@ -11,6 +11,8 @@ <%= `` %> <%= `` %> + + diff --git a/sample_data/home/template.ejs b/sample_data/home/template.ejs index 872322c..d1a3be3 100644 --- a/sample_data/home/template.ejs +++ b/sample_data/home/template.ejs @@ -15,6 +15,8 @@ <%= `` %> <% } %> + + From 847d228c0a3e62db320936338838ba907f6ac8c9 Mon Sep 17 00:00:00 2001 From: Klemek Date: Sun, 23 Jun 2019 15:06:15 +0200 Subject: [PATCH 4/4] Updated templates --- sample_data/home/error.ejs | 9 ++++++++- sample_data/home/index.ejs | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sample_data/home/error.ejs b/sample_data/home/error.ejs index c348a4b..b8ccbdc 100644 --- a/sample_data/home/error.ejs +++ b/sample_data/home/error.ejs @@ -2,7 +2,14 @@ - Error <%= error %> + <%= info.title %> - Error <%= error %> + + + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> diff --git a/sample_data/home/index.ejs b/sample_data/home/index.ejs index c429cda..67c0afb 100644 --- a/sample_data/home/index.ejs +++ b/sample_data/home/index.ejs @@ -5,8 +5,8 @@ <%= info.title %> - Home - <%= `` %> - <%= `` %> + <%= `` %> + <%= `` %> <%= `` %> <%= `` %> <%= `` %>