diff --git a/app.js b/app.js index 7aab9b8..d749531 100755 --- a/app.js +++ b/app.js @@ -1,12 +1,13 @@ const express = require('express'); +const showdown = require('showdown') const crypto = require('crypto'); // For encrypting passwords const { fromUnixTime, format, getUnixTime } = require("date-fns") const fs = require('fs'); const users = require('./users.js'); const posts = require('./posts.js'); const config = require('./config.js'); +let converter = new showdown.Converter({simpleLineBreaks: true, tables: true, strikethrough: true, tasklists: true, encodeEmails: true}) const app = express(); -const port = 8080; let footer_div = config.site_wide_footer footer_div = replace_format_indicators(footer_div) @@ -53,7 +54,7 @@ function replace_format_indicators(input_string, post_index=0, tag_name="tag") { .replaceAll("%%", "%") .replaceAll("%A", (post_object["tags"])) .replaceAll("%B", (hyperlink_tags(post_object["tags"]))) - .replaceAll("%C", markdown_to_html(post_object["content"])) + .replaceAll("%C", converter.makeHtml(post_object["content"])) .replaceAll("%D", unix_time_to_date_format(post_object["pubdate"])) .replaceAll("%E", unix_time_to_date_format(post_object["editdate"])) .replaceAll("%F", users.users[post_object["userID"]]['prettyname']) @@ -65,7 +66,7 @@ function replace_format_indicators(input_string, post_index=0, tag_name="tag") { .replaceAll("%O", `/edit/${post_index}`) .replaceAll("%R", "/rss") .replaceAll("%S", config.seperator) - .replaceAll("%T", markdown_to_html(post_object["title"])) + .replaceAll("%T", post_object["title"]) .replaceAll("%U", `/user/${users.users[post_object["userID"]]['username']}`) .replaceAll("%Y", config.site_name) .replaceAll("%W", config.site_description) @@ -89,22 +90,6 @@ function escape_input(input) { return output } -// Markdown supported: -// *text* = bold -// _text_ = italic -// [page](url) = hyperlink -// ```code``` = code -function markdown_to_html(input) { - // FIXME backticks before these should negate stuff - let output = input - .replaceAll(/\[(.*)\]\((https:\/\/|http:\/\/)(.*)\)/g, "$1") - .replaceAll(/\*(.*)\*/g,"$1") - .replaceAll(/_(.*)_/g,"$1") - .replaceAll(/```(.*)```/gms,"$1") - .replaceAll("\n","
") - return output -} - app.get(config.rss_path, (req,res) => { if (config.rss == false) { res.send("Sorry, RSS is disabled!") @@ -122,7 +107,7 @@ app.get(config.rss_path, (req,res) => { ${posts.posts[i]["title"]} ${config.site_url}/post/${i}.${config.file_extension} - ")}]]> + ${config.site_url}/post/${i} ${unix_time_to_rss_date(posts.posts[i]['pubdate'])}` for (let j = 0; j < posts.posts[i]['tags'].length; j++) { @@ -197,8 +182,8 @@ app.get("/post", (req,res) => {


- - * Markdown supported: *bold*, _italic_, (link)[url] and \`\`\`code block\`\`\` +
+ * Markdown supported `); }); app.get("/edit/:post_id", (req,res) => { @@ -211,15 +196,12 @@ app.get("/edit/:post_id", (req,res) => {

- -
+ +


- +
+ * Markdown supported `); }); @@ -281,6 +263,6 @@ app.post("/submit_post", (req,res) => { } }); -app.listen(port, () => { - console.log(`Server is running at http://localhost:${port} in ${config.root_path}`); +app.listen(config.port, () => { + console.log(`Server is running at http://localhost:${config.port} in ${config.root_path}`); }); diff --git a/config.js b/config.js index 63e1d3c..74b59e9 100755 --- a/config.js +++ b/config.js @@ -1,6 +1,7 @@ export const seperator = "
" export const site_name = "Deadvey's Blog" export const site_url = "https://deadvey.com" +export const port = 8080 export const site_description = "Films, tech, random shit" export const timeline_length = 20 export const enable_hitcount = true // Can slow down page loading a bit @@ -103,6 +104,9 @@ export const css = ` color: #282828; border: 1px solid #282828; } + table { + border: solid 1px #282828; + } } @media (prefers-color-scheme: dark) { body { @@ -129,6 +133,9 @@ export const css = ` color: #ebdbb2; border: 1px solid #ebdbb2; } + table, td, th { + border: solid 1px #ebdbb2; + } } ` diff --git a/hitcount.txt b/hitcount.txt index 4e9e288..a09fd8a 100644 --- a/hitcount.txt +++ b/hitcount.txt @@ -1 +1 @@ -63 \ No newline at end of file +124 \ No newline at end of file