From 590d6750755c988acadc50f81b6050e83e43ef57 Mon Sep 17 00:00:00 2001 From: DeaDvey Date: Sun, 20 Jul 2025 23:59:30 +0100 Subject: [PATCH] config docs --- CONFIG.md | 209 +++++++++++++++++++++----------------------- README.md | 2 + app.js | 2 +- example-config.json | 2 +- 4 files changed, 102 insertions(+), 113 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 59d0c38..035c8fc 100755 --- a/CONFIG.md +++ b/CONFIG.md @@ -1,130 +1,117 @@ # Configuration Documentation ## Introduction The configuration file is stored in a file called config.json, for an example, copy example-config.json to config.json (`cp example-config.json config.json`) and modify from there.
-Currently all values in example-config.json are required, however I plan to add support for default values in the case of no value being set. +Currently all values in example-config.json are required, however I plan to add support for default values in the case of no value being set.
+All options show an example configuartion value and the variable type + an explaination below it.
## Technical configuration * "site_url": "https://example.com"
This value defines the url of your site, this used for the RSS feed to link back to post. * "port": 8080
- This value defines the port that you run the blog on. Don't change this value if you don't know what that means. + Integer. This value defines the port that you run the blog on. Don't change this value if you don't know what that means. * "allow_signup": true
- Boolean that defines weather new people should be allowed to signup. + Boolean. Defines weather new people should be allowed to signup. * "timeline_length": 20
- How many posts will be shown on the timeline (home page). + Integer. How many posts will be shown on the timeline (home page). * "enable_hitcount": true
- Enabling the hitcount (a number that represents the amount of front page loads (stored in hitcount.txt)) can slightly slow down loading of the front page. + Boolean. Enabling the hitcount (a number that represents the amount of front page loads (stored in hitcount.txt)) can slightly slow down loading of the front page. * "charset": "UTF-8"
- This is the value in the tag in the html of all pages, you should not change this unless you know why. + String. This is the value in the tag in the html of all pages, you should not change this unless you know why. +* "root_path": "/path/to/root/of/website" + String. Anything in this directory will be in the webroot, so put favicon.ico and anything else here. ## Basic Customisation -seperator = "
" -site_name = "My Blog" -site_description = "Read my blogs!" +* "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. +* "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. -// Anything in this directory will be in the webroot, so put favicon.ico and anything else here. -root_path = "/path/to/root/of/website" +## Syndication +* "rss": true
+ Boolean. Enable or Disable RSS feeds. +* "rss_path": "/rss"
+ String. The path of the global rss feed file. -// Default username if no username is inputted in comment submission -default_username = "Anon" +## Dates +Read more at [date-fns](https://date-fns.org/v4.1.0/docs/format)
+* "date_format": "yyyy-MM-dd"
+ String. The format of date's on the website. +* "time_zone": "+0000"
+ String. Your offset from UTC -// RSS feeds -rss = true -rss_path = "/rss" +## Advanced Customisation +All of these customisations support format indicators
+Format indicatos are a % sign followed by a character and represent a piece of information
+relevant to the data at hand. +
+Format Indicators + The syntax for this is pretty simple +* %% - A literal % +* %A - List of tags +* %B - List of tags, each one with a hyperlink to that tag page +* %C - Post content +* %D - Published date in the format specified by date_format +* %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 +* %M - comments +* %N - the username of the user (poster) +* %O - URL to edit this post +* %P - URL to create a new post +* %Q - URL to sign up +* %R - Site wide RSS feed +* %S - post seperator as defined by post_seperator +* %T - Title +* %U - URL the the user (poster) +* %W - Site Description as defined by site_description +* %X - Comment submission box +* %Y - Site Name as defined by site_name +* %Z - Attribution (to me) and source code link and license +
+### Header's +* "timeline_header": "

%Y

%W

Create Post\
RSS Feed\
Sign Up\
Delete Account\
Hit count: %H%S"
+ String. The format of the header peice of the home page/timeline page, example includes the site name, desciption and some relevant links. +* "user_page_header": "

%F's posts:

%I%S"
+ String. The format of the header peice of the user page which contains all posts from a particular user. example includes the prettyname and their description. +* "tag_page_header": "

Posts tagged: %G

%S"
+ String. The format of the header peice of the tag page which contains all posts with a particular tag, example includes the tag name. +### Post's +* "user_post_format": "

%T

%C

%B\
Permalink<\br/\>%X%M%S"
+ String. The format of posts on the users page. Example includes title, content, tags, permalink and comments. +* "post_page_format": "

%T

%C

%B\
By %N\
Edit Post\
Posted: %D\
Edited: %E%S%X%M%S"
+ String. The format of the post on the post's page. Example includes title, content, tags, user page hyperlink, edit post hyperlink, publish date, modified date and comments. +* "timeline_post_format": "

