ssb+docs: prettier.

This commit is contained in:
Cory McWilliams 2024-11-27 12:07:00 -05:00
parent e1d93c003c
commit af6091760c
4 changed files with 57 additions and 26 deletions

View File

@ -408,9 +408,10 @@ ${JSON.stringify(mention, null, 2)}</pre
>
<tf-user id=${self.message.author} .users=${self.users}></tf-user>
<span style="padding-right: 8px"
><a tfarget="_top" href=${'#' + encodeURIComponent(self.message.id)}>%</a> ${new Date(
self.message.timestamp
).toLocaleString()}</span
><a tfarget="_top" href=${'#' + encodeURIComponent(self.message.id)}
>%</a
>
${new Date(self.message.timestamp).toLocaleString()}</span
>
${raw_button} ${self.format == 'raw' ? self.render_raw() : inner}
${self.render_votes()}
@ -449,7 +450,9 @@ ${JSON.stringify(mention, null, 2)}</pre
class="w3-card-4 w3-theme-d4 w3-border-theme"
style="margin-top: 8px; padding: 16px; overflow-wrap: anywhere"
>
<a target="_top" href=${'#' + encodeURIComponent(this.message.id)}>${this.message.id}</a>
<a target="_top" href=${'#' + encodeURIComponent(this.message.id)}
>${this.message.id}</a
>
(placeholder)
<div>${this.render_votes()}</div>
${(this.message.child_messages || []).map(
@ -600,7 +603,11 @@ ${JSON.stringify(content, null, 2)}</pre
${is_encrypted}
<span style="flex: 1"></span>
<span style="padding-right: 8px"
><a target="_top" href=${'#' + encodeURIComponent(self.message.id)}>%</a>
><a
target="_top"
href=${'#' + encodeURIComponent(self.message.id)}
>%</a
>
${new Date(this.message.timestamp).toLocaleString()}</span
>
<span>${raw_button}</span>
@ -643,7 +650,11 @@ ${JSON.stringify(content, null, 2)}</pre
${is_encrypted}
<span style="flex: 1"></span>
<span style="padding-right: 8px"
><a target="_top" href=${'#' + encodeURIComponent(self.message.id)}>%</a>
><a
target="_top"
href=${'#' + encodeURIComponent(self.message.id)}
>%</a
>
${new Date(this.message.timestamp).toLocaleString()}</span
>
<span>${raw_button}</span>
@ -733,7 +744,11 @@ ${JSON.stringify(content, null, 2)}</pre
<tf-user id=${this.message.author} .users=${this.users}></tf-user>
<span style="flex: 1"></span>
<span style="padding-right: 8px"
><a target="_top" href=${'#' + encodeURIComponent(self.message.id)}>%</a>
><a
target="_top"
href=${'#' + encodeURIComponent(self.message.id)}
>%</a
>
${new Date(this.message.timestamp).toLocaleString()}</span
>
<span>${raw_button}</span>

View File

@ -1,10 +1,9 @@
async function query(sql, args) {
let rows = [];
await ssb.sqlAsync(sql, args ?? [], function(row) {
await ssb.sqlAsync(sql, args ?? [], function (row) {
rows.push(row);
});
return rows;;
return rows;
}
async function get_biggest() {
@ -14,13 +13,16 @@ async function get_biggest() {
}
async function get_total() {
return (await query(`
return (
await query(`
select sum(length(content)) as size, count(distinct author) as count from messages;
`))[0];
`)
)[0];
}
async function get_names(identities) {
return query(`
return query(
`
SELECT author, name FROM (
SELECT
messages.author,
@ -32,7 +34,9 @@ async function get_names(identities) {
json_extract(messages.content, '$.type') = 'about' AND
content ->> 'about' = messages.author AND name IS NOT NULL)
WHERE author_rank = 1
`, [JSON.stringify(identities)]);
`,
[JSON.stringify(identities)]
);
}
async function get_most_follows() {
@ -58,22 +62,32 @@ function nice_size(bytes) {
}
async function main() {
await app.setDocument('<p style="color: #fff">Finding the top 10 largest feeds...</p>');
await app.setDocument(
'<p style="color: #fff">Finding the top 10 largest feeds...</p>'
);
let most_follows = await get_most_follows();
let total = await get_total();
let identities = await ssb.getAllIdentities();
let following1 = await ssb.following(identities, 1);
let following2 = await ssb.following(identities, 2);
let biggest = await get_biggest();
let names = await get_names([].concat(biggest.map(x => x.author), most_follows.map(x => x.author)));
names = Object.fromEntries(names.map(x => [x.author, x.name]));
let names = await get_names(
[].concat(
biggest.map((x) => x.author),
most_follows.map((x) => x.author)
)
);
names = Object.fromEntries(names.map((x) => [x.author, x.name]));
for (let item of biggest) {
item.name = names[item.author];
item.following =
identities.indexOf(item.author) != -1 ? 0 :
following1[item.author] !== undefined ? 1 :
following2[item.author] !== undefined ? 2 :
undefined;
identities.indexOf(item.author) != -1
? 0
: following1[item.author] !== undefined
? 1
: following2[item.author] !== undefined
? 2
: undefined;
}
for (let item of most_follows) {
item.name = names[item.author];
@ -108,4 +122,6 @@ async function main() {
await app.setDocument(html);
}
main().catch(function(e) { print(e); });
main().catch(function (e) {
print(e);
});

2
docs

@ -1 +1 @@
Subproject commit f17105d473c0174a6608d713295add65c6a82b62
Subproject commit a40758cc4bef5ded4d214c2acf1c95e554e20564