added site header in forms routes

This commit is contained in:
2026-06-01 14:07:19 +01:00
parent 5a14b125d2
commit 9aff454ec2
10 changed files with 99 additions and 163 deletions
+10 -3
View File
@@ -5,12 +5,15 @@ const func = require('../functions')
const router = express.Router(); const router = express.Router();
///////////////////// Form pages //////////////////////////// ///////////////////// Form pages ////////////////////////////
// new post
router.get(`${config.site_path}/${config.new_post_url}`, (req,res) => { router.get(`${config.site_path}/${config.new_post_url}`, (req,res) => {
res.render("forms/new_post", { res.render("forms/new_post", {
config, config,
locale, locale,
}); });
}); // /post }); // /post
// signup
router.get(`${config.site_path}/${config.signup_url}`, (req,res) => { router.get(`${config.site_path}/${config.signup_url}`, (req,res) => {
// if the server does allow signup // if the server does allow signup
if (config.allow_signup == true) { if (config.allow_signup == true) {
@@ -33,20 +36,24 @@ router.get(`${config.site_path}/${config.signup_url}`, (req,res) => {
console.log("Error, invalid value for allow_signup (bool)") console.log("Error, invalid value for allow_signup (bool)")
} }
}); // /signup }); // /signup
// edit account
router.get(`${config.site_path}/${config.edit_account_base_url}/:user_id`, (req,res) => { router.get(`${config.site_path}/${config.edit_account_base_url}/:user_id`, (req,res) => {
const userID = parseInt(req.params.user_id); const userID = parseInt(req.params.user_id);
res.render("forms/edit_account", res.render("forms/edit_account",
{ {
config, config,
locale, locale,
user: data.getdata('users', 'id', userID), user: data.getdata('users', 'id', userID)[0],
userID userID
}); });
}); // /delete_account }); // /delete_account
// edit post
router.get(`${config.site_path}/${config.edit_post_base_url}/:post_id`, (req,res) => { router.get(`${config.site_path}/${config.edit_post_base_url}/:post_id`, (req,res) => {
const postID = req.params.post_id const postID = req.params.post_id
const post = data.getdata('posts','id', postID) const post = data.getdata('posts','id', postID)[0]
const user = data.getdata('users', 'id', post.userID) const user = data.getdata('users', 'id', post.userID)[0]
res.render("forms/edit_post", res.render("forms/edit_post",
{ {
config, config,
+1 -1
View File
@@ -118,7 +118,7 @@ router.get(`${config.site_path}/comment/:postID-:commentID`, (req,res) => {
const commentID = parseInt(req.params.commentID); const commentID = parseInt(req.params.commentID);
const postID = parseInt(req.params.postID); const postID = parseInt(req.params.postID);
let posts_comments = data.getdata('comments', 'id', postID)["comments"] let posts_comments = data.getdata('comments', 'id', postID)[0]["comments"]
let comment = 1 let comment = 1
// For loop to find the comment with matching ID // For loop to find the comment with matching ID
posts_comments.forEach((current_comment, index) => { posts_comments.forEach((current_comment, index) => {
+6 -1
View File
@@ -1,9 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<%= config.language %"> <html lang="<%= config.language %>">
<head> <head>
<%- include("../partials/head") %> <%- include("../partials/head") %>
</head> </head>
<body> <body>
<div id="main">
<header id="site-header">
<%- include("../headers/site_wide") %>
</header>
<form action="<%= config.site_path %>/submit_edit_user" method="POST"> <form action="<%= config.site_path %>/submit_edit_user" method="POST">
<input name="userID" type="hidden" value="<%= userID %>"> <input name="userID" type="hidden" value="<%= userID %>">
<label><%= locale.password %>:</label><br/> <label><%= locale.password %>:</label><br/>
@@ -18,5 +22,6 @@
<label><%- locale.delete_account_confirmation %>: </label><input type="checkbox" name="agreement"><br/> <label><%- locale.delete_account_confirmation %>: </label><input type="checkbox" name="agreement"><br/>
<input type="submit" value="Submit"><br/> <input type="submit" value="Submit"><br/>
</form> </form>
</div>
</body> </body>
</html> </html>
+5
View File
@@ -4,6 +4,10 @@
<%- include("../partials/head") %> <%- include("../partials/head") %>
</head> </head>
<body> <body>
<div id="main">
<header id="site-header">
<%- include("../headers/site_wide") %>
</header>
<form action="<%= config.site_path %>/submit_edit_post" method="POST" onsubmit="sha512password()"> <form action="<%= config.site_path %>/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="<%= postID %>"> <input name="postID" type="hidden" value="<%= postID %>">
@@ -23,5 +27,6 @@
<label>Delete forever (no undo): </label><input name="delete" type="checkbox"><br/> <label>Delete forever (no undo): </label><input name="delete" type="checkbox"><br/>
<input type="submit" value="Submit"><br/> <input type="submit" value="Submit"><br/>
</form> </form>
</div>
</body> </body>
</html> </html>
+7 -1
View File
@@ -4,6 +4,10 @@
<%- include('../partials/head.ejs') %> <%- include('../partials/head.ejs') %>
</head> </head>
<body> <body>
<div id="main">
<header id="site-header">
<%- include("../headers/site_wide") %>
</header>
<form action="<%= config.site_path %>/submit_post" method="POST"> <form action="<%= config.site_path %>/submit_post" method="POST">
<label><%= locale.username %>:</label><br/> <label><%= locale.username %>:</label><br/>
<input required name="username"><br/><br/> <input required name="username"><br/><br/>
@@ -21,5 +25,7 @@
<input name="tags"><br/><br/> <input name="tags"><br/><br/>
<input type="submit" value="Submit"><br/> <input type="submit" value="Submit"><br/>
</form>
</div>
</body> </body>
</form></html> </html>
+5
View File
@@ -4,6 +4,10 @@
<%- include("../partials/head") %> <%- include("../partials/head") %>
</head> </head>
<body> <body>
<div id="main">
<header id="site-header">
<%- include("../headers/site_wide") %>
</header>
<form action="<%= config.site_path %>/submit_signup" method="POST"> <form action="<%= config.site_path %>/submit_signup" method="POST">
<label><%= locale.username %></label><br/> <label><%= locale.username %></label><br/>
<input required name="username"><br/><br/> <input required name="username"><br/><br/>
@@ -20,5 +24,6 @@
<label><%- locale.signup_agreement %>: </label><input type="checkbox" name="agreement" required><br/> <label><%- locale.signup_agreement %>: </label><input type="checkbox" name="agreement" required><br/>
<input type="submit" value="Submit"><br/> <input type="submit" value="Submit"><br/>
</form> </form>
</div>
</body> </body>
</html> </html>
-22
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>
-22
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>
-24
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>
-24
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>