From 11517c1ab32d2675df69f6b6850c6b69e008fac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Thu, 5 Dec 2024 22:57:40 +0000 Subject: [PATCH 1/9] Initial commit of Bluesky translator --- Bluesky.js | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Bluesky.js diff --git a/Bluesky.js b/Bluesky.js new file mode 100644 index 0000000000..f5c1ba7cb9 --- /dev/null +++ b/Bluesky.js @@ -0,0 +1,149 @@ +{ + "translatorID": "3bba003a-ad42-457e-9ea1-547df39d9d00", + "label": "Bluesky", + "creator": "Stephan Hügel", + "target": "^https://bsky\\.app/", + "minVersion": "5.0", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcsibv", + "lastUpdated": "2024-12-06 01:00:42" +} + +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2024 Stephan Hügel + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see . + + ***** END LICENSE BLOCK ***** +*/ + +function detectWeb(doc, url) { + if (url.includes('/post/')) { + return 'forumPost'; + } + return false; +} + +async function doWeb(doc, url) { + await scrapeAPI(doc, url); +} + +async function scrapeAPI(doc, url) { + const handle = /(?:\/profile\/)(([^/]+))/; + const postId = /(?:\/post\/)([a-zA-Z0-9]+)/; + + var foundHandle = url.match(handle)[1]; + var foundPostId = url.match(postId)[1]; + + var apiUrl = `https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?uri=at://${foundHandle}/app.bsky.feed.post/${foundPostId}`; + let data = await ZU.requestJSON(apiUrl); + if (data.thread && data.thread.post) { + var post = data.thread.post; + var item = new Zotero.Item("forumPost"); + // Main post details + // cut off titles longer than 140 characters + let title = post.record.text || "Bluesky Skeet"; // Use the post text as the title + if (title.length < 140) { + item.title = title; + } + else { + item.title = ZU.ellipsize(title, 140, true); + item.abstractNote = title; + // we'll keep the full text in the abstract in this case; + } + item.forumTitle = "Bluesky"; + item.type = "Skeet"; + item.url = url; + item.date = post.record.createdAt || post.author.createdAt; + item.language = post.record.langs ? post.record.langs.join(", ") : "en"; + + // Add author information + if (post.author) { + var authorName = post.author.displayName || post.author.handle; + item.creators.push(Zotero.Utilities.cleanAuthor(authorName, "author")); + } + + // Add metadata for likes, reposts, etc. + if (post.likeCount !== undefined) item.extra = `Likes: ${post.likeCount}`; + if (post.repostCount !== undefined) item.extra += ` | Reposts: ${post.repostCount}`; + if (post.quoteCount !== undefined) item.extra += ` | Quotes: ${post.quoteCount}`; + + // Handle embedded records (if any) + if (post.embed && post.embed.record && post.embed.record.value) { + var embeddedPost = post.embed.record.value; + item.notes.push(`Quoting this post by @${post.embed.record.author.handle}: "${embeddedPost.text}"`); + } + + // Handle replies (if any) + if (data.thread.replies && data.thread.replies.length > 0) { + for (let reply of data.thread.replies) { + if (reply.post && reply.post.record) { + item.notes.push(`Reply by @${reply.post.author.handle}: "${reply.post.record.text}"`); + } + } + } + item.attachments.push({ document: doc, title: "Snapshot" }); + item.complete(); + } else { + Zotero.debug("There was an error saving the Skeet") + } +} + +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "https://bsky.app/profile/watershedlab.bsky.social/post/3lcl3glmdx226", + "defer": true, + "items": [ + { + "itemType": "forumPost", + "title": "My first and only job in media was as a reporter on a small newspaper in England in 2002. My salary was £8700. Per year.", + "creators": [ + { + "firstName": "Dan", + "lastName": "Shugar", + "creatorType": "author" + } + ], + "date": "2024-12-05T16:25:35.749Z", + "extra": "Likes: 6 | Reposts: 0 | Quotes: 0", + "forumTitle": "Bluesky", + "language": "en", + "postType": "Skeet", + "url": "https://bsky.app/profile/watershedlab.bsky.social/post/3lcl3glmdx226", + "attachments": [ + { + "title": "Snapshot", + "mimeType": "text/html" + } + ], + "tags": [], + "notes": [ + "Quoting this post by @ericwickham.ca: \"Told the guy replacing my car window how much I made at my first job in radio and I feel like it deeply changed what he thought about people in media.\"", + "Reply by @ericwickham.ca: \"LOOK AT THESE MEDIA ELITES\"" + ], + "seeAlso": [] + } + ] + } +] +/** END TEST CASES **/ From 591455513f4bebb515a2d8c82c40212eb2f85388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Fri, 6 Dec 2024 01:18:50 +0000 Subject: [PATCH 2/9] Prefer let to var everywhere --- Bluesky.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Bluesky.js b/Bluesky.js index f5c1ba7cb9..c3ce8d9861 100644 --- a/Bluesky.js +++ b/Bluesky.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-12-06 01:00:42" + "lastUpdated": "2024-12-06 01:13:45" } /* @@ -50,17 +50,17 @@ async function scrapeAPI(doc, url) { const handle = /(?:\/profile\/)(([^/]+))/; const postId = /(?:\/post\/)([a-zA-Z0-9]+)/; - var foundHandle = url.match(handle)[1]; - var foundPostId = url.match(postId)[1]; + let foundHandle = url.match(handle)[1]; + let foundPostId = url.match(postId)[1]; - var apiUrl = `https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?uri=at://${foundHandle}/app.bsky.feed.post/${foundPostId}`; + let apiUrl = `https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?uri=at://${foundHandle}/app.bsky.feed.post/${foundPostId}`; let data = await ZU.requestJSON(apiUrl); if (data.thread && data.thread.post) { - var post = data.thread.post; - var item = new Zotero.Item("forumPost"); + let post = data.thread.post; + let item = new Zotero.Item("forumPost"); // Main post details // cut off titles longer than 140 characters - let title = post.record.text || "Bluesky Skeet"; // Use the post text as the title + let title = post.record.text || "Bluesky Skeet"; if (title.length < 140) { item.title = title; } @@ -77,7 +77,7 @@ async function scrapeAPI(doc, url) { // Add author information if (post.author) { - var authorName = post.author.displayName || post.author.handle; + let authorName = post.author.displayName || post.author.handle; item.creators.push(Zotero.Utilities.cleanAuthor(authorName, "author")); } @@ -86,9 +86,9 @@ async function scrapeAPI(doc, url) { if (post.repostCount !== undefined) item.extra += ` | Reposts: ${post.repostCount}`; if (post.quoteCount !== undefined) item.extra += ` | Quotes: ${post.quoteCount}`; - // Handle embedded records (if any) + // Handle embedded quote records (if any) if (post.embed && post.embed.record && post.embed.record.value) { - var embeddedPost = post.embed.record.value; + let embeddedPost = post.embed.record.value; item.notes.push(`Quoting this post by @${post.embed.record.author.handle}: "${embeddedPost.text}"`); } @@ -108,7 +108,7 @@ async function scrapeAPI(doc, url) { } /** BEGIN TEST CASES **/ -var testCases = [ +let testCases = [ { "type": "web", "url": "https://bsky.app/profile/watershedlab.bsky.social/post/3lcl3glmdx226", From 521eb97e2d3571fb617a8ba13158292b7518c325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Fri, 6 Dec 2024 01:20:05 +0000 Subject: [PATCH 3/9] Zotero wants var for test cases --- Bluesky.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bluesky.js b/Bluesky.js index c3ce8d9861..8e1e5dd69f 100644 --- a/Bluesky.js +++ b/Bluesky.js @@ -108,7 +108,7 @@ async function scrapeAPI(doc, url) { } /** BEGIN TEST CASES **/ -let testCases = [ +var testCases = [ { "type": "web", "url": "https://bsky.app/profile/watershedlab.bsky.social/post/3lcl3glmdx226", From c4b50d3b58968c58ff5bff69d2dfd7430bf93af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Fri, 6 Dec 2024 20:34:46 +0000 Subject: [PATCH 4/9] Store reply summary instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Bsky API in fact returns all replies, which is a non-starter for popular posts which may have hundreds or thousands – we don't want to store a separate note for each. Instead, we now store a note with the number of direct replies at the time of storage, as an ISO datetime. --- Bluesky.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Bluesky.js b/Bluesky.js index 8e1e5dd69f..d30959ad6b 100644 --- a/Bluesky.js +++ b/Bluesky.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-12-06 01:13:45" + "lastUpdated": "2024-12-06 20:35:13" } /* @@ -89,16 +89,14 @@ async function scrapeAPI(doc, url) { // Handle embedded quote records (if any) if (post.embed && post.embed.record && post.embed.record.value) { let embeddedPost = post.embed.record.value; - item.notes.push(`Quoting this post by @${post.embed.record.author.handle}: "${embeddedPost.text}"`); + item.notes.push(`This post is quoting a post by @${post.embed.record.author.handle}: "${embeddedPost.text}"`); } // Handle replies (if any) if (data.thread.replies && data.thread.replies.length > 0) { - for (let reply of data.thread.replies) { - if (reply.post && reply.post.record) { - item.notes.push(`Reply by @${reply.post.author.handle}: "${reply.post.record.text}"`); - } - } + const date = new Date() + const utcStr = date.toUTCString() + item.notes.push(`This post had ${data.thread.replies.length} direct replies as of ${utcStr}`); } item.attachments.push({ document: doc, title: "Snapshot" }); item.complete(); @@ -125,7 +123,7 @@ var testCases = [ } ], "date": "2024-12-05T16:25:35.749Z", - "extra": "Likes: 6 | Reposts: 0 | Quotes: 0", + "extra": "Likes: 7 | Reposts: 0 | Quotes: 0", "forumTitle": "Bluesky", "language": "en", "postType": "Skeet", @@ -138,8 +136,8 @@ var testCases = [ ], "tags": [], "notes": [ - "Quoting this post by @ericwickham.ca: \"Told the guy replacing my car window how much I made at my first job in radio and I feel like it deeply changed what he thought about people in media.\"", - "Reply by @ericwickham.ca: \"LOOK AT THESE MEDIA ELITES\"" + "This post is quoting a post by @ericwickham.ca: \"Told the guy replacing my car window how much I made at my first job in radio and I feel like it deeply changed what he thought about people in media.\"", + "This post had 1 direct replies as of Fri, 06 Dec 2024 20:31:24 GMT" ], "seeAlso": [] } From 38567c1a245db7b54dd24a1126295a2e127fbf8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Mon, 9 Dec 2024 16:51:01 +0000 Subject: [PATCH 5/9] Ensure full post text is always available in AbstractNote Also remove newlines and extra whitespace --- Bluesky.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Bluesky.js b/Bluesky.js index d30959ad6b..31b15a1d2f 100644 --- a/Bluesky.js +++ b/Bluesky.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-12-06 20:35:13" + "lastUpdated": "2024-12-09 16:47:45" } /* @@ -59,15 +59,17 @@ async function scrapeAPI(doc, url) { let post = data.thread.post; let item = new Zotero.Item("forumPost"); // Main post details - // cut off titles longer than 140 characters - let title = post.record.text || "Bluesky Skeet"; - if (title.length < 140) { - item.title = title; + + // remove newlines and extra whitespace + let title_cleaned = post.record.text.replace(/\s+/g, ' '); + // Ensure that full post text is always available + item.abstractNote = title_cleaned; + // Tidy if necessary + if (title_cleaned.length < 140) { + item.title = title_cleaned; } else { - item.title = ZU.ellipsize(title, 140, true); - item.abstractNote = title; - // we'll keep the full text in the abstract in this case; + item.title = ZU.ellipsize(title_cleaned, 140, true); } item.forumTitle = "Bluesky"; item.type = "Skeet"; @@ -123,7 +125,8 @@ var testCases = [ } ], "date": "2024-12-05T16:25:35.749Z", - "extra": "Likes: 7 | Reposts: 0 | Quotes: 0", + "abstractNote": "My first and only job in media was as a reporter on a small newspaper in England in 2002. My salary was £8700. Per year.", + "extra": "Likes: 8 | Reposts: 0 | Quotes: 0", "forumTitle": "Bluesky", "language": "en", "postType": "Skeet", @@ -137,7 +140,7 @@ var testCases = [ "tags": [], "notes": [ "This post is quoting a post by @ericwickham.ca: \"Told the guy replacing my car window how much I made at my first job in radio and I feel like it deeply changed what he thought about people in media.\"", - "This post had 1 direct replies as of Fri, 06 Dec 2024 20:31:24 GMT" + "This post had 1 direct replies as of Mon, 09 Dec 2024 16:47:41 GMT" ], "seeAlso": [] } From ceb46cc048ab6eec945de1fa0483855730247f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Thu, 19 Dec 2024 12:10:55 +0000 Subject: [PATCH 6/9] Address eslint nits --- Bluesky.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Bluesky.js b/Bluesky.js index 31b15a1d2f..56d5d9b4c1 100644 --- a/Bluesky.js +++ b/Bluesky.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-12-09 16:47:45" + "lastUpdated": "2024-12-12 23:07:38" } /* @@ -61,15 +61,15 @@ async function scrapeAPI(doc, url) { // Main post details // remove newlines and extra whitespace - let title_cleaned = post.record.text.replace(/\s+/g, ' '); + let titleCleaned = post.record.text.replace(/\s+/g, ' '); // Ensure that full post text is always available - item.abstractNote = title_cleaned; + item.abstractNote = titleCleaned; // Tidy if necessary - if (title_cleaned.length < 140) { - item.title = title_cleaned; + if (titleCleaned.length < 140) { + item.title = titleCleaned; } else { - item.title = ZU.ellipsize(title_cleaned, 140, true); + item.title = ZU.ellipsize(titleCleaned, 140, true); } item.forumTitle = "Bluesky"; item.type = "Skeet"; @@ -96,14 +96,15 @@ async function scrapeAPI(doc, url) { // Handle replies (if any) if (data.thread.replies && data.thread.replies.length > 0) { - const date = new Date() - const utcStr = date.toUTCString() + const date = new Date(); + const utcStr = date.toUTCString(); item.notes.push(`This post had ${data.thread.replies.length} direct replies as of ${utcStr}`); } item.attachments.push({ document: doc, title: "Snapshot" }); item.complete(); - } else { - Zotero.debug("There was an error saving the Skeet") + } + else { + Zotero.debug("There was an error saving the Skeet"); } } From ca79482c61f831aedcbdded030fe503155c3af04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Fri, 20 Dec 2024 14:25:46 +0000 Subject: [PATCH 7/9] Switch to Post --- Bluesky.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bluesky.js b/Bluesky.js index 56d5d9b4c1..78aa3f3f30 100644 --- a/Bluesky.js +++ b/Bluesky.js @@ -72,7 +72,7 @@ async function scrapeAPI(doc, url) { item.title = ZU.ellipsize(titleCleaned, 140, true); } item.forumTitle = "Bluesky"; - item.type = "Skeet"; + item.type = "Post"; item.url = url; item.date = post.record.createdAt || post.author.createdAt; item.language = post.record.langs ? post.record.langs.join(", ") : "en"; @@ -104,7 +104,7 @@ async function scrapeAPI(doc, url) { item.complete(); } else { - Zotero.debug("There was an error saving the Skeet"); + Zotero.debug("There was an error saving the post"); } } @@ -130,7 +130,7 @@ var testCases = [ "extra": "Likes: 8 | Reposts: 0 | Quotes: 0", "forumTitle": "Bluesky", "language": "en", - "postType": "Skeet", + "postType": "Post", "url": "https://bsky.app/profile/watershedlab.bsky.social/post/3lcl3glmdx226", "attachments": [ { From 308468a1d430928a4a18cdf02487fc9f4f26ab25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Fri, 20 Dec 2024 21:56:10 +0000 Subject: [PATCH 8/9] Address feedback --- Bluesky.js | 88 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 21 deletions(-) diff --git a/Bluesky.js b/Bluesky.js index 78aa3f3f30..93efa01867 100644 --- a/Bluesky.js +++ b/Bluesky.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-12-12 23:07:38" + "lastUpdated": "2024-12-20 23:42:25" } /* @@ -36,7 +36,13 @@ */ function detectWeb(doc, url) { - if (url.includes('/post/')) { + const handle = /(?:\/profile\/)(([^/]+))/; + const postId = /(?:\/post\/)([a-zA-Z0-9]+)/; + + let foundHandle = url.match(handle)[1]; + let foundPostId = url.match(postId)[1]; + + if (url.includes('/post/') && foundHandle && foundPostId) { return 'forumPost'; } return false; @@ -55,7 +61,10 @@ async function scrapeAPI(doc, url) { let apiUrl = `https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?uri=at://${foundHandle}/app.bsky.feed.post/${foundPostId}`; let data = await ZU.requestJSON(apiUrl); - if (data.thread && data.thread.post) { + if (!(data.thread && data.thread.post)) { + throw new Error("Couldn't save post due to missing metadata"); + } + else { let post = data.thread.post; let item = new Zotero.Item("forumPost"); // Main post details @@ -74,19 +83,29 @@ async function scrapeAPI(doc, url) { item.forumTitle = "Bluesky"; item.type = "Post"; item.url = url; - item.date = post.record.createdAt || post.author.createdAt; - item.language = post.record.langs ? post.record.langs.join(", ") : "en"; - + item.date = post.record.createdAt; // Add author information if (post.author) { - let authorName = post.author.displayName || post.author.handle; - item.creators.push(Zotero.Utilities.cleanAuthor(authorName, "author")); + if (post.author.displayName !== "") { + item.creators.push(Zotero.Utilities.cleanAuthor(post.author.displayName, "author")); + } + else if (post.author.handle !== "handle.invalid") { + item.creators.push(Zotero.Utilities.cleanAuthor(post.author.handle, "author")); + } + // we've got a blank display name and an invalid handle, so we can't add an author: bail out + else { + throw new Error("Couldn't save post due to missing author data: neither display name nor handle are available"); + } + if (post.author.handle !== "handle.invalid") { + item.setExtra("handle", post.author.handle); + } + // DID is the creator's unique id in the ATProto network + item.setExtra("DID", post.author.did); } - // Add metadata for likes, reposts, etc. - if (post.likeCount !== undefined) item.extra = `Likes: ${post.likeCount}`; - if (post.repostCount !== undefined) item.extra += ` | Reposts: ${post.repostCount}`; - if (post.quoteCount !== undefined) item.extra += ` | Quotes: ${post.quoteCount}`; + item.setExtra("Likes", post.likeCount); + item.setExtra("Reposts", post.repostCount); + item.setExtra("Quotes", post.quoteCount); // Handle embedded quote records (if any) if (post.embed && post.embed.record && post.embed.record.value) { @@ -96,16 +115,11 @@ async function scrapeAPI(doc, url) { // Handle replies (if any) if (data.thread.replies && data.thread.replies.length > 0) { - const date = new Date(); - const utcStr = date.toUTCString(); - item.notes.push(`This post had ${data.thread.replies.length} direct replies as of ${utcStr}`); + item.notes.push(`This post had ${data.thread.replies.length} direct replies when it was saved`); } item.attachments.push({ document: doc, title: "Snapshot" }); item.complete(); } - else { - Zotero.debug("There was an error saving the post"); - } } /** BEGIN TEST CASES **/ @@ -127,9 +141,8 @@ var testCases = [ ], "date": "2024-12-05T16:25:35.749Z", "abstractNote": "My first and only job in media was as a reporter on a small newspaper in England in 2002. My salary was £8700. Per year.", - "extra": "Likes: 8 | Reposts: 0 | Quotes: 0", + "extra": "handle: watershedlab.bsky.social\nDID: did:plc:ufufhaxc74cfl7fpjccykkyh\nLikes: 8\nReposts: 0\nQuotes: 0", "forumTitle": "Bluesky", - "language": "en", "postType": "Post", "url": "https://bsky.app/profile/watershedlab.bsky.social/post/3lcl3glmdx226", "attachments": [ @@ -141,8 +154,41 @@ var testCases = [ "tags": [], "notes": [ "This post is quoting a post by @ericwickham.ca: \"Told the guy replacing my car window how much I made at my first job in radio and I feel like it deeply changed what he thought about people in media.\"", - "This post had 1 direct replies as of Mon, 09 Dec 2024 16:47:41 GMT" + "This post had 1 direct replies when it was saved" + ], + "seeAlso": [] + } + ] + }, + { + "type": "web", + "url": "https://bsky.app/profile/did:plc:cxq4zxu7soi67juyvxml46zs/post/3ldr6ebdz5c24", + "defer": true, + "items": [ + { + "itemType": "forumPost", + "title": "💚 Site of the Day - Rain Delay Media Love that menu! ⚙️ SplitText 🛠️ Webflow site → raindelaymedia.com showcase → gsap.com/showcase", + "creators": [ + { + "firstName": "", + "lastName": "GSAP", + "creatorType": "author" + } ], + "date": "2024-12-20T19:59:08.958Z", + "abstractNote": "💚 Site of the Day - Rain Delay Media Love that menu! ⚙️ SplitText 🛠️ Webflow site → raindelaymedia.com showcase → gsap.com/showcase", + "extra": "DID: did:plc:cxq4zxu7soi67juyvxml46zs\nLikes: 4\nReposts: 0\nQuotes: 0", + "forumTitle": "Bluesky", + "postType": "Post", + "url": "https://bsky.app/profile/did:plc:cxq4zxu7soi67juyvxml46zs/post/3ldr6ebdz5c24", + "attachments": [ + { + "title": "Snapshot", + "mimeType": "text/html" + } + ], + "tags": [], + "notes": [], "seeAlso": [] } ] From 8c5b22fa290fb9da476099c268ddafb5b9f88f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Wed, 15 Jan 2025 17:54:55 +0000 Subject: [PATCH 9/9] Address feedback --- Bluesky.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Bluesky.js b/Bluesky.js index 93efa01867..7b5184607b 100644 --- a/Bluesky.js +++ b/Bluesky.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-12-20 23:42:25" + "lastUpdated": "2025-01-15 17:54:04" } /* @@ -97,7 +97,7 @@ async function scrapeAPI(doc, url) { throw new Error("Couldn't save post due to missing author data: neither display name nor handle are available"); } if (post.author.handle !== "handle.invalid") { - item.setExtra("handle", post.author.handle); + item.setExtra("Author Handle", post.author.handle); } // DID is the creator's unique id in the ATProto network item.setExtra("DID", post.author.did); @@ -110,12 +110,12 @@ async function scrapeAPI(doc, url) { // Handle embedded quote records (if any) if (post.embed && post.embed.record && post.embed.record.value) { let embeddedPost = post.embed.record.value; - item.notes.push(`This post is quoting a post by @${post.embed.record.author.handle}: "${embeddedPost.text}"`); + item.notes.push({ note: `This post is quoting a post by @${post.embed.record.author.handle}: "${embeddedPost.text}"` }); } // Handle replies (if any) if (data.thread.replies && data.thread.replies.length > 0) { - item.notes.push(`This post had ${data.thread.replies.length} direct replies when it was saved`); + item.notes.push({ note: `This post had ${data.thread.replies.length} direct replies when it was saved` }); } item.attachments.push({ document: doc, title: "Snapshot" }); item.complete(); @@ -141,7 +141,7 @@ var testCases = [ ], "date": "2024-12-05T16:25:35.749Z", "abstractNote": "My first and only job in media was as a reporter on a small newspaper in England in 2002. My salary was £8700. Per year.", - "extra": "handle: watershedlab.bsky.social\nDID: did:plc:ufufhaxc74cfl7fpjccykkyh\nLikes: 8\nReposts: 0\nQuotes: 0", + "extra": "Author Handle: watershedlab.bsky.social\nDID: did:plc:ufufhaxc74cfl7fpjccykkyh\nLikes: 8\nReposts: 0\nQuotes: 0", "forumTitle": "Bluesky", "postType": "Post", "url": "https://bsky.app/profile/watershedlab.bsky.social/post/3lcl3glmdx226", @@ -153,8 +153,12 @@ var testCases = [ ], "tags": [], "notes": [ - "This post is quoting a post by @ericwickham.ca: \"Told the guy replacing my car window how much I made at my first job in radio and I feel like it deeply changed what he thought about people in media.\"", - "This post had 1 direct replies when it was saved" + { + "note": "This post is quoting a post by @ericwickham.ca: \"Told the guy replacing my car window how much I made at my first job in radio and I feel like it deeply changed what he thought about people in media.\"" + }, + { + "note": "This post had 1 direct replies when it was saved" + } ], "seeAlso": [] } @@ -177,7 +181,7 @@ var testCases = [ ], "date": "2024-12-20T19:59:08.958Z", "abstractNote": "💚 Site of the Day - Rain Delay Media Love that menu! ⚙️ SplitText 🛠️ Webflow site → raindelaymedia.com showcase → gsap.com/showcase", - "extra": "DID: did:plc:cxq4zxu7soi67juyvxml46zs\nLikes: 4\nReposts: 0\nQuotes: 0", + "extra": "Author Handle: gsap-greensock.bsky.social\nDID: did:plc:cxq4zxu7soi67juyvxml46zs\nLikes: 6\nReposts: 0\nQuotes: 0", "forumTitle": "Bluesky", "postType": "Post", "url": "https://bsky.app/profile/did:plc:cxq4zxu7soi67juyvxml46zs/post/3ldr6ebdz5c24",