diff --git a/.gitignore b/.gitignore index 7ffc407..a25ca90 100755 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,4 @@ data.json hitcount.txt *.swp data -webroot images/* diff --git a/Makefile b/Makefile index a6967b8..41b82ce 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ WEBROOT_DIR=webroot all: config css users posts comments data clean: rm -rf data - rm -rf webroot + rm -f webroot/custom.css rm -f config.json # config file @@ -17,7 +17,7 @@ config.json: css: $(WEBROOT_DIR)/custom.css $(WEBROOT_DIR)/custom.css: 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: $(DATA_DIR)/users.json diff --git a/example-config.json b/example-config.json index b32d8db..1c13d5c 100755 --- a/example-config.json +++ b/example-config.json @@ -3,8 +3,9 @@ "seperator": "
", "site_name": "My Blog", "site_url": "https://example.com", - "language": "en-US", + "locale": "en-US", "port": 8080, + "data_storage": "json", "cache_data": false, "allow_signup": true, "site_description": "Read my blogs!", diff --git a/src/data.js b/src/data.js index 8eedbd4..82e4826 100644 --- a/src/data.js +++ b/src/data.js @@ -20,6 +20,11 @@ export function increment_hitcount(postID = -1) { // -1 Means it will increment writedata('posts', post, postID) return 0 } + else { + post.hitcount = 1; + writedata('posts', post, postID) + return 0 + } return 1 } } @@ -72,9 +77,7 @@ export function getdata(data, index=-1) { if (index < result.length) { return result[index] } - else { - return 1 // This index doesn't exist - } + return 1 // This index doesn't exist } return result } diff --git a/src/functions.js b/src/functions.js index e06f979..8cfd817 100644 --- a/src/functions.js +++ b/src/functions.js @@ -54,14 +54,11 @@ export function unix_time_to_atom_date(unix_time) { export function render_tags(tags) { let string = "" // Initialises the string 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 { for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag - string += `${tags[tag_index].trim()}` // 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 += ", "; - } + string += `#${tags[tag_index].trim()} ` // Adds the tag to the string as a HTML href } } return string diff --git a/views/headers/site_wide.ejs b/views/headers/site_wide.ejs index d60a348..9b6c210 100644 --- a/views/headers/site_wide.ejs +++ b/views/headers/site_wide.ejs @@ -19,7 +19,7 @@
-

<%- config.site_name %>

+

<%= config.site_name %>

<%- config.site_description %>

diff --git a/views/partials/head.ejs b/views/partials/head.ejs index f29bc9e..df9da08 100644 --- a/views/partials/head.ejs +++ b/views/partials/head.ejs @@ -5,4 +5,5 @@ + diff --git a/views/posts/post.ejs b/views/posts/post.ejs index fc6ff2c..7c0ed6d 100644 --- a/views/posts/post.ejs +++ b/views/posts/post.ejs @@ -1,29 +1,34 @@

- <%= post.title %> + '><%= post.title %>

+ +
+ <%- func.render_tags(post.tags) %>
+
+

<%- func.render_md(post.content) %>

-
- <%= locale.written_by %> <%= user.username %>
-
-
- <%- func.render_tags(post.tags) %>
-
-
- "><%= locale.edit_post %>
-
-
+ + <%= locale.written_by %> <%= user.username %> + + - + <%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %>
-
+
<%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %>
+
+ "> + +
+
<% if (config.enable_hitcount == true) { %>
Hitcount: <%- post.hitcount %> @@ -31,6 +36,8 @@ <% } %>
+
+
diff --git a/views/posts/tag.ejs b/views/posts/tag.ejs index 4064079..e532c71 100644 --- a/views/posts/tag.ejs +++ b/views/posts/tag.ejs @@ -1,51 +1,32 @@

- <%= post.title %> + '><%= post.title %>

+ +
+ <%- func.render_tags(post.tags) %>
+
+

- <%- func.render_md(post.content) %>
+ <%- func.render_md(post.content) %>

-
- <%= locale.written_by %> <%= user.username %>
-
-
- "><%= locale.permalink %> -
-
- <%- func.render_tags(post.tags) %>
-
+ +
<%= user.username %> + + - + + <%= func.unix_time_to_date_format(post.pubdate) %>
+
+
- "><%= locale.edit_post %>
+ "> + +
-
- <%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %>
-
-
- <%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %>
-
-
- -
- - - "> -


-

- - -
- -
- <% comments.forEach((comment, index) => { %> -
- <%- include('../partials/comment', {comment: comment}) %> -
- <% }) %>
<%- config.seperator %> - diff --git a/views/posts/timeline.ejs b/views/posts/timeline.ejs index 2cbb84c..e532c71 100644 --- a/views/posts/timeline.ejs +++ b/views/posts/timeline.ejs @@ -3,49 +3,30 @@ '><%= post.title %>
+ +
+ <%- func.render_tags(post.tags) %>
+
+

<%- func.render_md(post.content) %>

-
- <%= locale.written_by %> <%= user.username %>
-
-
- "><%= locale.permalink %> -
-
- <%- func.render_tags(post.tags) %>
-
+ +
<%= user.username %> + + - + + <%= func.unix_time_to_date_format(post.pubdate) %>
+
+
- "><%= locale.edit_post %>
+ "> + +
-
- <%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %>
-
-
- <%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %>
-
-
- -
- -
- "> -


-

- -
-
- -
- <% comments.forEach((comment, index) => { %> -
- <%- include('../partials/comment', {comment: comment}) %> -
- <% }) %>
<%- config.seperator %> - diff --git a/views/posts/user.ejs b/views/posts/user.ejs index d6bd80e..e532c71 100644 --- a/views/posts/user.ejs +++ b/views/posts/user.ejs @@ -1,48 +1,32 @@

- <%= post.title %> + '><%= post.title %>

+ +
+ <%- func.render_tags(post.tags) %>
+
+

- <%- func.render_md(post.content) %>
+ <%- func.render_md(post.content) %>

-
- "><%= locale.permalink %> -
-
- <%- func.render_tags(post.tags) %>
-
+ +
<%= user.username %> + + - + + <%= func.unix_time_to_date_format(post.pubdate) %>
+
+
- "><%= locale.edit_post %>
+ "> + +
-
- <%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %>
-
-
- <%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %>
-
-
- -
- -
- "> -


-

- -
-
- -
- <% comments.forEach((comment, index) => { %> -
- <%- include('../partials/comment', {comment: comment}) %> -
- <% }) %>
<%- config.seperator %> - diff --git a/webroot/custom.css b/webroot/custom.css new file mode 100644 index 0000000..ba7834c --- /dev/null +++ b/webroot/custom.css @@ -0,0 +1,4 @@ +* { +font-family: sans-serif; + +} diff --git a/webroot/default.css b/webroot/default.css new file mode 100644 index 0000000..5a6843c --- /dev/null +++ b/webroot/default.css @@ -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; +} diff --git a/webroot/icons/edit.png b/webroot/icons/edit.png new file mode 100644 index 0000000..21123c0 Binary files /dev/null and b/webroot/icons/edit.png differ