Compare commits
34 Commits
0c43c7315c
...
master
Author | SHA1 | Date | |
---|---|---|---|
e3e5469e1a | |||
c8af978259 | |||
99e07389d0 | |||
532010f873 | |||
5917789c5b | |||
4f0941262e | |||
27b9ee6437 | |||
c73ce69f93 | |||
5bd0429ae2 | |||
6e583d1410 | |||
cf784a1a99 | |||
b3ea048244 | |||
9b5d3f3f73 | |||
5f07db1e15 | |||
d298717519 | |||
0b25fb221b | |||
f85c4aa893 | |||
6fc1f85e18 | |||
8418318d80 | |||
44a060508b | |||
49c7fc7cdf | |||
144c276bc9 | |||
df4bc99d9a | |||
3e2a63bfd7 | |||
bced9c7c0e | |||
f723e37732 | |||
8b9ddcf048 | |||
5f2aba0c2b | |||
cdfc5f2c30 | |||
88b198365d | |||
b683b658f7 | |||
0cc319a702 | |||
72316094e4 | |||
47877e71d4 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ users.json
|
||||
config.json
|
||||
hitcount.txt
|
||||
*.swp
|
||||
webroot/
|
||||
|
48
README.md
48
README.md
@@ -9,47 +9,43 @@ beautiful and featureful blogging frontend, this isn't for you.<br/>
|
||||
|
||||
See the software in action: [deadvey.com](https://deadvey.com)<br/>
|
||||
|
||||
# Installation and Running:
|
||||
Read the [installation guide](/docs/INSTALLATION.md)
|
||||
|
||||
# Confiuration
|
||||
# Confiuration:
|
||||
Read the [configuation guide](docs/CONFIG.md) for configuration help (in config.json)
|
||||
|
||||
# Features
|
||||
* post creation via the web frontend (no need to remote to your server to make a post)
|
||||
# Features:
|
||||
* post creation, modification and deletion via frontend
|
||||
* user creation, modification and deletion via frontend
|
||||
* multi user
|
||||
* powerful customisation
|
||||
* rss
|
||||
* timeline, user page, post page and tag specific page
|
||||
* edit/delete posts
|
||||
* powerful customisation via EJS
|
||||
* site wide and user specific rss, atom
|
||||
* hitcount
|
||||
* Markdown syntax in posts
|
||||
* Commenting on posts
|
||||
* sign up and delete account
|
||||
* ejs
|
||||
* custom CSS _file_
|
||||
* Commenting on posts and replying to other comments
|
||||
* site wide custom CSS
|
||||
* Page indexes
|
||||
|
||||
# Bugs
|
||||
# Bugs:
|
||||
* probably scales like shit
|
||||
* probably insecure as hell
|
||||
|
||||
# Planned features/todo list
|
||||
* user specific RSS feeds
|
||||
* atom
|
||||
# Planned features/todo list:
|
||||
* federation (looks tricky)
|
||||
* All strings (including in edit and post page) customisable
|
||||
* formatable custom strings
|
||||
* inline comments and docs
|
||||
* clean up code a bit
|
||||
* comment pages?
|
||||
* /postID and /userID pages
|
||||
* site index
|
||||
* Make EJS modification more user friendly
|
||||
* API for returning posts, users, comments, tags other?...
|
||||
|
||||
TODO (not finished)
|
||||
# EJS variable names
|
||||
* config.variable_name - pass any variable in config.json
|
||||
* hitcount - value in hitcount.txt (a single number)
|
||||
## Posts (/views/posts/)
|
||||
* post - an object that includes the data for that post, eg post.title, post.content etc
|
||||
* user - the object of the user who posted this
|
||||
* index - an int that refers to the index of the current post
|
||||
## Comments (/views/partials/comment.ejs)
|
||||
* comment - an object storing the comment, eg comment.name, comment.content
|
||||
# Docs:
|
||||
See [docs/DOCUMENTATION.md](docs/DOCUMENTATION.md)
|
||||
|
||||
# Customisation:
|
||||
Customisation of settings can be done via the config.json file (use example-config.json as an example) and see [the configuration guide](docs/CONFIG.md)<br/>
|
||||
Additionaly, more complex configuration of the precise template of the whole site, can be done via [EJS](https://ejs.co/) (in /views) (see [the list of things variables and functions available in EJS](docs/EJS.md) (you will need to understand EJS syntax and JavaScript, to customise this (why did I use EJS? well I originally had this weird system of format indicators with percent (%) signs and stuff (like in unix's date (`date`)) but then I was told EJS is better and it sure is, though it is a bit harder to understand but MUCH more powerful!))
|
||||
Also, if you want to change any of the strings on the website, please modify or create a new, customised locale in /locales
|
||||
|
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"seperator": "<hr/>",
|
||||
"site_name": "My Blog",
|
||||
"site_url": "https://example.com",
|
||||
"language": "en",
|
||||
"port": 8080,
|
||||
"allow_signup": true,
|
||||
"site_description": "Read my blogs!",
|
||||
"timeline_length": 20,
|
||||
"enable_hitcount": true,
|
||||
"charset": "UTF-8",
|
||||
"root_path": "/home/deadvey/code/web/blogger-webroot/",
|
||||
"edit_account_base_url": "/edit_account",
|
||||
"new_post_url": "/post",
|
||||
"signup_url": "/signup",
|
||||
"edit_post_base_url": "/edit",
|
||||
"default_comenter_username": "Anon",
|
||||
"rss": true,
|
||||
"atom": true,
|
||||
"date_format": "yyyy-MM-dd",
|
||||
"time_zone": "+0000",
|
||||
"string": {
|
||||
"signup_agreement": "I agree to not post illegal or hateful content",
|
||||
"signups_unavailable": "Sorry, this server does not allow signups",
|
||||
"user_exists": "Sorry, this user already exists, try a different username",
|
||||
"user_doesnt_exist": "Sorry, this user does not exist",
|
||||
"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": ""
|
||||
}
|
4
docs/CLASSES_AND_IDS.md
Normal file
4
docs/CLASSES_AND_IDS.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Post:
|
||||
|
||||

|
||||
|
@@ -5,43 +5,37 @@ Currently all values in example-config.json are required, however I plan to add
|
||||
All options show an example configuartion value and the variable type + an explaination below it.<br/>
|
||||
|
||||
## Technical configuration
|
||||
* "site_url": "https://example.com"<br/>
|
||||
This value defines the url of your site, this used for the RSS feed to link back to post.
|
||||
* "port": 8080<br/>
|
||||
Integer. This value defines the port that you run the blog on. Don't change this value if you don't know what that means.
|
||||
* "allow_signup": true<br/>
|
||||
Boolean. Defines weather new people should be allowed to signup.
|
||||
* "timeline_length": 20<br/>
|
||||
Integer. How many posts will be shown on the timeline (home page).
|
||||
* "enable_hitcount": true<br/>
|
||||
Boolean. Enabling the hitcount (a number that represents the amount of front page loads (stored in hitcount.txt)) can slightly slow down loading of the front page.
|
||||
* "charset": "UTF-8"<br/>
|
||||
String. This is the value in the <meta charset=""> tag in the html of all pages, you should not change this unless you know why.
|
||||
* "root_path": "/path/to/root/of/website"
|
||||
String. Anything in this directory will be in the webroot, so put favicon.ico and anything else here.
|
||||
| name | example value | variable type | explanation |
|
||||
|-----------------|----------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| site_url | "https://example.com" | String | This value defines the url of your site, this used for the RSS feed to link back to post. |
|
||||
| port | 8080 | Integer | This value defines the port that you run the blog on. Don't change this value if you don't know what that means. |
|
||||
| allow_signup | true | Boolean | Defines weather new people should be allowed to signup. |
|
||||
| timeline_length | 20 | Integer | How many posts will be shown on the timeline (home page). |
|
||||
| enable_hitcount | true | Boolean | Enabling the hitcount (a number that represents the amount of front page loads (stored in hitcount.txt)) can slightly slow down loading of the front page. |
|
||||
| charset | "UTF-8" | String | This is the value in the <meta charset=""> tag in the html of all pages, you should not change this unless you know why. |
|
||||
| root_path | "/path/to/root/of/website" | String | Anything in this directory will be in the webroot, so put favicon.ico and anything else here. |
|
||||
|
||||
## Basic Customisation
|
||||
* "seperator": "\<hr/\>"<br/>
|
||||
String. This is what %S represents in the formatting, this will go inbetween posts and generally to seperate out content on pages.
|
||||
* "site_name": "My Blog"<br/>
|
||||
String. This is what %Y represents; it's the name of your instance, a human readable string.
|
||||
* "site_description": "Read my blogs!"
|
||||
String. This is what %W represents; it's the description of your instance, a human readable string.
|
||||
* "default_commenter_username": "Anon"
|
||||
String. Default commenter username if no username is inputted in comment submission.
|
||||
| name | example value | variable type | explanation |
|
||||
|-----------------|----------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|locale|"en"|String|Your locale, see [/locales](/locales) for a list of all locales (you can open a PR for a new translation too)|
|
||||
|seperator|"\<hr/\>"|String|This is what %S represents in the formatting, this will go inbetween posts and generally to seperate out content on pages.|
|
||||
|site_name|"My Blog"|String|This is what %Y represents; it's the name of your instance, a human readable string.|
|
||||
|site_description|"Read my blogs!"|String|This is what %W represents; it's the description of your instance, a human readable string.|
|
||||
|default_commenter_username|"Anon"|String|Default commenter username if no username is inputted in comment submission.|
|
||||
|
||||
## Syndication
|
||||
* "rss": true<br/>
|
||||
Boolean. Enable or Disable RSS feeds.
|
||||
* "rss_path": "/rss"<br/>
|
||||
String. The path of the global rss feed file.
|
||||
| name | example value | variable type | explanation |
|
||||
|------|---------------|---------------|-------------------------------|
|
||||
| rss | true | Boolean | Enable or Disable RSS feeds. |
|
||||
| atom | true | Boolean | Enable or Disable ATOM feeds. |
|
||||
|
||||
## Dates
|
||||
Read more at [date-fns](https://date-fns.org/v4.1.0/docs/format)<br/>
|
||||
* "date_format": "yyyy-MM-dd"<br/>
|
||||
String. The format of date's on the website.
|
||||
* "time_zone": "+0000"<br/>
|
||||
String. Your offset from UTC
|
||||
| name | example value | variable type | explanation |
|
||||
|------|---------------|---------------|-------------------------------|
|
||||
|date_format|"yyyy-MM-dd"|String|The format of date's on the website.|
|
||||
|time_zone|"+0000"|String|\Your offset from UTC|
|
||||
|
||||
## Advanced Customisation
|
||||
* /views/* files are EJS files (used for formatting HTML) and can be editted to your liking, you might want to read [the EJS docs](https://ejs.co/#docs) for help.
|
||||
@@ -50,20 +44,4 @@ Read more at [date-fns](https://date-fns.org/v4.1.0/docs/format)<br/>
|
||||
You can also edit the custom.css file in the webroot, as by default this is linked in the global header.
|
||||
|
||||
## Custom Strings
|
||||
All of these values are of type String
|
||||
* "signup_agreement": "I agree to not post illegal or hateful content"<br/>
|
||||
The agreement people must check to signup for the server.
|
||||
* "signups_unavailable": "Sorry, this server does not allow signups"<br/>
|
||||
The string to be displayed if the user tries to signup when signup's are disabled.
|
||||
* "user_exists": "Sorry, this user already exists, try a different username"<br/>
|
||||
The string to be shown when someone is trying to signup with a name exists.
|
||||
* "user_doesnt_exist": "Sorry, this user does not exist"<br/>
|
||||
The string to be shown when someone tries to edit their account or make a post but the username doesn't exist.
|
||||
* "delete_account_confirmation": "I agree that my account and all of my posts will be permanently deleted instantly"<br/>
|
||||
The string to be shown as a confirmation when a user tries to delete their account.
|
||||
* "incorrect_password": "Incorrect Password"<br/>
|
||||
The string to be shown if the password is incorrect.
|
||||
|
||||
## Other
|
||||
* "attribution" = "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
|
||||
String. Represented by format indicator %Z. Only change this value if you modify the source code or just want to change some of the formatting.
|
||||
* You can edit all the strings on the site in /locales/<your-locale>.json
|
||||
|
1
docs/CONTRIBUTING.md
Normal file
1
docs/CONTRIBUTING.md
Normal file
@@ -0,0 +1 @@
|
||||
Just open a PR or something, if it's good I'll pull
|
4
docs/DOCUMENTATION.md
Normal file
4
docs/DOCUMENTATION.md
Normal file
@@ -0,0 +1,4 @@
|
||||
All documentation is under construction as the program is also under construction and so is constantly changing and is also a mess and I'm shit at documentation
|
||||
- [EJS Variables and functions](EJS.md)
|
||||
- [configuring config.json](CONFIG.md)
|
||||
- [Contributing](CONTRIBUTING.md)
|
27
docs/EJS.md
Normal file
27
docs/EJS.md
Normal file
@@ -0,0 +1,27 @@
|
||||
This is not a guide on how EJS works, look at [EJS's website](https://ejs.co/) for that!<br/>
|
||||
This is just a list of functions and pieces of information provided to each EJS file.<br/>
|
||||
<br/>
|
||||
# syndication/global_rss:
|
||||
- All config.json data
|
||||
- All posts from posts.json
|
||||
- showdown.JS's converter functions
|
||||
- All functions in functions.js
|
||||
# syndication/user_rss:
|
||||
- All config.json data
|
||||
- All posts from posts.json
|
||||
- showdown.JS's converter functions
|
||||
- All functions in functions.js
|
||||
- the userID of the user in question (integer)
|
||||
# syndication/global_atom:
|
||||
- All config.json data
|
||||
- All posts from posts.json
|
||||
- showdown.JS's converter functions
|
||||
- All functions in functions.js
|
||||
- getUnixTime function from date-fns
|
||||
# syndication/user_atom:
|
||||
- All config.json data
|
||||
- All posts from posts.json
|
||||
- showdown.JS's converter functions
|
||||
- All functions in functions.js
|
||||
- the userID of the user in question (integer)
|
||||
- getUnixTime function from date-fns
|
12
docs/INSTALLATION.md
Normal file
12
docs/INSTALLATION.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Installation
|
||||
This program is currently just ran manually.<br/>
|
||||
All you need to do is clone the git repository:<br/>
|
||||
```git clone https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs.git```<br/>
|
||||
Then navigate to /src:<br/>
|
||||
```cd src```<br/>
|
||||
Then run the initialisation function:<br/>
|
||||
```node server.js --first-time```<br/>
|
||||
Then you should modify config.json in / to suit your needs.<br/>
|
||||
# Running
|
||||
I would reccomend running the program in tmux so it does not stop running when you close the terminal window.<br/>
|
||||
• There is currently no init system support. I might add this later (or you could open a PR).
|
BIN
docs/images/post-css.png
Normal file
BIN
docs/images/post-css.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 239 KiB |
@@ -1,15 +1,16 @@
|
||||
{
|
||||
"site_admin": "your name",
|
||||
"seperator": "<hr/>",
|
||||
"site_name": "My Blog",
|
||||
"site_url": "https://example.com",
|
||||
"language": "en",
|
||||
"language": "en-US",
|
||||
"port": 8080,
|
||||
"allow_signup": true,
|
||||
"site_description": "Read my blogs!",
|
||||
"timeline_length": 20,
|
||||
"enable_hitcount": true,
|
||||
"charset": "UTF-8",
|
||||
"root_path": "/path/to/blogger-webroot",
|
||||
"root_path": "/path/to/webroot",
|
||||
"edit_account_base_url": "/edit_account",
|
||||
"new_post_url": "/post",
|
||||
"signup_url": "/signup",
|
||||
@@ -24,7 +25,9 @@
|
||||
"signups_unavailable": "Sorry, this server does not allow signups",
|
||||
"user_exists": "Sorry, this user already exists, try a different username",
|
||||
"user_doesnt_exist": "Sorry, this user does not exist",
|
||||
"delete_account_confirmation": "I agree that my account and all of my posts will be permanently deleted instantly",
|
||||
"comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted",
|
||||
"post_doesnt_exist": "This post doesn't exist or was deleted",
|
||||
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
|
||||
"incorrect_password": "Incorrect Password",
|
||||
"rss_disabled": "Sorry, RSS is disabled",
|
||||
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
|
||||
|
42
locales/en-GB.json
Normal file
42
locales/en-GB.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"quotes": "“”‘’",
|
||||
"password": "Password",
|
||||
"username": "Username",
|
||||
"prettyname": "Prettyname",
|
||||
"description": "Description (social links, what you write about etc), supports markdown",
|
||||
"title": "Title",
|
||||
"post_content": "Post Content, supports markdown",
|
||||
"tags": "Tags (comma seperated)",
|
||||
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
|
||||
"signup_agreement": "I agree to not post illegal or hateful content",
|
||||
"comment": "Comment",
|
||||
"submit": "Sumbit",
|
||||
|
||||
"site_ran_by": "Site is ran by",
|
||||
"signups_unavailable": "Sorry, this server does not allow signups",
|
||||
"user_exists": "Sorry, this user already exists, try a different username",
|
||||
"user_doesnt_exist": "Sorry, this user does not exist",
|
||||
"comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted",
|
||||
"post_doesnt_exist": "This post doesn't exist or was deleted",
|
||||
"incorrect_password": "Incorrect Password",
|
||||
"rss_disabled": "Sorry, RSS is disabled",
|
||||
"atom_disabled": "Sorry, ATOM is disabled",
|
||||
"AI_consent": "The content on this website may not be copied, scraped, or used to train AI models or large language models (LLMs) without prior written consent.",
|
||||
|
||||
"rss_feed": "RSS Feed",
|
||||
"atom_feed": "ATOM Feed",
|
||||
"no_tags": "No Tags",
|
||||
"new_post": "New Post",
|
||||
"edit_post": "Edit Post",
|
||||
"sign_up": "Sign Up",
|
||||
"edit_account": "Edit Account",
|
||||
"permalink": "Permalink",
|
||||
"written_by": "Written by",
|
||||
"published": "Published",
|
||||
"last_modified": "Last Modified",
|
||||
"hitcount": "Hitcount",
|
||||
"posts_tagged": "Posts Tagged",
|
||||
"home_page": "Home Page",
|
||||
"site_index": "Site Index",
|
||||
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
|
||||
}
|
42
locales/en-US.json
Normal file
42
locales/en-US.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"quotes": "“”‘’",
|
||||
"password": "Password",
|
||||
"username": "Username",
|
||||
"prettyname": "Prettyname",
|
||||
"description": "Description (social links, what you write about etc), supports markdown",
|
||||
"title": "Title",
|
||||
"post_content": "Post Content, supports markdown",
|
||||
"tags": "Tags (comma seperated)",
|
||||
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
|
||||
"signup_agreement": "I agree to not post illegal or hateful content",
|
||||
"comment": "Comment",
|
||||
"submit": "Sumbit",
|
||||
|
||||
"site_ran_by": "Site is ran by",
|
||||
"signups_unavailable": "Sorry, this server does not allow signups",
|
||||
"user_exists": "Sorry, this user already exists, try a different username",
|
||||
"user_doesnt_exist": "Sorry, this user does not exist",
|
||||
"comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted",
|
||||
"post_doesnt_exist": "This post doesn't exist or was deleted",
|
||||
"incorrect_password": "Incorrect Password",
|
||||
"rss_disabled": "Sorry, RSS is disabled",
|
||||
"atom_disabled": "Sorry, ATOM is disabled",
|
||||
"AI_consent": "The·content·on·this·website·may·not·be·copied,·scraped,·or·used·to·train·AI·models·or·large·language·models·(LLMs)·without·prior·written·consent.",
|
||||
|
||||
"rss_feed": "RSS Feed",
|
||||
"atom_feed": "ATOM Feed",
|
||||
"no_tags": "No Tags",
|
||||
"new_post": "New Post",
|
||||
"edit_post": "Edit Post",
|
||||
"sign_up": "Sign Up",
|
||||
"edit_account": "Edit Account",
|
||||
"permalink": "Permalink",
|
||||
"written_by": "Written by",
|
||||
"published": "Published",
|
||||
"last_modified": "Last Modified",
|
||||
"hitcount": "Hitcount",
|
||||
"posts_tagged": "Posts Tagged",
|
||||
"home_page": "Home Page",
|
||||
"site_index": "Site Index",
|
||||
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
|
||||
}
|
39
locales/template.json
Normal file
39
locales/template.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"quotes": "“”‘’",
|
||||
"password": "Password",
|
||||
"username": "Username",
|
||||
"prettyname": "Prettyname",
|
||||
"description": "Description (social links, what you write about etc), supports markdown",
|
||||
"title": "Title",
|
||||
"post_content": "Post Content, supports markdown",
|
||||
"tags": "Tags (comma seperated)",
|
||||
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
|
||||
"signup_agreement": "I agree to not post illegal or hateful content",
|
||||
"comment": "Comment",
|
||||
"submit": "Sumbit",
|
||||
|
||||
"signups_unavailable": "Sorry, this server does not allow signups",
|
||||
"user_exists": "Sorry, this user already exists, try a different username",
|
||||
"user_doesnt_exist": "Sorry, this user does not exist",
|
||||
"comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted",
|
||||
"post_doesnt_exist": "This post doesn't exist or was deleted",
|
||||
"incorrect_password": "Incorrect Password",
|
||||
"rss_disabled": "Sorry, RSS is disabled",
|
||||
"atom_disabled": "Sorry, ATOM is disabled",
|
||||
|
||||
"rss_feed": "RSS Feed",
|
||||
"atom_feed": "ATOM Feed",
|
||||
"new_post": "New Post",
|
||||
"edit_post": "Edit Post",
|
||||
"sign_up": "Sign Up",
|
||||
"edit_account": "Edit Account",
|
||||
"permalink": "Permalink",
|
||||
"written_by": "Written by",
|
||||
"published": "Published",
|
||||
"last_modified": "Last Modified",
|
||||
"hitcount": "Hitcount",
|
||||
"posts_tagged": "Posts Tagged",
|
||||
"home_page": "Home Page",
|
||||
"site_index": "Site Index",
|
||||
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
|
||||
}
|
@@ -1,8 +1,13 @@
|
||||
{
|
||||
"name": "blogger-nodejs",
|
||||
"version": "0.0.5",
|
||||
"description": "Simple web logging backend",
|
||||
"author": "DeaDvey",
|
||||
"license": "WTFPL",
|
||||
"dependencies": {
|
||||
"date-fns": "^4.1.0",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^5.1.0",
|
||||
"showdown": "^2.1.0"
|
||||
"markdown-it": "^14.1.0"
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
import { createRequire } from 'module';
|
||||
const require = createRequire(import.meta.url)
|
||||
const config = require("../config.json")
|
||||
const locale = require(`../locales/${config.locale}.json`)
|
||||
|
||||
// The configuration defines a date format using the date-fns (a datetime library) syntax
|
||||
// eg "yyyy-MM-dd"
|
||||
@@ -8,7 +10,6 @@ const require = createRequire(import.meta.url)
|
||||
// returns the formatted date (string)
|
||||
export function unix_time_to_date_format(unix_time) {
|
||||
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
|
||||
const config = require("../config.json")
|
||||
let date = fromUnixTime(unix_time)
|
||||
let formatted_date = format(date, config.date_format)
|
||||
return formatted_date
|
||||
@@ -20,7 +21,6 @@ export function unix_time_to_date_format(unix_time) {
|
||||
// returns the formatted date (string)
|
||||
export function unix_time_to_rss_date(unix_time) {
|
||||
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
|
||||
const config = require("../config.json")
|
||||
let date = fromUnixTime(unix_time)
|
||||
let formatted_date = format(date, "EEE, dd MMM yyyy HH:mm:ss")
|
||||
return `${formatted_date} ${config.time_zone}`
|
||||
@@ -29,7 +29,7 @@ export function unix_time_to_rss_date(unix_time) {
|
||||
export function unix_time_to_atom_date(unix_time) {
|
||||
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
|
||||
let date = fromUnixTime(unix_time)
|
||||
let formatted_date = format(date, "yyyy-MM-dd\\THH:mm:ss\\Z")
|
||||
let formatted_date = format(date, "yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||
return `${formatted_date}`
|
||||
}
|
||||
// This function accepts a list of strings eg ["string1","string2,"string3"] (any length)
|
||||
@@ -37,14 +37,19 @@ 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>"
|
||||
// this is so you can have a list of tags that each point to their individual tag page
|
||||
// returns: string
|
||||
export function hyperlink_tags(tags) {
|
||||
export function render_tags(tags) {
|
||||
let string = "" // Initialises the string
|
||||
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag
|
||||
string += `<a href="/tag/${tags[tag_index]}">${tags[tag_index]}</a>` // Adds the tag to the string as a HTML href
|
||||
if (tag_index < tags.length - 1) { // If there are more tags, then insert a comma
|
||||
string += ", ";
|
||||
}
|
||||
}
|
||||
if (tags.length == 1 && tags[0] == "") {
|
||||
string = locale.no_tags; // If there are no tags, output something
|
||||
}
|
||||
else {
|
||||
for (let tag_index = 0; tag_index < tags.length; tag_index++) { // Loop over each tag
|
||||
string += `<a href="/tag/${tags[tag_index]}">${tags[tag_index]}</a>` // Adds the tag to the string as a HTML href
|
||||
if (tag_index < tags.length - 1) { // If there are more tags, then insert a comma
|
||||
string += ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
return string
|
||||
}
|
||||
// The users are stored as a list of objects [ user_object, user_object, user_object ]
|
||||
@@ -61,6 +66,18 @@ export function get_userID(username) {
|
||||
}
|
||||
return -1 // If user is not present, return -1
|
||||
}
|
||||
|
||||
export function get_comment(commentID) { // TODO scales like shit
|
||||
const comments = require("../data/comments.json")
|
||||
for (let i = 0; i < comments.comments.length; i++) { // Loop over every post
|
||||
for (let j = 0; j < comments.comments[i].length; j++) { // Then every comment in that post
|
||||
if (comments.comments[i][j]["id"] == commentID) {
|
||||
return comments.comments[i][j]
|
||||
};
|
||||
}
|
||||
}
|
||||
return -1 // If comment is not present, return -1
|
||||
}
|
||||
// This escapes some potentially dangerous HTML characters with their HTML entities
|
||||
// https://www.freeformatter.com/html-entities.html
|
||||
// accepts a string
|
||||
@@ -74,5 +91,28 @@ export function escape_input(input) {
|
||||
.replaceAll("'", "'")
|
||||
.replaceAll("/", "/")
|
||||
.replaceAll("%", "%")
|
||||
.replaceAll("&", "&")
|
||||
return output
|
||||
}
|
||||
|
||||
// Render comment content by replacing the >> int with a url link to that comment
|
||||
export function render_comment(comment_content) {
|
||||
return comment_content
|
||||
.replaceAll(/>> ([0-9]*)/g, "<a href='/comment/$1'>>> $1</a>")
|
||||
.replaceAll(/>>([0-9]*)/g, "<a href='/comment/$1'>>>$1</a>")
|
||||
.replaceAll(/>> ([0-9]*)/g, "<a href='/comment/$1'>>> $1</a>")
|
||||
.replaceAll(/>>([0-9]*)/g, "<a href='/comment/$1'>>>$1</a>")
|
||||
.replaceAll("\n", "<br/>")
|
||||
};
|
||||
export function render_md(content) {
|
||||
const markdownit = require("markdown-it")
|
||||
const md = markdownit({
|
||||
html: false,
|
||||
xhtmlOut: false,
|
||||
breaks: true,
|
||||
linkify: false,
|
||||
typographer: true,
|
||||
quotes: locale.quotes,
|
||||
})
|
||||
return md.render(content)
|
||||
};
|
||||
|
@@ -1,21 +1,24 @@
|
||||
import { createRequire } from 'module';
|
||||
const require = createRequire(import.meta.url)
|
||||
// Initialise the program by creating users.js, comments.js, posts.js and config.js
|
||||
// All require default content in them to start off with
|
||||
// Then exit successfully
|
||||
// returns nothing
|
||||
function initialise() {
|
||||
export function initialise() {
|
||||
const fs = require("fs");
|
||||
try {
|
||||
const users = require("../data/users.js");
|
||||
const users = require("../data/users.json");
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Creating users file")
|
||||
fs.writeFileSync(`../data/users.json`, `{\n"users": []\n}`)
|
||||
fs.writeFileSync(`../data/users.json`, `[]`)
|
||||
}
|
||||
try {
|
||||
const posts = require("../data/posts.json");
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Creating posts file")
|
||||
fs.writeFileSync(`../data/posts.json`, `{\n"posts": []\n}`)
|
||||
fs.writeFileSync(`../data/posts.json`, `[]`)
|
||||
}
|
||||
try {
|
||||
const comments = require("../data/comments.json");
|
||||
@@ -25,15 +28,24 @@ function initialise() {
|
||||
fs.writeFileSync(`../data/comments.json`, `{\n"comments": [],\n"counter": 0}`)
|
||||
}
|
||||
try {
|
||||
const config = require("../data/config.js");
|
||||
const config = require("../config.json");
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Copying the example config to config.js")
|
||||
console.log("!!! PLEASE MODIFY config.js TO YOUR NEEDS !!!")
|
||||
fs.copyFile('example-config.js', 'config.js', (err) => {
|
||||
console.log("!!! PLEASE MODIFY config.json TO YOUR NEEDS !!!")
|
||||
fs.copyFile('../example-config.json', '../config.json', (err) => {
|
||||
console.log("Error copying file")
|
||||
})
|
||||
}
|
||||
try {
|
||||
fs.readFileSync("../data/hitcount.txt")
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Creating hitcount file")
|
||||
fs.writeFileSync("../data/hitcount.txt", "0", (err) => {
|
||||
console.log("Error creating hitcount.txt")
|
||||
})
|
||||
}
|
||||
console.log("Successfully initialised")
|
||||
process.exit(0)
|
||||
}
|
||||
|
274
src/server.js
274
src/server.js
@@ -1,7 +1,6 @@
|
||||
// Get the libraries
|
||||
const fs = require('fs'); // For modifying and reading files
|
||||
const express = require('express'); // For running a webserver in nodejs
|
||||
const showdown = require('showdown') // For converting markdown to html on demand, https://showdownjs.com/
|
||||
const crypto = require('crypto'); // For encrypting passwords, I use sha512
|
||||
// fromUnixTime(): Create a date from a Unix timestamp (in seconds). Decimal values will be discarded.
|
||||
// format(): Return the formatted date string in the given format. The result may vary by locale.
|
||||
@@ -40,15 +39,14 @@ catch (error) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// https://showdownjs.com/docs/available-options
|
||||
let converter = new showdown.Converter({
|
||||
simpleLineBreaks: true, // Parse line breaks as <br/> in paragraphs (GitHub-style behavior).
|
||||
tables: true, // Enable support for tables syntax.
|
||||
strikethrough: true, // Enable support for strikethrough: ~~text~~
|
||||
tasklists: true, // Enable support for GitHub style tasklists. - [x] and - [ ]
|
||||
encodeEmails: true, //Enable automatic obfuscation of email addresses. emails are encoded via character entities
|
||||
headerLevelStart: 3, //Set starting level for the heading tags.
|
||||
})
|
||||
// Import the locale
|
||||
try {
|
||||
locale = require(`../locales/${config.locale}.json`);
|
||||
}
|
||||
catch (error) {
|
||||
console.log("This locale doesn't exist, if you want to create it then you can create a PR")
|
||||
console.log("Locale selected: ", config.locale)
|
||||
}
|
||||
|
||||
// Define stuff to do with express (nodejs webserver)
|
||||
const app = express();
|
||||
@@ -60,11 +58,11 @@ app.set('view engine', 'ejs');
|
||||
app.set('views', '../views')
|
||||
|
||||
////////////////////// SYNDICATION ////////////////////////
|
||||
// RSS protocol gets
|
||||
// global RSS protocol gets
|
||||
app.get("/rss", (req,res) => {
|
||||
if (config.rss == false) {
|
||||
res.render("partials/message", {
|
||||
message: config.string.rss_disabled,
|
||||
message: locale.rss_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
@@ -73,16 +71,35 @@ app.get("/rss", (req,res) => {
|
||||
res.render("syndication/global_rss", {
|
||||
config,
|
||||
posts,
|
||||
converter,
|
||||
func,
|
||||
})
|
||||
};
|
||||
});
|
||||
// ATOM protocol gets
|
||||
app.get("/atom", (req,res) => {
|
||||
// user RSS protocol gets
|
||||
app.get("/user/:username/rss", (req,res) => {
|
||||
const username = req.params.username;
|
||||
const userID = func.get_userID(username);
|
||||
if (config.rss == false) {
|
||||
res.render("partials/message", {
|
||||
message: config.string.rss_disabled,
|
||||
message: locale.rss_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/user_rss", {
|
||||
config,
|
||||
posts,
|
||||
func,
|
||||
userID,
|
||||
})
|
||||
};
|
||||
});
|
||||
// global ATOM protocol gets
|
||||
app.get("/atom", (req,res) => {
|
||||
if (config.atom == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.atom_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
@@ -91,11 +108,60 @@ app.get("/atom", (req,res) => {
|
||||
res.render("syndication/global_atom", {
|
||||
config,
|
||||
posts,
|
||||
converter,
|
||||
func,
|
||||
getUnixTime,
|
||||
})
|
||||
};
|
||||
});
|
||||
// user ATOM protocol gets
|
||||
app.get("/user/:username/atom", (req,res) => {
|
||||
const username = req.params.username;
|
||||
const userID = func.get_userID(username);
|
||||
if (config.atom == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.atom_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/user_atom", {
|
||||
config,
|
||||
posts,
|
||||
func,
|
||||
userID,
|
||||
getUnixTime,
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
///////////////////// Page index's ///////////////////////
|
||||
app.get("/index/pages", (req,res) => {
|
||||
res.render("indexes/all_pages", {
|
||||
config,
|
||||
posts,
|
||||
users,
|
||||
comments: comments.comments,
|
||||
});
|
||||
}); // /index/posts
|
||||
app.get("/index/posts", (req,res) => {
|
||||
res.render("indexes/posts", {
|
||||
config,
|
||||
posts,
|
||||
});
|
||||
}); // /index/posts
|
||||
app.get("/index/users", (req,res) => {
|
||||
res.render("indexes/users", {
|
||||
config,
|
||||
users,
|
||||
});
|
||||
}); // /index/posts
|
||||
app.get("/index/comments", (req,res) => {
|
||||
res.render("indexes/comments", {
|
||||
config,
|
||||
comments: comments.comments,
|
||||
});
|
||||
}); // /index/posts
|
||||
|
||||
|
||||
///////////////////// Standard Pages //////////////////////
|
||||
@@ -111,6 +177,7 @@ app.get("/", (req,res) => {
|
||||
res.render("pages/timeline",
|
||||
{
|
||||
config,
|
||||
locale,
|
||||
posts,
|
||||
users,
|
||||
comments: comments.comments,
|
||||
@@ -119,65 +186,109 @@ app.get("/", (req,res) => {
|
||||
format,
|
||||
getUnixTime,
|
||||
func,
|
||||
converter,
|
||||
})
|
||||
}); // /
|
||||
app.get("/user/:username", (req, res) => {
|
||||
const userID = func.get_userID(req.params.username)
|
||||
console.log(userID)
|
||||
console.log(users[userID].prettyname)
|
||||
res.render("pages/user",
|
||||
{
|
||||
config: config,
|
||||
posts: posts,
|
||||
user: users[userID],
|
||||
userID: userID,
|
||||
comments: comments.comments,
|
||||
fromUnixTime: fromUnixTime,
|
||||
format: format,
|
||||
getUnixTime: getUnixTime,
|
||||
func,
|
||||
converter,
|
||||
})
|
||||
if (userID != -1) {
|
||||
res.render("pages/user",
|
||||
{
|
||||
config,
|
||||
locale,
|
||||
posts,
|
||||
user: users[userID],
|
||||
userID: userID,
|
||||
comments: comments.comments,
|
||||
fromUnixTime: fromUnixTime,
|
||||
format: format,
|
||||
getUnixTime: getUnixTime,
|
||||
func,
|
||||
})
|
||||
}
|
||||
else if (userID == -1) {
|
||||
res.render("partials/message",
|
||||
{
|
||||
message: locale.user_doesnt_exist,
|
||||
config,
|
||||
})
|
||||
}
|
||||
}); // /user/:username
|
||||
app.get("/post/:post_index", (req, res) => {
|
||||
const postID = req.params.post_index
|
||||
res.render("pages/post",
|
||||
{
|
||||
if (postID > posts.length-1 || posts[postID]["deleted"] == true) {
|
||||
res.render("partials/message", {
|
||||
message: locale.post_doesnt_exist,
|
||||
config,
|
||||
post: posts[postID],
|
||||
postID: postID,
|
||||
user: users[posts[postID].userID],
|
||||
comments: comments.comments[postID],
|
||||
fromUnixTime,
|
||||
format,
|
||||
getUnixTime,
|
||||
func,
|
||||
converter,
|
||||
})
|
||||
}
|
||||
else if (typeof posts[postID]["deleted"] == "undefined" || posts[postID]["deleted"] == false) {
|
||||
res.render("pages/post",
|
||||
{
|
||||
config,
|
||||
locale,
|
||||
post: posts[postID],
|
||||
postID: postID,
|
||||
user: users[posts[postID].userID],
|
||||
comments: comments.comments[postID],
|
||||
fromUnixTime,
|
||||
format,
|
||||
getUnixTime,
|
||||
func,
|
||||
})
|
||||
}
|
||||
else {
|
||||
console.log("Error loading page")
|
||||
res.redirect(301,"/")
|
||||
}
|
||||
}); // /post/:post_index
|
||||
app.get("/tag/:tag", (req,res) => {
|
||||
const tag = req.params.tag
|
||||
res.render("pages/tag",
|
||||
{
|
||||
config: config,
|
||||
tag: tag,
|
||||
posts: posts,
|
||||
users: users,
|
||||
config,
|
||||
locale,
|
||||
tag,
|
||||
posts,
|
||||
users,
|
||||
comments: comments.comments,
|
||||
fromUnixTime: fromUnixTime,
|
||||
format: format,
|
||||
getUnixTime: getUnixTime,
|
||||
func,
|
||||
converter,
|
||||
})
|
||||
}); // /tag/:tag
|
||||
app.get("/comment/:commentID", (req,res) => {
|
||||
const commentID = req.params.commentID;
|
||||
const comment = func.get_comment(commentID)
|
||||
if (comment == -1) {
|
||||
res.render("partials/message", {
|
||||
config,
|
||||
message: locale.comment_doesnt_exist,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.render("pages/comment",
|
||||
{
|
||||
config: config,
|
||||
locale,
|
||||
post: posts[comment["id"]],
|
||||
users,
|
||||
comment,
|
||||
fromUnixTime: fromUnixTime,
|
||||
format: format,
|
||||
getUnixTime: getUnixTime,
|
||||
func,
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
///////////////////// Form pages ////////////////////////////
|
||||
app.get(config.new_post_url, (req,res) => {
|
||||
res.render("forms/new_post", {
|
||||
config
|
||||
config,
|
||||
locale,
|
||||
});
|
||||
}); // /post
|
||||
app.get(config.signup_url, (req,res) => {
|
||||
@@ -185,13 +296,14 @@ app.get(config.signup_url, (req,res) => {
|
||||
if (config.allow_signup == true) {
|
||||
// Send the page for signing up to the server
|
||||
res.render("forms/signup", {
|
||||
config
|
||||
config,
|
||||
locale,
|
||||
});
|
||||
}
|
||||
// if the server does not allow signup
|
||||
else if (config.allow_signup == false) {
|
||||
res.render("partials/message", {
|
||||
message: config.string.signups_unavailable,
|
||||
message: locale.signups_unavailable,
|
||||
config,
|
||||
})
|
||||
}
|
||||
@@ -203,7 +315,12 @@ app.get(config.signup_url, (req,res) => {
|
||||
}); // /signup
|
||||
app.get(`${config.edit_account_base_url}/:user_id`, (req,res) => {
|
||||
const userID = parseInt(req.params.user_id);
|
||||
res.render("forms/edit_account", { config, user: users[userID], userID });
|
||||
res.render("forms/edit_account", {
|
||||
config,
|
||||
locale,
|
||||
user: users[userID],
|
||||
userID
|
||||
});
|
||||
}); // /delete_account
|
||||
app.get(`${config.edit_post_base_url}/:post_id`, (req,res) => {
|
||||
const post_id = req.params.post_id
|
||||
@@ -211,6 +328,7 @@ app.get(`${config.edit_post_base_url}/:post_id`, (req,res) => {
|
||||
const user = users[post['userID']]
|
||||
res.render("forms/edit_post", {
|
||||
config,
|
||||
locale,
|
||||
post,
|
||||
post_id,
|
||||
user,
|
||||
@@ -231,7 +349,7 @@ app.post("/submit_comment", (req,res) => {
|
||||
"id": comments.counter,
|
||||
"pubdate": unix_timestamp
|
||||
};
|
||||
let counter = comments.counter+1;
|
||||
comments.counter += 1;
|
||||
comments.comments[req.body.post_index].push(new_comment);
|
||||
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
|
||||
|
||||
@@ -241,13 +359,13 @@ app.post("/submit_post", (req,res) => {
|
||||
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
|
||||
const username = func.escape_input(req.body.username)
|
||||
const title = func.escape_input(req.body.title)
|
||||
const content = func.escape_input(req.body.content)
|
||||
const content = req.body.content
|
||||
const tags = func.escape_input(req.body.tags).split(',');
|
||||
const unix_timestamp = getUnixTime(new Date())
|
||||
|
||||
if (func.get_userID(username) == -1) {
|
||||
res.render("partials/message", {
|
||||
message: config.string.user_doesnt_exit,
|
||||
message: locale.user_doesnt_exit,
|
||||
config,
|
||||
})
|
||||
}
|
||||
@@ -255,6 +373,7 @@ app.post("/submit_post", (req,res) => {
|
||||
else if (users[func.get_userID(username)]['hash'] == password) { // Password matches
|
||||
console.log(username, "is submitting a post titled:", title);
|
||||
posts.push({
|
||||
"id": posts.length,
|
||||
"userID": func.get_userID(username),
|
||||
"title": title,
|
||||
"content": content,
|
||||
@@ -269,7 +388,7 @@ app.post("/submit_post", (req,res) => {
|
||||
}
|
||||
else {
|
||||
res.render("partials/message", {
|
||||
message: config.string.incorrect_password,
|
||||
message: locale.incorrect_password,
|
||||
config,
|
||||
})
|
||||
}
|
||||
@@ -278,7 +397,7 @@ app.post("/submit_signup", (req,res) => {
|
||||
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
|
||||
const username = func.escape_input(req.body.username)
|
||||
const prettyname = func.escape_input(req.body.prettyname)
|
||||
const description = func.escape_input(req.body.description)
|
||||
const description = req.body.description
|
||||
|
||||
// Check that signups are allowed
|
||||
if (config.allow_signup == true) {
|
||||
@@ -286,6 +405,7 @@ app.post("/submit_signup", (req,res) => {
|
||||
// so this checks that the user does not exist
|
||||
if (func.get_userID(username) == -1) {
|
||||
users.push({
|
||||
"id": users.length,
|
||||
"username": username,
|
||||
"prettyname": prettyname,
|
||||
"hash": password,
|
||||
@@ -297,14 +417,14 @@ app.post("/submit_signup", (req,res) => {
|
||||
// if the user does exist then
|
||||
else {
|
||||
res.render("partials/message", {
|
||||
message: config.string.user_exists,
|
||||
message: locale.user_exists,
|
||||
config,
|
||||
})
|
||||
}
|
||||
}
|
||||
else if (config.allow_signup == false) {
|
||||
res.render("partials/message", {
|
||||
message: config.string.signups_unavailable,
|
||||
message: locale.signups_unavailable,
|
||||
config,
|
||||
})
|
||||
}
|
||||
@@ -318,7 +438,7 @@ app.post("/submit_edit_user", (req,res) => {
|
||||
// Get the form info
|
||||
const password = crypto.createHash("sha512").update(req.body.password).digest("hex");
|
||||
const userID = func.escape_input(req.body.userID)
|
||||
const description = func.escape_input(req.body.description)
|
||||
const description = req.body.description
|
||||
const prettyname = func.escape_input(req.body.prettyname)
|
||||
const delete_bool = req.body.delete
|
||||
|
||||
@@ -330,12 +450,12 @@ app.post("/submit_edit_user", (req,res) => {
|
||||
|
||||
if (delete_bool == true) {
|
||||
// Delete the user
|
||||
users[userID] = {"deleted": true}
|
||||
users[userID] = {"id": userID,"deleted": true}
|
||||
// Delete all their posts
|
||||
for (let postid = 0; postid < posts.length; postid++) { // loop over all posts
|
||||
if (posts[postid]['userID'] == userID) { // if userID matches
|
||||
posts[postid] = {"deleted": true} // delete the post
|
||||
comments.comments[postid] = {"deleted": true} // the comments for this post should also be deleted
|
||||
posts[postid] = {"id": postid, "deleted": true} // delete the post
|
||||
comments.comments[postid] = [] // the comments for this post should also be deleted
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -347,7 +467,7 @@ app.post("/submit_edit_user", (req,res) => {
|
||||
}
|
||||
else { // password does not match
|
||||
res.render("partials/message", {
|
||||
message: config.string.incorrect_password,
|
||||
message: locale.incorrect_password,
|
||||
config
|
||||
}
|
||||
)
|
||||
@@ -355,21 +475,21 @@ app.post("/submit_edit_user", (req,res) => {
|
||||
}
|
||||
else {
|
||||
res.render("partials/message", {
|
||||
message: config.string.user_doesnt_exist,
|
||||
message: locale.user_doesnt_exist,
|
||||
config,
|
||||
})
|
||||
}
|
||||
}); // /submit_delete_account
|
||||
app.post("/submit_edit_post", (req,res) => {
|
||||
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
|
||||
const postID = req.body.postID
|
||||
const userID = req.body.userID
|
||||
const title = req.body.title
|
||||
const content = req.body.content
|
||||
const tags = req.body.tags.split(',');
|
||||
const delete_bool = req.body.delete
|
||||
const unix_timestamp = getUnixTime(new Date())
|
||||
console.log(users[userID]['prettyname'], "is editting the post titled:", title);
|
||||
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
|
||||
const postID = req.body.postID
|
||||
const userID = req.body.userID
|
||||
const title = func.escape_input(req.body.title)
|
||||
const content = req.body.content
|
||||
const tags = func.escape_input(req.body.tags).split(",")
|
||||
const delete_bool = req.body.delete
|
||||
const unix_timestamp = getUnixTime(new Date())
|
||||
console.log(users[userID]['prettyname'], "is editting the post titled:", title);
|
||||
|
||||
if (users[userID]['hash'] == password) { // password matches
|
||||
let post = posts[postID]
|
||||
@@ -379,8 +499,8 @@ app.post("/submit_edit_post", (req,res) => {
|
||||
post['editdate'] = unix_timestamp
|
||||
if (typeof delete_bool != "undefined") {
|
||||
console.log("Deleting post!")
|
||||
posts[postID] = {"deleted": true}
|
||||
comments.comments[postID] = {"deleted": true}
|
||||
posts[postID] = {"id": post["id"], "deleted": true}
|
||||
comments.comments[postID] = [];
|
||||
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
|
||||
}
|
||||
fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8');
|
||||
@@ -388,7 +508,7 @@ app.post("/submit_edit_post", (req,res) => {
|
||||
}
|
||||
else {
|
||||
res.render("partials/message", {
|
||||
message: config.string.incorrect_password,
|
||||
message: locale.incorrect_password,
|
||||
config,
|
||||
})
|
||||
}
|
||||
|
@@ -6,10 +6,16 @@
|
||||
<body>
|
||||
<form action="/submit_edit_user" method="POST">
|
||||
<input name="userID" type="hidden" value="<%= userID %>">
|
||||
<input placeholder="<%= user.prettyname %>'s password" type="password" required id="password" name="password"><br/>
|
||||
<input placeholder="Pretty Name" name="prettyname" value="<%= user.prettyname %>"><br/>
|
||||
<textarea placeholder="Description" name="description"><%= user.description %></textarea><br/>
|
||||
<label><%- config.string.delete_account_confirmation %>: </label><input type="checkbox" name="agreement"><br/>
|
||||
<label><%= locale.password %>:</label><br/>
|
||||
<input type="password" required id="password" name="password"><br/><br/>
|
||||
|
||||
<label><%= locale.prettyname %>:</label><br/>
|
||||
<input name="prettyname" value="<%= user.prettyname %>"><br/><br/>
|
||||
|
||||
<label><%= locale.description %>:</label><br/>
|
||||
<textarea name="description"><%= user.description %></textarea><br/><br/>
|
||||
|
||||
<label><%- locale.delete_account_confirmation %>: </label><input type="checkbox" name="agreement"><br/>
|
||||
<input type="submit" value="Submit"><br/>
|
||||
</form>
|
||||
</body>
|
||||
|
@@ -7,13 +7,21 @@
|
||||
<form action="/submit_edit_post" method="POST" onsubmit="sha512password()">
|
||||
<input name="userID" type="hidden" value="<%= post['userID'] %>">
|
||||
<input name="postID" type="hidden" value="<%= post_id %>">
|
||||
<input placeholder="<%= user['prettyname'] %>'s password" type="password" required id="password" name="password"><br/>
|
||||
<input placeholder="title" value=" <%=post['title'] %>" required name="title"><br/>
|
||||
<textarea placeholder="content" required name="content"><%= post['content'] %></textarea><br/>
|
||||
<input placeholder="tags (comma seperated)" value="<%= post['tags'] %>" name="tags"><br/>
|
||||
|
||||
<label><%= locale.password %>:</label><br/>
|
||||
<input type="password" required id="password" name="password"><br/><br/>
|
||||
|
||||
<label><%= locale.title %>:</label><br/>
|
||||
<input value="<%=post['title'] %>" required name="title"><br/><br/>
|
||||
|
||||
<label><%= locale.post_content %>:</label><br/>
|
||||
<textarea required name="content"><%= post['content'] %></textarea><br/><br/>
|
||||
|
||||
<label><%= locale.tags %>:</label><br/>
|
||||
<input value="<%= post['tags'] %>" name="tags"><br/><br/>
|
||||
|
||||
<label>Delete forever (no undo): </label><input name="delete" type="checkbox"><br/>
|
||||
<input type="submit" value="Submit"><br/>
|
||||
<small>* Markdown supported</small>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -5,12 +5,21 @@
|
||||
</head>
|
||||
<body>
|
||||
<form action="/submit_post" method="POST">
|
||||
<input placeholder="username" required name="username"><br/>
|
||||
<input placeholder="password" type="password" required id="password" name="password"><br/>
|
||||
<input placeholder="title" required name="title"><br/>
|
||||
<textarea placeholder="post content*" required name="content"></textarea><br/>
|
||||
<input placeholder="Tags (comma seperated)" name="tags"><br/>
|
||||
<label><%= locale.username %>:</label><br/>
|
||||
<input required name="username"><br/><br/>
|
||||
|
||||
<label><%= locale.password %>:</label><br/>
|
||||
<input type="password" required id="password" name="password"><br/><br/>
|
||||
|
||||
<label><%= locale.title %>:</label><br/>
|
||||
<input required name="title"><br/><br/>
|
||||
|
||||
<label><%= locale.post_content %>:</label><br/>
|
||||
<textarea required name="content"></textarea><br/><br/>
|
||||
|
||||
<label><%= locale.tags %>:</label><br/>
|
||||
<input name="tags"><br/><br/>
|
||||
|
||||
<input type="submit" value="Submit"><br/>
|
||||
<small>* Markdown supported</small>
|
||||
</body>
|
||||
</form></html>
|
||||
|
@@ -5,11 +5,19 @@
|
||||
</head>
|
||||
<body>
|
||||
<form action="/submit_signup" method="POST">
|
||||
<input placeholder="username" required name="username"><br/>
|
||||
<input placeholder="prettyname" required name="prettyname"><br/>
|
||||
<input placeholder="password" type="password" required id="password" name="password"><br/>
|
||||
<textarea placeholder="description (social links, what you do etc), supports markdown" id="description" name="description"></textarea><br/>
|
||||
<label><%- config.string.signup_agreement %>: </label><input type="checkbox" name="agreement" required><br/>
|
||||
<label><%= locale.username %></label><br/>
|
||||
<input required name="username"><br/><br/>
|
||||
|
||||
<label><%= locale.prettyname %></label><br/>
|
||||
<input required name="prettyname"><br/><br/>
|
||||
|
||||
<label><%= locale.password %></label><br/>
|
||||
<input type="password" required id="password" name="password"><br/><br/>
|
||||
|
||||
<label><%= locale.description %></label><br/>
|
||||
<textarea id="description" name="description"></textarea><br/><br/>
|
||||
|
||||
<label><%- locale.signup_agreement %>: </label><input type="checkbox" name="agreement" required><br/>
|
||||
<input type="submit" value="Submit"><br/>
|
||||
</form>
|
||||
</body>
|
||||
|
5
views/headers/site_wide.ejs
Normal file
5
views/headers/site_wide.ejs
Normal file
@@ -0,0 +1,5 @@
|
||||
<a href="/"><%= locale.home_page %></a>
|
||||
<a href="/index/pages"><%= locale.site_index %></a>
|
||||
<a href="<%= config.new_post_url %>"><%= locale.new_post %></a>
|
||||
<br/>
|
||||
<%- config.seperator %>
|
@@ -1,4 +1,4 @@
|
||||
<h1>
|
||||
Post's tagged "<%- tag %>":
|
||||
<%= locale.posts_tagged %>: "<%- tag %>"
|
||||
</h1>
|
||||
<%- config.seperator %>
|
||||
|
@@ -4,10 +4,17 @@
|
||||
<h2>
|
||||
<%- config.site_description %>
|
||||
</h2>
|
||||
<a href="<%= config.rss_url %>">RSS Feed</a><br/>
|
||||
<a href="<%= config.new_post_url %>">New post</a><br/>
|
||||
<a href="<%= config.signup_url %>">Sign Up</a><br/>
|
||||
<% if (config.rss == true) { %>
|
||||
<a href="/rss"><%= locale.rss_feed %></a><br/>
|
||||
<% } %>
|
||||
<% if (config.atom == true) { %>
|
||||
<a href="/atom"><%= locale.atom_feed %></a><br/>
|
||||
<% } %>
|
||||
<a href="<%= config.new_post_url %>"><%= locale.new_post %></a><br/>
|
||||
<% if (config.allow_signup == true) { %>
|
||||
<a href="<%= config.signup_url %>"><%= locale.sign_up %></a><br/>
|
||||
<% } %>
|
||||
<% if (config.enable_hitcount == true) { %>
|
||||
Hitcount: <%= hitcount %>
|
||||
<%= locale.hitcount %>: <%= hitcount %>
|
||||
<% } %>
|
||||
<%- config.seperator %>
|
||||
|
@@ -1,6 +1,8 @@
|
||||
<h1>
|
||||
<%= user.prettyname %>'s posts
|
||||
<%= user.prettyname %>
|
||||
</h1>
|
||||
<p><%- converter.makeHtml(user.description) %></p>
|
||||
<a href="<%= config.edit_account_base_url %>/<%= userID %>">edit account</a>
|
||||
<p><%- func.render_md(user.description) %></p>
|
||||
<a href="<%= config.edit_account_base_url %>/<%= userID %>"><%= locale.edit_account %></a><br/>
|
||||
<a href="/user/<%= user.username %>/rss"><%= locale.rss_feed %></a><br/>
|
||||
<a href="/user/<%= user.username %>/atom"><%= locale.atom_feed %></a>
|
||||
<%- config.seperator %>
|
||||
|
47
views/indexes/all_pages.ejs
Normal file
47
views/indexes/all_pages.ejs
Normal file
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= config.charset %>">
|
||||
<head>
|
||||
<%- include("../partials/head") %>
|
||||
</head>
|
||||
<body>
|
||||
Misc:<br/>
|
||||
<a href="/">Home Page</a><br/>
|
||||
<a href="<%= config.new_post_url %>">New Post Form</a><br/>
|
||||
<a href="<%= config.signup_url %>">Signup Form</a><br/>
|
||||
Indexes:<br/>
|
||||
<a href="/index/posts">Posts Index</a><br/>
|
||||
<a href="/index/users">Users Index</a><br/>
|
||||
<a href="/index/comments">Comments Index</a><br/>
|
||||
Posts:<br/>
|
||||
<% for (let postID = 0; postID < posts.length; postID++) { %>
|
||||
<% if (posts[postID]["deleted"] != true) { %>
|
||||
<a href="/post/<%= postID %>"><%= posts[postID]["title"] %></a><br/>
|
||||
<% }; %>
|
||||
<% }; %>
|
||||
Comments:<br/>
|
||||
<% for (let postID = 0; postID < comments.length; postID++) { %>
|
||||
<% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %>
|
||||
<a href="/comment/<%= comments[postID][comment_index]["id"] %>"><%= comments[postID][comment_index]["id"] %></a><br/>
|
||||
<% }; %>
|
||||
<% }; %>
|
||||
Users:<br/>
|
||||
<% for (let userID = 0; userID < users.length; userID++) { %>
|
||||
<% if (users[userID]["deleted"] != true) { %>
|
||||
<a href="/user/<%= users[userID]["username"] %>"><%= users[userID]["username"] %></a><br/>
|
||||
<% }; %>
|
||||
<% }; %>
|
||||
Edit Posts:<br/>
|
||||
<% for (let postID = 0; postID < posts.length; postID++) { %>
|
||||
<% if (posts[postID]["deleted"] != true) { %>
|
||||
<a href="/<%= config.edit_post_base_url %>/<%= postID %>">Edit <%= posts[postID]["title"] %></a><br/>
|
||||
<% }; %>
|
||||
<% }; %>
|
||||
Edit Users:<br/>
|
||||
<% for (let userID = 0; userID < users.length; userID++) { %>
|
||||
<% if (users[userID]["deleted"] != true) { %>
|
||||
<a href="/<%= config.edit_account_base_url %>/<%= users[userID]["username"] %>">Edit <%= users[userID]["username"] %></a><br/>
|
||||
<% }; %>
|
||||
<% }; %>
|
||||
<!-- TODO add tags -->
|
||||
</body>
|
||||
</html>
|
13
views/indexes/comments.ejs
Normal file
13
views/indexes/comments.ejs
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= config.charset %>">
|
||||
<head>
|
||||
<%- include("../partials/head") %>
|
||||
</head>
|
||||
<body>
|
||||
<% for (let postID = 0; postID < comments.length; postID++) { %>
|
||||
<% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %>
|
||||
<a href="/comment/<%= comments[postID][comment_index]["id"] %>"><%= comments[postID][comment_index]["id"] %></a><br/>
|
||||
<% }; %>
|
||||
<% }; %>
|
||||
</body>
|
||||
</html>
|
13
views/indexes/posts.ejs
Normal file
13
views/indexes/posts.ejs
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= config.charset %>">
|
||||
<head>
|
||||
<%- include("../partials/head") %>
|
||||
</head>
|
||||
<body>
|
||||
<% for (let postID = 0; postID < posts.length; postID++) { %>
|
||||
<% if (posts[postID]["deleted"] != true) { %>
|
||||
<a href="/post/<%= postID %>"><%= posts[postID]["title"] %></a><br/>
|
||||
<% }; %>
|
||||
<% }; %>
|
||||
</body>
|
||||
</html>
|
13
views/indexes/users.ejs
Normal file
13
views/indexes/users.ejs
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= config.charset %>">
|
||||
<head>
|
||||
<%- include("../partials/head") %>
|
||||
</head>
|
||||
<body>
|
||||
<% for (let userID = 0; userID < users.length; userID++) { %>
|
||||
<% if (users[userID]["deleted"] != true) { %>
|
||||
<a href="/user/<%= users[userID]["username"] %>"><%= users[userID]["username"] %></a><br/>
|
||||
<% }; %>
|
||||
<% }; %>
|
||||
</body>
|
||||
</html>
|
14
views/pages/comment.ejs
Normal file
14
views/pages/comment.ejs
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<%- include('../partials/head'); %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<%- include("../headers/site_wide") %>
|
||||
</div>
|
||||
<div id="comment">
|
||||
<%- include("../partials/comment"); %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -4,6 +4,9 @@
|
||||
<%- include('../partials/head'); %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<%- include("../headers/site_wide") %>
|
||||
</div>
|
||||
<div id="posts">
|
||||
<%- include('../posts/post'); %>
|
||||
</div>
|
||||
|
@@ -5,15 +5,18 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<%- include('../headers/site_wide'); %>
|
||||
<%- include('../headers/tag'); %>
|
||||
</div>
|
||||
<div id="posts">
|
||||
<% for (let index = posts.length - 1; index >= 0; index--) { %>
|
||||
<% posts[index].tags.forEach((current_tag, tag_index) => { %>
|
||||
<% if (current_tag == tag) { %>
|
||||
<%- include('../posts/tag', {post: posts[index], postID: index}); %>
|
||||
<% } %>
|
||||
<% }) %>
|
||||
<% if ( posts[index].deleted != true) { %>
|
||||
<% posts[index].tags.forEach((current_tag, tag_index) => { %>
|
||||
<% if (current_tag == tag) { %>
|
||||
<%- include('../posts/tag', {post: posts[index], user: users[posts[index].userID], comments: comments[index]}); %>
|
||||
<% } %>
|
||||
<% }) %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
<footer>
|
||||
|
@@ -5,12 +5,20 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<%- include("../headers/site_wide") %>
|
||||
<%- include('../headers/timeline'); %>
|
||||
</div>
|
||||
<form method="POST" action="/submit_nothing" style="display:none">
|
||||
<!-- Form is used to help mitigate spam as it is the first form on the front page -->
|
||||
<input type="hidden" name="post_index" value="0">
|
||||
<input placeholder="username" name="name"><br/>
|
||||
<textarea placeholder="comment" name="content"></textarea><br/>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
<div id="posts">
|
||||
<% for (let index = posts.length - 1; index >= 0; index--) { %>
|
||||
<% if (posts[index]["deleted"] != true) { %>
|
||||
<%- include('../posts/timeline', {post: posts[index], index: index, user: users[posts[index].userID]}); %>
|
||||
<%- include('../posts/timeline', {post: posts[index], postID: index, user: users[posts[index].userID], comments: comments[index]}); %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
|
@@ -5,12 +5,13 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<%- include("../headers/site_wide") %>
|
||||
<%- include('../headers/user'); %>
|
||||
</div>
|
||||
<div id="posts">
|
||||
<% for (let index = posts.length - 1; index >= 0; index--) { %>
|
||||
<% if (posts[index].userID == userID) { %>
|
||||
<%- include('../posts/user', {post: posts[index], index: index, user: user}); %>
|
||||
<%- include('../posts/user', {post: posts[index], postID: index, user: user, comments: comments[index]}); %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
|
@@ -1,2 +1,3 @@
|
||||
<b><%= comment.name %></b> <%= func.unix_time_to_date_format(comment.pubdate) %> <i>No. <%= comment.id %></i>:<br/>
|
||||
<%= comment.content %>
|
||||
<%- func.render_comment(comment.content) %>
|
||||
<br/>
|
||||
|
@@ -1,2 +1,3 @@
|
||||
Site is ran by deadvey<br/>
|
||||
<%- config.string.attribution %>
|
||||
<%= locale.site_ran_by %> <%= config.site_admin %><br/>
|
||||
<%- locale.attribution %><br/>
|
||||
<%= locale.AI_consent %> <!-- remove consent for AI scrapers -->
|
||||
|
@@ -1,9 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%=config.language%>
|
||||
<html lang="<%= config.language %>">
|
||||
<head>
|
||||
<%- include('head') %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<%- include("../headers/site_wide") %>
|
||||
</div>
|
||||
<%- message %>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,28 +1,48 @@
|
||||
<h1>
|
||||
<%= post.title %>
|
||||
</h1>
|
||||
<%- converter.makeHtml(post.content) %><br/>
|
||||
<i>
|
||||
By <a href="/user/<%= user.username %>"><%= user.username %></a><br/>
|
||||
</i>
|
||||
<%- func.hyperlink_tags(post.tags) %><br/>
|
||||
<a href="<%= config.edit_post_base_url %>/<%= postID %>">Edit</a><br/>
|
||||
<i>Published: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
<i>Last Modified: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
|
||||
<%- config.seperator %>
|
||||
|
||||
<!-- Comment form -->
|
||||
<form method="POST" action="/submit_comment">
|
||||
<input type="hidden" name="post_index" value="<%= postID %>">
|
||||
<input placeholder="username" name="name"><br/>
|
||||
<textarea placeholder="comment" name="content"></textarea><br/>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<% comments.forEach((comment, postID) => { %>
|
||||
<%- include('../partials/comment', {comment: comment}) %>
|
||||
<% }) %>
|
||||
<div id="post-header">
|
||||
<h1>
|
||||
<%= post.title %>
|
||||
</h1>
|
||||
</div>
|
||||
<div id="post-content">
|
||||
<p>
|
||||
<%- func.render_md(post.content) %><br/>
|
||||
</p>
|
||||
</div>
|
||||
<div id="post-details">
|
||||
<div id="post-author">
|
||||
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
|
||||
</div>
|
||||
<div id="post-tags">
|
||||
<%- func.render_tags(post.tags) %><br/>
|
||||
</div>
|
||||
<div id="post-edit">
|
||||
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
|
||||
</div>
|
||||
<div id="post-pubdate">
|
||||
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
</div>
|
||||
<div id="post-editdate">
|
||||
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="post-commentform">
|
||||
<!-- Comment form -->
|
||||
<form method="POST" action="/submit_comment">
|
||||
<input type="hidden" name="post_index" value="<%= post["id"] %>">
|
||||
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
|
||||
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
|
||||
<button type="submit"><%= locale.submit %></button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="post-comments">
|
||||
<% comments.forEach((comment, index) => { %>
|
||||
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>">
|
||||
<%- include('../partials/comment', {comment: comment}) %>
|
||||
</div>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
<%- config.seperator %>
|
||||
|
||||
|
@@ -1,21 +1,51 @@
|
||||
<h3>
|
||||
<%= post.title %>
|
||||
</h3>
|
||||
<%- converter.makeHtml(post.content) %><br/>
|
||||
<a href="/post/<%- postID %>">Permalink</a><br/>
|
||||
<%- func.hyperlink_tags(post.tags) %>
|
||||
<div id="post-header">
|
||||
<h1>
|
||||
<%= post.title %>
|
||||
</h1>
|
||||
</div>
|
||||
<div id="post-content">
|
||||
<p>
|
||||
<%- func.render_md(post.content) %><br/>
|
||||
</p>
|
||||
</div>
|
||||
<div id="post-details">
|
||||
<div id="post-author">
|
||||
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
|
||||
</div>
|
||||
<div id="post-permalink">
|
||||
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
|
||||
</div>
|
||||
<div id="post-tags">
|
||||
<%- func.render_tags(post.tags) %><br/>
|
||||
</div>
|
||||
<div id="post-edit">
|
||||
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
|
||||
</div>
|
||||
<div id="post-pubdate">
|
||||
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
</div>
|
||||
<div id="post-editdate">
|
||||
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Comment form -->
|
||||
<form method="POST" action="/submit_comment">
|
||||
<input type="hidden" name="post_index" value="<%= postID %>">
|
||||
<input placeholder="username" name="name"><br/>
|
||||
<textarea placeholder="comment" name="content"></textarea><br/>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
<div id="post-commentform">
|
||||
<!-- Comment form -->
|
||||
<form method="POST" action="/submit_comment">
|
||||
<input type="hidden" name="post_index" value="<%= post["id"] %>">
|
||||
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
|
||||
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
|
||||
<button type="submit"><%= locale.submit %></button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<% comments[postID].forEach((comment) => { %>
|
||||
<%- include('../partials/comment', {comment: comment}) %>
|
||||
<% }) %>
|
||||
<div id="post-comments">
|
||||
<% comments.forEach((comment, index) => { %>
|
||||
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>">
|
||||
<%- include('../partials/comment', {comment: comment}) %>
|
||||
</div>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
<%- config.seperator %>
|
||||
|
||||
|
@@ -1,23 +1,51 @@
|
||||
<h3>
|
||||
<%= post.title %>
|
||||
</h3>
|
||||
<%- converter.makeHtml(post.content) %><br/>
|
||||
<a href="/post/<%- index %>">Permalink</a><br/>
|
||||
<i>
|
||||
By <a href="/user/<%= user.username %>"><%= user.username %></a><br/>
|
||||
</i>
|
||||
<div id="post-header">
|
||||
<h1>
|
||||
<%= post.title %>
|
||||
</h1>
|
||||
</div>
|
||||
<div id="post-content">
|
||||
<p>
|
||||
<%- func.render_md(post.content) %><br/>
|
||||
</p>
|
||||
</div>
|
||||
<div id="post-details">
|
||||
<div id="post-author">
|
||||
<i><%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/></i>
|
||||
</div>
|
||||
<div id="post-permalink">
|
||||
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
|
||||
</div>
|
||||
<div id="post-tags">
|
||||
<%- func.render_tags(post.tags) %><br/>
|
||||
</div>
|
||||
<div id="post-edit">
|
||||
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
|
||||
</div>
|
||||
<div id="post-pubdate">
|
||||
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
</div>
|
||||
<div id="post-editdate">
|
||||
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Comment form -->
|
||||
<form method="POST" action="/submit_comment">
|
||||
<input type="hidden" name="post_index" value="<%= index %>">
|
||||
<input placeholder="username" name="name"><br/>
|
||||
<textarea placeholder="comment" name="content"></textarea><br/>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
<div id="post-commentform">
|
||||
<!-- Comment form -->
|
||||
<form method="POST" action="/submit_comment">
|
||||
<input type="hidden" name="post_index" value="<%= post["id"] %>">
|
||||
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
|
||||
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
|
||||
<button type="submit"><%= locale.submit %></button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<% comments[index].forEach((comment, index) => { %>
|
||||
<%- include('../partials/comment', {comment: comment}) %>
|
||||
<% }) %>
|
||||
<div id="post-comments">
|
||||
<% comments.forEach((comment, index) => { %>
|
||||
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>">
|
||||
<%- include('../partials/comment', {comment: comment}) %>
|
||||
</div>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
<%- config.seperator %>
|
||||
|
||||
|
@@ -1,20 +1,48 @@
|
||||
<h3>
|
||||
<%= post.title %>
|
||||
</h3>
|
||||
<%- converter.makeHtml(post.content) %><br/>
|
||||
<a href="/post/<%- index %>">Permalink</a><br/>
|
||||
<div id="post-header">
|
||||
<h1>
|
||||
<%= post.title %>
|
||||
</h1>
|
||||
</div>
|
||||
<div id="post-content">
|
||||
<p>
|
||||
<%- func.render_md(post.content) %><br/>
|
||||
</p>
|
||||
</div>
|
||||
<div id="post-details">
|
||||
<div id="post-permalink">
|
||||
<a href="/post/<%= post["id"] %>"><%= locale.permalink %><a/>
|
||||
</div>
|
||||
<div id="post-tags">
|
||||
<%- func.render_tags(post.tags) %><br/>
|
||||
</div>
|
||||
<div id="post-edit">
|
||||
<a href="<%= config.edit_post_base_url %>/<%= post["id"] %>"><%= locale.edit_post %></a><br/>
|
||||
</div>
|
||||
<div id="post-pubdate">
|
||||
<i><%= locale.published %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
</div>
|
||||
<div id="post-editdate">
|
||||
<i><%= locale.last_modified %>: <%= func.unix_time_to_date_format(post.pubdate) %></i><br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Comment form -->
|
||||
<form method="POST" action="/submit_comment">
|
||||
<input type="hidden" name="post_index" value="<%= index %>">
|
||||
<input placeholder="username" name="name"><br/>
|
||||
<textarea placeholder="comment" name="content"></textarea><br/>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
<div id="post-commentform">
|
||||
<!-- Comment form -->
|
||||
<form method="POST" action="/submit_comment">
|
||||
<input type="hidden" name="post_index" value="<%= post["id"] %>">
|
||||
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
|
||||
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
|
||||
<button type="submit"><%= locale.submit %></button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<% comments[index].forEach((comment, index) => { %>
|
||||
<%- include('../partials/comment', {comment: comment}) %>
|
||||
<% }) %>
|
||||
<div id="post-comments">
|
||||
<% comments.forEach((comment, index) => { %>
|
||||
<div id="comment-no<%= comment.id %>" class="post-comment-<%= index %>">
|
||||
<%- include('../partials/comment', {comment: comment}) %>
|
||||
</div>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
<%- config.seperator %>
|
||||
|
||||
|
@@ -3,6 +3,20 @@
|
||||
<title><%= config.site_name %></title>
|
||||
<link><%= config.site_url %></title>
|
||||
<description><%= config.site_description %></description>
|
||||
<updated><%= new Date() %></updated>
|
||||
<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>
|
||||
|
@@ -5,10 +5,11 @@
|
||||
<link><%= config.site_url %></title>
|
||||
<description><%= config.site_description %></description>
|
||||
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
|
||||
<% if (posts[postID]["deleted"] != true) { %>
|
||||
<item>
|
||||
<title><%= posts[postID]["title"] %></title>
|
||||
<link><%= config.site_url %>/post/<%= postID %></link>
|
||||
<description><![CDATA[<%= converter.makeHtml(posts[postID]["content"]) %>]]></description>
|
||||
<description><![CDATA[<%- func.render_md(posts[postID]["content"]) %>]]></description>
|
||||
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
|
||||
<pubDate><%= func.unix_time_to_rss_date(posts[postID]['pubdate']) %></pubDate>
|
||||
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
|
||||
@@ -16,5 +17,6 @@
|
||||
<% } %>
|
||||
</item>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</channel>
|
||||
</rss>
|
||||
|
24
views/syndication/user_atom.ejs
Normal file
24
views/syndication/user_atom.ejs
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="<%= config.charset %>" ?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title><%= config.site_name %></title>
|
||||
<link><%= config.site_url %></title>
|
||||
<description><%= config.site_description %></description>
|
||||
<updated><%= func.unix_time_to_atom_date(getUnixTime(new Date())) %></updated>
|
||||
<id><%= config.site_url %></id>
|
||||
<% for (let postID = posts.length-1; postID >= 0; postID--) { %>
|
||||
<% if (posts[postID]["userID"] == userID) { %>
|
||||
<% if (posts[postID]["deleted"] != true) { %>
|
||||
<entry>
|
||||
<title><%= posts[postID]["title"] %></title>
|
||||
<link><%= config.site_url %>/post/<%= postID %></link>
|
||||
<summary><![CDATA[<%- func.render_md(posts[postID]["content"]) %>]]></summary>
|
||||
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
|
||||
<pubDate><%# func.unix_time_to_atom_date(posts[postID]['pubdate']) %></pubDate>
|
||||
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
|
||||
<category><![CDATA[<%= posts[postID]['tags'][tag_index] %>]]></category>
|
||||
<% } %>
|
||||
</entry>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</feed>
|
@@ -5,10 +5,12 @@
|
||||
<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[<%= converter.makeHtml(posts[postID]["content"]) %>]]></description>
|
||||
<description><![CDATA[<%- func.render_md(posts[postID]["content"]) %>]]></description>
|
||||
<guid isPermaLink="true"><%= config.site_url %>/post/<%= postID %></guid>
|
||||
<pubDate><%= func.unix_time_to_rss_date(posts[postID]['pubdate']) %></pubDate>
|
||||
<% for (let tag_index = 0; tag_index < posts[postID]['tags'].length; tag_index++) { %>
|
||||
@@ -16,5 +18,7 @@
|
||||
<% } %>
|
||||
</item>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</channel>
|
||||
</rss>
|
Reference in New Issue
Block a user