implement link formatting
This commit is contained in:
parent
e7a41a520a
commit
711a799482
3 changed files with 24 additions and 9 deletions
15
lib.js
15
lib.js
|
@ -10,7 +10,20 @@ function apiStat(res, next, message, success = false, redirect = '/') {
|
||||||
}
|
}
|
||||||
|
|
||||||
function splitUp(content) {
|
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;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ let db = await initDb();
|
||||||
//todo: fix jank
|
//todo: fix jank
|
||||||
|
|
||||||
router.get('/:id', async (req, res, next) => {
|
router.get('/:id', async (req, res, next) => {
|
||||||
|
|
||||||
let replies = [];
|
let replies = [];
|
||||||
let feeder = req.params.id;
|
let feeder = req.params.id;
|
||||||
let feederType = 'comment';
|
let feederType = 'comment';
|
||||||
|
|
|
@ -7,13 +7,16 @@
|
||||||
Context
|
Context
|
||||||
<% } %>
|
<% } %>
|
||||||
</h1>
|
</h1>
|
||||||
<% for (let contentN of content) { %>
|
<div>
|
||||||
<% if (contentN[0] == 'file' && contentN [1]) { %>
|
<% for (let contentN of content) { %>
|
||||||
<img class='art' src='<%= new URL(contentN[1], 'https://tbg.dervland.net/') %>'>
|
<% if (contentN[0] == 'file') { %>
|
||||||
<% } else { %>
|
<img class='art' src='<%= new URL(contentN[1], 'https://tbg.dervland.net/') %>'>
|
||||||
<div class='commentbox'><%= contentN[0] %></div>
|
<% } else if (contentN[0] == 'link') { %>
|
||||||
<% } %>
|
<a class='link' href='<%= contentN[1] %>.'><%= contentN[1] %></a>
|
||||||
<% } %>
|
<% } else if (contentN[0].replaceAll(' ','').length > 0) { %>
|
||||||
|
<span class='commentbox'><%= contentN[0] %></span>
|
||||||
|
<% } } %>
|
||||||
|
</div>
|
||||||
<% if (!isNaN(date * 1)) { %>
|
<% if (!isNaN(date * 1)) { %>
|
||||||
<div class='sub'><b>Posted on</b> <%= new Date(date).toISOString() %> </div>
|
<div class='sub'><b>Posted on</b> <%= new Date(date).toISOString() %> </div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
Loading…
Reference in a new issue