From 1af3e44a1c4fe52706dbc79cbee7d1160cd417ab Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 30 May 2021 00:18:13 +0200 Subject: Add Pleroma recipe Pleroma is lightweight fediverse server: https://pleroma.social/ --- recipes/pleroma/README.md | 2 ++ recipes/pleroma/icon.png | Bin 0 -> 4548 bytes recipes/pleroma/icon.svg | 1 + recipes/pleroma/index.js | 19 +++++++++++++++++++ recipes/pleroma/package.json | 14 ++++++++++++++ recipes/pleroma/webview.js | 14 ++++++++++++++ 6 files changed, 50 insertions(+) create mode 100644 recipes/pleroma/README.md create mode 100644 recipes/pleroma/icon.png create mode 100644 recipes/pleroma/icon.svg create mode 100644 recipes/pleroma/index.js create mode 100644 recipes/pleroma/package.json create mode 100644 recipes/pleroma/webview.js (limited to 'recipes/pleroma') diff --git a/recipes/pleroma/README.md b/recipes/pleroma/README.md new file mode 100644 index 0000000..0fac78e --- /dev/null +++ b/recipes/pleroma/README.md @@ -0,0 +1,2 @@ +# Pleroma for Ferdi +This is a Ferdi recipe for Pleroma diff --git a/recipes/pleroma/icon.png b/recipes/pleroma/icon.png new file mode 100644 index 0000000..90681bf Binary files /dev/null and b/recipes/pleroma/icon.png differ diff --git a/recipes/pleroma/icon.svg b/recipes/pleroma/icon.svg new file mode 100644 index 0000000..46afe81 --- /dev/null +++ b/recipes/pleroma/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/recipes/pleroma/index.js b/recipes/pleroma/index.js new file mode 100644 index 0000000..c6cf368 --- /dev/null +++ b/recipes/pleroma/index.js @@ -0,0 +1,19 @@ +module.exports = Ferdi => class Pleroma extends Ferdi { + async validateUrl(url) { + try { + const resp = await window.fetch(`${url}/api/v1/instance`, { + Accept: 'application/json', + }); + const data = await resp.json(); + const version = data.version; + return typeof (version) === 'string' && version.indexOf('Pleroma') >= 0; + } catch (err) { + console.log('Pleroma server validation error', err); + } + return false; + } + + buildUrl(url) { + return `${url}/main/friends`; + } +}; diff --git a/recipes/pleroma/package.json b/recipes/pleroma/package.json new file mode 100644 index 0000000..31fa06f --- /dev/null +++ b/recipes/pleroma/package.json @@ -0,0 +1,14 @@ +{ + "id": "pleroma", + "name": "Pleroma", + "version": "1.0.0", + "description": "Pleroma — a lightweight fediverse server", + "main": "index.js", + "author": "Ferdi ", + "license": "MIT", + "config": { + "serviceURL": "", + "serviceName": "Pleroma", + "hasCustomUrl": true + } +} diff --git a/recipes/pleroma/webview.js b/recipes/pleroma/webview.js new file mode 100644 index 0000000..d08216d --- /dev/null +++ b/recipes/pleroma/webview.js @@ -0,0 +1,14 @@ +module.exports = (Ferdi) => { + const titleRegex = /^\((\d+)\)/; + + const getMessages = () => { + let directCount = 0; + const matchArr = document.title.match(titleRegex); + if (matchArr) { + directCount = parseInt(matchArr[1], 10); + } + Ferdi.setBadge(directCount, 0); + }; + + Ferdi.loop(getMessages); +}; -- cgit v1.2.3-70-g09d2