Run prettier.
This commit is contained in:
@ -1,11 +1,19 @@
|
||||
import * as commonmark from './commonmark.min.js';
|
||||
|
||||
function escape(text) {
|
||||
return (text ?? '').replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');
|
||||
return (text ?? '')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>');
|
||||
}
|
||||
|
||||
function escapeAttribute(text) {
|
||||
return (text ?? '').replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll("'", ''');
|
||||
return (text ?? '')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll("'", ''');
|
||||
}
|
||||
|
||||
export async function get_blog_message(id) {
|
||||
@ -13,7 +21,7 @@ export async function get_blog_message(id) {
|
||||
await ssb.sqlAsync(
|
||||
'SELECT author, timestamp, content FROM messages WHERE id = ?',
|
||||
[id],
|
||||
function(row) {
|
||||
function (row) {
|
||||
let content = JSON.parse(row.content);
|
||||
message = {
|
||||
author: row.author,
|
||||
@ -21,7 +29,8 @@ export async function get_blog_message(id) {
|
||||
blog: content?.blog,
|
||||
title: content?.title,
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
if (message) {
|
||||
await ssb.sqlAsync(
|
||||
`
|
||||
@ -34,9 +43,10 @@ export async function get_blog_message(id) {
|
||||
ORDER BY sequence DESC LIMIT 1
|
||||
`,
|
||||
[message.author],
|
||||
function(row) {
|
||||
function (row) {
|
||||
message.name = row.name;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
@ -51,8 +61,12 @@ export function markdown(md) {
|
||||
node = event.node;
|
||||
if (event.entering) {
|
||||
if (node.destination?.startsWith('&')) {
|
||||
node.destination = '/' + node.destination + '/view?filename=' + node.firstChild?.literal;
|
||||
} else if (node.destination?.startsWith('@') || node.destination?.startsWith('%')) {
|
||||
node.destination =
|
||||
'/' + node.destination + '/view?filename=' + node.firstChild?.literal;
|
||||
} else if (
|
||||
node.destination?.startsWith('@') ||
|
||||
node.destination?.startsWith('%')
|
||||
) {
|
||||
node.destination = '/~core/ssb/#' + escape(node.destination);
|
||||
}
|
||||
}
|
||||
@ -107,7 +121,7 @@ export function render_html(blogs) {
|
||||
<h1>🪵Tilde Friends Blog</h1>
|
||||
<div style="font-size: xx-small; vertical-align: middle"><a href="/~cory/blog/atom">atom feed</a></div>
|
||||
</div>
|
||||
${blogs.map(blog_post => render_blog_post(blog_post)).join('\n')}
|
||||
${blogs.map((blog_post) => render_blog_post(blog_post)).join('\n')}
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
@ -135,14 +149,15 @@ export function render_atom(blogs) {
|
||||
<link href="${core.url}"/>
|
||||
<id>${core.url}</id>
|
||||
<updated>${new Date().toString()}</updated>
|
||||
${blogs.map(blog_post => render_blog_post_atom(blog_post)).join('\n')}
|
||||
${blogs.map((blog_post) => render_blog_post_atom(blog_post)).join('\n')}
|
||||
</feed>`;
|
||||
}
|
||||
|
||||
export async function get_posts() {
|
||||
let blogs = [];
|
||||
let ids = await ssb.getIdentities();
|
||||
await ssb.sqlAsync(`
|
||||
await ssb.sqlAsync(
|
||||
`
|
||||
WITH
|
||||
blogs AS (
|
||||
SELECT
|
||||
@ -182,8 +197,11 @@ export async function get_posts() {
|
||||
JOIN public ON public.author = blogs.author
|
||||
LEFT OUTER JOIN names ON names.author = blogs.author
|
||||
ORDER BY blogs.timestamp DESC LIMIT 20
|
||||
`, [JSON.stringify(ids)], function(row) {
|
||||
blogs.push(row);
|
||||
});
|
||||
`,
|
||||
[JSON.stringify(ids)],
|
||||
function (row) {
|
||||
blogs.push(row);
|
||||
}
|
||||
);
|
||||
return blogs;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user