Skip to content

Commit

Permalink
Merge pull request #9 from Klemek/dev
Browse files Browse the repository at this point in the history
v1.1.4
  • Loading branch information
Klemek authored Jun 23, 2019
2 parents 000104c + 847d228 commit 2c5f2e5
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
12 changes: 11 additions & 1 deletion sample_data/home/error.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Error <%= error %></title>
<title><%= info.title %> - Error <%= error %></title>

<meta name="twitter:card" content="summary_large_image">
<%= `<meta property="og: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="org:url" content="${info.host}/">` %>

<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">

<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>
Expand Down
16 changes: 13 additions & 3 deletions sample_data/home/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GitBlog.md - Home</title>
<title><%= info.title %> - Home</title>

<meta name="twitter:card" content="summary_large_image">
<%= `<meta property="og: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="org:url" content="${info.host}/">` %>

<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">

<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<main>
<h1>GitBlog.md</h1>
A static blog using Markdown pulled from your git repository
<h1><%= info.title %></h1>
<%= info.description %>
<h2>Articles in this blog :</h2>
<% articles.forEach((article) => { %>
<div class="article">
Expand Down
16 changes: 15 additions & 1 deletion sample_data/home/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GitBlog.md - <%= article.title %></title>
<title><%= info.title %> - <%= article.title %></title>

<meta name="twitter:card" content="summary_large_image">
<%= `<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="twitter:description" content="${info.description}">` %>
<%= `<meta property="org:url" content="${info.host + article.url}">` %>
<% if (article.thumbnail) { %>
<%= `<meta property="org:image" content="${info.host + article.thumbnail}">` %>
<%= `<meta property="twitter:image" content="${info.host + article.thumbnail}">` %>
<% } %>

<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">

<link rel="stylesheet" type="text/css" href="/prism.css">
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
Expand Down
12 changes: 12 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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']) {
Expand Down
2 changes: 2 additions & 0 deletions src/config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down

0 comments on commit 2c5f2e5

Please sign in to comment.