From 2dc2d9ebf61700406fef14693d53468a30c18dae Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 19 Mar 2023 13:07:33 +0000 Subject: [PATCH] Add appstore, so I can get apps more easily to my phone. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4235 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/appstore.json | 3 +++ apps/appstore/app.js | 55 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 apps/appstore.json create mode 100644 apps/appstore/app.js diff --git a/apps/appstore.json b/apps/appstore.json new file mode 100644 index 00000000..ac0280b4 --- /dev/null +++ b/apps/appstore.json @@ -0,0 +1,3 @@ +{ + "type": "tildefriends-app" +} \ No newline at end of file diff --git a/apps/appstore/app.js b/apps/appstore/app.js new file mode 100644 index 00000000..02719736 --- /dev/null +++ b/apps/appstore/app.js @@ -0,0 +1,55 @@ +async function get_apps() { + let results = {}; + await ssb.sqlStream(` + SELECT messages.* + FROM messages_fts('"application/tildefriends"') + JOIN messages ON messages.rowid = messages_fts.rowid + ORDER BY timestamp + `, + [], + function(row) { + let content = JSON.parse(row.content); + for (let mention of content.mentions) { + if (mention?.type === 'application/tildefriends') { + results[JSON.stringify([row.author, mention.name])] = { + message: row, + blob: mention.link, + name: mention.name, + }; + } + } + }); + return Object.values(results).sort((x, y) => y.message.timestamp - x.message.timestamp); +} + +function render_app(app) { + return ` +
+ @ + % + ${app.name} +
+ `; +} + +async function main() { + let apps = await get_apps(); + app.setDocument(` + + + + + + +

${apps.length} apps

+ ${apps.map(render_app).join('\n')} + + + `); +} + +main(); \ No newline at end of file