%T

%C

Permalink<\br/\>By %N%X%M%S"
+ String. The format of the posts on the timeline, example includes title, content, permalink, user page hyperlink and comments. +* "tag_post_format": "

%T

%C

%B\
Permalink\
By %N%S" + String. The format of the posts on the tag page, example includes title, content, permalink and user page hyperlink. +### Other +* "site_wide_footer": "Site is ran by DeaDvey\
%Z"
+ String. The format of the site wide footer, shown on every page. +* "css": "body { background: red; }"
+ String. Custom CSS to be applied to all pages, if you want more complex css, you can edit custom.css. -// Dates -// https://date-fns.org/v4.1.0/docs/format -date_format = "yyyy-MM-dd" -time_zone = "+0000" +## Custom Strings +All of these values are of type String +* "signup_agreement": "I agree to not post illegal or hateful content"
+ The agreement people must check to signup for the server. +* "signups_unavailable": "Sorry, this server does not allow signups"
+ The string to be displayed if the user tries to signup when signup's are disabled. +* "user_exists": "Sorry, this user already exists, try a different username"
+ The string to be shown when someone is trying to signup with a name exists. +* "user_doesnt_exist": "Sorry, this user does not exist"
+ The string to be shown when someone tries to edit their account or make a post but the username doesn't exist. +* "delete_account_confirmation": "I agree that my account and all of my posts will be permanently deleted instantly"
+ The string to be shown as a confirmation when a user tries to delete their account. +* "incorrect_password": "Incorrect Password"
+ The string to be shown if the password is incorrect. -//// Format ///// -// The syntax for this is pretty simple -// %% - A literal % -// %A - List of tags -// %B - List of tags, each one with a hyperlink to that tag page -// %C - Post content -// %D - Published date in the format specified by date_format -// %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 -// %M - comments -// %N - the username of the user (poster) -// %O - URL to edit this post -// %P - URL to create a new post -// %Q - URL to sign up -// %R - Site wide RSS feed -// %S - post seperator as defined by post_seperator -// %T - Title -// %U - URL the the user (poster) -// %W - Site Description as defined by site_description -// %X - Comment submission box -// %Y - Site Name as defined by site_name -// %Z - Attribution (to me) and source code link and license - -timeline_header = `

%Y

-

%W

-Create Post
-RSS Feed
-Sign Up
-Delete Account
-Hit count: %H -%S` -user_page_header = `

%F's posts:

-%I -%S` -tag_page_header = `

Posts tagged: %G

%S` -// --------------------------------------------- -user_post_format = `

%T

-

%C

-%B
-Permalink
-%X -%M -%S` -post_page_format = `

%T

-

%C

-%B
-By %N
-Edit Post
-Posted: %D
-Edited: %E -%S -%X -%M -%S` -timeline_post_format = `

%T

-

%C

-Permalink
-By %N -%X -%M -%S` -tag_post_format = `

%T

-

%C

-%B
-Permalink
-By %N -%S` -// ------------------------------------- -site_wide_footer = `Site is ran by DeaDvey
-%Z` - -// Custom Strings -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" -delete_account_confirmation = "I agree that my account and all of my posts will be permanently deleted instantly" -incorrect_password = "Incorrect Password" - -/// Custom CSS to be applied to every page -css = ` -/* Put you custom CSS here, -Read about existing classes and ID's in the docs (coming soon)*\ -` - -// pretty please don't change this -attribution = "Powered by blogger-nodejs: Source Code, license (WTFPL)" +## Other +* "attribution" = "Powered by blogger-nodejs: Source Code, license (WTFPL)" + String. Represented by format indicator %Z. Only change this value if you modify the source code or just want to change some of the formatting. diff --git a/README.md b/README.md index e884d34..1153473 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Read the [configuation guide](CONFIG.md) for configuration help (in config.json) * probably insecure as hell # planned features/todo list +* custom CSS _file_ +* custom strings use format indicators * seperate functions into modules * builtin crypto * ejs diff --git a/app.js b/app.js index 7f9675f..36fc436 100755 --- a/app.js +++ b/app.js @@ -388,7 +388,7 @@ app.post("/submit_comment", (req,res) => { const unix_timestamp = getUnixTime(new Date()) let name = escape_input(req.body.name) if (name == "") { - name = config.default_username + name = config.default_commenter_username } new_comment = { "name": name, diff --git a/example-config.json b/example-config.json index 779c818..37d44ee 100755 --- a/example-config.json +++ b/example-config.json @@ -9,7 +9,7 @@ "enable_hitcount": true, "charset": "UTF-8", "root_path": "/path/to/root/of/website", - "default_username": "Anon", + "default_comenter_username": "Anon", "rss": true, "rss_path": "/rss", "date_format": "yyyy-MM-dd",