Fixed an issue with an incomplete example-config.json that made the
server not work at all. Also added a default.css file
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,5 +8,4 @@ data.json
|
|||||||
hitcount.txt
|
hitcount.txt
|
||||||
*.swp
|
*.swp
|
||||||
data
|
data
|
||||||
webroot
|
|
||||||
images/*
|
images/*
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -4,7 +4,7 @@ WEBROOT_DIR=webroot
|
|||||||
all: config css users posts comments data
|
all: config css users posts comments data
|
||||||
clean:
|
clean:
|
||||||
rm -rf data
|
rm -rf data
|
||||||
rm -rf webroot
|
rm -f webroot/custom.css
|
||||||
rm -f config.json
|
rm -f config.json
|
||||||
|
|
||||||
# config file
|
# config file
|
||||||
@@ -17,7 +17,7 @@ config.json:
|
|||||||
css: $(WEBROOT_DIR)/custom.css
|
css: $(WEBROOT_DIR)/custom.css
|
||||||
$(WEBROOT_DIR)/custom.css:
|
$(WEBROOT_DIR)/custom.css:
|
||||||
mkdir -p webroot
|
mkdir -p webroot
|
||||||
echo '* {\n font-family: sans-serif;\n}' > $(WEBROOT_DIR)/custom.css
|
echo '* { font-family: sans-serif; }' > $(WEBROOT_DIR)/custom.css
|
||||||
|
|
||||||
# users.json
|
# users.json
|
||||||
users: $(DATA_DIR)/users.json
|
users: $(DATA_DIR)/users.json
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
"seperator": "<hr/>",
|
"seperator": "<hr/>",
|
||||||
"site_name": "My Blog",
|
"site_name": "My Blog",
|
||||||
"site_url": "https://example.com",
|
"site_url": "https://example.com",
|
||||||
"language": "en-US",
|
"locale": "en-US",
|
||||||
"port": 8080,
|
"port": 8080,
|
||||||
|
"data_storage": "json",
|
||||||
"cache_data": false,
|
"cache_data": false,
|
||||||
"allow_signup": true,
|
"allow_signup": true,
|
||||||
"site_description": "Read my blogs!",
|
"site_description": "Read my blogs!",
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ export function increment_hitcount(postID = -1) { // -1 Means it will increment
|
|||||||
writedata('posts', post, postID)
|
writedata('posts', post, postID)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
post.hitcount = 1;
|
||||||
|
writedata('posts', post, postID)
|
||||||
|
return 0
|
||||||
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,9 +77,7 @@ export function getdata(data, index=-1) {
|
|||||||
if (index < result.length) {
|
if (index < result.length) {
|
||||||
return result[index]
|
return result[index]
|
||||||
}
|
}
|
||||||
else {
|
return 1 // This index doesn't exist
|
||||||
return 1 // This index doesn't exist
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,14 +54,11 @@ export function unix_time_to_atom_date(unix_time) {
|
|||||||
export function render_tags(tags) {
|
export function render_tags(tags) {
|
||||||
let string = "" // Initialises the string
|
let string = "" // Initialises the string
|
||||||
if (tags.length == 1 && tags[0] == "") {
|
if (tags.length == 1 && tags[0] == "") {
|
||||||
string = locale.no_tags; // If there are no tags, output something
|
string = ''; // If there are no tags, output nothing
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag
|
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag
|
||||||
string += `<a href="/tag/${tags[tag_index].trim()}">${tags[tag_index].trim()}</a>` // Adds the tag to the string as a HTML href
|
string += `<a href="/tag/${tags[tag_index].trim()}">#${tags[tag_index].trim()}</a> ` // Adds the tag to the string as a HTML href
|
||||||
if (tag_index < tags.length - 1) { // If there are more tags, then insert a comma
|
|
||||||
string += ", ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string
|
return string
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</form>
|
</form>
|
||||||
<br/>
|
<br/>
|
||||||
<div id='site-name'>
|
<div id='site-name'>
|
||||||
<h1><%- config.site_name %></h2>
|
<h1><a id='home-page-link' href="/"><%= config.site_name %></a></h1>
|
||||||
</div>
|
</div>
|
||||||
<div id='site-description'>
|
<div id='site-description'>
|
||||||
<h2><%- config.site_description %></h2>
|
<h2><%- config.site_description %></h2>
|
||||||
|
|||||||
@@ -5,4 +5,5 @@
|
|||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/default.css">
|
||||||
<link rel="stylesheet" href="/custom.css">
|
<link rel="stylesheet" href="/custom.css">
|
||||||
|
|||||||
@@ -1,29 +1,34 @@
|
|||||||
<div id="post-header">
|
<div id="post-header">
|
||||||
<h1>
|
<h1>
|
||||||
<%= post.title %>
|
<a href='/post/<%= post['id'] %>'><%= post.title %></a>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="post-tags">
|
||||||
|
<%- func.render_tags(post.tags) %><br/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="post-content">
|
<div id="post-content">
|
||||||
<p>
|
<p>
|
||||||
<%- func.render_md(post.content) %><br/>
|
<%- func.render_md(post.content) %><br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="post-details">
|
<div id="post-details">
|
||||||
<div id="post-author">
|
<span id="post-author">
|
||||||
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
|
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a></i>
|
||||||
</div>
|
</span>
|
||||||
<div id="post-tags">
|
-
|
||||||
<%- func.render_tags(post.tags) %><br/>
|
<span id="post-pubdate">
|
||||||
</div>
|
|
||||||
<div id="post-edit">
|
|
||||||
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
|
|
||||||
</div>
|
|
||||||
<div id="post-pubdate">
|
|
||||||
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||||
</div>
|
</span>
|
||||||
<div id="post-editdate">
|
<div id="post-editdate">
|
||||||
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="post-edit">
|
||||||
|
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>">
|
||||||
|
<img src='/icons/edit.png'>
|
||||||
|
</a><br/>
|
||||||
|
</div>
|
||||||
<% if (config.enable_hitcount == true) { %>
|
<% if (config.enable_hitcount == true) { %>
|
||||||
<div id='post-hitcount'>
|
<div id='post-hitcount'>
|
||||||
Hitcount: <%- post.hitcount %>
|
Hitcount: <%- post.hitcount %>
|
||||||
@@ -31,6 +36,8 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
<div id="post-commentform">
|
<div id="post-commentform">
|
||||||
<!-- Comment form -->
|
<!-- Comment form -->
|
||||||
<form method="POST" action="/submit_comment">
|
<form method="POST" action="/submit_comment">
|
||||||
|
|||||||
@@ -1,51 +1,32 @@
|
|||||||
<div id="post-header">
|
<div id="post-header">
|
||||||
<h1>
|
<h1>
|
||||||
<%= post.title %>
|
<a href='/post/<%= post['id'] %>'><%= post.title %></a>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="post-tags">
|
||||||
|
<%- func.render_tags(post.tags) %><br/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="post-content">
|
<div id="post-content">
|
||||||
<p>
|
<p>
|
||||||
<%- func.render_md(post.content) %><br/>
|
<%- func.render_md(post.content) %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="post-details">
|
<div id="post-details">
|
||||||
<div id="post-author">
|
<span id="post-author">
|
||||||
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
|
<i><a href="/user/<%= user.username %>"><%= user.username %></a></i>
|
||||||
</div>
|
</span>
|
||||||
<div id="post-permalink">
|
-
|
||||||
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
|
<span id="post-pubdate">
|
||||||
</div>
|
<i><%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||||
<div id="post-tags">
|
</span>
|
||||||
<%- func.render_tags(post.tags) %><br/>
|
<br/>
|
||||||
</div>
|
|
||||||
<div id="post-edit">
|
<div id="post-edit">
|
||||||
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
|
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>">
|
||||||
|
<img src='/icons/edit.png'>
|
||||||
|
</a><br/>
|
||||||
</div>
|
</div>
|
||||||
<div id="post-pubdate">
|
|
||||||
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
|
||||||
</div>
|
|
||||||
<div id="post-editdate">
|
|
||||||
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="post-commentform">
|
|
||||||
<!-- Comment form -->
|
|
||||||
<form method="POST" action="/submit_comment">
|
|
||||||
<input type="hidden" name="post_index" value="<%= post["id"] %>">
|
|
||||||
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
|
|
||||||
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
|
|
||||||
<button type="submit"><%= locale.submit %></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="post-comments">
|
|
||||||
<% comments.forEach((comment, index) => { %>
|
|
||||||
<div id="comment-no-<%= post.id %>-<%= comment.id %>" class="comment post-comment-<%= index %>">
|
|
||||||
<%- include('../partials/comment', {comment: comment}) %>
|
|
||||||
</div>
|
|
||||||
<% }) %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%- config.seperator %>
|
<%- config.seperator %>
|
||||||
|
|
||||||
|
|||||||
@@ -3,49 +3,30 @@
|
|||||||
<a href='/post/<%= post['id'] %>'><%= post.title %></a>
|
<a href='/post/<%= post['id'] %>'><%= post.title %></a>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="post-tags">
|
||||||
|
<%- func.render_tags(post.tags) %><br/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="post-content">
|
<div id="post-content">
|
||||||
<p>
|
<p>
|
||||||
<%- func.render_md(post.content) %>
|
<%- func.render_md(post.content) %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="post-details">
|
<div id="post-details">
|
||||||
<div id="post-author">
|
<span id="post-author">
|
||||||
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
|
<i><a href="/user/<%= user.username %>"><%= user.username %></a></i>
|
||||||
</div>
|
</span>
|
||||||
<div id="post-permalink">
|
-
|
||||||
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
|
<span id="post-pubdate">
|
||||||
</div>
|
<i><%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||||
<div id="post-tags">
|
</span>
|
||||||
<%- func.render_tags(post.tags) %><br/>
|
<br/>
|
||||||
</div>
|
|
||||||
<div id="post-edit">
|
<div id="post-edit">
|
||||||
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
|
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>">
|
||||||
|
<img src='/icons/edit.png'>
|
||||||
|
</a><br/>
|
||||||
</div>
|
</div>
|
||||||
<div id="post-pubdate">
|
|
||||||
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
|
||||||
</div>
|
|
||||||
<div id="post-editdate">
|
|
||||||
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="post-commentform">
|
|
||||||
<!-- Comment form -->
|
|
||||||
<form method="POST" action="/submit_comment">
|
|
||||||
<input type="hidden" name="post_index" value="<%= post["id"] %>">
|
|
||||||
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
|
|
||||||
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
|
|
||||||
<button type="submit"><%= locale.submit %></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="post-comments">
|
|
||||||
<% comments.forEach((comment, index) => { %>
|
|
||||||
<div id="comment-no-<%= post.id %>-<%= comment.id %>" class="comment post-comment-<%= index %>">
|
|
||||||
<%- include('../partials/comment', {comment: comment}) %>
|
|
||||||
</div>
|
|
||||||
<% }) %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%- config.seperator %>
|
<%- config.seperator %>
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +1,32 @@
|
|||||||
<div id="post-header">
|
<div id="post-header">
|
||||||
<h1>
|
<h1>
|
||||||
<%= post.title %>
|
<a href='/post/<%= post['id'] %>'><%= post.title %></a>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="post-tags">
|
||||||
|
<%- func.render_tags(post.tags) %><br/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="post-content">
|
<div id="post-content">
|
||||||
<p>
|
<p>
|
||||||
<%- func.render_md(post.content) %><br/>
|
<%- func.render_md(post.content) %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="post-details">
|
<div id="post-details">
|
||||||
<div id="post-permalink">
|
<span id="post-author">
|
||||||
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
|
<i><a href="/user/<%= user.username %>"><%= user.username %></a></i>
|
||||||
</div>
|
</span>
|
||||||
<div id="post-tags">
|
-
|
||||||
<%- func.render_tags(post.tags) %><br/>
|
<span id="post-pubdate">
|
||||||
</div>
|
<i><%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||||
|
</span>
|
||||||
|
<br/>
|
||||||
<div id="post-edit">
|
<div id="post-edit">
|
||||||
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
|
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>">
|
||||||
|
<img src='/icons/edit.png'>
|
||||||
|
</a><br/>
|
||||||
</div>
|
</div>
|
||||||
<div id="post-pubdate">
|
|
||||||
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
|
||||||
</div>
|
|
||||||
<div id="post-editdate">
|
|
||||||
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="post-commentform">
|
|
||||||
<!-- Comment form -->
|
|
||||||
<form method="POST" action="/submit_comment">
|
|
||||||
<input type="hidden" name="post_index" value="<%= post["id"] %>">
|
|
||||||
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
|
|
||||||
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
|
|
||||||
<button type="submit"><%= locale.submit %></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="post-comments">
|
|
||||||
<% comments.forEach((comment, index) => { %>
|
|
||||||
<div id="comment-no-<%= post.id %>-<%= comment.id %>" class="comment post-comment-<%= index %>">
|
|
||||||
<%- include('../partials/comment', {comment: comment}) %>
|
|
||||||
</div>
|
|
||||||
<% }) %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%- config.seperator %>
|
<%- config.seperator %>
|
||||||
|
|
||||||
|
|||||||
4
webroot/custom.css
Normal file
4
webroot/custom.css
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
* {
|
||||||
|
font-family: sans-serif;
|
||||||
|
|
||||||
|
}
|
||||||
16
webroot/default.css
Normal file
16
webroot/default.css
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
body {
|
||||||
|
max-width: 900px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
#header {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
#post-edit img {
|
||||||
|
width: 20px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
BIN
webroot/icons/edit.png
Normal file
BIN
webroot/icons/edit.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 454 B |
Reference in New Issue
Block a user