feat: add FreshRSS widget
This commit is contained in:
parent
9f91cd27f3
commit
0fc662ba4d
@ -98,6 +98,10 @@
|
||||
"leech": "Leech",
|
||||
"seed": "Seed"
|
||||
},
|
||||
"freshrss": {
|
||||
"subscriptions": "Subscriptions",
|
||||
"unread": "Unread"
|
||||
},
|
||||
"changedetectionio": {
|
||||
"totalObserved": "Total Observed",
|
||||
"diffsDetected": "Diffs Detected"
|
||||
|
||||
@ -34,8 +34,7 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
"ghostfolio",
|
||||
"truenas",
|
||||
"pterodactyl",
|
||||
].includes(widget.type))
|
||||
{
|
||||
].includes(widget.type)) {
|
||||
headers.Authorization = `Bearer ${widget.key}`;
|
||||
} else if (widget.type === "proxmox") {
|
||||
headers.Authorization = `PVEAPIToken=${widget.username}=${widget.password}`;
|
||||
@ -54,6 +53,20 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
} else {
|
||||
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||
}
|
||||
} else if (widget.type === "freshrss") {
|
||||
const resp = await fetch(`${widget.url}/api/greader.php/accounts/ClientLogin`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
Email: widget.username,
|
||||
Passwd: widget.password,
|
||||
})
|
||||
})
|
||||
const text = await resp.text()
|
||||
const [, token] = text.split('\n').find(line => line.startsWith('Auth=')).split('=')
|
||||
headers.Authorization = `GoogleLogin auth=${token}`
|
||||
} else {
|
||||
headers["X-API-Key"] = `${widget.key}`;
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ const components = {
|
||||
emby: dynamic(() => import("./emby/component")),
|
||||
fileflows: dynamic(() => import("./fileflows/component")),
|
||||
flood: dynamic(() => import("./flood/component")),
|
||||
freshrss: dynamic(() => import("./freshrss/component")),
|
||||
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
||||
gluetun: dynamic(() => import("./gluetun/component")),
|
||||
gotify: dynamic(() => import("./gotify/component")),
|
||||
|
||||
37
src/widgets/freshrss/component.jsx
Normal file
37
src/widgets/freshrss/component.jsx
Normal file
@ -0,0 +1,37 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { data: subscriptionsData, error: subscriptionsError } = useWidgetAPI(widget, "subscriptions");
|
||||
const { data: unreadData, error: unreadError } = useWidgetAPI(widget, "unread");
|
||||
|
||||
if (subscriptionsError) {
|
||||
return <Container error={subscriptionsError} />;
|
||||
}
|
||||
if (unreadError) {
|
||||
return <Container error={unreadError} />;
|
||||
}
|
||||
|
||||
if (!subscriptionsData || !unreadData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="freshrss.unread" />
|
||||
<Block label="freshrss.subscriptions" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="freshrss.unread" value={t("common.number", { value: unreadData.count })} />
|
||||
<Block label="freshrss.subscriptions" value={t("common.number", { value: subscriptionsData.count })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
24
src/widgets/freshrss/widget.js
Normal file
24
src/widgets/freshrss/widget.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { asJson } from "utils/proxy/api-helpers";
|
||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/greader.php/{endpoint}?output=json",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
subscriptions: {
|
||||
endpoint: "reader/api/0/subscription/list",
|
||||
map: (data) => ({
|
||||
count: asJson(data).subscriptions.length
|
||||
}),
|
||||
},
|
||||
unread: {
|
||||
endpoint: "reader/api/0/unread-count",
|
||||
map: (data) => ({
|
||||
count: asJson(data).max
|
||||
}),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default widget;
|
||||
@ -12,6 +12,7 @@ import downloadstation from "./downloadstation/widget";
|
||||
import emby from "./emby/widget";
|
||||
import fileflows from "./fileflows/widget";
|
||||
import flood from "./flood/widget";
|
||||
import freshrss from "./freshrss/widget";
|
||||
import ghostfolio from "./ghostfolio/widget"
|
||||
import gluetun from "./gluetun/widget";
|
||||
import gotify from "./gotify/widget";
|
||||
@ -90,6 +91,7 @@ const widgets = {
|
||||
emby,
|
||||
fileflows,
|
||||
flood,
|
||||
freshrss,
|
||||
ghostfolio,
|
||||
gluetun,
|
||||
gotify,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user