diff --git a/.gitignore b/.gitignore
index 189278f..858c562 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,8 @@
node_modules
package-lock.json
-posts.js
-comments.js
-users.js
-config.js
+posts.json
+comments.json
+users.json
+config.json
hitcount.txt
*.swp
diff --git a/example-config.js b/CONFIG.md
similarity index 83%
rename from example-config.js
rename to CONFIG.md
index 1171d86..d9eb315 100755
--- a/example-config.js
+++ b/CONFIG.md
@@ -2,7 +2,7 @@ export const seperator = "
"
export const site_name = "My Blog"
export const site_url = "https://example.com"
export const port = 8080
-export const allow_signup = false
+export const allow_signup = true
export const site_description = "Read my blogs!"
export const timeline_length = 20
export const enable_hitcount = true // Can slow down page loading a bit
@@ -54,6 +54,8 @@ export const timeline_header = `%Y
%W
Create Post
RSS Feed
+Sign Up
+Delete Account
Hit count: %H
%S`
export const user_page_header = `%F's posts:
@@ -96,6 +98,13 @@ export const tag_post_format = `%T
export const site_wide_footer = `Site is ran by DeaDvey
%Z`
+// Custom Strings
+export const signup_agreement = "I agree to not post illegal or hateful content"
+export const signups_unavailable = "Sorry, this server does not allow signups"
+export const user_exists = "Sorry, this user already exists, try a different username"
+export const user_doesnt_exist = "Sorry, this user does not exist"
+export const delete_account_confirmation = "I agree that my account and all of my posts will be permanently deleted instantly"
+export const incorrect_password = "Incorrect Password"
/// Custom CSS to be applied to every page
export const css = `
diff --git a/README.md b/README.md
index 3cf6633..1bc5170 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,9 @@ In action on my website: [deadvey.com](https://deadvey.com)
* probably insecure as hell
# planned features/todo list
+* seperate functions into modules
+* builtin crypto
+* ejs
* user specific RSS feeds
* atom
* federation (looks tricky)
diff --git a/app.js b/app.js
index 8f2e59d..7f9675f 100755
--- a/app.js
+++ b/app.js
@@ -23,10 +23,10 @@ let config // contains a set of configuration for the site, see example-config.j
try {
// We're going to try and import the modules,
- users = require('./users.js');
- posts = require('./posts.js');
- comments = require('./comments.js');
- config = require('./config.js');
+ users = require('./users.json');
+ posts = require('./posts.json');
+ comments = require('./comments.json');
+ config = require('./config.json');
}
catch (error) {
// if they don't all import then
@@ -56,7 +56,6 @@ const app = express();
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.static(config.root_path));
-
// Initialise the program by creating users.js, comments.js, posts.js and config.js
// All require default content in them to start off with
// Then exit successfully
@@ -67,21 +66,21 @@ function initialise() {
}
catch (error) {
console.log("Creating users file")
- fs.writeFileSync(`${__dirname}/users.js`, `export const users = []`)
+ fs.writeFileSync(`${__dirname}/users.json`, `{\n"users": []\n}`)
}
try {
- const posts = require("./posts.js");
+ const posts = require("./posts.json");
}
catch (error) {
console.log("Creating posts file")
- fs.writeFileSync(`${__dirname}/posts.js`, `export const posts = []`)
+ fs.writeFileSync(`${__dirname}/posts.json`, `{\n"posts": []\n}`)
}
try {
- const comments = require("./comments.js");
+ const comments = require("./comments.json");
}
catch (error) {
console.log("Creating comments file")
- fs.writeFileSync(`${__dirname}/comments.js`, `export const comments = []\nexport const counter = 0`)
+ fs.writeFileSync(`${__dirname}/comments.json`, `{\n"comments": [],\n"counter": 0}`)
}
try {
const config = require("./config.js");
@@ -103,8 +102,8 @@ function initialise() {
// if the user is present, it returns the index of the user (integer)
// if the user is not present it returns -1
function get_userID(username) {
- for (let i = 0; i < users.users.length; i++) { // Loop over every user
- if (users.users[i]['username'] == username) {
+ for (let i = 0; i < users.length; i++) { // Loop over every user
+ if (users[i]['username'] == username) {
return i // If the username matches then return the index of that user
}
}
@@ -169,22 +168,22 @@ function replace_format_indicators(template, post_index=-1, tag_name="tag", user
.replaceAll("%Z", config.attribution)
.replaceAll("%S", config.seperator)
if (post_index >= 0) { // These can only be replaced if a post is specified (by default the post id is -1)
- post_object = posts.posts[post_index] // Defines the post object for easy reference
+ post_object = posts[post_index] // Defines the post object for easy reference
output_string = output_string
.replaceAll("%A", (post_object["tags"]))
.replaceAll("%B", (hyperlink_tags(post_object["tags"])))
.replaceAll("%C", converter.makeHtml(post_object["content"]))
.replaceAll("%D", unix_time_to_date_format(post_object["pubdate"]))
.replaceAll("%E", unix_time_to_date_format(post_object["editdate"]))
- .replaceAll("%F", users.users[post_object["userID"]]['prettyname'])
+ .replaceAll("%F", users[post_object["userID"]]['prettyname'])
.replaceAll("%G", tag_name)
- .replaceAll("%I", converter.makeHtml(users.users[post_object['userID']]['description']))
+ .replaceAll("%I", converter.makeHtml(users[post_object['userID']]['description']))
.replaceAll("%L", `/post/${post_index}`)
.replaceAll("%M", return_comments(post_index))
- .replaceAll("%N", users.users[post_object["userID"]]['username'])
+ .replaceAll("%N", users[post_object["userID"]]['username'])
.replaceAll("%S", config.seperator)
.replaceAll("%T", post_object["title"])
- .replaceAll("%U", `/user/${users.users[post_object["userID"]]['username']}`)
+ .replaceAll("%U", `/user/${users[post_object["userID"]]['username']}`)
.replaceAll("%X", `