From 2765ebde0cfa423f863c5e051e0206e72efeb2db Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Fri, 5 Mar 2021 12:04:55 +0100 Subject: [PATCH] scratch that, use local timezones and mock it. --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ jest.config.js | 1 + package.json | 2 +- src/masto-feed-parser.js | 4 ++-- 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 jest.config.js diff --git a/README.md b/README.md index 7ab9b4b..d837080 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,45 @@ Usage example: Note that this **does not** delete the notes dir with every call. It simply checks if there isn't already a file with the same name (based on the publication date), and adds one if not. +Example feed entry: + +```xml + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + https://chat.brainbaking.com/objects/77a3ecfb-47e1-4d7a-a24a-8b779d80a8ac + I pulled the Google plug and installed LineageOS: https://brainbaking.com/post/2021/03/getting-ri... + I pulled the Google plug and installed LineageOS: <a href="https://brainbaking.com/post/2021/03/getting-rid-of-tracking-using-lineageos/" rel="ugc">https://brainbaking.com/post/2021/03/getting-rid-of-tracking-using-lineageos/</a> Very impressed so far! Also rely on my own CalDAV server to replace GCalendar. Any others here running <a class="hashtag" data-tag="lineageos" href="https://chat.brainbaking.com/tag/lineageos" rel="tag ugc">#lineageos</a> for privacy reasons? + 2021-03-01T19:03:35.273023Z + 2021-03-01T19:03:35.273023Z + + https://chat.brainbaking.com/contexts/ff9aa62e-3357-41ad-951d-15f6ad506424 + + + + + + + + + +``` + +This generates the file `01h20m3s35.md` (it uses your local timezone based on the `` tag - mine is GMT+1) with contents: + +```md +--- +source: "https://chat.brainbaking.com/objects/77a3ecfb-47e1-4d7a-a24a-8b779d80a8ac" +context: "" +title: "I pulled the Google plug and installed LineageOS: https://brainbaking.com/post/2021/03/getting-ri..." +date: "2021-03-01T19:03:35" +--- + +I pulled the Google plug and installed LineageOS: https://brainbaking.com/post/2021/03/getting-rid-of-tracking-using-lineageos/ Very impressed so far! Also rely on my own CalDAV server to replace GCalendar. Any others here running #lineageos for privacy reasons? +``` + +See implementation for more details and features. + ### 2. Goodreads #### 2.1 `createWidget` diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..432d473 --- /dev/null +++ b/jest.config.js @@ -0,0 +1 @@ +process.env.TZ = 'GMT'; diff --git a/package.json b/package.json index 2690b70..ca22492 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jam-my-stack", - "version": "1.0.1", + "version": "1.0.2", "repository": { "url": "https://github.com/wgroeneveld/jam-my-stack", "type": "git" diff --git a/src/masto-feed-parser.js b/src/masto-feed-parser.js index cad66ca..454d6ca 100644 --- a/src/masto-feed-parser.js +++ b/src/masto-feed-parser.js @@ -27,7 +27,7 @@ function convertAtomItemToMd(item, opts) { source: "${item.url}" context: "${item.context}" title: "${item.title}" -date: "${item.year}-${item.month}-${item.day}T${strpad(item.date.getUTCHours())}:${strpad(item.date.getMinutes())}:${strpad(item.date.getSeconds())}" +date: "${item.year}-${item.month}-${item.day}T${strpad(item.date.getHours())}:${strpad(item.date.getMinutes())}:${strpad(item.date.getSeconds())}" --- ${item.content} @@ -69,7 +69,7 @@ async function parseMastoFeed(opts) { url: item.id, // format: https://chat.brainbaking.com/objects/0707fd54-185d-4ee7-9204-be370d57663c context, id: stripBeforeLastSlash(item.id), - hash: `${day}h${date.getUTCHours()}m${date.getMinutes()}s${date.getSeconds()}`, + hash: `${day}h${date.getHours()}m${date.getMinutes()}s${date.getSeconds()}`, date, // format: 2021-03-02T16:18:46.658056Z year, month,