mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
Change default value, fix API
This commit is contained in:
@@ -1,17 +1,13 @@
|
|||||||
import Consola from 'consola';
|
|
||||||
|
|
||||||
import { getCookie } from 'cookies-next';
|
|
||||||
|
|
||||||
import { decode } from 'html-entities';
|
|
||||||
|
|
||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
import Consola from 'consola';
|
||||||
|
import { getCookie } from 'cookies-next';
|
||||||
|
import { decode } from 'html-entities';
|
||||||
import Parser from 'rss-parser';
|
import Parser from 'rss-parser';
|
||||||
|
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { getConfig } from '../../../../tools/config/getConfig';
|
import { getConfig } from '../../../../tools/config/getConfig';
|
||||||
import { IRssWidget } from '../../../../widgets/rss/RssWidgetTile';
|
|
||||||
import { Stopwatch } from '../../../../tools/shared/time/stopwatch.tool';
|
import { Stopwatch } from '../../../../tools/shared/time/stopwatch.tool';
|
||||||
|
import { IRssWidget } from '../../../../widgets/rss/RssWidgetTile';
|
||||||
|
|
||||||
type CustomItem = {
|
type CustomItem = {
|
||||||
'media:content': string;
|
'media:content': string;
|
||||||
@@ -28,6 +24,7 @@ const parser: Parser<any, CustomItem> = new Parser({
|
|||||||
|
|
||||||
const getQuerySchema = z.object({
|
const getQuerySchema = z.object({
|
||||||
widgetId: z.string().uuid(),
|
widgetId: z.string().uuid(),
|
||||||
|
feedUrl: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Get = async (request: NextApiRequest, response: NextApiResponse) => {
|
export const Get = async (request: NextApiRequest, response: NextApiResponse) => {
|
||||||
@@ -44,7 +41,6 @@ export const Get = async (request: NextApiRequest, response: NextApiResponse) =>
|
|||||||
const rssWidget = config.widgets.find(
|
const rssWidget = config.widgets.find(
|
||||||
(x) => x.type === 'rss' && x.id === parseResult.data.widgetId
|
(x) => x.type === 'rss' && x.id === parseResult.data.widgetId
|
||||||
) as IRssWidget | undefined;
|
) as IRssWidget | undefined;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!rssWidget ||
|
!rssWidget ||
|
||||||
!rssWidget.properties.rssFeedUrl ||
|
!rssWidget.properties.rssFeedUrl ||
|
||||||
@@ -56,7 +52,7 @@ export const Get = async (request: NextApiRequest, response: NextApiResponse) =>
|
|||||||
|
|
||||||
Consola.info('Requesting RSS feed...');
|
Consola.info('Requesting RSS feed...');
|
||||||
const stopWatch = new Stopwatch();
|
const stopWatch = new Stopwatch();
|
||||||
const feed = await parser.parseURL(rssWidget.properties.rssFeedUrl);
|
const feed = await parser.parseURL(parseResult.data.feedUrl);
|
||||||
Consola.info(`Retrieved RSS feed after ${stopWatch.getEllapsedMilliseconds()} milliseconds`);
|
Consola.info(`Retrieved RSS feed after ${stopWatch.getEllapsedMilliseconds()} milliseconds`);
|
||||||
|
|
||||||
const orderedFeed = {
|
const orderedFeed = {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const definition = defineWidget({
|
|||||||
options: {
|
options: {
|
||||||
rssFeedUrl: {
|
rssFeedUrl: {
|
||||||
type: 'multiple-text',
|
type: 'multiple-text',
|
||||||
defaultValue: ['https://japantimes.co.jp/feed'],
|
defaultValue: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
gridstack: {
|
gridstack: {
|
||||||
|
|||||||
Reference in New Issue
Block a user