From 23744f400079b794f359d22c1452f6e6bcb63099 Mon Sep 17 00:00:00 2001 From: deadvey Date: Wed, 24 Sep 2025 20:57:47 +0100 Subject: [PATCH] Bug fix and Document fix Removed the string object from config.json as it's now all in the locale. and I fixed data.getdata() to return an error code if the index is out of bounds, it now returns a 1. Signed-off-by: deadvey --- docs/CONFIG.md | 11 ++++++----- example-config.json | 12 ------------ src/data.js | 5 +++++ src/routes/standard_pages.js | 3 +-- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 0e87f94..83c8bff 100755 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -19,9 +19,9 @@ All options show an example configuartion value and the variable type + an expla ## Basic Customisation | name | example value | variable type | explanation | |-----------------|----------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| -|locale|"en"|String|Your locale, see [/locales](/locales) for a list of all locales (you can open a PR for a new translation too)| -|seperator|"\
"|String|This is what %S represents in the formatting, this will go inbetween posts and generally to seperate out content on pages.| -|site_name|"My Blog"|String|This is what %Y represents; it's the name of your instance, a human readable string.| +|locale|"en-GB"|String|Your locale, see [/locales](/locales) for a list of all locales (you can open a PR for a new translation too)| +|seperator|"\
"|String|By default, this will go inbetween posts and generally to seperate out content on pages.| +|site_name|"Pete's Blogging Site!"|String|It's the name of your blog site, a human readable string.| |site_description|"Read my blogs!"|String|This is what %W represents; it's the description of your instance, a human readable string.| |default_commenter_username|"Anon"|String|Default commenter username if no username is inputted in comment submission.| @@ -36,13 +36,14 @@ Read more at [date-fns](https://date-fns.org/v4.1.0/docs/format)
| name | example value | variable type | explanation | |------|---------------|---------------|-------------------------------| |date_format|"yyyy-MM-dd"|String|The format of date's on the website.| -|time_zone|"+0000"|String|\Your offset from UTC| +|time_zone|"+0000"|String|Your offset from UTC| ## Advanced Customisation * /views/* files are EJS files (used for formatting HTML) and can be editted to your liking, you might want to read [the EJS docs](https://ejs.co/#docs) for help. * "css": "body { background: red; }"
String. Custom CSS to be applied to all pages, if you want more complex css, you can edit custom.css.
You can also edit the custom.css file in the webroot, as by default this is linked in the global header. +* You can create a file called custom.css in the webroot and that will be loaded as a style onto every page. ## Custom Strings -* You can edit all the strings on the site in /locales/.json +* You can edit all the strings on the site in /locales/\.json diff --git a/example-config.json b/example-config.json index 822d5c6..de8f2c5 100755 --- a/example-config.json +++ b/example-config.json @@ -21,17 +21,5 @@ "atom": true, "date_format": "yyyy-MM-dd", "time_zone": "+0000", - "string": { - "signup_agreement": "I agree to not post illegal or hateful content", - "signups_unavailable": "Sorry, this server does not allow signups", - "user_exists": "Sorry, this user already exists, try a different username", - "user_doesnt_exist": "Sorry, this user does not exist", - "comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted", - "post_doesnt_exist": "This post doesn't exist or was deleted", - "delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)", - "incorrect_password": "Incorrect Password", - "rss_disabled": "Sorry, RSS is disabled", - "attribution": "Powered by blogger-nodejs: Source Code, license (WTFPL)" - }, "css": "" } diff --git a/src/data.js b/src/data.js index ed5c7e2..2fb5db9 100644 --- a/src/data.js +++ b/src/data.js @@ -11,7 +11,12 @@ export function getdata(data, index=-1) { if (data == "posts" || data == 'users' || data == 'comments') { let result = func.require_module(`../data/${data}.json`) if (index != -1) { + if (index < result.length-1) { return result[index] + } + else { + return 1 // This index doesn't exist + } } return result } diff --git a/src/routes/standard_pages.js b/src/routes/standard_pages.js index 16b9da0..b74bbc4 100644 --- a/src/routes/standard_pages.js +++ b/src/routes/standard_pages.js @@ -62,8 +62,7 @@ router.get("/user/:username", (req, res) => { router.get("/post/:post_index", (req, res) => { const postID = req.params.post_index let post = data.getdata('posts', postID) - - if (post["deleted"] == true || post == 1) { // data.getdata returns error code 1 if nothing is available + if (post == 1) { // data.getdata returns error code 1 if nothing is available res.render("partials/message", { message: locale.post_doesnt_exist, config,