Experimental browser for the Atmosphere
{ "uri": "at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3lm3sjwkdwg22", "cid": "bafyreicfkp36eg5x3si57oun7zs3i2nsla4d2pfg5ggzjaeeh3kaev3nbe", "value": { "$type": "sh.tangled.repo.pull", "patch": "diff --git a/x b/x\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..f6e443158e8a51289a50fdcf9834d0aa56fa13f0\n--- /dev/null\n+++ b/x\n@@ -0,0 +1,463 @@\n+From 489bb110616aa4da596aed7ae0a048c919ed333e Mon Sep 17 00:00:00 2001\n+From: Akshay <nerdy@peppe.rs>\n+Date: Thu, 26 Dec 2024 19:19:37 +0000\n+Subject: [PATCH 1/3] add footer, comments, linenrs etc\n+\n+---\n+ src/mixins/footer.pug | 9 +++++++++\n+ src/mixins/post.pug | 3 ++-\n+ src/mixins/utils.pug | 4 ++++\n+ src/public/styles.css | 21 +++++++++++++++++++--\n+ src/routes.ts | 33 +++++++++++++++++++++++++++++----\n+ src/views/index.pug | 3 +++\n+ src/views/paste.pug | 28 +++++++++++++++++++++-------\n+ 7 files changed, 87 insertions(+), 14 deletions(-)\n+ create mode 100644 src/mixins/footer.pug\n+\n+diff --git a/src/mixins/footer.pug b/src/mixins/footer.pug\n+new file mode 100644\n+index 0000000..be71086\n+--- /dev/null\n++++ b/src/mixins/footer.pug\n+@@ -0,0 +1,9 @@\n++mixin footer()\n++ hr\n++ div.footer\n++ div.left-side\n++ div.right-side\n++ p\n++ | made by \n++ a(href=\"https://bsky.app/profile/oppi.li\") @oppi.li\n++\n+diff --git a/src/mixins/post.pug b/src/mixins/post.pug\n+index 77d78aa..e98bcf8 100644\n+--- a/src/mixins/post.pug\n++++ b/src/mixins/post.pug\n+@@ -13,4 +13,5 @@ mixin post(paste, handle, did)\n+ | #{paste.lang}\n+ | ·\n+ | #{paste.code.split('\\n').length} loc\n+-\n++ | · \n++ a(href=`/p/${paste.shortUrl}/#comments`) #{paste.commentCount} #{pluralize(paste.commentCount, 'comment')}\n+diff --git a/src/mixins/utils.pug b/src/mixins/utils.pug\n+index 857bddd..08507d3 100644\n+--- a/src/mixins/utils.pug\n++++ b/src/mixins/utils.pug\n+@@ -2,6 +2,10 @@\n+ function randInt(min, max) {\n+ return Math.floor(Math.random() * (max - min + 1)) + min;\n+ }\n++- \n++ function pluralize(count, noun) {\n++ return count==1?noun:`${noun}s`;\n++ }\n+ -\n+ function timeDifference(current, previous) {\n+ if (!current || !previous) {\n+diff --git a/src/public/styles.css b/src/public/styles.css\n+index f88b533..6f80f5f 100644\n+--- a/src/public/styles.css\n++++ b/src/public/styles.css\n+@@ -104,7 +104,6 @@ textarea {\n+ hr {\n+ border: none;\n+ border-top: 1px solid var(--bg-color-muted);\n+- padding: 1rem;\n+ }\n+ \n+ .post-form {\n+@@ -152,7 +151,7 @@ hr {\n+ flex: 1\n+ }\n+ \n+-.header {\n++.header, .footer {\n+ display: flex;\n+ flex-direction: row;\n+ justify-content: space-between;\n+@@ -165,3 +164,21 @@ select {\n+ text-indent: 1px;\n+ text-overflow: '';\n+ }\n++\n++.code-line {\n++ display: flex;\n++}\n++\n++.code-line-num {\n++ white-space: pre;\n++ -webkit-user-select: none;\n++ user-select: none;\n++ margin-right: 0.4em;\n++ padding: 0 0.4em 0 0.4em;\n++ color: var(--text-color-muted);\n++ text-align: right;\n++}\n++\n++.code-line-content {\n++ color: var(--text-color);\n++}\n+diff --git a/src/routes.ts b/src/routes.ts\n+index 70f931d..17fa00e 100644\n+--- a/src/routes.ts\n++++ b/src/routes.ts\n+@@ -105,8 +105,20 @@ export const createRouter = (ctx: Ctx) => {\n+ \t\tconst agent = await getSessionAgent(req, res, ctx);\n+ \t\tconst pastes = await ctx.db\n+ \t\t\t.selectFrom(\"paste\")\n+-\t\t\t.selectAll()\n+-\t\t\t.orderBy(\"indexedAt\", \"desc\")\n++\t\t\t.leftJoin(\"comment\", \"comment.pasteUri\", \"paste.uri\")\n++\t\t\t.select([\n++\t\t\t\t\"paste.uri\",\n++\t\t\t\t\"paste.shortUrl\",\n++\t\t\t\t\"paste.authorDid\",\n++\t\t\t\t\"paste.code\",\n++\t\t\t\t\"paste.lang\",\n++\t\t\t\t\"paste.title\",\n++\t\t\t\t\"paste.createdAt\",\n++\t\t\t\t\"paste.indexedAt as pasteIndexedAt\",\n++\t\t\t\tctx.db.fn.count(\"comment.uri\").as(\"commentCount\")\n++\t\t\t])\n++\t\t\t.groupBy(\"paste.uri\")\n++\t\t\t.orderBy(\"pasteIndexedAt\", \"desc\")\n+ \t\t\t.limit(25)\n+ \t\t\t.execute();\n+ \n+@@ -130,8 +142,21 @@ export const createRouter = (ctx: Ctx) => {\n+ \t\tconst { authorDid } = req.params;\n+ \t\tconst pastes = await ctx.db\n+ \t\t\t.selectFrom(\"paste\")\n+-\t\t\t.selectAll()\n+-\t\t\t.where(\"authorDid\", \"=\", authorDid)\n++\t\t\t.leftJoin(\"comment\", \"comment.pasteUri\", \"paste.uri\")\n++\t\t\t.select([\n++\t\t\t\t\"paste.uri\",\n++\t\t\t\t\"paste.shortUrl\",\n++\t\t\t\t\"paste.authorDid as pasteAuthorDid\",\n++\t\t\t\t\"paste.code\",\n++\t\t\t\t\"paste.lang\",\n++\t\t\t\t\"paste.title\",\n++\t\t\t\t\"paste.createdAt as pasteCreatedAt\",\n++\t\t\t\t\"paste.indexedAt as pasteIndexedAt\",\n++\t\t\t\tctx.db.fn.count(\"comment.uri\").as(\"commentCount\")\n++\t\t\t])\n++\t\t\t.groupBy(\"paste.uri\")\n++\t\t\t.where(\"pasteAuthorDid\", \"=\", authorDid)\n++\t\t\t.orderBy(\"pasteCreatedAt\", \"desc\")\n+ \t\t\t.execute();\n+ \t\tlet didHandleMap: Record<string, string> = {};\n+ \t\tdidHandleMap[authorDid] = await ctx.resolver.resolveDidToHandle(authorDid);\n+diff --git a/src/views/index.pug b/src/views/index.pug\n+index 3443deb..e04403d 100644\n+--- a/src/views/index.pug\n++++ b/src/views/index.pug\n+@@ -1,6 +1,7 @@\n+ include ../mixins/mkPost\n+ include ../mixins/head\n+ include ../mixins/header\n++include ../mixins/footer\n+ include ../mixins/utils\n+ include ../mixins/post\n+ \n+@@ -19,6 +20,7 @@ include ../mixins/post\n+ \"c\",\n+ \"c#\",\n+ \"c++\",\n++ \"cobol\",\n+ ].toSorted())\n+ doctype html\n+ html\n+@@ -34,3 +36,4 @@ html\n+ each paste in pastes\n+ - var handle = didHandleMap[paste.authorDid]\n+ +post(paste, handle, paste.authorDid)\n++ +footer()\n+diff --git a/src/views/paste.pug b/src/views/paste.pug\n+index 29516d3..f8a0906 100644\n+--- a/src/views/paste.pug\n++++ b/src/views/paste.pug\n+@@ -15,12 +15,21 @@ html\n+ | #{paste.lang} · \n+ | #{paste.code.split('\\n').length} loc · \n+ a(href=`/r/${paste.shortUrl}`) raw\n++ | · \n++ | #{comments.length} #{pluralize(comments.length, 'comment')}\n+ pre\n+- | #{paste.code}\n++ code\n++ - var lines = paste.code.split(/\\r?\\n|\\r|\\n/g)\n++ - var tot_chars = lines.length.toString().length\n++ each line, idx in lines\n++ span.code-line\n++ span.code-line-num(id=`L${idx + 1}` style=`min-width: ${tot_chars}ch;`)\n++ | #{idx + 1}\n++ span.code-line-content #{line}\n+ hr\n+ \n+ if comments.length != 0\n+- h1 comments\n++ h1(id=\"comments\") comments\n+ div.comments\n+ each comment in comments\n+ div.comment(id=`${encodeURIComponent(comment.uri)}`)\n+@@ -33,9 +42,14 @@ html\n+ pre.comment-body #{comment.body}\n+ hr\n+ \n+- form(action=`/${encodeURIComponent(paste.uri)}/comment` method=\"post\").post-form\n+- div.post-row\n+- textarea#code(name=\"comment\" rows=\"5\" placeholder=\"add a comment\" required).post-input-code\n++ if ownDid\n++ form(action=`/${encodeURIComponent(paste.uri)}/comment` method=\"post\").post-form\n++ div.post-row\n++ textarea#code(name=\"comment\" rows=\"5\" placeholder=\"add a comment\" required).post-input-code\n+ \n+- div.post-submit-row\n+- button(type=\"submit\").post-input-submit zonk!\n++ div.post-submit-row\n++ button(type=\"submit\").post-input-submit zonk!\n++ else \n++ p\n++ a(href=\"/login\") login\n++ | to post a comment\n+-- \n+2.47.0\n+\n+From 436f4d5e8912c50068d8c70e623a23ce2ca9e6e7 Mon Sep 17 00:00:00 2001\n+From: Akshay <nerdy@peppe.rs>\n+Date: Thu, 26 Dec 2024 21:12:07 +0000\n+Subject: [PATCH 2/3] footer everywhere\n+\n+---\n+ src/views/index.pug | 1 +\n+ src/views/login.pug | 2 ++\n+ src/views/paste.pug | 6 ++++--\n+ src/views/user.pug | 3 +++\n+ 4 files changed, 10 insertions(+), 2 deletions(-)\n+\n+diff --git a/src/views/index.pug b/src/views/index.pug\n+index e04403d..bc9085a 100644\n+--- a/src/views/index.pug\n++++ b/src/views/index.pug\n+@@ -36,4 +36,5 @@ html\n+ each paste in pastes\n+ - var handle = didHandleMap[paste.authorDid]\n+ +post(paste, handle, paste.authorDid)\n++\n+ +footer()\n+diff --git a/src/views/login.pug b/src/views/login.pug\n+index 55aa048..b5a35e0 100644\n+--- a/src/views/login.pug\n++++ b/src/views/login.pug\n+@@ -1,4 +1,5 @@\n+ include ../mixins/head\n++include ../mixins/footer\n+ \n+ doctype html\n+ html\n+@@ -10,3 +11,4 @@ html\n+ div.login-row\n+ input(type=\"text\" name=\"handle\" placeholder=\"enter handle\" required).login-input-title\n+ button(type=\"submit\").login-submit-button login\n++ +footer()\n+diff --git a/src/views/paste.pug b/src/views/paste.pug\n+index f8a0906..653c02e 100644\n+--- a/src/views/paste.pug\n++++ b/src/views/paste.pug\n+@@ -1,6 +1,7 @@\n+ - var now = new Date()\n+ include ../mixins/head\n+ include ../mixins/header\n++include ../mixins/footer\n+ include ../mixins/utils\n+ doctype html\n+ html\n+@@ -40,7 +41,6 @@ html\n+ | #{timeDifference(now, Date.parse(paste.createdAt))} ago\n+ p \n+ pre.comment-body #{comment.body}\n+- hr\n+ \n+ if ownDid\n+ form(action=`/${encodeURIComponent(paste.uri)}/comment` method=\"post\").post-form\n+@@ -49,7 +49,9 @@ html\n+ \n+ div.post-submit-row\n+ button(type=\"submit\").post-input-submit zonk!\n+- else \n++ else\n+ p\n+ a(href=\"/login\") login\n+ | to post a comment\n++\n++ +footer()\n+diff --git a/src/views/user.pug b/src/views/user.pug\n+index 3523e16..b2b2743 100644\n+--- a/src/views/user.pug\n++++ b/src/views/user.pug\n+@@ -2,6 +2,7 @@\n+ - var handle = didHandleMap[authorDid]\n+ include ../mixins/head\n+ include ../mixins/header\n++include ../mixins/footer\n+ include ../mixins/utils\n+ include ../mixins/post\n+ doctype html\n+@@ -14,3 +15,5 @@ html\n+ div.timeline\n+ each paste in pastes\n+ +post(paste, handle, authorDid)\n++\n++ +footer()\n+-- \n+2.47.0\n+\n+From a717f0702e818515e34187cde86c15c00d2e66ba Mon Sep 17 00:00:00 2001\n+From: Akshay <nerdy@peppe.rs>\n+Date: Thu, 26 Dec 2024 23:14:37 +0000\n+Subject: [PATCH 3/3] stylin for links\n+\n+---\n+ src/mixins/post.pug | 2 +-\n+ src/public/styles.css | 51 ++++++++++++++++++++++++++++++++++++++++++-\n+ src/views/paste.pug | 9 ++++----\n+ 3 files changed, 55 insertions(+), 7 deletions(-)\n+\n+diff --git a/src/mixins/post.pug b/src/mixins/post.pug\n+index e98bcf8..51af1ff 100644\n+--- a/src/mixins/post.pug\n++++ b/src/mixins/post.pug\n+@@ -1,7 +1,7 @@\n+ mixin post(paste, handle, did)\n+ div.post\n+ p\n+- a(href=`/p/${paste.shortUrl}`)\n++ a(href=`/p/${paste.shortUrl}`).post-link\n+ | #{paste.title}\n+ p.post-info\n+ | by \n+diff --git a/src/public/styles.css b/src/public/styles.css\n+index 6f80f5f..b153f92 100644\n+--- a/src/public/styles.css\n++++ b/src/public/styles.css\n+@@ -58,7 +58,6 @@ a:visited {\n+ }\n+ \n+ pre {\n+- background-color: var(--bg-color-muted);\n+ padding: 1rem;\n+ overflow-x: auto;\n+ }\n+@@ -66,6 +65,11 @@ pre {\n+ .comment-body {\n+ background-color: var(--bg-color);\n+ padding: 0;\n++ margin-top: 0.1rem;\n++}\n++\n++.comment-info {\n++ margin-bottom: 0;\n+ }\n+ \n+ input, textarea, select, button {\n+@@ -137,10 +141,40 @@ hr {\n+ align-self: flex-end;\n+ }\n+ \n++.post-link {\n++ color: var(--text-color);\n++ text-decoration: none;\n++}\n++.post-link:hover {\n++ text-decoration: underline;\n++}\n++.post-link:visited {\n++ color: var(--text-color-muted);\n++}\n++\n++.post-info {\n++ margin-top: 0;\n++}\n++\n++.post-info, .comment-info {\n++ color: var(--text-color-muted);\n++}\n++.post-info a, .comment-info a {\n++ color: var(--text-color-muted);\n++ text-decoration: none;\n++}\n++.post-info a:visited, .comment-info a:visited {\n++ color: var(--text-color-muted);\n++}\n++.post-info a:hover, .comment-info a:hover {\n++ text-decoration: underline;\n++}\n++\n+ .timeline, .comments {\n+ display: flex;\n+ flex-direction: column;\n+ gap: 1rem;\n++ padding-bottom: 1rem;\n+ }\n+ \n+ .login-input-title {\n+@@ -182,3 +216,18 @@ select {\n+ .code-line-content {\n+ color: var(--text-color);\n+ }\n++\n++.header, .footer {\n++ color: var(--text-color);\n++}\n++\n++.header a, .header a:visited,\n++.footer a, .footer a:visited {\n++ color: var(--link-color);\n++ text-decoration: none;\n++}\n++\n++.header a:hover,\n++.footer a:hover {\n++ text-decoration: underline;\n++}\n+diff --git a/src/views/paste.pug b/src/views/paste.pug\n+index 653c02e..3014107 100644\n+--- a/src/views/paste.pug\n++++ b/src/views/paste.pug\n+@@ -10,13 +10,13 @@ html\n+ main#content\n+ +header(ownDid, didHandleMap)\n+ h1 #{paste.title}\n+- p \n++ p.post-info\n+ | @#{didHandleMap[paste.authorDid]} ·\n+ | #{timeDifference(now, Date.parse(paste.createdAt))} ago ·\n+ | #{paste.lang} · \n+ | #{paste.code.split('\\n').length} loc · \n+ a(href=`/r/${paste.shortUrl}`) raw\n+- | · \n++ | ·\n+ | #{comments.length} #{pluralize(comments.length, 'comment')}\n+ pre\n+ code\n+@@ -34,13 +34,12 @@ html\n+ div.comments\n+ each comment in comments\n+ div.comment(id=`${encodeURIComponent(comment.uri)}`)\n+- p \n++ p.comment-info\n+ a(href=`/u/${comment.authorDid}`)\n+ | @#{didHandleMap[comment.authorDid]}\n+ | ·\n+ | #{timeDifference(now, Date.parse(paste.createdAt))} ago\n+- p \n+- pre.comment-body #{comment.body}\n++ pre.comment-body #{comment.body}\n+ \n+ if ownDid\n+ form(action=`/${encodeURIComponent(paste.uri)}/comment` method=\"post\").post-form\n+-- \n+2.47.0\n+\n", "title": "plonkin", "pullId": 1, "source": { "branch": "plonkin" }, "targetRepo": "at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo/3ljstrrobog22", "targetBranch": "main" } }