diff --git a/README.md b/README.md
index 40f84c6..920c60f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
This is a blogging site written in nodejs, all pages are served directly by the nodejs backend.
+Please don't use this yet, it's not finished
In action on my website: [deadvey.com](https://deadvey.com)
# features
@@ -9,8 +10,11 @@ In action on my website: [deadvey.com](https://deadvey.com)
* timeline, user page, post page and tag specific page
* edit/delete posts
* probably insecure as hell
+* hitcount
# planned features
* atom
* federation
* sign up
+* Markdown syntax in posts
+* All strings (including in edit and post page) customisable
diff --git a/app.js b/app.js
index 225adc8..e3d4a0d 100755
--- a/app.js
+++ b/app.js
@@ -7,6 +7,8 @@ const posts = require('./posts.js');
const config = require('./config.js');
const app = express();
const port = 8080;
+let footer_div = config.site_wide_footer
+footer_div = replace_format_indicators(footer_div)
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
@@ -67,6 +69,11 @@ function replace_format_indicators(input_string, post_index=0, tag_name="tag") {
.replaceAll("%U", `/user/${users.users[post_object["userID"]]['username']}`)
.replaceAll("%Y", config.site_name)
.replaceAll("%W", config.site_description)
+ .replaceAll("%Z", config.attribution)
+ if (config.enable_hitcount == true) {
+ output_string = output_string
+ .replaceAll("%H", fs.readFileSync('hitcount.txt'))
+ }
return output_string
}
@@ -105,6 +112,13 @@ app.get(config.rss_path, (req,res) => {
});
app.get("/", (req,res) => {
+ if (config.enable_hitcount) {
+ let hitcount = parseInt(fs.readFileSync('hitcount.txt'))
+ hitcount += 1
+ console.log(`/ Is loaded, hitcount: ${hitcount}`)
+ fs.writeFileSync(`${__dirname}/hitcount.txt`, `${hitcount}`, 'utf-8');
+ }
+
header_div = config.timeline_header
header_div = replace_format_indicators(header_div);
posts_div = "";
@@ -115,7 +129,7 @@ app.get("/", (req,res) => {
posts_div += replace_format_indicators(post, counter);
counter -= 1;
}
- res.send(`
${posts_div}
`);
+ res.send(`${posts_div}
`);
});
app.get("/post", (req,res) => {
@@ -161,13 +175,13 @@ app.get("/user/:username", (req, res) => {
posts_div += replace_format_indicators(post, post_index);
}
}
- res.send(`${posts_div}
`);
+ res.send(`${posts_div}
`);
});
app.get("/post/:post_index", (req, res) => {
post_div = "";
let post = config.post_page_format;
post_div += replace_format_indicators(post, req.params.post_index);
- res.send(`${post_div}
`);
+ res.send(`${post_div}
`);
});
app.get("/tag/:tag", (req,res) => {
const tag = req.params.tag
@@ -180,7 +194,7 @@ app.get("/tag/:tag", (req,res) => {
page_content += replace_format_indicators(post, i);
};
};
- res.send(`${page_content}
`);
+ res.send(`${page_content}
`);
});
app.post("/submit_edit", (req,res) => {
diff --git a/config.js b/config.js
index a30ee77..63e1d3c 100755
--- a/config.js
+++ b/config.js
@@ -3,6 +3,7 @@ export const site_name = "Deadvey's Blog"
export const site_url = "https://deadvey.com"
export const site_description = "Films, tech, random shit"
export const timeline_length = 20
+export const enable_hitcount = true // Can slow down page loading a bit
export const charset = "UTF-8" // Don't change unless you know why
// Anything in this directory will be in the webroot, so put favicon.ico and anything else here.
export const root_path = "/var/www/deadvey.com/blog"
@@ -26,6 +27,7 @@ export const time_zone = "+0000"
// %E - Edited date in the format specified by date_format
// %F - Pretty name
// %G - Tag name (used for the tag page only)
+// %H - Frontpage hit count
// %I - User description
// %L - URL Permanent link to the post
// %N - the username of the user (poster)
@@ -37,11 +39,13 @@ export const time_zone = "+0000"
// %U - URL the the user (poster)
// %Y - Site Name as defined by site_name
// %W - Site Description as defined by site_description
+// %Z - Attribution (to me) and source code link and license
export const timeline_header = `%Y
%W
Create Post
RSS Feed
+Hit count: %H
%S`
export const user_page_header = `%F's posts:
%I
@@ -59,7 +63,8 @@ export const post_page_format = `%T
By %N
Edit Post
Posted: %D
-Edited: %E`
+Edited: %E
+%S`
export const timeline_post_format = `%T
%C
Permalink
@@ -71,6 +76,9 @@ export const tag_post_format = `%T
Permalink
By %N
%S`
+// -------------------------------------
+export const site_wide_footer = `Site is ran by DeaDvey
+%Z`
/// Custom CSS to be applied to every page
@@ -123,3 +131,6 @@ export const css = `
}
}
`
+
+// pretty please don't change this
+export const attribution = "Powered by blogger-nodejs: Source Code, license (WTFPL)"
diff --git a/hitcount.txt b/hitcount.txt
new file mode 100644
index 0000000..3f10ffe
--- /dev/null
+++ b/hitcount.txt
@@ -0,0 +1 @@
+15
\ No newline at end of file