diff --git a/app.js b/app.js
index 4d9462f..7ce98b0 100755
--- a/app.js
+++ b/app.js
@@ -155,8 +155,7 @@ function hyperlink_tags(tags) {
// the post index (int) as an optional paramter to indicate what post is to be used (for replacing things like content and titles)
// the tag (strig) as an optional parameter to indicate what tag is being used (for /tag/:tag pages)
// returns the template with it's format indiactors replaced (string)
-function replace_format_indicators(template, post_index=0, tag_name="tag") {
- post_object = posts.posts[post_index] // Defines the post object for easy reference
+function replace_format_indicators(template, post_index=-1, tag_name="tag", user_index=-1) {
output_string = template // These should always be replaceable
.replaceAll("%%", "%")
.replaceAll("%P", "/post")
@@ -165,7 +164,9 @@ function replace_format_indicators(template, post_index=0, tag_name="tag") {
.replaceAll("%Y", config.site_name)
.replaceAll("%W", config.site_description)
.replaceAll("%Z", config.attribution)
- if (posts.posts.length > 0) { // These can only be replaced if there are more than 0 posts in the posts list
+ .replaceAll("%S", config.seperator)
+ if (post_index >= 0) { // These can only be replaced if a post is specified (by default the post id is -1)
+ post_object = posts.posts[post_index] // Defines the post object for easy reference
output_string = output_string
.replaceAll("%A", (post_object["tags"]))
.replaceAll("%B", (hyperlink_tags(post_object["tags"])))
@@ -174,7 +175,7 @@ function replace_format_indicators(template, post_index=0, tag_name="tag") {
.replaceAll("%E", unix_time_to_date_format(post_object["editdate"]))
.replaceAll("%F", users.users[post_object["userID"]]['prettyname'])
.replaceAll("%G", tag_name)
- .replaceAll("%I", users.users[post_object['userID']]['description'])
+ .replaceAll("%I", converter.makeHtml(users.users[post_object['userID']]['description']))
.replaceAll("%L", `/post/${post_index}`)
.replaceAll("%M", return_comments(post_index))
.replaceAll("%N", users.users[post_object["userID"]]['username'])
@@ -187,11 +188,21 @@ function replace_format_indicators(template, post_index=0, tag_name="tag") {
`)
- }
- if (config.enable_hitcount == true) { // Finally, the hitcounter should only be replaced if config.enable_hitcount is true
- output_string = output_string
- .replaceAll("%H", fs.readFileSync('hitcount.txt'))
- }
+ }
+ if (user_index >= 0) { // these should only be replaced if a user is specified (by default the user id is -1)
+ output_string = output_string
+ .replaceAll("%F", users.users[user_index]['prettyname'])
+ .replaceAll("%G", tag_name)
+ .replaceAll("%I", converter.makeHtml(users.users[user_index]['description']))
+ .replaceAll("%L", `/post/${post_index}`)
+ .replaceAll("%N", users.users[user_index]['username'])
+ .replaceAll("%S", config.seperator)
+ .replaceAll("%U", `/user/${users.users[user_index]['username']}`)
+ }
+ if (config.enable_hitcount == true) { // Finally, the hitcounter should only be replaced if config.enable_hitcount is true
+ output_string = output_string
+ .replaceAll("%H", fs.readFileSync('hitcount.txt'))
+ }
return output_string
}
@@ -220,6 +231,7 @@ function return_comments(post_id) {
let comment = {...post_comments[comment_index]};
comment['content'] = comment['content']
.replaceAll(/>> ([0-9]*)/g, ">> $1")
+ .replaceAll(/>> ([0-9]*)/g, ">> $1")
.replaceAll("\n", "
")
comment_content += `