Compare commits

...

36 Commits

Author SHA1 Message Date
e3e5469e1a Made it so if an invalid user or post is loaded, a proper error message is
shown instead of just a nodeJS error message
2025-09-06 23:54:49 +01:00
c8af978259 docs and also I improved the readability/user friendliness of the EJS 2025-09-03 22:28:50 +01:00
99e07389d0 * more proffesional language in rejecting AI
* footer uses locales
2025-08-27 19:00:49 +01:00
532010f873 bug fix for site_admin config field 2025-08-27 18:53:29 +01:00
5917789c5b add webadmin as a field in the config 2025-08-27 18:51:59 +01:00
4f0941262e Withdraw consent for AI scraping 2025-08-27 18:49:33 +01:00
27b9ee6437 * added "quotes" to the locales
* made all the ejs pages use "postID" as the variable for post indexes
* split up en-GB and en-US
2025-08-27 18:30:26 +01:00
c73ce69f93 bug fix: postID -> post_index 2025-08-27 18:19:12 +01:00
5bd0429ae2 timeline, userpage and tag page have an edit post option. 2025-08-27 17:58:48 +01:00
6e583d1410 removed webroot dir 2025-08-27 16:41:39 +01:00
cf784a1a99 removed webroot dir (in .gitignore) 2025-08-27 16:40:53 +01:00
b3ea048244 bug fix RSS and ATOM using func.render_md instead of showdown 2025-08-27 16:36:21 +01:00
9b5d3f3f73 Fixed issue relating to showdownjs not escaping html tags by porting to
markdown-it, also introduced a new function: func.render_md
2025-08-27 15:09:57 +01:00
5f07db1e15 tables in CONFIG.md 2025-08-09 21:10:23 +01:00
d298717519 Testing markdown tables 2025-08-09 21:05:58 +01:00
0b25fb221b Documentation 2025-08-09 20:53:57 +01:00
f85c4aa893 Minor change to /index/pages EJS 2025-08-09 16:59:57 +01:00
6fc1f85e18 Added locale (english only at the moment) and modifed the EJS so I think
every string is customisable (via the /locales/selected locale)
2025-08-09 16:57:31 +01:00
8418318d80 Added fake form at the top of html in attempt to mitigate spam, probably
wont work that well but might as well try
2025-08-09 13:18:44 +01:00
44a060508b Hitcount is now created by init.initialise() 2025-08-09 13:00:07 +01:00
49c7fc7cdf init.initialise() checks for correct path of config.json (bug fix) 2025-08-09 12:51:43 +01:00
144c276bc9 Fixed init.initialise() checking for .js files as opposed to .json files 2025-08-09 12:48:25 +01:00
df4bc99d9a Initialise() imports fs (bug fix) 2025-08-09 12:44:39 +01:00
3e2a63bfd7 Export the init.initialise() function (bug fix) 2025-08-09 12:42:18 +01:00
bced9c7c0e CONFIG.md documentation and also fixed a bug where when ATOM files are
loaded the config.rss boolean is actually checked as opposed to
config.atom, fixed by also adding string.atom_disabled to config.json :)
2025-08-02 03:00:20 +01:00
f723e37732 docs and that 2025-08-02 02:48:22 +01:00
8b9ddcf048 Added page indexes for comments, posts, users and pages overall, should
add one for tags but it might be inefficient as I don't store all tags
in an array or anything...
2025-08-02 00:51:33 +01:00
5f2aba0c2b Site wide header (currently only used for a link to / but will add
index's for stuff later)
2025-08-01 23:27:28 +01:00
cdfc5f2c30 Post doesn't exist page 2025-08-01 23:21:43 +01:00
88b198365d user, post and comment objects contain their ID's now. 2025-08-01 12:34:29 +01:00
b683b658f7 Comments now have their own pages, at /comment/commentID, these are
linked to when someone replies to another comment (>> id), I also fixed
a bug in comment submission where the counter was not incrementing
2025-07-31 03:58:28 +01:00
0cc319a702 Added user specific RSS and ATOM feeds and updated the EJS templates to
add them by default to the user's header section
2025-07-30 01:28:23 +01:00
72316094e4 Updated the readme to have a better feature section 2025-07-30 01:12:29 +01:00
47877e71d4 atom functionality is added and I fixed an issue in the RSS that is
caused by the deleted posts not having valid data.
2025-07-30 01:09:51 +01:00
0c43c7315c editing user redirects to user's page and began to implment ATOM 2025-07-30 00:43:21 +01:00
39eba8fcda posts are marked as deleted to preserve array structure 2025-07-28 15:11:26 +01:00
47 changed files with 1017 additions and 344 deletions

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ users.json
config.json
hitcount.txt
*.swp
webroot/

View File

@@ -9,47 +9,43 @@ beautiful and featureful blogging frontend, this isn't for you.<br/>
See the software in action: [deadvey.com](https://deadvey.com)<br/>
# Installation and Running:
Read the [installation guide](/docs/INSTALLATION.md)
# Confiuration
# Confiuration:
Read the [configuation guide](docs/CONFIG.md) for configuration help (in config.json)
# Features
* post creation via the web frontend (no need to remote to your server to make a post)
# Features:
* post creation, modification and deletion via frontend
* user creation, modification and deletion via frontend
* multi user
* powerful customisation
* rss
* timeline, user page, post page and tag specific page
* edit/delete posts
* powerful customisation via EJS
* site wide and user specific rss, atom
* hitcount
* Markdown syntax in posts
* Commenting on posts
* sign up and delete account
* ejs
* custom CSS _file_
* Commenting on posts and replying to other comments
* site wide custom CSS
* Page indexes
# Bugs
# Bugs:
* probably scales like shit
* probably insecure as hell
# Planned features/todo list
* URGENT give each post and user a hard postID to prevent potential issues
* edit user (could be on instead of the delete_account page)
* user specific RSS feeds
* atom
# Planned features/todo list:
* federation (looks tricky)
* All strings (including in edit and post page) customisable
* formatable custom strings
* inline comments and docs
* clean up code a bit
* comment pages?
* /postID and /userID pages
* site index
* Make EJS modification more user friendly
* API for returning posts, users, comments, tags other?...
TODO (not finished)
# EJS variable names
* config.variable_name - pass any variable in config.json
* hitcount - value in hitcount.txt (a single number)
## Posts (/views/posts/)
* post - an object that includes the data for that post, eg post.title, post.content etc
* user - the object of the user who posted this
* index - an int that refers to the index of the current post
## Comments (/views/partials/comment.ejs)
* comment - an object storing the comment, eg comment.name, comment.content
# Docs:
See [docs/DOCUMENTATION.md](docs/DOCUMENTATION.md)
# Customisation:
Customisation of settings can be done via the config.json file (use example-config.json as an example) and see [the configuration guide](docs/CONFIG.md)<br/>
Additionaly, more complex configuration of the precise template of the whole site, can be done via [EJS](https://ejs.co/) (in /views) (see [the list of things variables and functions available in EJS](docs/EJS.md) (you will need to understand EJS syntax and JavaScript, to customise this (why did I use EJS? well I originally had this weird system of format indicators with percent (%) signs and stuff (like in unix's date (`date`)) but then I was told EJS is better and it sure is, though it is a bit harder to understand but MUCH more powerful!))
Also, if you want to change any of the strings on the website, please modify or create a new, customised locale in /locales

View File

@@ -1,33 +0,0 @@
{
"seperator": "<hr/>",
"site_name": "My Blog",
"site_url": "https://example.com",
"language": "en",
"port": 8080,
"allow_signup": true,
"site_description": "Read my blogs!",
"timeline_length": 20,
"enable_hitcount": true,
"charset": "UTF-8",
"root_path": "/home/deadvey/code/web/blogger-webroot/",
"delete_account_url": "/delete_account",
"new_post_url": "/post",
"signup_url": "/signup",
"edit_post_base_url": "/edit",
"default_comenter_username": "Anon",
"rss": true,
"rss_url": "/rss",
"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",
"delete_account_confirmation": "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: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
},
"css": ""
}

4
docs/CLASSES_AND_IDS.md Normal file
View File

@@ -0,0 +1,4 @@
Post:
![images/post-css.png](An image showing the css id's assosciated with each part of a post)

View File

@@ -5,43 +5,37 @@ Currently all values in example-config.json are required, however I plan to add
All options show an example configuartion value and the variable type + an explaination below it.<br/>
## Technical configuration
* "site_url": "https://example.com"<br/>
This value defines the url of your site, this used for the RSS feed to link back to post.
* "port": 8080<br/>
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<br/>
Boolean. Defines weather new people should be allowed to signup.
* "timeline_length": 20<br/>
Integer. How many posts will be shown on the timeline (home page).
* "enable_hitcount": true<br/>
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"<br/>
String. This is the value in the <meta charset=""> 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.
| name | example value | variable type | explanation |
|-----------------|----------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| site_url | "https://example.com" | String | This value defines the url of your site, this used for the RSS feed to link back to post. |
| port | 8080 | 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 | Defines weather new people should be allowed to signup. |
| timeline_length | 20 | Integer | How many posts will be shown on the timeline (home page). |
| enable_hitcount | true | 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" | String | This is the value in the <meta charset=""> 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": "\<hr/\>"<br/>
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"<br/>
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.
| 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|"\<hr/\>"|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.|
## Syndication
* "rss": true<br/>
Boolean. Enable or Disable RSS feeds.
* "rss_path": "/rss"<br/>
String. The path of the global rss feed file.
| name | example value | variable type | explanation |
|------|---------------|---------------|-------------------------------|
| rss | true | Boolean | Enable or Disable RSS feeds. |
| atom | true | Boolean | Enable or Disable ATOM feeds. |
## Dates
Read more at [date-fns](https://date-fns.org/v4.1.0/docs/format)<br/>
* "date_format": "yyyy-MM-dd"<br/>
String. The format of date's on the website.
* "time_zone": "+0000"<br/>
String. Your offset from UTC
| 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|
## 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.
@@ -50,20 +44,4 @@ Read more at [date-fns](https://date-fns.org/v4.1.0/docs/format)<br/>
You can also edit the custom.css file in the webroot, as by default this is linked in the global header.
## Custom Strings
All of these values are of type String
* "signup_agreement": "I agree to not post illegal or hateful content"<br/>
The agreement people must check to signup for the server.
* "signups_unavailable": "Sorry, this server does not allow signups"<br/>
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"<br/>
The string to be shown when someone is trying to signup with a name exists.
* "user_doesnt_exist": "Sorry, this user does not exist"<br/>
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"<br/>
The string to be shown as a confirmation when a user tries to delete their account.
* "incorrect_password": "Incorrect Password"<br/>
The string to be shown if the password is incorrect.
## Other
* "attribution" = "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
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.
* You can edit all the strings on the site in /locales/<your-locale>.json

1
docs/CONTRIBUTING.md Normal file
View File

@@ -0,0 +1 @@
Just open a PR or something, if it's good I'll pull

4
docs/DOCUMENTATION.md Normal file
View File

@@ -0,0 +1,4 @@
All documentation is under construction as the program is also under construction and so is constantly changing and is also a mess and I'm shit at documentation
- [EJS Variables and functions](EJS.md)
- [configuring config.json](CONFIG.md)
- [Contributing](CONTRIBUTING.md)

27
docs/EJS.md Normal file
View File

@@ -0,0 +1,27 @@
This is not a guide on how EJS works, look at [EJS's website](https://ejs.co/) for that!<br/>
This is just a list of functions and pieces of information provided to each EJS file.<br/>
<br/>
# syndication/global_rss:
- All config.json data
- All posts from posts.json
- showdown.JS's converter functions
- All functions in functions.js
# syndication/user_rss:
- All config.json data
- All posts from posts.json
- showdown.JS's converter functions
- All functions in functions.js
- the userID of the user in question (integer)
# syndication/global_atom:
- All config.json data
- All posts from posts.json
- showdown.JS's converter functions
- All functions in functions.js
- getUnixTime function from date-fns
# syndication/user_atom:
- All config.json data
- All posts from posts.json
- showdown.JS's converter functions
- All functions in functions.js
- the userID of the user in question (integer)
- getUnixTime function from date-fns

12
docs/INSTALLATION.md Normal file
View File

@@ -0,0 +1,12 @@
# Installation
This program is currently just ran manually.<br/>
All you need to do is clone the git repository:<br/>
```git clone https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs.git```<br/>
Then navigate to /src:<br/>
```cd src```<br/>
Then run the initialisation function:<br/>
```node server.js --first-time```<br/>
Then you should modify config.json in / to suit your needs.<br/>
# Running
I would reccomend running the program in tmux so it does not stop running when you close the terminal window.<br/>
• There is currently no init system support. I might add this later (or you could open a PR).

BIN
docs/images/post-css.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

View File

@@ -1,22 +1,23 @@
{
"site_admin": "your name",
"seperator": "<hr/>",
"site_name": "My Blog",
"site_url": "https://example.com",
"language": "en",
"language": "en-US",
"port": 8080,
"allow_signup": true,
"site_description": "Read my blogs!",
"timeline_length": 20,
"enable_hitcount": true,
"charset": "UTF-8",
"root_path": "/path/to/blogger-webroot",
"delete_account_url": "/delete_account",
"root_path": "/path/to/webroot",
"edit_account_base_url": "/edit_account",
"new_post_url": "/post",
"signup_url": "/signup",
"edit_post_base_url": "/edit",
"default_comenter_username": "Anon",
"rss": true,
"rss_url": "/rss",
"atom": true,
"date_format": "yyyy-MM-dd",
"time_zone": "+0000",
"string": {
@@ -24,7 +25,9 @@
"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",
"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: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"

42
locales/en-GB.json Normal file
View File

@@ -0,0 +1,42 @@
{
"quotes": "“”‘’",
"password": "Password",
"username": "Username",
"prettyname": "Prettyname",
"description": "Description (social links, what you write about etc), supports markdown",
"title": "Title",
"post_content": "Post Content, supports markdown",
"tags": "Tags (comma seperated)",
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
"signup_agreement": "I agree to not post illegal or hateful content",
"comment": "Comment",
"submit": "Sumbit",
"site_ran_by": "Site is ran by",
"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",
"incorrect_password": "Incorrect Password",
"rss_disabled": "Sorry, RSS is disabled",
"atom_disabled": "Sorry, ATOM is disabled",
"AI_consent": "The content on this website may not be copied, scraped, or used to train AI models or large language models (LLMs) without prior written consent.",
"rss_feed": "RSS Feed",
"atom_feed": "ATOM Feed",
"no_tags": "No Tags",
"new_post": "New Post",
"edit_post": "Edit Post",
"sign_up": "Sign Up",
"edit_account": "Edit Account",
"permalink": "Permalink",
"written_by": "Written by",
"published": "Published",
"last_modified": "Last Modified",
"hitcount": "Hitcount",
"posts_tagged": "Posts Tagged",
"home_page": "Home Page",
"site_index": "Site Index",
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
}

42
locales/en-US.json Normal file
View File

@@ -0,0 +1,42 @@
{
"quotes": "“”‘’",
"password": "Password",
"username": "Username",
"prettyname": "Prettyname",
"description": "Description (social links, what you write about etc), supports markdown",
"title": "Title",
"post_content": "Post Content, supports markdown",
"tags": "Tags (comma seperated)",
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
"signup_agreement": "I agree to not post illegal or hateful content",
"comment": "Comment",
"submit": "Sumbit",
"site_ran_by": "Site is ran by",
"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",
"incorrect_password": "Incorrect Password",
"rss_disabled": "Sorry, RSS is disabled",
"atom_disabled": "Sorry, ATOM is disabled",
"AI_consent": "The·content·on·this·website·may·not·be·copied,·scraped,·or·used·to·train·AI·models·or·large·language·models·(LLMs)·without·prior·written·consent.",
"rss_feed": "RSS Feed",
"atom_feed": "ATOM Feed",
"no_tags": "No Tags",
"new_post": "New Post",
"edit_post": "Edit Post",
"sign_up": "Sign Up",
"edit_account": "Edit Account",
"permalink": "Permalink",
"written_by": "Written by",
"published": "Published",
"last_modified": "Last Modified",
"hitcount": "Hitcount",
"posts_tagged": "Posts Tagged",
"home_page": "Home Page",
"site_index": "Site Index",
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
}

39
locales/template.json Normal file
View File

@@ -0,0 +1,39 @@
{
"quotes": "“”‘’",
"password": "Password",
"username": "Username",
"prettyname": "Prettyname",
"description": "Description (social links, what you write about etc), supports markdown",
"title": "Title",
"post_content": "Post Content, supports markdown",
"tags": "Tags (comma seperated)",
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
"signup_agreement": "I agree to not post illegal or hateful content",
"comment": "Comment",
"submit": "Sumbit",
"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",
"incorrect_password": "Incorrect Password",
"rss_disabled": "Sorry, RSS is disabled",
"atom_disabled": "Sorry, ATOM is disabled",
"rss_feed": "RSS Feed",
"atom_feed": "ATOM Feed",
"new_post": "New Post",
"edit_post": "Edit Post",
"sign_up": "Sign Up",
"edit_account": "Edit Account",
"permalink": "Permalink",
"written_by": "Written by",
"published": "Published",
"last_modified": "Last Modified",
"hitcount": "Hitcount",
"posts_tagged": "Posts Tagged",
"home_page": "Home Page",
"site_index": "Site Index",
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
}

View File

@@ -1,8 +1,13 @@
{
"name": "blogger-nodejs",
"version": "0.0.5",
"description": "Simple web logging backend",
"author": "DeaDvey",
"license": "WTFPL",
"dependencies": {
"date-fns": "^4.1.0",
"ejs": "^3.1.10",
"express": "^5.1.0",
"showdown": "^2.1.0"
"markdown-it": "^14.1.0"
}
}

View File

@@ -1,5 +1,7 @@
import { createRequire } from 'module';
const require = createRequire(import.meta.url)
const config = require("../config.json")
const locale = require(`../locales/${config.locale}.json`)
// The configuration defines a date format using the date-fns (a datetime library) syntax
// eg "yyyy-MM-dd"
@@ -8,7 +10,6 @@ const require = createRequire(import.meta.url)
// returns the formatted date (string)
export function unix_time_to_date_format(unix_time) {
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
const config = require("../config.json")
let date = fromUnixTime(unix_time)
let formatted_date = format(date, config.date_format)
return formatted_date
@@ -20,24 +21,35 @@ export function unix_time_to_date_format(unix_time) {
// returns the formatted date (string)
export function unix_time_to_rss_date(unix_time) {
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
const config = require("../config.json")
let date = fromUnixTime(unix_time)
let formatted_date = format(date, "EEE, dd MMM yyyy HH:mm:ss")
return `${formatted_date} ${config.time_zone}`
}
// And again with atom's date format
export function unix_time_to_atom_date(unix_time) {
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
let date = fromUnixTime(unix_time)
let formatted_date = format(date, "yyyy-MM-dd'T'HH:mm:ss'Z'")
return `${formatted_date}`
}
// This function accepts a list of strings eg ["string1","string2,"string3"] (any length)
// then returns a string of them each pointing to a seperate url
// eg "<a href="/tag/string1">string1</a>, <a href="/tag/string2">string2</a>, <a href="/tag/string3">string3</a>"
// this is so you can have a list of tags that each point to their individual tag page
// returns: string
export function hyperlink_tags(tags) {
export function render_tags(tags) {
let string = "" // Initialises the string
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag
string += `<a href="/tag/${tags[tag_index]}">${tags[tag_index]}</a>` // 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 += ", ";
}
}
if (tags.length == 1 && tags[0] == "") {
string = locale.no_tags; // If there are no tags, output something
}
else {
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag
string += `<a href="/tag/${tags[tag_index]}">${tags[tag_index]}</a>` // 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 += ", ";
}
}
}
return string
}
// The users are stored as a list of objects [ user_object, user_object, user_object ]
@@ -54,6 +66,18 @@ export function get_userID(username) {
}
return -1 // If user is not present, return -1
}
export function get_comment(commentID) { // TODO scales like shit
const comments = require("../data/comments.json")
for (let i = 0; i < comments.comments.length; i++) { // Loop over every post
for (let j = 0; j < comments.comments[i].length; j++) { // Then every comment in that post
if (comments.comments[i][j]["id"] == commentID) {
return comments.comments[i][j]
};
}
}
return -1 // If comment is not present, return -1
}
// This escapes some potentially dangerous HTML characters with their HTML entities
// https://www.freeformatter.com/html-entities.html
// accepts a string
@@ -67,5 +91,28 @@ export function escape_input(input) {
.replaceAll("'", "&#39;")
.replaceAll("/", "&#47;")
.replaceAll("%", "&#37;")
.replaceAll("&", "&amp;")
return output
}
// Render comment content by replacing the >> int with a url link to that comment
export function render_comment(comment_content) {
return comment_content
.replaceAll(/>> ([0-9]*)/g, "<a href='/comment/$1'>>> $1</a>")
.replaceAll(/>>([0-9]*)/g, "<a href='/comment/$1'>>>$1</a>")
.replaceAll(/&gt;&gt; ([0-9]*)/g, "<a href='/comment/$1'>>> $1</a>")
.replaceAll(/&gt;&gt;([0-9]*)/g, "<a href='/comment/$1'>>>$1</a>")
.replaceAll("\n", "<br/>")
};
export function render_md(content) {
const markdownit = require("markdown-it")
const md = markdownit({
html: false,
xhtmlOut: false,
breaks: true,
linkify: false,
typographer: true,
quotes: locale.quotes,
})
return md.render(content)
};

View File

@@ -1,21 +1,24 @@
import { createRequire } from 'module';
const require = createRequire(import.meta.url)
// 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
// returns nothing
function initialise() {
export function initialise() {
const fs = require("fs");
try {
const users = require("../data/users.js");
const users = require("../data/users.json");
}
catch (error) {
console.log("Creating users file")
fs.writeFileSync(`../data/users.json`, `{\n"users": []\n}`)
fs.writeFileSync(`../data/users.json`, `[]`)
}
try {
const posts = require("../data/posts.json");
}
catch (error) {
console.log("Creating posts file")
fs.writeFileSync(`../data/posts.json`, `{\n"posts": []\n}`)
fs.writeFileSync(`../data/posts.json`, `[]`)
}
try {
const comments = require("../data/comments.json");
@@ -25,15 +28,24 @@ function initialise() {
fs.writeFileSync(`../data/comments.json`, `{\n"comments": [],\n"counter": 0}`)
}
try {
const config = require("../data/config.js");
const config = require("../config.json");
}
catch (error) {
console.log("Copying the example config to config.js")
console.log("!!! PLEASE MODIFY config.js TO YOUR NEEDS !!!")
fs.copyFile('example-config.js', 'config.js', (err) => {
console.log("!!! PLEASE MODIFY config.json TO YOUR NEEDS !!!")
fs.copyFile('../example-config.json', '../config.json', (err) => {
console.log("Error copying file")
})
}
try {
fs.readFileSync("../data/hitcount.txt")
}
catch (error) {
console.log("Creating hitcount file")
fs.writeFileSync("../data/hitcount.txt", "0", (err) => {
console.log("Error creating hitcount.txt")
})
}
console.log("Successfully initialised")
process.exit(0)
}

View File

@@ -1,7 +1,6 @@
// Get the libraries
const fs = require('fs'); // For modifying and reading files
const express = require('express'); // For running a webserver in nodejs
const showdown = require('showdown') // For converting markdown to html on demand, https://showdownjs.com/
const crypto = require('crypto'); // For encrypting passwords, I use sha512
// fromUnixTime(): Create a date from a Unix timestamp (in seconds). Decimal values will be discarded.
// format(): Return the formatted date string in the given format. The result may vary by locale.
@@ -40,15 +39,14 @@ catch (error) {
process.exit(1)
}
// https://showdownjs.com/docs/available-options
let converter = new showdown.Converter({
simpleLineBreaks: true, // Parse line breaks as <br/> in paragraphs (GitHub-style behavior).
tables: true, // Enable support for tables syntax.
strikethrough: true, // Enable support for strikethrough: ~~text~~
tasklists: true, // Enable support for GitHub style tasklists. - [x] and - [ ]
encodeEmails: true, //Enable automatic obfuscation of email addresses. emails are encoded via character entities
headerLevelStart: 3, //Set starting level for the heading tags.
})
// Import the locale
try {
locale = require(`../locales/${config.locale}.json`);
}
catch (error) {
console.log("This locale doesn't exist, if you want to create it then you can create a PR")
console.log("Locale selected: ", config.locale)
}
// Define stuff to do with express (nodejs webserver)
const app = express();
@@ -60,24 +58,110 @@ app.set('view engine', 'ejs');
app.set('views', '../views')
////////////////////// SYNDICATION ////////////////////////
// RSS protocol gets
app.get(config.rss_url, (req,res) => {
// global RSS protocol gets
app.get("/rss", (req,res) => {
if (config.rss == false) {
res.render("partials/message", {
message: config.string.rss_disabled,
message: locale.rss_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/rss", {
res.render("syndication/global_rss", {
config,
posts,
converter,
func,
})
};
});
// user RSS protocol gets
app.get("/user/:username/rss", (req,res) => {
const username = req.params.username;
const userID = func.get_userID(username);
if (config.rss == false) {
res.render("partials/message", {
message: locale.rss_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/user_rss", {
config,
posts,
func,
userID,
})
};
});
// global ATOM protocol gets
app.get("/atom", (req,res) => {
if (config.atom == false) {
res.render("partials/message", {
message: locale.atom_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/global_atom", {
config,
posts,
func,
getUnixTime,
})
};
});
// user ATOM protocol gets
app.get("/user/:username/atom", (req,res) => {
const username = req.params.username;
const userID = func.get_userID(username);
if (config.atom == false) {
res.render("partials/message", {
message: locale.atom_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/user_atom", {
config,
posts,
func,
userID,
getUnixTime,
})
};
});
///////////////////// Page index's ///////////////////////
app.get("/index/pages", (req,res) => {
res.render("indexes/all_pages", {
config,
posts,
users,
comments: comments.comments,
});
}); // /index/posts
app.get("/index/posts", (req,res) => {
res.render("indexes/posts", {
config,
posts,
});
}); // /index/posts
app.get("/index/users", (req,res) => {
res.render("indexes/users", {
config,
users,
});
}); // /index/posts
app.get("/index/comments", (req,res) => {
res.render("indexes/comments", {
config,
comments: comments.comments,
});
}); // /index/posts
///////////////////// Standard Pages //////////////////////
@@ -93,6 +177,7 @@ app.get("/", (req,res) => {
res.render("pages/timeline",
{
config,
locale,
posts,
users,
comments: comments.comments,
@@ -101,65 +186,109 @@ app.get("/", (req,res) => {
format,
getUnixTime,
func,
converter,
})
}); // /
app.get("/user/:username", (req, res) => {
const userID = func.get_userID(req.params.username)
console.log(userID)
console.log(users[userID].prettyname)
res.render("pages/user",
{
config: config,
posts: posts,
user: users[userID],
userID: userID,
comments: comments.comments,
fromUnixTime: fromUnixTime,
format: format,
getUnixTime: getUnixTime,
func,
converter,
})
if (userID != -1) {
res.render("pages/user",
{
config,
locale,
posts,
user: users[userID],
userID: userID,
comments: comments.comments,
fromUnixTime: fromUnixTime,
format: format,
getUnixTime: getUnixTime,
func,
})
}
else if (userID == -1) {
res.render("partials/message",
{
message: locale.user_doesnt_exist,
config,
})
}
}); // /user/:username
app.get("/post/:post_index", (req, res) => {
const postID = req.params.post_index
res.render("pages/post",
{
if (postID > posts.length-1 || posts[postID]["deleted"] == true) {
res.render("partials/message", {
message: locale.post_doesnt_exist,
config,
post: posts[postID],
postID: postID,
user: users[posts[postID].userID],
comments: comments.comments[postID],
fromUnixTime,
format,
getUnixTime,
func,
converter,
})
}
else if (typeof posts[postID]["deleted"] == "undefined" || posts[postID]["deleted"] == false) {
res.render("pages/post",
{
config,
locale,
post: posts[postID],
postID: postID,
user: users[posts[postID].userID],
comments: comments.comments[postID],
fromUnixTime,
format,
getUnixTime,
func,
})
}
else {
console.log("Error loading page")
res.redirect(301,"/")
}
}); // /post/:post_index
app.get("/tag/:tag", (req,res) => {
const tag = req.params.tag
res.render("pages/tag",
{
config: config,
tag: tag,
posts: posts,
users: users,
config,
locale,
tag,
posts,
users,
comments: comments.comments,
fromUnixTime: fromUnixTime,
format: format,
getUnixTime: getUnixTime,
func,
converter,
})
}); // /tag/:tag
app.get("/comment/:commentID", (req,res) => {
const commentID = req.params.commentID;
const comment = func.get_comment(commentID)
if (comment == -1) {
res.render("partials/message", {
config,
message: locale.comment_doesnt_exist,
})
}
else {
res.render("pages/comment",
{
config: config,
locale,
post: posts[comment["id"]],
users,
comment,
fromUnixTime: fromUnixTime,
format: format,
getUnixTime: getUnixTime,
func,
})
}
});
///////////////////// Form pages ////////////////////////////
app.get(config.new_post_url, (req,res) => {
res.render("forms/new_post", {
config
config,
locale,
});
}); // /post
app.get(config.signup_url, (req,res) => {
@@ -167,13 +296,14 @@ app.get(config.signup_url, (req,res) => {
if (config.allow_signup == true) {
// Send the page for signing up to the server
res.render("forms/signup", {
config
config,
locale,
});
}
// if the server does not allow signup
else if (config.allow_signup == false) {
res.render("partials/message", {
message: config.string.signups_unavailable,
message: locale.signups_unavailable,
config,
})
}
@@ -183,8 +313,14 @@ app.get(config.signup_url, (req,res) => {
console.log("Error, invalid value for allow_signup (bool)")
}
}); // /signup
app.get(config.delete_account_url, (req,res) => {
res.render("forms/delete_account", { config });
app.get(`${config.edit_account_base_url}/:user_id`, (req,res) => {
const userID = parseInt(req.params.user_id);
res.render("forms/edit_account", {
config,
locale,
user: users[userID],
userID
});
}); // /delete_account
app.get(`${config.edit_post_base_url}/:post_id`, (req,res) => {
const post_id = req.params.post_id
@@ -192,6 +328,7 @@ app.get(`${config.edit_post_base_url}/:post_id`, (req,res) => {
const user = users[post['userID']]
res.render("forms/edit_post", {
config,
locale,
post,
post_id,
user,
@@ -212,7 +349,7 @@ app.post("/submit_comment", (req,res) => {
"id": comments.counter,
"pubdate": unix_timestamp
};
let counter = comments.counter+1;
comments.counter += 1;
comments.comments[req.body.post_index].push(new_comment);
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
@@ -222,13 +359,13 @@ app.post("/submit_post", (req,res) => {
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const username = func.escape_input(req.body.username)
const title = func.escape_input(req.body.title)
const content = func.escape_input(req.body.content)
const content = req.body.content
const tags = func.escape_input(req.body.tags).split(',');
const unix_timestamp = getUnixTime(new Date())
if (func.get_userID(username) == -1) {
res.render("partials/message", {
message: config.string.user_doesnt_exit,
message: locale.user_doesnt_exit,
config,
})
}
@@ -236,6 +373,7 @@ app.post("/submit_post", (req,res) => {
else if (users[func.get_userID(username)]['hash'] == password) { // Password matches
console.log(username, "is submitting a post titled:", title);
posts.push({
"id": posts.length,
"userID": func.get_userID(username),
"title": title,
"content": content,
@@ -250,7 +388,7 @@ app.post("/submit_post", (req,res) => {
}
else {
res.render("partials/message", {
message: config.string.incorrect_password,
message: locale.incorrect_password,
config,
})
}
@@ -259,7 +397,7 @@ app.post("/submit_signup", (req,res) => {
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const username = func.escape_input(req.body.username)
const prettyname = func.escape_input(req.body.prettyname)
const description = func.escape_input(req.body.description)
const description = req.body.description
// Check that signups are allowed
if (config.allow_signup == true) {
@@ -267,6 +405,7 @@ app.post("/submit_signup", (req,res) => {
// so this checks that the user does not exist
if (func.get_userID(username) == -1) {
users.push({
"id": users.length,
"username": username,
"prettyname": prettyname,
"hash": password,
@@ -278,14 +417,14 @@ app.post("/submit_signup", (req,res) => {
// if the user does exist then
else {
res.render("partials/message", {
message: config.string.user_exists,
message: locale.user_exists,
config,
})
}
}
else if (config.allow_signup == false) {
res.render("partials/message", {
message: config.string.signups_unavailable,
message: locale.signups_unavailable,
config,
})
}
@@ -295,34 +434,40 @@ app.post("/submit_signup", (req,res) => {
console.log("Error, invalid value for allow_signup (bool)")
}
}); // /submit_signup
app.post("/submit_delete_account", (req,res) => {
app.post("/submit_edit_user", (req,res) => {
// Get the form info
const password = crypto.createHash("sha512").update(req.body.password).digest("hex");
const username = func.escape_input(req.body.username)
// get the userID
const userID = func.get_userID(username)
const userID = func.escape_input(req.body.userID)
const description = req.body.description
const prettyname = func.escape_input(req.body.prettyname)
const delete_bool = req.body.delete
if (userID >= 0) { // The user exists
if (password == users[userID]['hash']) { // password matches
console.log(username, "(userID:", userID, ") is trying deleting their account")
// Delete the user
users.splice(userID,1)
// Delete all their posts
for (let postid = 0; postid < posts.length; postid++) { // loop over all posts
if (posts[postid]['userID'] == userID) { // if userID matches
posts.splice(postid,1) // delete the post
comments.comments.splice(postid,1) // the comments for this post should also be delete
}
};
console.log(userID, " (userID) is modifying their account")
users[userID]["prettyname"] = prettyname;
users[userID]["description"] = description;
if (delete_bool == true) {
// Delete the user
users[userID] = {"id": userID,"deleted": true}
// Delete all their posts
for (let postid = 0; postid < posts.length; postid++) { // loop over all posts
if (posts[postid]['userID'] == userID) { // if userID matches
posts[postid] = {"id": postid, "deleted": true} // delete the post
comments.comments[postid] = [] // the comments for this post should also be deleted
}
};
}
// Write these changes
fs.writeFileSync(`../data/users.json`, `${JSON.stringify(users)}`, 'utf-8');
fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8');
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments.comments)}\nexport const counter = ${comments.counter}`, 'utf-8');
res.redirect(301,"/")
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
res.redirect(301,`/user/${users[userID]["username"]}`)
}
else { // password does not match
res.render("partials/message", {
message: config.string.incorrect_password,
message: locale.incorrect_password,
config
}
)
@@ -330,21 +475,21 @@ app.post("/submit_delete_account", (req,res) => {
}
else {
res.render("partials/message", {
message: config.string.user_doesnt_exist,
message: locale.user_doesnt_exist,
config,
})
}
}); // /submit_delete_account
app.post("/submit_edit", (req,res) => {
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const postID = req.body.postID
const userID = req.body.userID
const title = req.body.title
const content = req.body.content
const tags = req.body.tags.split(',');
const delete_bool = req.body.delete
const unix_timestamp = getUnixTime(new Date())
console.log(users[userID]['prettyname'], "is editting the post titled:", title);
app.post("/submit_edit_post", (req,res) => {
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const postID = req.body.postID
const userID = req.body.userID
const title = func.escape_input(req.body.title)
const content = req.body.content
const tags = func.escape_input(req.body.tags).split(",")
const delete_bool = req.body.delete
const unix_timestamp = getUnixTime(new Date())
console.log(users[userID]['prettyname'], "is editting the post titled:", title);
if (users[userID]['hash'] == password) { // password matches
let post = posts[postID]
@@ -354,16 +499,16 @@ app.post("/submit_edit", (req,res) => {
post['editdate'] = unix_timestamp
if (typeof delete_bool != "undefined") {
console.log("Deleting post!")
posts.splice(postID,1)
comments.comments.splice(postID,1)
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments.comments)}\nexport const counter = ${comments.counter}`, 'utf-8');
posts[postID] = {"id": post["id"], "deleted": true}
comments.comments[postID] = [];
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
}
fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8');
res.redirect(302, "/");
}
else {
res.render("partials/message", {
message: config.string.incorrect_password,
message: locale.incorrect_password,
config,
})
}

View File

@@ -1,14 +0,0 @@
<!DOCTYPE html>
<html lang="<%= config.language %>
<head>
<%- include("../partials/head") %>
</head>
<body>
<form action="/submit_delete_account" method="POST">
<input placeholder="username" required name="username"><br/>
<input placeholder="password" type="password" required id="password" name="password"><br/>
<label><%- config.string.delete_account_confirmation %>: </label><input type="checkbox" name="agreement" required><br/>
<input type="submit" value="Submit"><br/>
</form>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="<%= config.language %>
<head>
<%- include("../partials/head") %>
</head>
<body>
<form action="/submit_edit_user" method="POST">
<input name="userID" type="hidden" value="<%= userID %>">
<label><%= locale.password %>:</label><br/>
<input type="password" required id="password" name="password"><br/><br/>
<label><%= locale.prettyname %>:</label><br/>
<input name="prettyname" value="<%= user.prettyname %>"><br/><br/>
<label><%= locale.description %>:</label><br/>
<textarea name="description"><%= user.description %></textarea><br/><br/>
<label><%- locale.delete_account_confirmation %>: </label><input type="checkbox" name="agreement"><br/>
<input type="submit" value="Submit"><br/>
</form>
</body>
</html>

View File

@@ -4,16 +4,24 @@
<%- include("../partials/head") %>
</head>
<body>
<form action="/submit_edit" method="POST" onsubmit="sha512password()">
<form action="/submit_edit_post" method="POST" onsubmit="sha512password()">
<input name="userID" type="hidden" value="<%= post['userID'] %>">
<input name="postID" type="hidden" value="<%= post_id %>">
<input placeholder="<%= user['prettyname'] %>'s password" type="password" required id="password" name="password"><br/>
<input placeholder="title" value=" <%=post['title'] %>" required name="title"><br/>
<textarea placeholder="content" required name="content"><%= post['content'] %></textarea><br/>
<input placeholder="tags (comma seperated)" value="<%= post['tags'] %>" name="tags"><br/>
<label><%= locale.password %>:</label><br/>
<input type="password" required id="password" name="password"><br/><br/>
<label><%= locale.title %>:</label><br/>
<input value="<%=post['title'] %>" required name="title"><br/><br/>
<label><%= locale.post_content %>:</label><br/>
<textarea required name="content"><%= post['content'] %></textarea><br/><br/>
<label><%= locale.tags %>:</label><br/>
<input value="<%= post['tags'] %>" name="tags"><br/><br/>
<label>Delete forever (no undo): </label><input name="delete" type="checkbox"><br/>
<input type="submit" value="Submit"><br/>
<small>* Markdown supported</small>
</form>
</body>
</html>

View File

@@ -5,12 +5,21 @@
</head>
<body>
<form action="/submit_post" method="POST">
<input placeholder="username" required name="username"><br/>
<input placeholder="password" type="password" required id="password" name="password"><br/>
<input placeholder="title" required name="title"><br/>
<textarea placeholder="post content*" required name="content"></textarea><br/>
<input placeholder="Tags (comma seperated)" name="tags"><br/>
<label><%= locale.username %>:</label><br/>
<input required name="username"><br/><br/>
<label><%= locale.password %>:</label><br/>
<input type="password" required id="password" name="password"><br/><br/>
<label><%= locale.title %>:</label><br/>
<input required name="title"><br/><br/>
<label><%= locale.post_content %>:</label><br/>
<textarea required name="content"></textarea><br/><br/>
<label><%= locale.tags %>:</label><br/>
<input name="tags"><br/><br/>
<input type="submit" value="Submit"><br/>
<small>* Markdown supported</small>
</body>
</form></html>

View File

@@ -5,11 +5,19 @@
</head>
<body>
<form action="/submit_signup" method="POST">
<input placeholder="username" required name="username"><br/>
<input placeholder="prettyname" required name="prettyname"><br/>
<input placeholder="password" type="password" required id="password" name="password"><br/>
<textarea placeholder="description (social links, what you do etc), supports markdown" id="description" name="description"></textarea><br/>
<label><%- config.string.signup_agreement %>: </label><input type="checkbox" name="agreement" required><br/>
<label><%= locale.username %></label><br/>
<input required name="username"><br/><br/>
<label><%= locale.prettyname %></label><br/>
<input required name="prettyname"><br/><br/>
<label><%= locale.password %></label><br/>
<input type="password" required id="password" name="password"><br/><br/>
<label><%= locale.description %></label><br/>
<textarea id="description" name="description"></textarea><br/><br/>
<label><%- locale.signup_agreement %>: </label><input type="checkbox" name="agreement" required><br/>
<input type="submit" value="Submit"><br/>
</form>
</body>

View File

@@ -0,0 +1,5 @@
<a href="/"><%= locale.home_page %></a>
<a href="/index/pages"><%= locale.site_index %></a>
<a href="<%= config.new_post_url %>"><%= locale.new_post %></a>
<br/>
<%- config.seperator %>

View File

@@ -1,4 +1,4 @@
<h1>
Post's tagged "<%- tag %>":
<%= locale.posts_tagged %>: "<%- tag %>"
</h1>
<%- config.seperator %>

View File

@@ -4,11 +4,17 @@
<h2>
<%- config.site_description %>
</h2>
<a href="<%= config.rss_url %>">RSS Feed</a><br/>
<a href="<%= config.new_post_url %>">New post</a><br/>
<a href="<%= config.signup_url %>">Sign Up</a><br/>
<a href="<%= config.delete_account_url %>">Delete Account</a><br/>
<% if (config.rss == true) { %>
<a href="/rss"><%= locale.rss_feed %></a><br/>
<% } %>
<% if (config.atom == true) { %>
<a href="/atom"><%= locale.atom_feed %></a><br/>
<% } %>
<a href="<%= config.new_post_url %>"><%= locale.new_post %></a><br/>
<% if (config.allow_signup == true) { %>
<a href="<%= config.signup_url %>"><%= locale.sign_up %></a><br/>
<% } %>
<% if (config.enable_hitcount == true) { %>
Hitcount: <%= hitcount %>
<%= locale.hitcount %>: <%= hitcount %>
<% } %>
<%- config.seperator %>

View File

@@ -1,4 +1,8 @@
<h1>
<%- user.prettyname %>'s posts
<%= user.prettyname %>
</h1>
<p><%- func.render_md(user.description) %></p>
<a href="<%= config.edit_account_base_url %>/<%= userID %>"><%= locale.edit_account %></a><br/>
<a href="/user/<%= user.username %>/rss"><%= locale.rss_feed %></a><br/>
<a href="/user/<%= user.username %>/atom"><%= locale.atom_feed %></a>
<%- config.seperator %>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="<%= config.charset %>">
<head>
<%- include("../partials/head") %>
</head>
<body>
Misc:<br/>
<a href="/">Home Page</a><br/>
<a href="<%= config.new_post_url %>">New Post Form</a><br/>
<a href="<%= config.signup_url %>">Signup Form</a><br/>
Indexes:<br/>
<a href="/index/posts">Posts Index</a><br/>
<a href="/index/users">Users Index</a><br/>
<a href="/index/comments">Comments Index</a><br/>
Posts:<br/>
<% for (let postID = 0; postID < posts.length; postID++) { %>
<% if (posts[postID]["deleted"] != true) { %>
<a href="/post/<%= postID %>"><%= posts[postID]["title"] %></a><br/>
<% }; %>
<% }; %>
Comments:<br/>
<% for (let postID = 0; postID < comments.length; postID++) { %>
<% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %>
<a href="/comment/<%= comments[postID][comment_index]["id"] %>"><%= comments[postID][comment_index]["id"] %></a><br/>
<% }; %>
<% }; %>
Users:<br/>
<% for (let userID = 0; userID < users.length; userID++) { %>
<% if (users[userID]["deleted"] != true) { %>
<a href="/user/<%= users[userID]["username"] %>"><%= users[userID]["username"] %></a><br/>
<% }; %>
<% }; %>
Edit Posts:<br/>
<% for (let postID = 0; postID < posts.length; postID++) { %>
<% if (posts[postID]["deleted"] != true) { %>
<a href="/<%= config.edit_post_base_url %>/<%= postID %>">Edit <%= posts[postID]["title"] %></a><br/>
<% }; %>
<% }; %>
Edit Users:<br/>
<% for (let userID = 0; userID < users.length; userID++) { %>
<% if (users[userID]["deleted"] != true) { %>
<a href="/<%= config.edit_account_base_url %>/<%= users[userID]["username"] %>">Edit <%= users[userID]["username"] %></a><br/>
<% }; %>
<% }; %>
<!-- TODO add tags -->
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="<%= config.charset %>">
<head>
<%- include("../partials/head") %>
</head>
<body>
<% for (let postID = 0; postID < comments.length; postID++) { %>
<% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %>
<a href="/comment/<%= comments[postID][comment_index]["id"] %>"><%= comments[postID][comment_index]["id"] %></a><br/>
<% }; %>
<% }; %>
</body>
</html>

13
views/indexes/posts.ejs Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="<%= config.charset %>">
<head>
<%- include("../partials/head") %>
</head>
<body>
<% for (let postID = 0; postID < posts.length; postID++) { %>
<% if (posts[postID]["deleted"] != true) { %>
<a href="/post/<%= postID %>"><%= posts[postID]["title"] %></a><br/>
<% }; %>
<% }; %>
</body>
</html>

13
views/indexes/users.ejs Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="<%= config.charset %>">
<head>
<%- include("../partials/head") %>
</head>
<body>
<% for (let userID = 0; userID < users.length; userID++) { %>
<% if (users[userID]["deleted"] != true) { %>
<a href="/user/<%= users[userID]["username"] %>"><%= users[userID]["username"] %></a><br/>
<% }; %>
<% }; %>
</body>
</html>

14
views/pages/comment.ejs Normal file
View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<%- include('../partials/head'); %>
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
</div>
<div id="comment">
<%- include("../partials/comment"); %>
</div>
</body>
</html>

View File

@@ -4,6 +4,9 @@
<%- include('../partials/head'); %>
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
</div>
<div id="posts">
<%- include('../posts/post'); %>
</div>

View File

@@ -5,15 +5,18 @@
</head>
<body>
<div id="header">
<%- include('../headers/site_wide'); %>
<%- include('../headers/tag'); %>
</div>
<div id="posts">
<% for (let index = posts.length - 1; index >= 0; index--) { %>
<% posts[index].tags.forEach((current_tag, tag_index) => { %>
<% if (current_tag == tag) { %>
<%- include('../posts/tag', {post: posts[index], postID: index}); %>
<% } %>
<% }) %>
<% if ( posts[index].deleted != true) { %>
<% posts[index].tags.forEach((current_tag, tag_index) => { %>
<% if (current_tag == tag) { %>
<%- include('../posts/tag', {post: posts[index], user: users[posts[index].userID], comments: comments[index]}); %>
<% } %>
<% }) %>
<% } %>
<% } %>
</div>
<footer>

View File

@@ -5,11 +5,21 @@
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
<%- include('../headers/timeline'); %>
</div>
<form method="POST" action="/submit_nothing" style="display:none">
<!-- Form is used to help mitigate spam as it is the first form on the front page -->
<input type="hidden" name="post_index" value="0">
<input placeholder="username" name="name"><br/>
<textarea placeholder="comment" name="content"></textarea><br/>
<button type="submit">Submit</button>
</form>
<div id="posts">
<% for (let index = posts.length - 1; index >= 0; index--) { %>
<%- include('../posts/timeline', {post: posts[index], index: index, user: users[posts[index].userID]}); %>
<% if (posts[index]["deleted"] != true) { %>
<%- include('../posts/timeline', {post: posts[index], postID: index, user: users[posts[index].userID], comments: comments[index]}); %>
<% } %>
<% } %>
</div>
<footer>

View File

@@ -5,12 +5,13 @@
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
<%- include('../headers/user'); %>
</div>
<div id="posts">
<% for (let index = posts.length - 1; index >= 0; index--) { %>
<% if (posts[index].userID == userID) { %>
<%- include('../posts/user', {post: posts[index], index: index, user: user}); %>
<%- include('../posts/user', {post: posts[index], postID: index, user: user, comments: comments[index]}); %>
<% } %>
<% } %>
</div>

View File

@@ -1,2 +1,3 @@
<b><%= comment.name %></b> <%= func.unix_time_to_date_format(comment.pubdate) %> <i>No. <%= comment.id %></i>:<br/>
<%= comment.content %>
<%- func.render_comment(comment.content) %>
<br/>

View File

@@ -1,2 +1,3 @@
Site is ran by deadvey<br/>
<%- config.string.attribution %>
<%= locale.site_ran_by %> <%= config.site_admin %><br/>
<%- locale.attribution %><br/>
<%= locale.AI_consent %> <!-- remove consent for AI scrapers -->

View File

@@ -1,9 +1,12 @@
<!DOCTYPE html>
<html lang="<%=config.language%>
<html lang="<%= config.language %>">
<head>
<%- include('head') %>
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
</div>
<%- message %>
</body>
</html>

View File

@@ -1,28 +1,48 @@
<h1>
<%= post.title %>
</h1>
<%- converter.makeHtml(post.content) %><br/>
<i>
By <a href="/user/<%= user.username %>"><%= user.username %></a><br/>
</i>
<%- func.hyperlink_tags(post.tags) %><br/>
<a href="<%= config.edit_post_base_url %>/<%= postID %>">Edit</a><br/>
<i>Published: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
<i>Last Modified: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
<%- config.seperator %>
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= postID %>">
<input placeholder="username" name="name"><br/>
<textarea placeholder="comment" name="content"></textarea><br/>
<button type="submit">Submit</button>
</form>
<% comments.forEach((comment, postID) => { %>
<%- include('../partials/comment', {comment: comment}) %>
<% }) %>
<div id="post-header">
<h1>
<%= post.title %>
</h1>
</div>
<div id="post-content">
<p>
<%- func.render_md(post.content) %><br/>
</p>
</div>
<div id="post-details">
<div id="post-author">
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
</div>
<div id="post-tags">
<%- func.render_tags(post.tags) %><br/>
</div>
<div id="post-edit">
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
</div>
<div id="post-pubdate">
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div>
<div id="post-editdate">
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div>
</div>
<div id="post-commentform">
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= post["id"] %>">
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
<button type="submit"><%= locale.submit %></button>
</form>
</div>
<div id="post-comments">
<% comments.forEach((comment, index) => { %>
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>">
<%- include('../partials/comment', {comment: comment}) %>
</div>
<% }) %>
</div>
<%- config.seperator %>

View File

@@ -1,21 +1,51 @@
<h3>
<%= post.title %>
</h3>
<%- converter.makeHtml(post.content) %><br/>
<a href="/post/<%- postID %>">Permalink</a><br/>
<%- func.hyperlink_tags(post.tags) %>
<div id="post-header">
<h1>
<%= post.title %>
</h1>
</div>
<div id="post-content">
<p>
<%- func.render_md(post.content) %><br/>
</p>
</div>
<div id="post-details">
<div id="post-author">
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
</div>
<div id="post-permalink">
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
</div>
<div id="post-tags">
<%- func.render_tags(post.tags) %><br/>
</div>
<div id="post-edit">
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
</div>
<div id="post-pubdate">
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div>
<div id="post-editdate">
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div>
</div>
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= postID %>">
<input placeholder="username" name="name"><br/>
<textarea placeholder="comment" name="content"></textarea><br/>
<button type="submit">Submit</button>
</form>
<div id="post-commentform">
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= post["id"] %>">
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
<button type="submit"><%= locale.submit %></button>
</form>
</div>
<% comments[postID].forEach((comment) => { %>
<%- include('../partials/comment', {comment: comment}) %>
<% }) %>
<div id="post-comments">
<% comments.forEach((comment, index) => { %>
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>">
<%- include('../partials/comment', {comment: comment}) %>
</div>
<% }) %>
</div>
<%- config.seperator %>

View File

@@ -1,23 +1,51 @@
<h3>
<%= post.title %>
</h3>
<%- converter.makeHtml(post.content) %><br/>
<a href="/post/<%- index %>">Permalink</a><br/>
<i>
By <a href="/user/<%= user.username %>"><%= user.username %></a><br/>
</i>
<div id="post-header">
<h1>
<%= post.title %>
</h1>
</div>
<div id="post-content">
<p>
<%- func.render_md(post.content) %><br/>
</p>
</div>
<div id="post-details">
<div id="post-author">
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
</div>
<div id="post-permalink">
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
</div>
<div id="post-tags">
<%- func.render_tags(post.tags) %><br/>
</div>
<div id="post-edit">
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
</div>
<div id="post-pubdate">
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div>
<div id="post-editdate">
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div>
</div>
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= index %>">
<input placeholder="username" name="name"><br/>
<textarea placeholder="comment" name="content"></textarea><br/>
<button type="submit">Submit</button>
</form>
<div id="post-commentform">
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= post["id"] %>">
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
<button type="submit"><%= locale.submit %></button>
</form>
</div>
<% comments[index].forEach((comment, index) => { %>
<%- include('../partials/comment', {comment: comment}) %>
<% }) %>
<div id="post-comments">
<% comments.forEach((comment, index) => { %>
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>">
<%- include('../partials/comment', {comment: comment}) %>
</div>
<% }) %>
</div>
<%- config.seperator %>

View File

@@ -1,20 +1,48 @@
<h3>
<%= post.title %>
</h3>
<%- converter.makeHtml(post.content) %><br/>
<a href="/post/<%- index %>">Permalink</a><br/>
<div id="post-header">
<h1>
<%= post.title %>
</h1>
</div>
<div id="post-content">
<p>
<%- func.render_md(post.content) %><br/>
</p>
</div>
<div id="post-details">
<div id="post-permalink">
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
</div>
<div id="post-tags">
<%- func.render_tags(post.tags) %><br/>
</div>
<div id="post-edit">
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
</div>
<div id="post-pubdate">
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div>
<div id="post-editdate">
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div>
</div>
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= index %>">
<input placeholder="username" name="name"><br/>
<textarea placeholder="comment" name="content"></textarea><br/>
<button type="submit">Submit</button>
</form>
<div id="post-commentform">
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= post["id"] %>">
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
<button type="submit"><%= locale.submit %></button>
</form>
</div>
<% comments[index].forEach((comment, index) => { %>
<%- include('../partials/comment', {comment: comment}) %>
<% }) %>
<div id="post-comments">
<% comments.forEach((comment, index) => { %>
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>">
<%- include('../partials/comment', {comment: comment}) %>
</div>
<% }) %>
</div>
<%- config.seperator %>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="<%= config.charset %>" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><%= config.site_name %></title>
<link><%= config.site_url %></title>
<description><%= config.site_description %></description>
<updated><%= func.unix_time_to_atom_date(getUnixTime(new Date())) %></updated>
<id><%= config.site_url %></id>
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
<% if (posts[postID]["deleted"] != true) { %>
<entry>
<title><%= posts[postID]["title"] %></title>
<link><%= config.site_url %>/post/<%= postID %></link>
<summary><![CDATA[<%- func.render_md(posts[postID]["content"]) %>]]></summary>
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
<pubDate><%# func.unix_time_to_atom_date(posts[postID]['pubdate']) %></pubDate>
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
<category><![CDATA[<%= posts[postID]['tags'][tag_index] %>]]></category>
<% } %>
</entry>
<% } %>
<% } %>
</feed>

View File

@@ -5,10 +5,11 @@
<link><%= config.site_url %></title>
<description><%= config.site_description %></description>
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
<% if (posts[postID]["deleted"] != true) { %>
<item>
<title><%= posts[postID]["title"] %></title>
<link><%= config.site_url %>/post/<%= postID %></link>
<description><![CDATA[<%= converter.makeHtml(posts[postID]["content"]) %>]]></description>
<description><![CDATA[<%- func.render_md(posts[postID]["content"]) %>]]></description>
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
<pubDate><%= func.unix_time_to_rss_date(posts[postID]['pubdate']) %></pubDate>
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
@@ -16,5 +17,6 @@
<% } %>
</item>
<% } %>
<% } %>
</channel>
</rss>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="<%= config.charset %>" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><%= config.site_name %></title>
<link><%= config.site_url %></title>
<description><%= config.site_description %></description>
<updated><%= func.unix_time_to_atom_date(getUnixTime(new Date())) %></updated>
<id><%= config.site_url %></id>
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
<% if (posts[postID]["userID"] == userID) { %>
<% if (posts[postID]["deleted"] != true) { %>
<entry>
<title><%= posts[postID]["title"] %></title>
<link><%= config.site_url %>/post/<%= postID %></link>
<summary><![CDATA[<%- func.render_md(posts[postID]["content"]) %>]]></summary>
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
<pubDate><%# func.unix_time_to_atom_date(posts[postID]['pubdate']) %></pubDate>
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
<category><![CDATA[<%= posts[postID]['tags'][tag_index] %>]]></category>
<% } %>
</entry>
<% } %>
<% } %>
<% } %>
</feed>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="<%= config.charset %>" ?>
<rss version="2.0">
<channel>
<title><%= config.site_name %></title>
<link><%= config.site_url %></title>
<description><%= config.site_description %></description>
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
<% if (posts[postID]["userID"] == userID) { %>
<% if (posts[postID]["deleted"] != true) { %>
<item>
<title><%= posts[postID]["title"] %></title>
<link><%= config.site_url %>/post/<%= postID %></link>
<description><![CDATA[<%- func.render_md(posts[postID]["content"]) %>]]></description>
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
<pubDate><%= func.unix_time_to_rss_date(posts[postID]['pubdate']) %></pubDate>
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
<category><![CDATA[<%= posts[postID]['tags'][tag_index] %>]]></category>
<% } %>
</item>
<% } %>
<% } %>
<% } %>
</channel>
</rss>