From ccb132523a4ee740d5b576574e9f44668021fbe6 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 13 Oct 2024 15:28:45 +0200 Subject: New feed mode: HTML + XPath + JSON dot notation (JSON in HTML) (#6888) * New feed mode: HTML + XPath + JSON dot notation (JSON in HTML) Same as `JSON+DotNotation` but first extracting the JSON string from an HTML document thanks to an XPath expression. Example: `//script[@type='application/json']` fix https://github.com/FreshRSS/FreshRSS/discussions/6876 * JavaScript UI to show/hide new field * Casing xPathToJson * Slight renaming --- app/views/helpers/export/opml.phtml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/views/helpers/export') diff --git a/app/views/helpers/export/opml.phtml b/app/views/helpers/export/opml.phtml index b9563815a..eecfc5d23 100644 --- a/app/views/helpers/export/opml.phtml +++ b/app/views/helpers/export/opml.phtml @@ -33,6 +33,9 @@ function feedsToOutlines(array $feeds, bool $excludeMutedFeeds = false): array { case FreshRSS_Feed::KIND_JSONFEED: $outline['type'] = FreshRSS_Export_Service::TYPE_JSONFEED; break; + case FreshRSS_Feed::KIND_HTML_XPATH_JSON_DOTNOTATION: + $outline['type'] = FreshRSS_Export_Service::TYPE_HTML_XPATH_JSON_DOTNOTATION; + break; } if ($feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH || $feed->kind() === FreshRSS_Feed::KIND_XML_XPATH) { @@ -48,7 +51,7 @@ function feedsToOutlines(array $feeds, bool $excludeMutedFeeds = false): array { $outline['frss:xPathItemThumbnail'] = $xPathSettings['itemThumbnail'] ?? null; $outline['frss:xPathItemCategories'] = $xPathSettings['itemCategories'] ?? null; $outline['frss:xPathItemUid'] = $xPathSettings['itemUid'] ?? null; - } elseif ($feed->kind() === FreshRSS_Feed::KIND_JSON_DOTNOTATION) { + } elseif ($feed->kind() === FreshRSS_Feed::KIND_JSON_DOTNOTATION || $feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH_JSON_DOTNOTATION) { /** @var array */ $jsonSettings = $feed->attributeArray('json_dotnotation') ?? []; $outline['frss:jsonItem'] = $jsonSettings['item'] ?? null; @@ -61,6 +64,9 @@ function feedsToOutlines(array $feeds, bool $excludeMutedFeeds = false): array { $outline['frss:jsonItemThumbnail'] = $jsonSettings['itemThumbnail'] ?? null; $outline['frss:jsonItemCategories'] = $jsonSettings['itemCategories'] ?? null; $outline['frss:jsonItemUid'] = $jsonSettings['itemUid'] ?? null; + if ($feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH_JSON_DOTNOTATION) { + $outline['frss:xPathToJson'] = $feed->attributeString('xPathToJson'); + } } if (!empty($feed->filtersAction('read'))) { -- cgit v1.2.3