A free, self-hostable news aggregator…
OPML export/import frss:priority (#8158)
Alexandre Alapetite1217b6de34cc
diff --git a/app/Services/ExportService.php b/app/Services/ExportService.phpindex 69f0b3d2b..14f0a3f5c 100644--- a/app/Services/ExportService.php+++ b/app/Services/ExportService.php@@ -23,6 +23,12 @@ class FreshRSS_Export_Service {final public const TYPE_JSONFEED = 'JSONFeed';final public const TYPE_HTML_XPATH_JSON_DOTNOTATION = 'HTML+XPath+JSON+DotNotation';+ final public const PRIORITY_IMPORTANT = 'important';+ final public const PRIORITY_MAIN_STREAM = 'main';+ final public const PRIORITY_CATEGORY = 'category';+ final public const PRIORITY_FEED = 'feed';+ final public const PRIORITY_HIDDEN = 'hidden';+/*** Initialize the service for the given user.*/diff --git a/app/Services/ImportService.php b/app/Services/ImportService.phpindex b567544b3..1ab2b8d69 100644--- a/app/Services/ImportService.php+++ b/app/Services/ImportService.php@@ -177,6 +177,15 @@ class FreshRSS_Import_Service {break;}+ $feed->_priority(match (strtolower($feed_elt['frss:priority'] ?? '')) {+ FreshRSS_Export_Service::PRIORITY_IMPORTANT => FreshRSS_Feed::PRIORITY_IMPORTANT,+ FreshRSS_Export_Service::PRIORITY_MAIN_STREAM => FreshRSS_Feed::PRIORITY_MAIN_STREAM,+ FreshRSS_Export_Service::PRIORITY_CATEGORY => FreshRSS_Feed::PRIORITY_CATEGORY,+ FreshRSS_Export_Service::PRIORITY_FEED => FreshRSS_Feed::PRIORITY_FEED,+ FreshRSS_Export_Service::PRIORITY_HIDDEN => FreshRSS_Feed::PRIORITY_HIDDEN,+ default => FreshRSS_Feed::PRIORITY_MAIN_STREAM,+ });+if (isset($feed_elt['frss:cssFullContent'])) {$feed->_pathEntries(Minz_Helper::htmlspecialchars_utf8($feed_elt['frss:cssFullContent']));}diff --git a/app/views/helpers/export/opml.phtml b/app/views/helpers/export/opml.phtmlindex fba6d2498..de044332e 100644--- a/app/views/helpers/export/opml.phtml+++ b/app/views/helpers/export/opml.phtml@@ -38,6 +38,15 @@ function feedsToOutlines(array $feeds, bool $excludeMutedFeeds = false): array {break;}+ $outline['frss:priority'] = match ($feed->priority()) {+ FreshRSS_Feed::PRIORITY_IMPORTANT => FreshRSS_Export_Service::PRIORITY_IMPORTANT,+ FreshRSS_Feed::PRIORITY_MAIN_STREAM => null, // Default+ FreshRSS_Feed::PRIORITY_CATEGORY => FreshRSS_Export_Service::PRIORITY_CATEGORY,+ FreshRSS_Feed::PRIORITY_FEED => FreshRSS_Export_Service::PRIORITY_FEED,+ FreshRSS_Feed::PRIORITY_HIDDEN => FreshRSS_Export_Service::PRIORITY_HIDDEN,+ default => null,+ };+if ($feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH || $feed->kind() === FreshRSS_Feed::KIND_XML_XPATH) {/** @var array<string,string> */$xPathSettings = $feed->attributeArray('xpath') ?? [];diff --git a/docs/en/developers/OPML.md b/docs/en/developers/OPML.mdindex c6b42f108..cc93bfa4f 100644--- a/docs/en/developers/OPML.md+++ b/docs/en/developers/OPML.md@@ -89,6 +89,7 @@ A number of [cURL options](https://curl.se/libcurl/c/curl_easy_setopt.html) are### Miscellaneous+* `frss:priority`: Used for priority / visibility of the articles of that feed. Can be: `important`, `main` (default), `category`, `feed`, `hidden`.* `frss:cssFullContent`: [CSS Selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) to enable the download and extraction of the matching HTML section of each articles’ Web address.* Example: `div.main, .summary`* `frss:cssContentFilter`: [CSS Selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) to remove the matching HTML elements from the article content or from the full content retrieved by `frss:cssFullContent`.@@ -115,6 +116,7 @@ A number of [cURL options](https://curl.se/libcurl/c/curl_easy_setopt.html) arexmlUrl="https://www.example.net/page.html"htmlUrl="https://www.example.net/page.html"description="Example of Web scraping"+ frss:priority="main"frss:xPathItem="//a[contains(@href, '/interesting/')]/ancestor::article"frss:xPathItemTitle="descendant::h2"frss:xPathItemContent="."diff --git a/p/api/greader.php b/p/api/greader.phpindex fb2ea03f5..1986b8c3d 100644--- a/p/api/greader.php+++ b/p/api/greader.php@@ -365,12 +365,12 @@ final class GReaderAPI {'/api/greader.php/reader/api/0/subscription', '', // Security if base_url is not set properly$feed->favicon(absolute: true)),'frss:priority' => match ($feed->priority()) {- FreshRSS_Feed::PRIORITY_IMPORTANT => 'important',- FreshRSS_Feed::PRIORITY_MAIN_STREAM => 'main',- FreshRSS_Feed::PRIORITY_CATEGORY => 'category',- FreshRSS_Feed::PRIORITY_FEED => 'feed',- // FreshRSS_Feed::PRIORITY_HIDDEN => 'hidden', // Not returned by the API- default => 'main',+ FreshRSS_Feed::PRIORITY_IMPORTANT => FreshRSS_Export_Service::PRIORITY_IMPORTANT,+ FreshRSS_Feed::PRIORITY_MAIN_STREAM => FreshRSS_Export_Service::PRIORITY_MAIN_STREAM,+ FreshRSS_Feed::PRIORITY_CATEGORY => FreshRSS_Export_Service::PRIORITY_CATEGORY,+ FreshRSS_Feed::PRIORITY_FEED => FreshRSS_Export_Service::PRIORITY_FEED,+ // FreshRSS_Feed::PRIORITY_HIDDEN => FreshRSS_Export_Service::PRIORITY_HIDDEN, // Not returned by the API+ default => FreshRSS_Export_Service::PRIORITY_MAIN_STREAM,},];}