diff --git a/lib.js b/lib.js index 9610e3b..4d3a86d 100644 --- a/lib.js +++ b/lib.js @@ -10,7 +10,20 @@ function apiStat(res, next, message, success = false, redirect = '/') { } function splitUp(content) { - let out = content.split('\n').map(x => x.split('::')); + let out = content.split(/(\s)/g); + + for (let i in out) { + let res = out[i]; + if (res.startsWith('file::')) { + out[i] = ['file', res.slice('file::'.length)]; + continue; + } + if (res.startsWith('https://')) { + out[i] = ['link',res]; + continue; + } + out[i] = [res]; + } return out; } diff --git a/routes/comment.js b/routes/comment.js index a92c4fc..a34cdc4 100644 --- a/routes/comment.js +++ b/routes/comment.js @@ -7,7 +7,6 @@ let db = await initDb(); //todo: fix jank router.get('/:id', async (req, res, next) => { - let replies = []; let feeder = req.params.id; let feederType = 'comment'; diff --git a/views/comment.ejs b/views/comment.ejs index 6a1b776..afc6a93 100644 --- a/views/comment.ejs +++ b/views/comment.ejs @@ -7,13 +7,16 @@ Context <% } %> - <% for (let contentN of content) { %> - <% if (contentN[0] == 'file' && contentN [1]) { %> - '> - <% } else { %> -
<%= contentN[0] %>
- <% } %> - <% } %> +
+ <% for (let contentN of content) { %> + <% if (contentN[0] == 'file') { %> + '> + <% } else if (contentN[0] == 'link') { %> + <%= contentN[1] %> + <% } else if (contentN[0].replaceAll(' ','').length > 0) { %> + <%= contentN[0] %> + <% } } %> +
<% if (!isNaN(date * 1)) { %>
Posted on <%= new Date(date).toISOString() %>
<% } %>