* added "quotes" to the locales

* made all the ejs pages use "postID" as the variable for post indexes
* split up en-GB and en-US
This commit is contained in:
2025-08-27 18:30:26 +01:00
parent c73ce69f93
commit 27b9ee6437
10 changed files with 94 additions and 13 deletions

View File

@@ -2,7 +2,7 @@
"seperator": "<hr/>", "seperator": "<hr/>",
"site_name": "My Blog", "site_name": "My Blog",
"site_url": "https://example.com", "site_url": "https://example.com",
"language": "en", "language": "en-US",
"port": 8080, "port": 8080,
"allow_signup": true, "allow_signup": true,
"site_description": "Read my blogs!", "site_description": "Read my blogs!",

View File

@@ -1,4 +1,5 @@
{ {
"quotes": "“”‘’",
"password": "Password", "password": "Password",
"username": "Username", "username": "Username",
"prettyname": "Prettyname", "prettyname": "Prettyname",

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

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

39
locales/template.json Normal file
View File

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

View File

@@ -101,13 +101,15 @@ export function render_comment(comment_content) {
}; };
export function render_md(content) { export function render_md(content) {
const markdownit = require("markdown-it") const markdownit = require("markdown-it")
const config = require("../config.json")
const locale = require(`../locales/${config.locale}.json`)
const md = markdownit({ const md = markdownit({
html: false, html: false,
xhtmlOut: false, xhtmlOut: false,
breaks: true, breaks: true,
linkify: false, linkify: false,
typographer: true, typographer: true,
quotes: true, quotes: locale.quotes,
}) })
return md.render(content) return md.render(content)
}; };

View File

@@ -18,7 +18,7 @@
<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) { %>
<%- 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]}); %>
<% } %> <% } %>
<% } %> <% } %>
</div> </div>

View File

@@ -11,7 +11,7 @@
<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) { %> <% 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}); %>
<% } %> <% } %>
<% } %> <% } %>
</div> </div>

View File

@@ -2,7 +2,7 @@
<%= post.title %> <%= post.title %>
</h3> </h3>
<%- func.render_md(post.content) %><br/> <%- func.render_md(post.content) %><br/>
<a href="<%= config.edit_post_base_url %>/<%= post_index %>"><%= locale.edit_post %></a><br/> <a href="<%= config.edit_post_base_url %>/<%= postID %>"><%= locale.edit_post %></a><br/>
<a href="/post/<%- postID %>"><%= locale.permalink %></a><br/> <a href="/post/<%- postID %>"><%= locale.permalink %></a><br/>
<%- func.hyperlink_tags(post.tags) %> <%- func.hyperlink_tags(post.tags) %>
<br/> <br/>

View File

@@ -2,8 +2,8 @@
<%= post.title %> <%= post.title %>
</h3> </h3>
<%- func.render_md(post.content) %><br/> <%- func.render_md(post.content) %><br/>
<a href="<%= config.edit_post_base_url %>/<%= post_index %>"><%= locale.edit_post %></a><br/> <a href="<%= config.edit_post_base_url %>/<%= postID %>"><%= locale.edit_post %></a><br/>
<a href="/post/<%- index %>"><%= locale.permalink %></a><br/> <a href="/post/<%- postID %>"><%= locale.permalink %></a><br/>
<i> <i>
<%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/> <%= locale.written_by %> <a href="/user/<%= user.username %>"><%= user.username %></a><br/>
</i> </i>
@@ -11,13 +11,13 @@
<!-- Comment form --> <!-- Comment form -->
<form method="POST" action="/submit_comment"> <form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= index %>"> <input type="hidden" name="post_index" value="<%= postID %>">
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/> <label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/> <label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
<button type="submit"><%= locale.submit %></button> <button type="submit"><%= locale.submit %></button>
</form> </form>
<% comments[index].forEach((comment, index) => { %> <% comments[postID].forEach((comment, postID) => { %>
<%- include('../partials/comment', {comment: comment}) %> <%- include('../partials/comment', {comment: comment}) %>
<% }) %> <% }) %>

View File

@@ -2,19 +2,19 @@
<%= post.title %> <%= post.title %>
</h3> </h3>
<%- func.render_md(post.content) %><br/> <%- func.render_md(post.content) %><br/>
<a href="<%= config.edit_post_base_url %>/<%= post_index %>"><%= locale.edit_post %></a><br/> <a href="<%= config.edit_post_base_url %>/<%= postID %>"><%= locale.edit_post %></a><br/>
<a href="/post/<%- index %>"><%= locale.permalink %></a><br/> <a href="/post/<%- postID %>"><%= locale.permalink %></a><br/>
<br/> <br/>
<!-- Comment form --> <!-- Comment form -->
<form method="POST" action="/submit_comment"> <form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= index %>"> <input type="hidden" name="post_index" value="<%= postID %>">
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/> <label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
<label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/> <label><%= locale.comment %>:</label><br/><textarea name="content"></textarea><br/>
<button type="submit"><%= locale.submit %></button> <button type="submit"><%= locale.submit %></button>
</form> </form>
<% comments[index].forEach((comment, index) => { %> <% comments[postID].forEach((comment, postID) => { %>
<%- include('../partials/comment', {comment: comment}) %> <%- include('../partials/comment', {comment: comment}) %>
<% }) %> <% }) %>