Compare commits

...

57 Commits

Author SHA1 Message Date
deadvey
ad4efffed5 Database reading changes should work, gotta implement same for writing and finish up testing then merge back into master 2026-03-07 17:56:53 +00:00
deadvey
30cec0f7f0 Sydication updates 2026-03-06 21:26:00 +00:00
deadvey
9f5fd261c3 Changing how data is requested in DEV branch 2026-03-05 13:53:10 +00:00
deadvey
3fab094545 Made some small changes 2026-03-03 20:39:40 +00:00
Nullifier
9be261d415 Japanese locale typo fixed 2026-01-18 09:41:50 +00:00
Nullifier
9398919711 Japanese Locale - By Nullifier 2026-01-17 21:49:42 +00:00
545a848479 Stupid spelling error 2026-01-17 14:52:30 +00:00
54ffac931d Added english Australian, apparently there's no differences with GB and
AU
2026-01-17 12:11:04 +00:00
18b842e48c Merge pull request 'add(locale): sv-SE' (#3) from pickzelle/blogger-nodejs:master into master
Reviewed-on: #3
2026-01-16 23:23:52 +01:00
Pickzelle
c7bc64e59e add(locale): sv-SE 2026-01-16 23:19:02 +01:00
9383bd8058 Template .jsonc for locales 2026-01-16 21:25:47 +00:00
d554fce402 Added translated_by key to the locales 2026-01-16 21:15:11 +00:00
d17fcf2dd2 Merge pull request 'fix: these don't need to be executable' (#2) from javalsai/blogger-nodejs:fix-permissions into master
Reviewed-on: #2
2026-01-16 22:12:25 +01:00
a1fa0e3dbc Merge pull request 'add(locale): es-ES' (#1) from javalsai/blogger-nodejs:locale-es into master
Reviewed-on: #1
2026-01-16 22:12:17 +01:00
f44a15ed41 fix: these don't need to be executable 2026-01-16 21:12:58 +01:00
ab1fa5e69a add(locale): es-ES 2026-01-16 21:10:48 +01:00
be75382ead Add start up checks 2025-12-19 17:31:28 +00:00
3d58c5b244 Some minor changes to data handling error messages
and fixed a issue occuring in the forms routs that used the old
parameters for data.getdata
2025-11-30 17:04:15 +00:00
54b6f018cf Updated the data reading to have a data request limit, also updated docs
on new configuration options
2025-11-27 11:44:27 +00:00
7d38752f34 Changed how comments are stored and how data is retrieved 2025-11-27 11:34:12 +00:00
ef8711b0e1 Added a pipe | between the edit and RSS/ATOM buttons to make them more
seperated
2025-11-05 10:47:11 +00:00
c3de930b50 Split the page-header and site-header into seperate sections 2025-11-05 10:34:41 +00:00
1d1e4d863e Untracked robots.txt 2025-10-25 11:32:28 +01:00
3b47701c18 Made some divs consistent, the header was a div type with id='header'
and the footer was a footer type with no id, so now they are both both.
Also added some margins at the top and bottom of the page in CSS
2025-10-25 11:31:08 +01:00
deadvey
ddf9fcae13 Added icons for RSS and ATOM to make it look nicer 2025-10-24 13:59:41 +01:00
deadvey
9f0eb13bb4 BAD BUG! 2025-10-24 13:10:53 +01:00
deadvey
2d33ce79a8 Fixed a bug where comments could be submitted without any content
and where the hitcount was incremented before the program checked if
the post existed
2025-10-24 13:05:31 +01:00
deadvey
4ad7352fcc Updated some EJS and CSS to make it look a bit nicer (I am hopeless at
UX)
2025-10-24 12:48:54 +01:00
deadvey
f8f05221b2 removed custom.css from tracking 2025-10-24 12:29:57 +01:00
deadvey
35163b5584 Fixed an issue with an incomplete example-config.json that made the
server not work at all.
Also added a default.css file
2025-10-24 12:28:22 +01:00
66423cb3c0 There is now a Makefile because I learnt make syntax 2025-10-19 21:19:13 +01:00
cb7dcde7c5 Made tags case insensitive 2025-10-09 15:13:49 +01:00
553f126f2a Changed how comments are ided and classed 2025-10-09 14:43:48 +01:00
6f9e7aee13 small change in comment ids 2025-10-09 14:38:37 +01:00
23add8897b divs to spans because correct html 2025-10-09 14:30:48 +01:00
84a34d94f3 removed newlines from comments ejs 2025-10-09 14:28:51 +01:00
783f386dfe tiny fix 2025-10-09 14:19:16 +01:00
e63fb4a27a updated ejs 2025-10-09 14:18:03 +01:00
2ada1d970f Created a per-post hitcount as well a writedata() function that can
write to a particular index or to a whole data type
2025-10-02 13:34:55 +01:00
17919e3078 README 2025-10-02 11:13:39 +01:00
179a4f83bc Bug fix, most recent post would not show in the post's permalink due to
an indexing bug, pretty simple fix, I'm just a moron.
2025-10-02 10:47:38 +01:00
d9d45ff6ea Tracking /webroot, contains custom.css and robots.txt, might have to add
favicon.ico too.
2025-10-02 10:43:44 +01:00
87fd97730e Escape potentially dangerous input in the search field 2025-10-01 17:45:31 +01:00
acca51da20 README 2025-10-01 10:51:07 +01:00
788672cbea Bug fix with the search page's EJS 2025-10-01 10:44:34 +01:00
521dbccc7e Basic search functionality on the frontpage, I want to add support for
more advanced searches like using boolean operators, but right now it's
pretty basic.
2025-10-01 10:40:36 +01:00
8ad8f01043 Added basic search functionality (no frontend for it yet) 2025-09-30 23:15:33 +01:00
d27330a3db README update
I removed and added some stuff to the todo list
2025-09-24 23:41:29 +01:00
996bf0018b bug fix
numbers should be parsed

Signed-off-by: deadvey <deadvey@deadvey.com>
2025-09-24 21:21:48 +01:00
45af80f747 Updated how comments are searched for
commentID's aren't neccesarily = to the index, so instead of using it as an index,  I just use a for loop to find the matching comment.
I also added another form at the bottom of the timeline to trick bots

Signed-off-by: deadvey <deadvey@deadvey.com>
2025-09-24 21:12:21 +01:00
23744f4000 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 <deadvey@deadvey.com>
2025-09-24 20:57:47 +01:00
9305559660 Documentation fix
String -> Boolean

Signed-off-by: deadvey <deadvey@deadvey.com>
2025-09-24 20:39:42 +01:00
35e6b94ba1 Support for uncached data loading
So you don't have to restart the server, you can add "cache_data": false option to config.json to not cache data.
Documented in CONFIG.md
I added a require_module function that either does or does not cache the data based on this configuration option.

Signed-off-by: deadvey <deadvey@deadvey.com>
2025-09-24 20:37:35 +01:00
3f173fc2e3 bug fix
removed data/data.json from tracking

Signed-off-by: deadvey <deadvey@deadvey.com>
2025-09-24 20:20:48 +01:00
b44762ba7c bug fix
Hitcount updates visually, previously it just showed 1 on the frontend as the value wasn't actually  being retrieved from the data.getdata()

Signed-off-by: deadvey <deadvey@deadvey.com>
2025-09-24 20:18:05 +01:00
1ecc223433 small changes
Signed-off-by: deadvey <deadvey@deadvey.com>
2025-09-24 20:07:49 +01:00
22a7983737 data.getdata() is fully implemented
I think it all works now...

Signed-off-by: deadvey <deadvey@deadvey.com>
2025-09-24 19:31:32 +01:00
54 changed files with 982 additions and 593 deletions

6
.gitignore vendored Executable file → Normal file
View File

@@ -4,6 +4,10 @@ posts.json
comments.json comments.json
users.json users.json
config.json config.json
data.json
hitcount.txt hitcount.txt
*.swp *.swp
webroot/ data
images/*
webroot/custom.css
webroot/robots.txt

41
Makefile Normal file
View File

@@ -0,0 +1,41 @@
DATA_DIR=data
WEBROOT_DIR=webroot
all: config css users posts comments data
clean:
rm -rf data
rm -f webroot/custom.css
rm -f config.json
# config file
config: config.json
config.json:
cp example-config.json config.json
echo '!!!PLEASE MODIFY config.json ACCORDING TO YOUR NEEDS!!!'
# custom.css
css: $(WEBROOT_DIR)/custom.css
$(WEBROOT_DIR)/custom.css:
mkdir -p webroot
echo '* { font-family: sans-serif; }' > $(WEBROOT_DIR)/custom.css
# users.json
users: $(DATA_DIR)/users.json
$(DATA_DIR)/users.json:
mkdir -p data
echo '[]' > $(DATA_DIR)/users.json
# posts.json
posts: $(DATA_DIR)/posts.json
$(DATA_DIR)/posts.json:
mkdir -p data
echo '[]' > $(DATA_DIR)/posts.json
# comments.json
comments: $(DATA_DIR)/comments.json
$(DATA_DIR)/comments.json:
mkdir -p data
echo '[]' > $(DATA_DIR)/comments.json
# data.json
data: $(DATA_DIR)/data.json
$(DATA_DIR)/data.json:
mkdir -p data
echo '{"hitcount": 0}' > $(DATA_DIR)/data.json

View File

@@ -2,6 +2,7 @@ This software aims to provide a lot of power to the web admin who is running the
Customisation is unlimited with a bit of knowledge of EJS and CSS, you can edit the entire formatting of the pages, making the site truly yours!<br/> Customisation is unlimited with a bit of knowledge of EJS and CSS, you can edit the entire formatting of the pages, making the site truly yours!<br/>
This software also aims to be compatible with text based browsers and as a result contains no client side Javascript, if you're looking for a more<br/> This software also aims to be compatible with text based browsers and as a result contains no client side Javascript, if you're looking for a more<br/>
beautiful and featureful blogging frontend, this isn't for you.<br/> beautiful and featureful blogging frontend, this isn't for you.<br/>
The AI robots.txt file is from [ai.robots.txt (MIT)](https://github.com/ai-robots-txt/ai.robots.txt)<br/>
> [!CAUTION] > [!CAUTION]
> This software is not finished yet, so it's very buggy and probably really insecure<br/> > This software is not finished yet, so it's very buggy and probably really insecure<br/>
@@ -20,11 +21,12 @@ Read the [configuation guide](docs/CONFIG.md) for configuration help (in config.
* user creation, modification and deletion via frontend * user creation, modification and deletion via frontend
* multi user * multi user
* powerful customisation via EJS * powerful customisation via EJS
* Configuration via config.json
* site wide and user specific rss, atom * site wide and user specific rss, atom
* hitcount
* Markdown syntax in posts * Markdown syntax in posts
* Commenting on posts and replying to other comments * Commenting on posts and replying to other comments
* site wide custom CSS * site wide custom CSS and strings
* Search functionality
* Page indexes * Page indexes
# Bugs: # Bugs:
@@ -33,14 +35,15 @@ Read the [configuation guide](docs/CONFIG.md) for configuration help (in config.
# Planned features/todo list: # Planned features/todo list:
* federation (looks tricky) * federation (looks tricky)
* All strings (including in edit and post page) customisable
* formatable custom strings
* inline comments and docs * inline comments and docs
* clean up code a bit * clean up code a bit
* /postID and /userID pages * /postID and /userID pages
* site index * Make EJS modification more user friendly (half done)
* Make EJS modification more user friendly
* API for returning posts, users, comments, tags other?... * API for returning posts, users, comments, tags other?...
* Moderation tools including a keyword blacklist
* Request account function? Not sure how this should be implemented.
* optional SQL
* initialisation has prompts for setup process.
# Docs: # Docs:
See [docs/DOCUMENTATION.md](docs/DOCUMENTATION.md) See [docs/DOCUMENTATION.md](docs/DOCUMENTATION.md)

View File

@@ -1 +0,0 @@
{"hitcount":27}

17
docs/CONFIG.md Executable file → Normal file
View File

@@ -14,13 +14,17 @@ All options show an example configuartion value and the variable type + an expla
| 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. | | 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. | | 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. | | 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. |
| data_storage | "json" | String | JSON is currently the only supported format, but SQL is going to be added/is a work in progress |
| cache_data | true | Boolean | Not caching data means you can edit the posts, users, comments etc, maunally and not have to restart the server, however, for large instances this is not reccomended as it takes longer to load the required data. Note: config.json always needs a restart |
| request_data_limit | 20 | Integer | The maximum number of objects to return (latest), so if set to 20, then only the 20 most recent posts will ever show |
| root_path | '/var/www/blog_root' | String | Relative or Absolute path to the root directory of your static content, holds files such as favicon.ico, custom.css and robots.txt |
| locale | 'en_GB' | String | The locale to use which determines the language used and minor cultural differences |
## Basic Customisation ## Basic Customisation
| name | example value | variable type | explanation | | 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)| |locale|"en-US"|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.| |seperator|"\<hr/\>"|String|By default, 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_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.| |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.| |default_commenter_username|"Anon"|String|Default commenter username if no username is inputted in comment submission.|
@@ -35,13 +39,14 @@ Read more at [date-fns](https://date-fns.org/v4.1.0/docs/format)<br/>
| name | example value | variable type | explanation | | name | example value | variable type | explanation |
|------|---------------|---------------|-------------------------------| |------|---------------|---------------|-------------------------------|
|date_format|"yyyy-MM-dd"|String|The format of date's on the website.| |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 ## 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. * /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; }"<br/> * "css": "body { background: red; }"<br/>
String. Custom CSS to be applied to all pages, if you want more complex css, you can edit custom.css.<br/> String. Custom CSS to be applied to all pages, if you want more complex css, you can edit custom.css.<br/>
You can also edit the custom.css file in the webroot, as by default this is linked in the global header. 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 ## Custom Strings
* You can edit all the strings on the site in /locales/<your-locale>.json * You can edit all the strings on the site in /locales/\<your-locale>.json

View File

@@ -2,10 +2,8 @@
This program is currently just ran manually.<br/> This program is currently just ran manually.<br/>
All you need to do is clone the git repository:<br/> All you need to do is clone the git repository:<br/>
```git clone https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs.git```<br/> ```git clone https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs.git```<br/>
Then navigate to /src:<br/> Then run the Makefile:<br/>
```cd src```<br/> ```make```
Then run the initialisation function:<br/>
```node server.js --first-time```<br/>
Then you should modify config.json in / to suit your needs.<br/> Then you should modify config.json in / to suit your needs.<br/>
# Running # Running
I would reccomend running the program in tmux so it does not stop running when you close the terminal window.<br/> I would reccomend running the program in tmux so it does not stop running when you close the terminal window.<br/>

22
example-config.json Executable file → Normal file
View File

@@ -3,34 +3,24 @@
"seperator": "<hr/>", "seperator": "<hr/>",
"site_name": "My Blog", "site_name": "My Blog",
"site_url": "https://example.com", "site_url": "https://example.com",
"language": "en-US", "locale": "en-US",
"port": 8080, "port": 8080,
"data_storage": "json",
"cache_data": false,
"allow_signup": true, "allow_signup": true,
"site_description": "Read my blogs!", "site_description": "Read my blogs!",
"timeline_length": 20, "request_data_limit": 20,
"enable_hitcount": true, "enable_hitcount": true,
"charset": "UTF-8", "charset": "UTF-8",
"root_path": "/path/to/webroot", "root_path": "../webroot/",
"edit_account_base_url": "/edit_account", "edit_account_base_url": "/edit_account",
"new_post_url": "/post", "new_post_url": "/post",
"signup_url": "/signup", "signup_url": "/signup",
"edit_post_base_url": "/edit", "edit_post_base_url": "/edit",
"default_comenter_username": "Anon", "default_commenter_username": "Anon",
"rss": true, "rss": true,
"atom": true, "atom": true,
"date_format": "yyyy-MM-dd", "date_format": "yyyy-MM-dd",
"time_zone": "+0000", "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: <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": "" "css": ""
} }

View File

@@ -10,7 +10,7 @@
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)", "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", "signup_agreement": "I agree to not post illegal or hateful content",
"comment": "Comment", "comment": "Comment",
"submit": "Sumbit", "submit": "Submit",
"site_ran_by": "Site is ran by", "site_ran_by": "Site is ran by",
"signups_unavailable": "Sorry, this server does not allow signups", "signups_unavailable": "Sorry, this server does not allow signups",
@@ -39,5 +39,6 @@
"home_page": "Home Page", "home_page": "Home Page",
"site_index": "Site Index", "site_index": "Site Index",
"reply": "reply", "reply": "reply",
"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>" "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>",
"translated_by": "DeaDvey"
} }

View File

@@ -10,7 +10,7 @@
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)", "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", "signup_agreement": "I agree to not post illegal or hateful content",
"comment": "Comment", "comment": "Comment",
"submit": "Sumbit", "submit": "Submit",
"site_ran_by": "Site is ran by", "site_ran_by": "Site is ran by",
"signups_unavailable": "Sorry, this server does not allow signups", "signups_unavailable": "Sorry, this server does not allow signups",
@@ -39,5 +39,6 @@
"home_page": "Home Page", "home_page": "Home Page",
"site_index": "Site Index", "site_index": "Site Index",
"reply": "reply", "reply": "reply",
"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>" "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>",
"translated_by": "DeaDvey"
} }

View File

@@ -10,7 +10,7 @@
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)", "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", "signup_agreement": "I agree to not post illegal or hateful content",
"comment": "Comment", "comment": "Comment",
"submit": "Sumbit", "submit": "Submit",
"site_ran_by": "Site is ran by", "site_ran_by": "Site is ran by",
"signups_unavailable": "Sorry, this server does not allow signups", "signups_unavailable": "Sorry, this server does not allow signups",
@@ -39,5 +39,6 @@
"home_page": "Home Page", "home_page": "Home Page",
"site_index": "Site Index", "site_index": "Site Index",
"reply": "reply", "reply": "reply",
"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>" "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>",
"translated_by": "DeaDvey"
} }

43
locales/es-ES.json Normal file
View File

@@ -0,0 +1,43 @@
{
"quotes": "«»‹›",
"password": "Contraseña",
"username": "Nombre de Usuario",
"prettyname": "Nombre Bonito",
"description": "Descripción (enlaces de redes, sobre que escribes, etc), soporta markdown",
"title": "Título",
"post_content": "Contenido de la Publicación, soporta markdown",
"tags": "Etiquetas (separados por coma)",
"delete_account_confirmation": "Eliminar mi cuenta - (Estoy de acuerdo con que todas mis publicaciones serán permanentemente eliminadas al instante)",
"signup_agreement": "Acepto no publicar contenido ilegal o de odio",
"comment": "Comentar",
"submit": "Enviar",
"site_ran_by": "El sitio es llevado por",
"signups_unavailable": "Lo siento, este servidor no permite registrarse",
"user_exists": "Lo siento, este usuario ya existe, prueba otro diferente",
"user_doesnt_exist": "Lo siento, este usuario no existe",
"comment_doesnt_exist": "Este comentario no existe, esto puede ser porque la publicación en la que estaba adjunto se ha eliminado",
"post_doesnt_exist": "Esta publicación no existe o se ha aliminado",
"incorrect_password": "Contraseña Incorrecta",
"rss_disabled": "Lo siento, RSS está desactivado",
"atom_disabled": "Lo siento, ATOM está desactivado",
"AI_consent": "El contenido de este sitio no debe ser copiado, raspado, o usado para entrenar modelos de IA o de lenguaje (LLMs) sin consentimiento previo.",
"rss_feed": "Feed RSS",
"atom_feed": "Feed ATOM",
"no_tags": "Sin Etiquetas",
"new_post": "Nueva Publicación",
"edit_post": "Editar Publicación",
"sign_up": "Registrarse",
"edit_account": "Editar Cuenta",
"permalink": "Enlace Permanente",
"written_by": "Escrito por",
"published": "Publicado",
"last_modified": "Última Modificación",
"hitcount": "Visitas",
"post_tagged": "Publicaciones Etiquetadas",
"home_page": "Página Principal",
"site_index": "Índice del Sitio",
"reply": "Responder",
"attribution": "Empujado por blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Código Fuente</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>licencia (WTFPL)</a>",
"translated_by": "Javalsai"
}

44
locales/ja_JP.json Normal file
View File

@@ -0,0 +1,44 @@
{
"quotes": "“”‘’",
"password": "パスワード",
"username": "ユーザー名",
"prettyname": "きれいな名前",
"description": "説明 (例えばSNSのリンクや何を書くなど)、 マークダウンをスポートする",
"title": "題名",
"post_content": "投稿の内容、マークダウンをスポートする",
"tags": "タグ (カンマで区切られています)",
"delete_account_confirmation": "アカウントを削除する - (アカウントと投稿の全部をいつまでも削除するに賛成します。)",
"signup_agreement": "違法なコンテントと憎らしいコンテントをポストしないに賛成します。",
"comment": "コメント",
"submit": "提出する",
"site_ran_by": "アドミン:",
"signups_unavailable": "申し訳ございませんでもこのサーバーはサインアップ",
"user_exists": "申し訳ございませんでもこのユーザー名をつかえります。別のユーザー名を入ります。",
"user_doesnt_exist": "申し訳ございませんでもこのアカウントがいません。",
"comment_doesnt_exist": "このコメントがない、これから投稿を削除したかもしれない",
"post_doesnt_exist": "この投稿がないか又は削除しました。",
"incorrect_password": "パスワードが違う",
"rss_disabled": "申し訳ございませんでもRSSが使用不可能なります。",
"atom_disabled": "申し訳ございませんでもATOMが使用不可能なります。",
"AI_consent": "書面による同意がないとこのホームページの内容はコピーするか又はスクレイピングするか又はAIモデルか大規模言語モデルLLM)を仕込むことが禁断します。",
"rss_feed": "RSSのフィード",
"atom_feed": "ATOMのフィード",
"no_tags": "タグがない",
"new_post": "新しい投稿",
"edit_post": "投稿をエディットする",
"sign_up": "サインアップ",
"edit_account": "アカウントをエディットする",
"permalink": "恒久リンク",
"written_by": "作家は",
"published": "発行の日付",
"last_modified": "全変更",
"hitcount": "ヒット数",
"posts_tagged": "投稿をタグするの数",
"home_page": "ホーム",
"site_index": "ホームページの索引",
"reply": "返事",
"attribution": "blogger-nodejsで作成されています: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>ソースコード</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>ライセンス (WTFPL)</a>",
"translated_by": "Nullifier"
}

44
locales/sv-SE.json Normal file
View File

@@ -0,0 +1,44 @@
{
"quotes": "“”‘’",
"password": "Lösenord",
"username": "Användarnamn",
"prettyname": "Vackert namn",
"description": "Beskrivning (sociala länkar, vad du skriver om m.m.), stöder markdown",
"title": "Titel",
"post_content": "Inläggsinnehåll, stöder markdown",
"tags": "Taggar (komma separerade)",
"delete_account_confirmation": "Radera mitt konto - (Jag förstår och accepterar att mitt konto och alla mina inlägg kommer att raderas permanent omedelbart)",
"signup_agreement": "Jag samtycker till att inte publicera olagligt eller hatiskt innehåll",
"comment": "Kommentera",
"submit": "Skicka",
"site_ran_by": "Webbplatsen drivs av",
"signups_unavailable": "Tyvärr, denna server tillåter inte registreringar",
"user_exists": "Tyvärr, den här användaren finns redan. Försök med ett annat användarnamn",
"user_doesnt_exist": "Tyvärr, den här användaren finns inte",
"comment_doesnt_exist": "Denna kommentar finns inte, vilket kan bero på att inlägget den var kopplad till har raderats",
"post_doesnt_exist": "Det här inlägget finns inte eller har raderats",
"incorrect_password": "Felaktigt Lösenord",
"rss_disabled": "Tyvärr, RSS är inaktiverat",
"atom_disabled": "Tyvärr, ATOM är inaktiverat",
"AI_consent": "Innehållet på denna webbplats får inte kopieras, skrapas eller användas för att träna AI-modeller eller stora språkmodeller (LLM) utan skriftligt samtycke.",
"rss_feed": "RSS-flöde",
"atom_feed": "ATOM-flöde",
"no_tags": "Inga taggar",
"new_post": "Nytt inlägg",
"edit_post": "Redigera inlägg",
"sign_up": "Registrera",
"edit_account": "Redigera konto",
"permalink": "Permalänk",
"written_by": "Skriven av",
"published": "Publicerad",
"last_modified": "Senast ändrad",
"hitcount": "Besökare",
"posts_tagged": "Taggade inlägg",
"home_page": "Startsida",
"site_index": "Webbplatsindex",
"reply": "Svara",
"attribution": "Drivs av blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Källkod</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>licens (WTFPL)</a>",
"translated_by": "pickzelle"
}

61
locales/template.jsonc Normal file
View File

@@ -0,0 +1,61 @@
{
"quotes": "“”‘’", // Single and Double quotes, according to https://github.com/markdown-it/markdown-it format
// Placeholders in form inputs!
"password": "Password",
"username": "Username",
"prettyname": "Prettyname",
"description": "Description (social links, what you write about etc), supports markdown", // Should explain what can be entered into the user description/bio
"title": "Title", // Post title
"post_content": "Post Content, supports markdown",
"tags": "Tags (comma seperated)", // An input field that allows you to enter a comma seperated list of tags like: 'sus,test,haha'
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)", // Should make it clear that all user data and posts will be deleted
"signup_agreement": "I agree to not post illegal or hateful content", // Should make it clear that you cannot post illegal or hateful content
"comment": "Comment",
"submit": "Sumbit",
"site_ran_by": "Site is ran by", // eg 'Site is ran by Bob', it shows up in the footer of each page
// Error messages, should just apologise and make it clear the error
"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",
// Disclaimer, not legally binding
"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.",
// Hyperlinks to pages and plain text that shows up on the website
"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", // A post is written/authored by x person
"published": "Published", // Published on this date
"last_modified": "Last Modified", // Last modified on this date
"hitcount": "Hitcount", // The number of views/hits/visits to a page, eg: 'hitcount: 53'
"posts_tagged": "Posts Tagged",
"home_page": "Home Page", // The main or default page, ie index.html
"site_index": "Site Index", // Or 'site map'
"reply": "reply", // Reply to a comment
// Attribution for the source code, don't change the URLs obviously, just the text within them.
"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>",
// Comma seperated list of people who contributed to this translation
"translated_by": "DeaDvey"
// TODO
// indexes locales
// Password again
// site_admin?
// Should colons be part of the translations?
}

4
package.json Executable file → Normal file
View File

@@ -7,10 +7,10 @@
"dependencies": { "dependencies": {
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"ejs": "^3.1.10", "ejs": "^3.1.10",
"express": "^5.1.0", "express": "^5.2.1",
"express-router": "^0.0.1", "express-router": "^0.0.1",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"mysql": "^2.18.1", "mssql": "^12.2.0",
"package.json": "^2.0.1" "package.json": "^2.0.1"
} }
} }

View File

@@ -1,56 +1,142 @@
import { createRequire } from "module"; import { createRequire } from "module";
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
const func = require('./functions.js')
const config = require("../config.json") const config = require("../config.json")
const fs = require("fs") const fs = require("fs")
export function getdata(data, index=-1) { // Literally just +1 to the hitcount
export function increment_hitcount(postID = -1) { // -1 Means it will increment the timeline hitcount
if (config.data_storage == 'json') {
if (postID == -1) {
let hitcount = getdata('hitcount');
hitcount += 1
writedata('hitcount', hitcount);
}
else {
let post = getdata('posts','id', postID)[0];
if (post == 1) // Does not exist
{
return 1
}
else if (typeof post.hitcount != 'undefined') {
post.hitcount += 1;
writedata('posts', post, postID)
return 0
}
else {
post.hitcount = 1;
writedata('posts', post, postID)
return 0
}
return 1
}
}
};
export function searchdata(term, type) { // Searches users and posts for any matches
let search_results = {"posts": [], "users": []};
// Search users
if (type.includes('post')) {
let list = getdata('posts');
list.forEach((element,index) => {
if (typeof element.deleted == 'undefined' || element.deleted == false) {
if (element.content.includes(term)) {
search_results.posts.push(element)
}
else if (element.title.includes(term)) {
search_results.posts.push(element)
}
else if (element.tags.toString().includes(term)) {
search_results.posts.push(element)
};
};
});
}
if (type.includes('user')) {
let list = getdata('users');
list.forEach((element,index) => {
if (typeof element.deleted == 'undefined' || element.deleted == false) {
if (element.username.includes(term)) {
search_results.users.push(element)
}
else if (element.prettyname.includes(term)) {
search_results.users.push(element)
}
else if (element.description.includes(term)) {
search_results.users.push(element)
};
};
});
}
return search_results;
};
export function getdata(table_name, key=-1, value=-1) {
let result = undefined
switch (config["data_storage"]) {
case 'json':
switch (table_name) {
case 'users':
case 'posts':
case 'comments':
result = func.require_module(`../data/${table_name}.json`)
if (key != -1) {
if (key == 'id')
{ // id is the index
if (value < result.length && value >= 0)
{
return [result[value]]
}
else
{
console.log("No object of this ID exists for the selected table")
return 1
}
}
let return_list = func.find_key_value_pair(result,key,value)
return return_list
}
return result
case 'hitcount':
result = func.require_module('../data/data.json') // This file is actually called data.json
return result["hitcount"]
break;
default:
console.log("Error, invalid requested")
return -1
break;
}
break;
default:
console.log("Error, invalid database management system")
return 1
}
}
export function writedata(data, data_to_write, index=-1) {
if (config["data_storage"] == "json") { if (config["data_storage"] == "json") {
if (data == "posts" || data == 'users' || data == 'comments') { if (data == "posts" || data == 'users' || data == 'comments') {
let result = require(`../data/${data}.json`) if (index == -1) {
if (index != -1) { fs.writeFileSync(`../data/${data}.json`, JSON.stringify(data_to_write), 'utf-8')
return result[index] return 0
} }
return result else if (index >= 0) {
let result = getdata(data);
result[index] = data_to_write;
fs.writeFileSync(`../data/${data}.json`, JSON.stringify(result), 'utf-8')
return 0
}
return 1
} }
else if (data == "other_data") { else if (data == "hitcount") {
let result = require('../data/data.json') // This file is actually called data.json let other_data = func.require_module('../data/data.json') // This file is actually called data.json
return result other_data.hitcount = data_to_write
fs.writeFileSync('../data/data.json', JSON.stringify(other_data), 'utf-8')
} }
else { else {
console.log("Error, invalid requested") console.log("Error, invalid requested")
return 1 return 1
} }
} }
if (config["data_storage"] == "mysql") {
const mysql = require('mysql');
let con = mysql.createConnection({
host: config.database.host,
user: config.database.user,
password: config.database.password,
database: config.database.database,
});
con.connect(function(err) {
if (err) throw err;
if (data == "posts" || data == 'users' || data == 'comments') {
con.query(`SELECT * FROM ${data}`, function (err, result, fields) {
if (err) throw err;
console.log(result)
return result;
});
}
else if (data == 'hitcount') {
con.query(`SELECT paramValue FROM params WHERE paramName = '${data}'`, function (err, result, fields) {
if (err) throw err;
console.log(result)
return result;
});
}
});
}
} }

View File

@@ -4,12 +4,29 @@ const config = require("../config.json")
const fs = require('fs') const fs = require('fs')
const locale = require(`../locales/${config.locale}.json`) const locale = require(`../locales/${config.locale}.json`)
// This function requires a module without caching it
// So the server doesn't need to be restarted, though this can slow it down a bit.
// https://stackoverflow.com/a/16060619
export function require_module(module)
{
if (config.cache_data == false)
{
delete require.cache[require.resolve(module)];
return require(module);
}
else
{
return require(module);
}
}
// The configuration defines a date format using the date-fns (a datetime library) syntax // The configuration defines a date format using the date-fns (a datetime library) syntax
// eg "yyyy-MM-dd" // eg "yyyy-MM-dd"
// this converts unix time (an integer) into a string that is formatted according to config.js // this converts unix time (an integer) into a string that is formatted according to config.js
// uses date-fns's fromUnixTime() and format() functions // uses date-fns's fromUnixTime() and format() functions
// returns the formatted date (string) // returns the formatted date (string)
export function unix_time_to_date_format(unix_time) { export function unix_time_to_date_format(unix_time)
{
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
let date = fromUnixTime(unix_time) let date = fromUnixTime(unix_time)
let formatted_date = format(date, config.date_format) let formatted_date = format(date, config.date_format)
@@ -20,14 +37,16 @@ export function unix_time_to_date_format(unix_time) {
// eg "Mon, 23 May 2025 18:59:59 +0100" // eg "Mon, 23 May 2025 18:59:59 +0100"
// accepts unix time (int) // accepts unix time (int)
// returns the formatted date (string) // returns the formatted date (string)
export function unix_time_to_rss_date(unix_time) { export function unix_time_to_rss_date(unix_time)
{
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
let date = fromUnixTime(unix_time) let date = fromUnixTime(unix_time)
let formatted_date = format(date, "EEE, dd MMM yyyy HH:mm:ss") let formatted_date = format(date, "EEE, dd MMM yyyy HH:mm:ss")
return `${formatted_date} ${config.time_zone}` return `${formatted_date} ${config.time_zone}`
} }
// And again with atom's date format // And again with atom's date format
export function unix_time_to_atom_date(unix_time) { export function unix_time_to_atom_date(unix_time)
{
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
let date = fromUnixTime(unix_time) let date = fromUnixTime(unix_time)
let formatted_date = format(date, "yyyy-MM-dd'T'HH:mm:ss'Z'") let formatted_date = format(date, "yyyy-MM-dd'T'HH:mm:ss'Z'")
@@ -38,41 +57,30 @@ export function unix_time_to_atom_date(unix_time) {
// eg "<a href="/tag/string1">string1</a>, <a href="/tag/string2">string2</a>, <a href="/tag/string3">string3</a>" // 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 // this is so you can have a list of tags that each point to their individual tag page
// returns: string // returns: string
export function render_tags(tags) { export function render_tags(tags_string)
{
let tags = tags_string.split(',')
tags = tags.filter((item, index) => tags.indexOf(item) === index) // Remove duplicate tags
let string = "" // Initialises the string let string = "" // Initialises the string
if (tags.length == 1 && tags[0] == "") { if (tags.length == 1 && tags[0] == "")
string = locale.no_tags; // If there are no tags, output something {
string = ''; // If there are no tags, output nothing
} }
else { else
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag {
string += `<a href="/tag/${tags[tag_index].trim()}">${tags[tag_index].trim()}</a>` // Adds the tag to the string as a HTML href for (let tag_index = 0; tag_index < tags.length; tag_index++)
if (tag_index < tags.length - 1) { // If there are more tags, then insert a comma { // Loop over each tag
string += ", "; string += `<a href="/tag/${tags[tag_index].trim()}">#${tags[tag_index].trim()}</a> ` // Adds the tag to the string as a HTML href
}
} }
} }
return string return string
} }
// The users are stored as a list of objects [ user_object, user_object, user_object ]
// So you cannot easily find the userID (position in list) from the username
// This function returns the username for a given userID by looping over every user
// if the user is present, it returns the index of the user (integer)
// if the user is not present it returns -1
export function get_userID(username) {
const users = require("../data/users.json")
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
}
}
return -1 // If user is not present, return -1
}
// This escapes some potentially dangerous HTML characters with their HTML entities // This escapes some potentially dangerous HTML characters with their HTML entities
// https://www.freeformatter.com/html-entities.html // https://www.freeformatter.com/html-entities.html
// accepts a string // accepts a string
// returns a string with some character replaced by their entities // returns a string with some character replaced by their entities
export function escape_input(input) { export function escape_input(input)
{
let output = input let output = input
.replaceAll("&", "&amp;") // This must be first .replaceAll("&", "&amp;") // This must be first
.replaceAll("<", "&lt;") .replaceAll("<", "&lt;")
@@ -86,8 +94,9 @@ export function escape_input(input) {
} }
// Render comment content by replacing the >> int with a url link to that comment // Render comment content by replacing the >> int with a url link to that comment
export function render_comment(comment_content) { // Syntax: ">> postID-commentID"
console.log(comment_content) export function render_comment(comment_content)
{
return comment_content return comment_content
.replaceAll(/>> ([0-9]*)-([0-9]*)/g, "<a href='/comment/$1-$2'>>> $1-$2</a>") .replaceAll(/>> ([0-9]*)-([0-9]*)/g, "<a href='/comment/$1-$2'>>> $1-$2</a>")
.replaceAll(/>>([0-9]*)-([0-9]*)/g, "<a href='/comment/$1-$2'>>>$1-$2</a>") .replaceAll(/>>([0-9]*)-([0-9]*)/g, "<a href='/comment/$1-$2'>>>$1-$2</a>")
@@ -96,9 +105,13 @@ export function render_comment(comment_content) {
.replaceAll("\n", "<br/>") .replaceAll("\n", "<br/>")
}; };
export function render_md(content) {
// Renders a string into markdown using markdown-it library
export function render_md(content)
{
const markdownit = require("markdown-it") const markdownit = require("markdown-it")
const md = markdownit({ const md = markdownit
({ // this is just defining some options for markdown-it, should I add this to config.json?
html: false, html: false,
xhtmlOut: false, xhtmlOut: false,
breaks: true, breaks: true,
@@ -106,15 +119,18 @@ export function render_md(content) {
typographer: true, typographer: true,
quotes: locale.quotes, quotes: locale.quotes,
}) })
.disable('image');
return md.render(content) return md.render(content)
}; };
// Literally just +1 to the hitcount // Returns a list of matches
export function increment_hitcount() { export function find_key_value_pair(data_array, key, value) {
if (config.data_storage == 'json') { let return_list = []
let other_data = require('../data/data.json'); for (let i = 0; i < data_array.length; i++) {
other_data.hitcount += 1 let element = data_array[i][key]
console.log(`/ Is loaded, hitcount: ${other_data.hitcount}`) if (element == value || (key == 'tags' && element.includes(value))) {
fs.writeFileSync(`../data/data.json`, `${JSON.stringify(other_data)}`, 'utf-8'); return_list.push(data_array[i])
} }
}
return return_list
}; };

View File

@@ -1,50 +0,0 @@
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
export function initialise() {
const fs = require("fs");
try {
const users = require("../data/users.json");
}
catch (error) {
console.log("Creating users file")
fs.writeFileSync(`../data/users.json`, `[]`)
}
try {
const posts = require("../data/posts.json");
}
catch (error) {
console.log("Creating posts file")
fs.writeFileSync(`../data/posts.json`, `[]`)
}
try {
const comments = require("../data/comments.json");
}
catch (error) {
console.log("Creating comments file")
fs.writeFileSync(`../data/comments.json`, `[]`)
}
try {
const comments = require("../data/data.json");
}
catch (error) {
console.log("Creating generic data file")
fs.writeFileSync(`../data/data.json`, `{"hitcount": 0, "comment_counter": 0}`)
}
try {
const config = require("../config.json");
}
catch (error) {
console.log("Copying the example config to config.js")
console.log("!!! PLEASE MODIFY config.json TO YOUR NEEDS !!!")
fs.copyFile('../example-config.json', '../config.json', (err) => {
console.log("Error copying file")
})
}
console.log("Successfully initialised")
process.exit(0)
}

View File

@@ -19,21 +19,24 @@ router.post("/submit_comment", (req,res) => {
const postID = parseInt(req.body.post_index) const postID = parseInt(req.body.post_index)
const content = func.escape_input(req.body.content) const content = func.escape_input(req.body.content)
let name = func.escape_input(req.body.name) let name = func.escape_input(req.body.name)
if (name == "") { // Give the user the default username if they left that bit blank
if (name == "" || typeof name == 'undefined') {
name = config.default_commenter_username name = config.default_commenter_username
} }
let comments = data.getdata('comments') // Check there is actually content in the comment
if (content != '' && typeof content != 'undefined') {
let comments = data.getdata('comments')
new_comment = { new_comment = {
"name": name, "name": name,
"content": content, "content": content,
"id": comments[postID].length, "id": comments[postID]['comments'].length,
"pubdate": unix_timestamp, "pubdate": unix_timestamp,
"postID": postID, };
}; comments[postID]['comments'].push(new_comment);
comments[postID].push(new_comment); fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8'); }
res.redirect(301,`/post/${req.body.post_index}`) res.redirect(301,`/post/${req.body.post_index}`)
}); // /submit_comment }); // /submit_comment
@@ -55,8 +58,9 @@ router.post("/submit_post", (req,res) => {
else if (users[func.get_userID(username)]['hash'] == password) { // Password matches else if (users[func.get_userID(username)]['hash'] == password) { // Password matches
console.log(username, "is submitting a post titled:", title); console.log(username, "is submitting a post titled:", title);
id = posts.length
posts.push({ posts.push({
"id": posts.length, "id": id,
"userID": func.get_userID(username), "userID": func.get_userID(username),
"title": title, "title": title,
"content": content, "content": content,
@@ -65,7 +69,7 @@ router.post("/submit_post", (req,res) => {
"tags": tags, "tags": tags,
}) })
fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8'); fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8');
comments.push([]) comments.push({'id': id, 'comments': []})
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`) fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`)
res.redirect(302, "/"); res.redirect(302, "/");
} }
@@ -200,4 +204,26 @@ router.post("/submit_edit_post", (req,res) => {
} }
}); // /submit_edit }); // /submit_edit
router.get('/search', (req, res) => {
const search_term = func.escape_input(req.query.q); // 'q' is the parameter name
let search_type = req.query.type; // eg 'post', 'user'
if (typeof search_type == 'string') { // Make the search_term an array
search_type = [ search_type ]
}
if (typeof search_type == 'undefined') { // Default to all of the types
search_type = ['user', 'post'];
}
console.log('searching for: ', search_term);
const search_results = data.searchdata(search_term, search_type); // data.searchdata returns an array of search results
res.render('pages/search', {
config,
locale,
search_results,
search_term,
search_type,
})
}); // /search
module.exports = router; module.exports = router;

View File

@@ -38,19 +38,19 @@ router.get(`${config.edit_account_base_url}/:user_id`, (req,res) => {
res.render("forms/edit_account", { res.render("forms/edit_account", {
config, config,
locale, locale,
user: users[userID], user: data.getdata('users', 'id', userID),
userID userID
}); });
}); // /delete_account }); // /delete_account
router.get(`${config.edit_post_base_url}/:post_id`, (req,res) => { router.get(`${config.edit_post_base_url}/:post_id`, (req,res) => {
const post_id = req.params.post_id const postID = req.params.post_id
const post = posts[post_id] const post = data.getdata('posts','id', postID)
const user = users[post['userID']] const user = data.getdata('users', 'id', post.userID)
res.render("forms/edit_post", { res.render("forms/edit_post", {
config, config,
locale, locale,
post, post,
post_id, postID,
user, user,
}); });
}); // /edit/:post_id }); // /edit/:post_id

View File

@@ -9,11 +9,11 @@ const router = express.Router();
router.get("/index/pages", (req,res) => { router.get("/index/pages", (req,res) => {
res.render("indexes/all_pages", { res.render("indexes/all_pages", {
config, config,
posts, posts: data.getdata('posts'),
users, users: data.getdata('users'),
comments: comments.comments, comments: data.getdata('comments'),
}); });
}); // /index/posts }); // /index/pages
router.get("/index/posts", (req,res) => { router.get("/index/posts", (req,res) => {
res.render("indexes/posts", { res.render("indexes/posts", {
config, config,
@@ -25,13 +25,13 @@ router.get("/index/users", (req,res) => {
config, config,
users: data.getdata('users'), users: data.getdata('users'),
}); });
}); // /index/posts }); // /index/users
router.get("/index/comments", (req,res) => { router.get("/index/comments", (req,res) => {
res.render("indexes/comments", { res.render("indexes/comments", {
config, config,
comments: data.getdata('comments'), comments: data.getdata('comments'),
}); });
}); // /index/posts }); // /index/comments
module.exports = router; module.exports = router;

View File

@@ -7,45 +7,48 @@ const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date util
const router = express.Router(); const router = express.Router();
///////////////////// Standard Pages ////////////////////// ///////////////////// Standard Pages //////////////////////
// Timeline
router.get("/", (req,res) => { router.get("/", (req,res) => {
let posts = data.getdata('posts')
// Increment the hitcount // Increment the hitcount
if (config.enable_hitcount) { if (config.enable_hitcount) {
func.increment_hitcount() data.increment_hitcount()
} }
res.render("pages/timeline", res.render("pages/timeline",
{ {
config, config,
locale, locale,
posts: data.getdata("posts"), posts,
users: data.getdata("users"), users: data.getdata("users"),
comments: data.getdata("comments"), comments: data.getdata("comments"),
hitcount: data.getdata("hitcount"), hitcount: data.getdata("hitcount"),
fromUnixTime, fromUnixTime,
format, format,
getUnixTime, getUnixTime,
func, func,
}) })
}); // / }); // /
// Users
router.get("/user/:username", (req, res) => { router.get("/user/:username", (req, res) => {
const userID = func.get_userID(req.params.username) let user = data.getdata('users', 'username', req.params.username)
let user = data.getdata('users', userID) if (user.length > 0) {
if (userID != -1) {
res.render("pages/user", res.render("pages/user",
{ {
config, config,
locale, locale,
posts: data.getdata('posts'), posts: data.getdata('posts','userID',user[0].id),
user, user: user[0],
userID: userID, comments: data.getdata('comments'),
comments: data.getdata('comments'), fromUnixTime,
fromUnixTime, format,
format, getUnixTime,
getUnixTime, func,
func, })
})
} }
else if (userID == -1) { else {
res.render("partials/message", res.render("partials/message",
{ {
message: locale.user_doesnt_exist, message: locale.user_doesnt_exist,
@@ -53,61 +56,76 @@ router.get("/user/:username", (req, res) => {
}) })
} }
}); // /user/:username }); // /user/:username
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 // Posts
router.get("/post/:post_index", (req, res) => {
const postID = parseInt(req.params.post_index)
let post = data.getdata('posts','id', postID)[0]
if (post.length == 0) { // data.getdata returns error code 1 if nothing is available
res.render("partials/message", { res.render("partials/message", {
message: locale.post_doesnt_exist, message: locale.post_doesnt_exist,
config, config,
}) })
} }
else if (typeof post["deleted"] == "undefined" || post["deleted"] == false) {
res.render("pages/post",
{
config,
locale,
post,
postID,
user: data.getdata('users', post.userID),
comments: data.getdata('comments', postID),
fromUnixTime,
format,
getUnixTime,
func,
})
}
else { else {
console.log("Error loading page") if (config.enable_hitcount) {
res.redirect(301,"/") data.increment_hitcount(postID)
}
res.render("pages/post",
{
config,
locale,
post,
postID,
user: data.getdata('users','id', post.userID)[0],
comments: data.getdata('comments','id', postID)[0]["comments"],
fromUnixTime,
format,
getUnixTime,
func,
})
} }
}); // /post/:post_index }); // /post/:post_index
// Tags
router.get("/tag/:tag", (req,res) => { router.get("/tag/:tag", (req,res) => {
const tag = req.params.tag const tag = req.params.tag
const posts = data.getdata('posts','tags',tag);
console.log(posts)
const users = data.getdata('users')
const comments = data.getdata('comments')
res.render("pages/tag", res.render("pages/tag",
{ {
config, config,
locale, locale,
tag, tag,
posts: data.getdata('posts'), posts,
users: data.getdata('users'), users,
comments: data.getdata('comments'), comments,
fromUnixTime, fromUnixTime,
format, format,
getUnixTime, getUnixTime,
func, func,
}) })
}); // /tag/:tag }); // /tag/:tag
router.get("/comment/:postID-:commentID", (req,res) => {
const commentID = req.params.commentID;
const postID = req.params.postID;
let posts_comments = data.getdata('comments', postID)
let comment = posts_comments[commentID] // Comments
if (comment == -1) { router.get("/comment/:postID-:commentID", (req,res) => {
const commentID = parseInt(req.params.commentID);
const postID = parseInt(req.params.postID);
let posts_comments = data.getdata('comments', 'id', postID)["comments"]
let comment = 1
// For loop to find the comment with matching ID
posts_comments.forEach((current_comment, index) => {
if (current_comment.id == commentID) {
comment = posts_comments[index]
}
})
// If comment doesn't exist, show error
if (comment == 1 || posts_comments == 1) { // Comment of this ID was not found
res.render("partials/message", { res.render("partials/message", {
config, config,
message: locale.comment_doesnt_exist, message: locale.comment_doesnt_exist,

View File

@@ -3,6 +3,8 @@ const config = require('../../config')
const data = require('../data') const data = require('../data')
const func = require('../functions') const func = require('../functions')
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
const router = express.Router(); const router = express.Router();
////////////////////// SYNDICATION //////////////////////// ////////////////////// SYNDICATION ////////////////////////
@@ -16,9 +18,10 @@ router.get("/rss", (req,res) => {
} }
else { else {
res.setHeader('content-type', 'application/rss+xml'); res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/global_rss", { res.render("syndication/rss", {
config, config,
posts: data.getdata('posts'), posts: data.getdata('posts'),
users: data.getdata('users'),
func, func,
}) })
}; };
@@ -26,7 +29,7 @@ router.get("/rss", (req,res) => {
// user RSS protocol gets // user RSS protocol gets
router.get("/user/:username/rss", (req,res) => { router.get("/user/:username/rss", (req,res) => {
const username = req.params.username; const username = req.params.username;
const userID = func.get_userID(username); const user = data.getdata('users', 'username', username);
if (config.rss == false) { if (config.rss == false) {
res.render("partials/message", { res.render("partials/message", {
message: locale.rss_disabled, message: locale.rss_disabled,
@@ -35,11 +38,11 @@ router.get("/user/:username/rss", (req,res) => {
} }
else { else {
res.setHeader('content-type', 'application/rss+xml'); res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/user_rss", { res.render("syndication/rss", {
config, config,
posts: data.getdata('posts'), posts: data.getdata('posts'),
users: user,
func, func,
userID,
}) })
}; };
}); });
@@ -56,6 +59,7 @@ router.get("/atom", (req,res) => {
res.render("syndication/global_atom", { res.render("syndication/global_atom", {
config, config,
posts: data.getdata('posts'), posts: data.getdata('posts'),
users: data.getdata('users'),
func, func,
getUnixTime, getUnixTime,
}) })
@@ -76,6 +80,7 @@ router.get("/user/:username/atom", (req,res) => {
res.render("syndication/user_atom", { res.render("syndication/user_atom", {
config, config,
posts: data.getdata('posts'), posts: data.getdata('posts'),
users: data.getdata('users'),
func, func,
userID, userID,
getUnixTime, getUnixTime,

View File

@@ -10,38 +10,8 @@ const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date util
const ejs = require("ejs") const ejs = require("ejs")
const func = require("./functions.js") const func = require("./functions.js")
const data = require("./data.js") const data = require("./data.js")
const init = require("./initialise.js")
// There's only one possible argument, so we can just check if the user passed that one
// TODO I plan on adding more such as --help and --post so I should make this more robust at some point
if (process.argv[2] == "--first-time") {
init.initialise() // Creates any files such users.js, posts.js, comments.js or config.js if they are not present
}
// Define the modules now so they are global
let users // contains a list of users, each user is an object containing username,prettyname,hash and description
let posts // contains a list of posts,
let comments // contains a list of comments
let config // contains a set of configuration for the site, see example-config.js for an example
config = require('../config.json'); config = require('../config.json');
if (config["data_storage"] == "json") {
try {
// We're going to try and import the modules,
users = require('../data/users.json');
posts = require('../data/posts.json');
comments = require('../data/comments.json');
}
catch (error) {
// if they don't all import then
// inform the user to pass --first-time and exit with an error code
console.log("A file is missing!")
console.log("Run with --first-time to initialise the program")
console.log(error)
process.exit(1)
}
}
// Import the locale // Import the locale
try { try {
@@ -74,6 +44,45 @@ app.use('/', standard_pages_routes);
app.use('/', forms_routes); app.use('/', forms_routes);
app.use('/', form_actions_routes); app.use('/', form_actions_routes);
function perform_checks()
{
console.log("Performing startup checks...")
exit_flag = false
required_values = ['site_admin','seperator','site_name','site_url','locale','port','cache_data','allow_signup','site_description','request_data_limit','enable_hitcount','charset','root_path','edit_account_base_url','new_post_url','signup_url','default_commenter_username','rss','atom','date_format','time_zone','css']
// Perform some standard checks:
// data_storage
switch (config.data_storage)
{
case 'mysql':
case 'json':
break
default:
console.log("[ ERROR ] invalid value in `data_storage`\nPlease modify config.json. Value should be 'mysql' or 'json'.")
exit_flag = true
}
// auto_generated
if (config.auto_generated)
{
console.log("[ ERROR ] `autogenerated` option set to true\nplease edit the config.json file to include your relevant information, then set to false or remove the autogenerated option.")
exit_flag = true
}
// Check required values are present
required_values.forEach((value) => { // Use a loop to check each required value is present
if (typeof config[value] == 'undefined') {
exit_flag = true
console.log(`[ ERROR ] \`${value}\` is undefined\nPlease set it to something, read the documentation for help.`)
}
});
if (exit_flag)
{
console.log("Exiting due to errors.")
process.exit(1)
}
}
perform_checks()
app.listen(config.port, () => { app.listen(config.port, () => {
console.log(`Server is running at http://localhost:${config.port} webroot: ${config.root_path}`); console.log(`Server is running at http://localhost:${config.port} webroot: ${config.root_path}`);
console.log("Running in: ", __dirname) console.log("Running in: ", __dirname)

View File

@@ -6,7 +6,7 @@
<body> <body>
<form action="/submit_edit_post" method="POST" onsubmit="sha512password()"> <form action="/submit_edit_post" method="POST" onsubmit="sha512password()">
<input name="userID" type="hidden" value="<%= post['userID'] %>"> <input name="userID" type="hidden" value="<%= post['userID'] %>">
<input name="postID" type="hidden" value="<%= post_id %>"> <input name="postID" type="hidden" value="<%= postID %>">
<label><%= locale.password %>:</label><br/> <label><%= locale.password %>:</label><br/>
<input type="password" required id="password" name="password"><br/><br/> <input type="password" required id="password" name="password"><br/><br/>

View File

@@ -1,5 +1,30 @@
<a href="/"><%= locale.home_page %></a> <a id='home-page-link' href="/"><%= locale.home_page %></a>
<a href="/index/pages"><%= locale.site_index %></a> /
<a href="<%= config.new_post_url %>"><%= locale.new_post %></a> <% if (config.rss == true) { %>
<a id='rss-link' href="/rss">
<img class='icon' src='/icons/rss.png' alt="<%= locale.rss_feed %>" title='<%= locale.rss_feed %>'>
</a>
<% } %>
<% if (config.atom == true) { %>
<a id='atom-link' href="/atom">
<img class='icon' src='/icons/atom.png' alt='<%= locale.atom_feed %>' title='<%= locale.atom_feed %>'>
</a>
<% } %>
/
<a id='new-post-link' href="<%= config.new_post_url %>"><%= locale.new_post %></a>
/
<% if (config.allow_signup == true) { %>
<a id='signup-link' href="<%= config.signup_url %>"><%= locale.sign_up %></a>
<% } %>
/
<form id='search-form' method="GET" action="/search" style="display: inline">
<input type="text" placeholder="🔍" name="q"><input type="submit" value="Search">
</form>
<br/> <br/>
<div id='site-name'>
<h1><a id='home-page-link' href="/"><%= config.site_name %></a></h1>
</div>
<div id='site-description'>
<h2><%- config.site_description %></h2>
</div>
<%- config.seperator %> <%- config.seperator %>

View File

@@ -1,4 +1,6 @@
<h1> <div id='tag-page-title'>
<%= locale.posts_tagged %>: "<%- tag %>" <h1>
</h1> #<%- tag %>
</h1>
</div>
<%- config.seperator %> <%- config.seperator %>

View File

@@ -1,20 +0,0 @@
<h1>
<%- config.site_name %>
</h1>
<h2>
<%- config.site_description %>
</h2>
<% 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) { %>
<%= locale.hitcount %>: <%= hitcount %>
<% } %>
<%- config.seperator %>

View File

@@ -1,8 +1,17 @@
<h1> <div id='user-page-title'>
<%= user.prettyname %> <h1>
</h1> <%= user.prettyname %>
<p><%# func.render_md(user.description) %></p> </h1>
<a href="<%= config.edit_account_base_url %>/<%= userID %>"><%= locale.edit_account %></a><br/> </div>
<a href="/user/<%= user.username %>/rss"><%= locale.rss_feed %></a><br/> <p><%- func.render_md(user.description) %></p>
<a href="/user/<%= user.username %>/atom"><%= locale.atom_feed %></a> <a if='edit-account-link' href="<%= config.edit_account_base_url %>/<%= user.id %>">
<img class='icon' src='/icons/edit.png' alt='<%= locale.edit_account %>' title='<%= locale.edit_account %>'>
</a>
|
<a id='rss-link' href="/user/<%= user.username %>/rss">
<img class='icon' src='/icons/rss.png' alt="<%= locale.rss_feed %>" title='<%= locale.rss_feed %>'>
</a>
<a id='atom-link' href="/user/<%= user.username %>/atom">
<img class='icon' src='/icons/atom.png' alt='<%= locale.atom_feed %>' title='<%= locale.atom_feed %>'>
</a>
<%- config.seperator %> <%- config.seperator %>

View File

@@ -20,8 +20,8 @@
<% }; %> <% }; %>
Comments:<br/> Comments:<br/>
<% for (let postID = 0; postID < comments.length; postID++) { %> <% for (let postID = 0; postID < comments.length; postID++) { %>
<% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %> <% for (let comment_index = 0; comment_index < comments[postID]['comments'].length; comment_index++) { %>
<a href="/comment/<%= comments[postID][comment_index]["id"] %>"><%= comments[postID][comment_index]["id"] %></a><br/> <a href="/comment/<%= postID %>-<%= comment_index %>"><%= postID %>-<%= comment_index %></a><br/>
<% }; %> <% }; %>
<% }; %> <% }; %>
Users:<br/> Users:<br/>
@@ -33,13 +33,13 @@
Edit Posts:<br/> Edit Posts:<br/>
<% for (let postID = 0; postID < posts.length; postID++) { %> <% for (let postID = 0; postID < posts.length; postID++) { %>
<% if (posts[postID]["deleted"] != true) { %> <% if (posts[postID]["deleted"] != true) { %>
<a href="/<%= config.edit_post_base_url %>/<%= postID %>">Edit <%= posts[postID]["title"] %></a><br/> <a href="<%= config.edit_post_base_url %>/<%= postID %>">Edit <%= posts[postID]["title"] %></a><br/>
<% }; %> <% }; %>
<% }; %> <% }; %>
Edit Users:<br/> Edit Users:<br/>
<% for (let userID = 0; userID < users.length; userID++) { %> <% for (let userID = 0; userID < users.length; userID++) { %>
<% if (users[userID]["deleted"] != true) { %> <% if (users[userID]["deleted"] != true) { %>
<a href="/<%= config.edit_account_base_url %>/<%= users[userID]["username"] %>">Edit <%= users[userID]["username"] %></a><br/> <a href="<%= config.edit_account_base_url %>/<%= users[userID]["username"] %>">Edit <%= users[userID]["username"] %></a><br/>
<% }; %> <% }; %>
<% }; %> <% }; %>
<!-- TODO add tags --> <!-- TODO add tags -->

View File

@@ -5,8 +5,8 @@
</head> </head>
<body> <body>
<% for (let postID = 0; postID < comments.length; postID++) { %> <% for (let postID = 0; postID < comments.length; postID++) { %>
<% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %> <% for (let comment_index = 0; comment_index < comments[postID]['comments'].length; comment_index++) { %>
<a href="/comment/<%= comments[postID][comment_index]["id"] %>"><%= comments[postID][comment_index]["id"] %></a><br/> <a href="/comment/<%= postID %>-<%= comment_index %>"><%= postID %>-<%= comment_index %></a><br/>
<% }; %> <% }; %>
<% }; %> <% }; %>
</body> </body>

View File

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

View File

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

37
views/pages/search.ejs Normal file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang='<%- config.locale %>'>
<head>
<%- include('../partials/head'); %>
</head>
<body>
<div id='site-header'>
<%- include('../headers/site_wide'); %>
</div>
<div id='advanced-search'>
<form method="GET" action="/search">
<label>Search Term:</label>
<input type='text' placeholder='🔍' name='q' value='<%- search_term %>'><br/>
<label>Search for:</label><br/>
<label>Post:</label>
<input type="checkbox" name="type" value="post" <% if (search_type.includes('post')) {%>checked<% } %>><br/>
<label>User:</label>
<input type="checkbox" name="type" value="user" <% if (search_type.includes('user')) {%>checked<% } %>><br/>
<input type="submit" value="Submit">
</form>
</div>
<%- config.seperator %>
<div id='results'>
<% search_results.posts.forEach((result, index) => { %>
<a href="/post/<%- result.id %>"><%- result.title %></a><br/>
<% }); %>
<% search_results.users.forEach((result, index) => { %>
<a href="/user/<%- result.username %>"><%- result.prettyname %></a><br/>
<% }); %>
</div>
</body>
</html>

View File

@@ -4,22 +4,18 @@
<%- include('../partials/head'); %> <%- include('../partials/head'); %>
</head> </head>
<body> <body>
<div id="header"> <header id="site-header">
<%- include('../headers/site_wide'); %> <%- include('../headers/site_wide'); %>
</header>
<header id='page-header'>
<%- include('../headers/tag'); %> <%- include('../headers/tag'); %>
</div> </header>
<div id="posts"> <div id="posts">
<% for (let index = posts.length - 1; index >= 0; index--) { %> <% for (let index = posts.length - 1; index >= 0; index--) { %>
<% if ( posts[index].deleted != true) { %> <%- include('../posts/tag', {post: posts[index], postID: index, user: users[posts[index].userID], comments: comments[index]}); %>
<% 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> </div>
<footer> <footer id='footer'>
<%- include('../partials/footer'); %> <%- include('../partials/footer'); %>
</footer> </footer>
</body> </body>

View File

@@ -4,25 +4,21 @@
<%- include('../partials/head'); %> <%- include('../partials/head'); %>
</head> </head>
<body> <body>
<div id="header"> <header id="site-header">
<%- include("../headers/site_wide") %> <%- include("../headers/site_wide") %>
</header>
<header id='page-header'>
<%- include('../headers/timeline'); %> <%- include('../headers/timeline'); %>
</div> </header>
<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"> <div id="posts">
<% for (let index = posts.length - 1; index >= 0; index--) { %> <% for (let index = posts.length - 1; index >= 0; index--) { %>
<% if (posts[index]["deleted"] != true) { %> <% if (posts[index]["deleted"] != true) { %>
<%- console.log(posts[index]) %>
<%- include('../posts/timeline', {post: posts[index], postID: index, user: users[posts[index].userID], comments: comments[index]}); %> <%- include('../posts/timeline', {post: posts[index], postID: index, user: users[posts[index].userID], comments: comments[index]}); %>
<% } %> <% } %>
<% } %> <% } %>
</div> </div>
<footer> <footer id='footer'>
<%- include('../partials/footer'); %> <%- include('../partials/footer'); %>
</footer> </footer>
</body> </body>

View File

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

View File

@@ -1,5 +1,13 @@
<b><%= comment.name %></b> <span id='comment-name'>
<%= func.unix_time_to_date_format(comment.pubdate) %> <b><%= comment.name %></b>
<a href='/comment/<%= postID %>-<%= comment.id %>'>No. <%= postID %>-<%= comment.id %></a>:<br/> </span>
<%- func.render_comment(comment.content) %> <span id='comment-date' class='date'>
<%= func.unix_time_to_date_format(comment.pubdate) %>
</span>
<span id='comment-id' style='display: inline'>
<a href='/comment/<%= postID %>-<%= comment.id %>'>No. <%= postID %>-<%= comment.id %></a>:<br/>
</span>
<span id='comment-content'>
<%- func.render_comment(comment.content) %>
</span>
<br/> <br/>

View File

@@ -1,3 +1,4 @@
<a id='site-index-link' href="/index/pages"><%= locale.site_index %></a><br/>
<%= locale.site_ran_by %> <%= config.site_admin %><br/> <%= locale.site_ran_by %> <%= config.site_admin %><br/>
<%- locale.attribution %><br/> <%- locale.attribution %><br/>
<%= locale.AI_consent %> <!-- remove consent for AI scrapers --> <%= locale.AI_consent %> <!-- remove consent for AI scrapers -->

View File

@@ -5,4 +5,5 @@
</style> </style>
<link rel="stylesheet" href="/default.css">
<link rel="stylesheet" href="/custom.css"> <link rel="stylesheet" href="/custom.css">

View File

@@ -1,31 +1,43 @@
<div id="post-header"> <div id="post-header">
<h1> <h2>
<%= post.title %> <a href='/post/<%= post['id'] %>'><%= post.title %></a>
</h1> </h2>
</div> </div>
<div id="post-tags">
<%- func.render_tags(post.tags) %><br/>
</div>
<div id="post-content"> <div id="post-content">
<p> <p>
<%- func.render_md(post.content) %><br/> <%- func.render_md(post.content) %><br/>
</p> </p>
</div> </div>
<div id="post-details"> <div id="post-details">
<div id="post-author"> <span id="post-author">
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i> <i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.prettyname %></a></i>
</div> </span>
<div id="post-tags"> -
<%- func.render_tags(post.tags) %><br/> <span id="post-pubdate">
</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/> <i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div> </span>
<div id="post-editdate"> <div id="post-editdate">
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/> <i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</div> </div>
<div id="post-edit">
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>">
<img class='icon' src='/icons/edit.png' alt='<%= locale.edit_post %>' title='<%= locale.edit_post %>'>
</a><br/>
</div>
<% if (config.enable_hitcount == true) { %>
<div id='post-hitcount'>
Hitcount: <%- post.hitcount %>
</div>
<% } %>
</div> </div>
<hr/>
<div id="post-commentform"> <div id="post-commentform">
<!-- Comment form --> <!-- Comment form -->
<form method="POST" action="/submit_comment"> <form method="POST" action="/submit_comment">
@@ -38,7 +50,7 @@
<div id="post-comments"> <div id="post-comments">
<% comments.forEach((comment, index) => { %> <% comments.forEach((comment, index) => { %>
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>"> <div id="comment-no-<%= post.id %>-<%= comment.id %>" class="comment post-comment-<%= index %>">
<%- include('../partials/comment', {comment: comment}) %> <%- include('../partials/comment', {comment: comment}) %>
</div> </div>
<% }) %> <% }) %>

View File

@@ -1,51 +1,32 @@
<div id="post-header"> <div id="post-header">
<h1> <h2>
<%= post.title %> <a href='/post/<%= post['id'] %>'><%= post.title %></a>
</h1> </h2>
</div> </div>
<div id="post-tags">
<%- func.render_tags(post.tags) %><br/>
</div>
<div id="post-content"> <div id="post-content">
<p> <p>
<%- func.render_md(post.content) %><br/> <%- func.render_md(post.content) %>
</p> </p>
</div> </div>
<div id="post-details"> <div id="post-details">
<div id="post-author"> <span id="post-author">
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i> <i><a href="/user/<%= user.username %>"><%= user.prettyname %></a></i>
</div> </span>
<div id="post-permalink"> -
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/> <span id="post-pubdate">
</div> <i><%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
<div id="post-tags"> </span>
<%- func.render_tags(post.tags) %><br/> <br/>
</div>
<div id="post-edit"> <div id="post-edit">
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/> <a href="<%= config.edit_post_base_url %>/<%= post["id"] %>">
<img class='icon' src='/icons/edit.png' alt='<%= locale.edit_post %>' title='<%= locale.edit_post %>'>
</a><br/>
</div> </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> </div>
<%- config.seperator %> <%- config.seperator %>

View File

@@ -1,51 +1,36 @@
<div id="post-header"> <div id="post-header">
<h1> <h2>
<%= post.title %> <a href='/post/<%= post['id'] %>'><%= post.title %></a>
</h1> </h2>
</div> </div>
<div id="post-tags">
<%- func.render_tags(post.tags) %><br/>
</div>
<div id="post-content"> <div id="post-content">
<p> <p>
<%- func.render_md(post.content) %><br/> <%- func.render_md(post.content) %>
</p> </p>
</div> </div>
<div id="post-details"> <div id="post-details">
<div id="post-author"> <span id="post-author">
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i> <i><a href="/user/<%= user.username %>"><%= user.prettyname %></a></i>
</div> </span>
<div id="post-permalink"> -
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/> <a if='edit-account-link' href="<%= config.edit_account_base_url %>/<%= user.id %>">
</div> <img class='icon' src='/icons/edit.png' alt='<%= locale.edit_account %>' title='<%= locale.edit_account %>'>
<div id="post-tags"> </a>
<%- func.render_tags(post.tags) %><br/> -
</div> <span id="post-pubdate">
<i><%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</span>
<br/>
<div id="post-edit"> <div id="post-edit">
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/> <a href="<%= config.edit_post_base_url %>/<%= post["id"] %>">
<img class='icon' src='/icons/edit.png' alt='<%= locale.edit_post %>' title='<%= locale.edit_post %>'>
</a><br/>
</div> </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> </div>
<%- config.seperator %> <%- config.seperator %>

View File

@@ -1,48 +1,32 @@
<div id="post-header"> <div id="post-header">
<h1> <h2>
<%= post.title %> <a href='/post/<%= post['id'] %>'><%= post.title %></a>
</h1> </h2>
</div> </div>
<div id="post-tags">
<%- func.render_tags(post.tags) %><br/>
</div>
<div id="post-content"> <div id="post-content">
<p> <p>
<%- func.render_md(post.content) %><br/> <%- func.render_md(post.content) %>
</p> </p>
</div> </div>
<div id="post-details"> <div id="post-details">
<div id="post-permalink"> <span id="post-author">
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/> <i><a href="/user/<%= user.username %>"><%= user.prettyname %></a></i>
</div> </span>
<div id="post-tags"> -
<%- func.render_tags(post.tags) %><br/> <span id="post-pubdate">
</div> <i><%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
</span>
<br/>
<div id="post-edit"> <div id="post-edit">
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/> <a href="<%= config.edit_post_base_url %>/<%= post["id"] %>">
<img class='icon' src='/icons/edit.png' alt='<%= locale.edit_post %>' title='<%= locale.edit_post %>'>
</a><br/>
</div> </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> </div>
<%- config.seperator %> <%- config.seperator %>

View File

@@ -0,0 +1,23 @@
<?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_date_format(getUnixTime(new Date()),"yyyy-MM-dd'T'HH:mm:ss'Z'") %></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[<%- (posts[postID]["content"]) %>]]></summary>
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
<pubDate><%- func.unix_time_to_date_format(posts[postID]['pubdate'],"yyyy-MM-dd'T'HH:mm:ss'Z'") %></pubDate>
<% tags = posts[postID]['tags'].split(',') %>
<% for (let tag_index = 0; tag_index < tags.length; tag_index++) { %>
<category><![CDATA[<%= tags[tag_index] %>]]></category>
<% } %>
</entry>
<% } %>
<% } %>
</feed>

View File

@@ -1,22 +0,0 @@
<?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

@@ -1,22 +0,0 @@
<?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]["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>

23
views/syndication/rss.ejs Normal file
View File

@@ -0,0 +1,23 @@
<rss version="2.0">
<channel>
<title><%= config.site_name %></title>
<link><%= config.site_url %></link>
<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[<%- (posts[postID]["content"]) %>]]></description>
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
<pubDate><%= func.unix_time_to_date_format(posts[postID]['pubdate'],'EEE, dd MMM yyyy HH:mm:ss') %></pubDate>
<author><%= users[posts[postID]['userID']]['prettyname'] %></author>
<% tags = posts[postID]['tags'].split(',') %>
<% for (let tag_index = 0; tag_index < tags.length; tag_index++) { %>
<category><![CDATA[<%= tags[tag_index] %>]]></category>
<% } %>
</item>
<% } %>
<% } %>
</channel>
</rss>

View File

@@ -1,24 +0,0 @@
<?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

@@ -1,24 +0,0 @@
<?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>

73
webroot/default.css Normal file
View File

@@ -0,0 +1,73 @@
body {
max-width: 900px;
margin: auto;
}
#site-header {
margin-top: 10px;
text-align: center;
}
#footer {
margin-bottom: 10px;
}
.icon {
width: 15px;
}
input, textarea, button {
border: none;
border-radius: 5px;
font-size: 20px;
}
textarea {
width: 100%;
height: 250px;
field-sizing: content; /* Only supported by Chromium */
}
a {
text-decoration: none;
}
#search-form input {
border: none;
border-radius: 0px;
font-size: 14px;
}
}
a:hover {
text-decoration: underline;
}
@media (prefers-color-scheme: dark) {
body {
background-color: #333333;
color: #ffffff;
}
a {
color: #546BEB;
}
a:visited {
color: #EF46F1;
}
input, textarea, button {
background-color: #1E1E1E;
color: #ffffff;
}
hr {
color: white;
}
.comment:nth-child(even) {
background: #1E1E1E;
}
}
@media (prefers-color-scheme: light) {
input, textarea, button {
background-color: #DEDEDE;
color: #000000;
}
hr {
color: black;
}
.comment:nth-child(even) {
background: #EEEEEE;
}
}

BIN
webroot/icons/atom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

BIN
webroot/icons/edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

BIN
webroot/icons/rss.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B