Kaynağa Gözat

OPML export/import for cssFullContentConditions (#7082)

Follow-up of https://github.com/FreshRSS/FreshRSS/commit/33fd07f6f26310d4806077cc87bcdf9b8b940e35, which should have been a PR.
Alexandre Alapetite 1 yıl önce
ebeveyn
işleme
ab9a4e292c

+ 1 - 1
app/Controllers/subscriptionController.php

@@ -299,7 +299,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
 				}
 			}
 
-			$feed->_attribute('path_entries_condition', Minz_Request::paramTextToArray('path_entries_condition', plaintext: true));
+			$feed->_attribute('path_entries_conditions', Minz_Request::paramTextToArray('path_entries_conditions', plaintext: true));
 			$feed->_attribute('path_entries_filter', Minz_Request::paramString('path_entries_filter', true));
 
 			$values = [

+ 2 - 2
app/Models/Entry.php

@@ -814,9 +814,9 @@ HTML;
 		if ($url === '' || $feed === null || $feed->pathEntries() === '') {
 			return '';
 		}
-		if (!empty($feed->attributeArray('path_entries_condition'))) {
+		if (!empty($feed->attributeArray('path_entries_conditions'))) {
 			$found = false;
-			foreach ($feed->attributeArray('path_entries_condition') as $condition) {
+			foreach ($feed->attributeArray('path_entries_conditions') as $condition) {
 				if (!is_string($condition) || trim($condition) === '') {
 					continue;
 				}

+ 9 - 2
app/Services/ImportService.php

@@ -180,8 +180,15 @@ class FreshRSS_Import_Service {
 				$feed->_pathEntries(Minz_Helper::htmlspecialchars_utf8($feed_elt['frss:cssFullContent']));
 			}
 
-			if (isset($feed_elt['frss:cssFullContentFilter'])) {
-				$feed->_attribute('path_entries_filter', $feed_elt['frss:cssFullContentFilter']);
+			if (isset($feed_elt['frss:cssFullContentConditions'])) {
+				$feed->_attribute(
+					'path_entries_conditions',
+					preg_split('/\R/u', $feed_elt['frss:cssFullContentConditions']) ?: []
+				);
+			}
+
+			if (isset($feed_elt['frss:cssContentFilter']) || isset($feed_elt['frss:cssFullContentFilter'])) {
+				$feed->_attribute('path_entries_filter', $feed_elt['frss:cssContentFilter'] ?? $feed_elt['frss:cssFullContentFilter']);
 			}
 
 			if (isset($feed_elt['frss:filtersActionRead'])) {

+ 1 - 1
app/i18n/cs/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Nejsou vybrány žádné kanály.',
 		'number_entries' => '%d článků',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Viditelnost',
 			'archived' => 'Nezobrazovat (archivováno)',

+ 1 - 1
app/i18n/de/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Kein Feed ausgewählt.',
 		'number_entries' => '%d Artikel',
 		'open_feed' => 'Feed %s öffnen',
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Sichtbarkeit',
 			'archived' => 'Nicht anzeigen (archiviert)',

+ 1 - 1
app/i18n/el/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'No feed selected.',	// TODO
 		'number_entries' => '%d articles',	// TODO
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Visibility',	// TODO
 			'archived' => 'Do not show (archived)',	// TODO

+ 1 - 1
app/i18n/en-us/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'No feed selected.',	// IGNORE
 		'number_entries' => '%d articles',	// IGNORE
 		'open_feed' => 'Open feed %s',	// IGNORE
-		'path_entries_condition' => 'Condition for content retrieval',	// IGNORE
+		'path_entries_conditions' => 'Conditions for content retrieval',	// IGNORE
 		'priority' => array(
 			'_' => 'Visibility',	// IGNORE
 			'archived' => 'Do not show (archived)',	// IGNORE

+ 1 - 1
app/i18n/en/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'No feed selected.',
 		'number_entries' => '%d articles',
 		'open_feed' => 'Open feed %s',
-		'path_entries_condition' => 'Condition for content retrieval',
+		'path_entries_conditions' => 'Conditions for content retrieval',
 		'priority' => array(
 			'_' => 'Visibility',
 			'archived' => 'Do not show (archived)',

+ 1 - 1
app/i18n/es/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'No hay fuentes seleccionadas.',
 		'number_entries' => '%d artículos',
 		'open_feed' => 'Fuente abierta %s',
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Visibilidad',
 			'archived' => 'No mostrar (archivado)',

+ 1 - 1
app/i18n/fa/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => ' هیچ خوراکی انتخاب نشده است.',
 		'number_entries' => ' %d مقاله',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => ' دید',
 			'archived' => ' نشان داده نشود (بایگانی شده)',

+ 1 - 1
app/i18n/fi/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Syötettä ei ole valittu.',
 		'number_entries' => '%d artikkelia',
 		'open_feed' => 'Avaa syöte %s',
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Näkyvyys',
 			'archived' => 'Älä näytä (arkistoitu)',

+ 1 - 1
app/i18n/fr/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Aucun flux sélectionné.',
 		'number_entries' => '%d articles',	// IGNORE
 		'open_feed' => 'Ouvrir le flux %s',
-		'path_entries_condition' => 'Condition pour la récupération de contenu',
+		'path_entries_conditions' => 'Conditions pour la récupération de contenu',
 		'priority' => array(
 			'_' => 'Visibilité',
 			'archived' => 'Ne pas afficher (archivé)',

+ 1 - 1
app/i18n/he/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'אף הזנה לא נבחרה.',
 		'number_entries' => '%d מאמרים',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Visibility',	// TODO
 			'archived' => 'Do not show (archived)',	// TODO

+ 1 - 1
app/i18n/hu/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Nincsen hírforrás kiválasztva.',
 		'number_entries' => '%d cikkek',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Láthatóság',
 			'archived' => 'Ne jelenjen meg (archivált)',

+ 1 - 1
app/i18n/id/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'No feed selected.',	// TODO
 		'number_entries' => '%d articles',	// TODO
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Visibility',	// TODO
 			'archived' => 'Do not show (archived)',	// TODO

+ 1 - 1
app/i18n/it/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Nessun feed selezionato.',
 		'number_entries' => '%d articoli',
 		'open_feed' => 'Aprire il feed %s',
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Visibilità',
 			'archived' => 'Non mostrare (archiviato)',

+ 1 - 1
app/i18n/ja/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'どのフィードも選択されていません',
 		'number_entries' => '%d 記事数',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => '表示する場所',
 			'archived' => '非表示にする(アーカイブ)',

+ 1 - 1
app/i18n/ko/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => '선택된 피드가 없습니다.',
 		'number_entries' => '%d 개의 글',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => '표시',
 			'archived' => '표시하지 않음 (보관됨)',

+ 1 - 1
app/i18n/lv/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Barotne nav izvēlēta.',
 		'number_entries' => '%d raksti',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Prioritāte',
 			'archived' => 'Nerādīt (arhivēts)',

+ 1 - 1
app/i18n/nl/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Geen feed geselecteerd.',
 		'number_entries' => '%d artikelen',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Zichtbaarheid',
 			'archived' => 'Niet weergeven (gearchiveerd)',

+ 1 - 1
app/i18n/oc/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Cap de flux pas seleccionat.',
 		'number_entries' => '%d articles',	// IGNORE
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Visibilitat',
 			'archived' => 'Mostrar pas (archivat)',

+ 1 - 1
app/i18n/pl/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Brak kanałów.',
 		'number_entries' => '%d wiadomości',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Widoczność',
 			'archived' => 'Nie pokazuj (zarchiwizowany)',

+ 1 - 1
app/i18n/pt-br/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Nenhum feed selecionado.',
 		'number_entries' => '%d artigos',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Visibilidade',
 			'archived' => 'Não exibir (arquivado)',

+ 1 - 1
app/i18n/ru/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Ленты не выбраны.',
 		'number_entries' => '%d статей',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Видимость',
 			'archived' => 'Не показывать (архивировано)',

+ 1 - 1
app/i18n/sk/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Nevybrali ste kanál.',
 		'number_entries' => 'Počet článkov: %d',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Viditeľnosť',
 			'archived' => 'Nezobrazovať (archivované)',

+ 1 - 1
app/i18n/tr/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => 'Hiçbir akış seçilmedi.',
 		'number_entries' => '%d makale',
 		'open_feed' => '%s akışını aç',
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => 'Görünürlük',
 			'archived' => 'Gösterme (arşivlenmiş)',

+ 1 - 1
app/i18n/zh-cn/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => '未选择订阅源',
 		'number_entries' => '%d 篇文章',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => '可见性',
 			'archived' => '不显示(归档)',

+ 1 - 1
app/i18n/zh-tw/sub.php

@@ -202,7 +202,7 @@ return array(
 		'no_selected' => '未選擇訂閱源',
 		'number_entries' => '%d 篇文章',
 		'open_feed' => 'Open feed %s',	// TODO
-		'path_entries_condition' => 'Condition for content retrieval',	// TODO
+		'path_entries_conditions' => 'Conditions for content retrieval',	// TODO
 		'priority' => array(
 			'_' => '可見性',
 			'archived' => '不顯示(歸檔)',

+ 12 - 1
app/views/helpers/export/opml.phtml

@@ -82,8 +82,19 @@ function feedsToOutlines(array $feeds, bool $excludeMutedFeeds = false): array {
 			$outline['frss:cssFullContent'] = htmlspecialchars_decode($feed->pathEntries(), ENT_QUOTES);
 		}
 
+		if (!empty($feed->attributeArray('path_entries_conditions'))) {
+			$conditions = '';
+			foreach ($feed->attributeArray('path_entries_conditions') as $condition) {
+				if (is_string($condition)) {
+					$conditions .= $condition . "\n";
+				}
+			}
+			$conditions = trim($conditions);
+			$outline['frss:cssFullContentConditions'] = $conditions;
+		}
+
 		if ($feed->attributeString('path_entries_filter') != '') {
-			$outline['frss:cssFullContentFilter'] = $feed->attributeString('path_entries_filter');
+			$outline['frss:cssContentFilter'] = $feed->attributeString('path_entries_filter');
 		}
 
 		$curl_params = $feed->attributeArray('curl_params');

+ 3 - 3
app/views/helpers/feed/update.phtml

@@ -662,11 +662,11 @@
 			</div>
 
 			<div class="form-group">
-				<label class="group-name" for="path_entries_condition"><?= _t('sub.feed.path_entries_condition') ?></label>
+				<label class="group-name" for="path_entries_conditions"><?= _t('sub.feed.path_entries_conditions') ?></label>
 				<div class="group-controls">
-					<textarea class="w100" id="path_entries_condition" name="path_entries_condition"
+					<textarea class="w100" id="path_entries_conditions" name="path_entries_conditions"
 						rows="3" cols="64" spellcheck="false" placeholder="<?= _t('gen.short.blank_to_disable') ?>"><?php
-						foreach ($this->feed->attributeArray('path_entries_condition') ?? [] as $condition) {
+						foreach ($this->feed->attributeArray('path_entries_conditions') ?? [] as $condition) {
 							if (is_string($condition)) {
 								echo htmlspecialchars($condition, ENT_NOQUOTES, 'UTF-8'), PHP_EOL;
 							}

+ 2 - 1
docs/en/developers/OPML.md

@@ -91,8 +91,9 @@ A number of [cURL options](https://curl.se/libcurl/c/curl_easy_setopt.html) are
 
 * `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:cssFullContentFilter`: [CSS Selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) to remove the matching HTML elements from the full content retrieved by `frss:cssFullContent`.
+* `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`.
 	* Example: `.footer, .aside`
+. `frss:cssFullContentConditions`: List (separated by a new line) of search queries to trigger a full content retrieval as defined by `frss:cssFullContent`.
 * `frss:filtersActionRead`: List (separated by a new line) of search queries to automatically mark a new article as read.
 
 ### Dynamic OPML (reading lists)

+ 1 - 1
docs/i18n/freshrss.fr.po

@@ -5215,7 +5215,7 @@ msgstr ""
 #. type: Bullet: '* '
 #: en/./developers/OPML.md:54
 msgid ""
-"`frss:cssFullContentFilter`: [CSS Selector](https://developer.mozilla.org/en-"
+"`frss:cssContentFilter`: [CSS Selector](https://developer.mozilla.org/en-"
 "US/docs/Web/CSS/CSS_Selectors) to remove the matching HTML elements from the "
 "full content retrieved by `frss:cssFullContent`."
 msgstr ""

+ 1 - 1
docs/i18n/templates/freshrss.pot

@@ -4866,7 +4866,7 @@ msgstr ""
 #: en/./developers/OPML.md:54
 #, markdown-text
 msgid ""
-"`frss:cssFullContentFilter`: [CSS "
+"`frss:cssContentFilter`: [CSS "
 "Selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) to "
 "remove the matching HTML elements from the full content retrieved by "
 "`frss:cssFullContent`."