aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2021-02-16 12:00:49 -0500
committerGravatar GitHub <noreply@github.com> 2021-02-16 18:00:49 +0100
commitfe1fba9828ad4d68a3cc93ed5f8e361f34e5a873 (patch)
treeca9168f79844b0320f7731a1f2969d3d112c4eac
parent5daee165dc73fcf74673f2ede1891dbd5821c9f4 (diff)
Add a content action parameter to work with CSS selector (#3453)
Before, when retrieving article contents with CSS selector, the content of the RSS feed was replaced by the content of the CSS selector. It works well in most of the cases but if there is a different content in the feed and in the selector, the former is lost. Now, there is a parameter to decide which action is performed after retrieving the content. By default, the previous behavior is kept. But now, it is possible to append or prepend the CSS selector content to the feed content. See #3451
-rw-r--r--app/Controllers/subscriptionController.php2
-rw-r--r--app/Models/Entry.php16
-rw-r--r--app/i18n/cz/sub.php6
-rw-r--r--app/i18n/de/sub.php6
-rw-r--r--app/i18n/en-us/sub.php6
-rw-r--r--app/i18n/en/sub.php6
-rwxr-xr-xapp/i18n/es/sub.php6
-rw-r--r--app/i18n/fr/sub.php6
-rw-r--r--app/i18n/he/sub.php6
-rw-r--r--app/i18n/it/sub.php6
-rw-r--r--app/i18n/kr/sub.php6
-rw-r--r--app/i18n/nl/sub.php6
-rw-r--r--app/i18n/oc/sub.php6
-rw-r--r--app/i18n/pl/sub.php6
-rw-r--r--app/i18n/pt-br/sub.php6
-rw-r--r--app/i18n/ru/sub.php6
-rw-r--r--app/i18n/sk/sub.php6
-rw-r--r--app/i18n/tr/sub.php6
-rw-r--r--app/i18n/zh-cn/sub.php6
-rw-r--r--app/views/helpers/feed/update.phtml11
-rw-r--r--cli/i18n/ignore/en-us.php4
21 files changed, 133 insertions, 2 deletions
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index 7435f70b2..1cff6ff56 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -125,6 +125,8 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
}
$feed->_attributes('curl_params', empty($opts) ? null : $opts);
+ $feed->_attributes('content_action', Minz_Request::param('content_action', 'replace'));
+
if (FreshRSS_Auth::hasAccess('admin')) {
$feed->_attributes('ssl_verify', Minz_Request::paramTernary('ssl_verify'));
$timeout = intval(Minz_Request::param('timeout', 0));
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 784576455..13c32b7a6 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -446,8 +446,20 @@ class FreshRSS_Entry extends Minz_Model {
$feed->pathEntries(),
$feed->attributes()
);
- if ($fullContent != '') {
- $this->content = $fullContent;
+ if ('' !== $fullContent) {
+ switch ($feed->attributes('content_action')) {
+ case 'prepend':
+ $this->content = $fullContent . $this->content();
+ break;
+ case 'append':
+ $this->content = $this->content() . $fullContent;
+ break;
+ case 'replace':
+ default:
+ $this->content = $fullContent;
+ break;
+ }
+
return true;
}
} catch (Exception $e) {
diff --git a/app/i18n/cz/sub.php b/app/i18n/cz/sub.php
index c0926ebba..9e933f60d 100644
--- a/app/i18n/cz/sub.php
+++ b/app/i18n/cz/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'Přihlašovací jméno',
),
'clear_cache' => 'Always clear cache', // TODO - Translation
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Stáhne zkrácenou verzi RSS kanálů (pozor, náročnější na čas!)',
diff --git a/app/i18n/de/sub.php b/app/i18n/de/sub.php
index 99373d2c5..2e21a8f2c 100644
--- a/app/i18n/de/sub.php
+++ b/app/i18n/de/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP-Nutzername',
),
'clear_cache' => 'Nicht cachen (für defekte Feeds)',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Verwende Cookies beim Herunterladen des Feed-Inhalts mit CSS-Filtern',
'css_cookie_help' => 'Beispiel: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>',
'css_help' => 'Ruft bei gekürzten RSS-Feeds den vollständigen Artikelinhalt ab (Achtung, benötigt mehr Zeit!)',
diff --git a/app/i18n/en-us/sub.php b/app/i18n/en-us/sub.php
index 644da1c62..0aa3f7f4c 100644
--- a/app/i18n/en-us/sub.php
+++ b/app/i18n/en-us/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP username',
),
'clear_cache' => 'Always clear cache',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content',
+ 'append' => 'Add after existing content',
+ 'prepend' => 'Add before existing content',
+ 'replace' => 'Replace existing content',
+ ),
'css_cookie' => 'Use Cookies when fetching the article content',
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>',
'css_help' => 'Retrieves truncated RSS feeds (caution, requires more time!)',
diff --git a/app/i18n/en/sub.php b/app/i18n/en/sub.php
index 590ad0a63..2335addf6 100644
--- a/app/i18n/en/sub.php
+++ b/app/i18n/en/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP username',
),
'clear_cache' => 'Always clear cache',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content',
+ 'append' => 'Add after existing content',
+ 'prepend' => 'Add before existing content',
+ 'replace' => 'Replace existing content',
+ ),
'css_cookie' => 'Use Cookies when fetching the article content',
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>',
'css_help' => 'Retrieves truncated RSS feeds (caution, requires more time!)',
diff --git a/app/i18n/es/sub.php b/app/i18n/es/sub.php
index e89e70184..32376be75 100755
--- a/app/i18n/es/sub.php
+++ b/app/i18n/es/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'Nombre de usuario HTTP',
),
'clear_cache' => 'Always clear cache', // TODO - Translation
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Recibir fuentes RSS truncadas (aviso, ¡necesita más tiempo!)',
diff --git a/app/i18n/fr/sub.php b/app/i18n/fr/sub.php
index 18d35ed54..495c4c086 100644
--- a/app/i18n/fr/sub.php
+++ b/app/i18n/fr/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'Identifiant HTTP',
),
'clear_cache' => 'Toujours vider le cache',
+ 'content_action' => array(
+ '_' => 'Action à effectuer pour la réception du contenu des articles',
+ 'append' => 'Ajouter après le contenu existant',
+ 'prepend' => 'Ajouter avant le contenu existant',
+ 'replace' => 'Remplacer le contenu existant',
+ ),
'css_cookie' => 'Utiliser des cookies pour la réception du contenu des articles',
'css_cookie_help' => 'Exemple : <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>',
'css_help' => 'Permet de récupérer les flux tronqués (attention, demande plus de temps !)',
diff --git a/app/i18n/he/sub.php b/app/i18n/he/sub.php
index 33c511a11..3bb576952 100644
--- a/app/i18n/he/sub.php
+++ b/app/i18n/he/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP שם משתמש',
),
'clear_cache' => 'Always clear cache', // TODO - Translation
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'קבלת הזנות RSS קטומות (זהירות, לוקח זמן רב יותר!)',
diff --git a/app/i18n/it/sub.php b/app/i18n/it/sub.php
index c22c912e6..9c2fd1b08 100644
--- a/app/i18n/it/sub.php
+++ b/app/i18n/it/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP username', // TODO - Translation
),
'clear_cache' => 'Always clear cache', // TODO - Translation
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'In caso di RSS feeds troncati (attenzione, richiede molto tempo!)',
diff --git a/app/i18n/kr/sub.php b/app/i18n/kr/sub.php
index 4a6023630..a953808d7 100644
--- a/app/i18n/kr/sub.php
+++ b/app/i18n/kr/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP 사용자 이름',
),
'clear_cache' => '항상 캐시 지우기',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => '글의 일부가 포함된 RSS 피드를 가져옵니다 (주의, 시간이 좀 더 걸립니다!)',
diff --git a/app/i18n/nl/sub.php b/app/i18n/nl/sub.php
index 88ee4c98b..0eea491d9 100644
--- a/app/i18n/nl/sub.php
+++ b/app/i18n/nl/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP gebruikers naam',
),
'clear_cache' => 'Cache altijd leegmaken',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Haalt onvolledige RSS-feeds op (attentie, heeft meer tijd nodig!)',
diff --git a/app/i18n/oc/sub.php b/app/i18n/oc/sub.php
index 39cf09a7e..9b70bdac2 100644
--- a/app/i18n/oc/sub.php
+++ b/app/i18n/oc/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'Identificant HTTP',
),
'clear_cache' => 'Totjorn escafar lo cache',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Permet de recuperar los fluxes troncats (atencion, demanda mai de temps !)',
diff --git a/app/i18n/pl/sub.php b/app/i18n/pl/sub.php
index b6dab5203..b1e93f1e8 100644
--- a/app/i18n/pl/sub.php
+++ b/app/i18n/pl/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'Użytkownik HTTP',
),
'clear_cache' => 'Zawsze czyść pamięć podręczną',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Pozwala na ograniczenie zawartości kanałów (uwaga, wymaga więcej czasu!)',
diff --git a/app/i18n/pt-br/sub.php b/app/i18n/pt-br/sub.php
index 25fef4a94..2fd0138ed 100644
--- a/app/i18n/pt-br/sub.php
+++ b/app/i18n/pt-br/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'Usuário HTTP',
),
'clear_cache' => 'Sempre limpar o cache',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Retorna RSS feeds truncados (atenção, requer mais tempo!)',
diff --git a/app/i18n/ru/sub.php b/app/i18n/ru/sub.php
index 8f4a8f0ca..cd18f56de 100644
--- a/app/i18n/ru/sub.php
+++ b/app/i18n/ru/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP username', // TODO - Translation
),
'clear_cache' => 'Always clear cache', // TODO - Translation
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Retrieves truncated RSS feeds (caution, requires more time!)', // TODO - Translation
diff --git a/app/i18n/sk/sub.php b/app/i18n/sk/sub.php
index 5c97ef174..b60d16400 100644
--- a/app/i18n/sk/sub.php
+++ b/app/i18n/sk/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'Používateľské meno pre HTTP',
),
'clear_cache' => 'Vždy vymazať vyrovnávaciu pamäť',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Stiahnuť skrátenú verziu RSS kanála (pozor, vyžaduje viac času!)',
diff --git a/app/i18n/tr/sub.php b/app/i18n/tr/sub.php
index 5f07de552..83ea31fb2 100644
--- a/app/i18n/tr/sub.php
+++ b/app/i18n/tr/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP kullanıcı adı',
),
'clear_cache' => 'Always clear cache', // TODO - Translation
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => 'Dikkat, daha çok zaman gerekir!',
diff --git a/app/i18n/zh-cn/sub.php b/app/i18n/zh-cn/sub.php
index 0fdc9cbca..29160bf88 100644
--- a/app/i18n/zh-cn/sub.php
+++ b/app/i18n/zh-cn/sub.php
@@ -33,6 +33,12 @@ return array(
'username' => 'HTTP 用户名',
),
'clear_cache' => '总是清除缓存',
+ 'content_action' => array(
+ '_' => 'Content action when fetching the article content', // TODO - Translation
+ 'append' => 'Add after existing content', // TODO - Translation
+ 'prepend' => 'Add before existing content', // TODO - Translation
+ 'replace' => 'Replace existing content', // TODO - Translation
+ ),
'css_cookie' => 'Use Cookies when fetching the article content', // TODO - Translation
'css_cookie_help' => 'Example: <kbd>foo=bar; gdpr_consent=true; cookie=value</kbd>', // TODO - Translation
'css_help' => '用于获取全文(注意,这将耗费更多时间!)',
diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml
index 184d78114..361f94ab8 100644
--- a/app/views/helpers/feed/update.phtml
+++ b/app/views/helpers/feed/update.phtml
@@ -300,6 +300,17 @@
</div>
<div class="form-group">
+ <label class="group-name" for="content_action"><?= _t('sub.feed.content_action') ?></label>
+ <div class="group-controls">
+ <select name="content_action" id="content_action">
+ <option value="replace"<?= 'replace' === $this->feed->attributes('content_action') ? ' selected="selected"' : '' ?>><?= _t('sub.feed.content_action.replace') ?></option>
+ <option value="prepend"<?= 'prepend' === $this->feed->attributes('content_action') ? ' selected="selected"' : '' ?>><?= _t('sub.feed.content_action.prepend') ?></option>
+ <option value="append"<?= 'append' === $this->feed->attributes('content_action') ? ' selected="selected"' : '' ?>><?= _t('sub.feed.content_action.append') ?></option>
+ </select>
+ </div>
+ </div>
+
+ <div class="form-group">
<label class="group-name" for="path_entries"><?= _t('sub.feed.proxy') ?></label>
<div class="group-controls">
<select class="number" name="proxy_type" id="proxy_type"><?php
diff --git a/cli/i18n/ignore/en-us.php b/cli/i18n/ignore/en-us.php
index 889d90e8c..fad9a4aaa 100644
--- a/cli/i18n/ignore/en-us.php
+++ b/cli/i18n/ignore/en-us.php
@@ -712,6 +712,10 @@ return array(
'sub.feed.auth.password',
'sub.feed.auth.username',
'sub.feed.clear_cache',
+ 'sub.feed.content_action._',
+ 'sub.feed.content_action.append',
+ 'sub.feed.content_action.prepend',
+ 'sub.feed.content_action.replace',
'sub.feed.css_cookie',
'sub.feed.css_cookie_help',
'sub.feed.css_help',