Parcourir la source

New limit option when reloading a feed (#4370)

Alexandre Alapetite il y a 3 ans
Parent
commit
f5aaf5f460

+ 3 - 3
app/Controllers/feedController.php

@@ -814,7 +814,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 		@set_time_limit(300);
 
 		//Get Feed ID.
-		$feed_id = Minz_Request::param('id');
+		$feed_id = intval(Minz_Request::param('id', 0));
+		$limit = intval(Minz_Request::param('reload_limit', 10));
 
 		$feedDAO = FreshRSS_Factory::createFeedDao();
 		$entryDAO = FreshRSS_Factory::createEntryDao();
@@ -831,8 +832,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 		self::actualizeFeed($feed_id, '', false);
 
 		//Extract all feed entries from database, load complete content and store them back in database.
-		$entries = $entryDAO->listWhere('f', $feed_id, FreshRSS_Entry::STATE_ALL, 'DESC', 0);
-		//TODO: Parameter to limit the number of articles to reload
+		$entries = $entryDAO->listWhere('f', $feed_id, FreshRSS_Entry::STATE_ALL, 'DESC', $limit);
 
 		//We need another DB connection in parallel for unbuffered streaming
 		Minz_ModelPdo::$usesSharedPdo = false;

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Vymazat mezipaměť',
 			'clear_cache_help' => 'Vymazat mezipaměť pro tento kanál.',
 			'reload_articles' => 'Znovu načíst články',
-			'reload_articles_help' => 'Znovu načíst články a získat úplný obsah, pokud je definován přepínač.',
+			'reload_articles_help' => 'Znovu načíst články a získat úplný obsah, pokud je definován přepínač.',	// DIRTY
 			'title' => 'Údržba',
 		),
 		'moved_category_deleted' => 'Když odstraníte kategorii, její kanály jsou automaticky přesunuty do <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Zwischenspeicher leeren',
 			'clear_cache_help' => 'Zwischenspeicher für diesen Feed leeren.',
 			'reload_articles' => 'Artikel neuladen',
-			'reload_articles_help' => 'Artikel neuladen und komplette Inhalte holen, wenn ein Selektor festgelegt wurde.',
+			'reload_articles_help' => 'Artikel neuladen und komplette Inhalte holen, wenn ein Selektor festgelegt wurde.',	// DIRTY
 			'title' => 'Wartung',
 		),
 		'moved_category_deleted' => 'Wenn Sie eine Kategorie entfernen, werden deren Feeds automatisch in die Kategorie <em>%s</em> eingefügt.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Clear cache',	// IGNORE
 			'clear_cache_help' => 'Clear the cache for this feed.',	// IGNORE
 			'reload_articles' => 'Reload articles',	// IGNORE
-			'reload_articles_help' => 'Reload articles and fetch complete content if a selector is defined.',	// IGNORE
+			'reload_articles_help' => 'Reload that many articles and fetch complete content if a selector is defined.',	// IGNORE
 			'title' => 'Maintenance',	// IGNORE
 		),
 		'moved_category_deleted' => 'When you delete a category, its feeds are automatically classified under <em>%s</em>.',	// IGNORE

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Clear cache',
 			'clear_cache_help' => 'Clear the cache for this feed.',
 			'reload_articles' => 'Reload articles',
-			'reload_articles_help' => 'Reload articles and fetch complete content if a selector is defined.',
+			'reload_articles_help' => 'Reload that many articles and fetch complete content if a selector is defined.',
 			'title' => 'Maintenance',
 		),
 		'moved_category_deleted' => 'When you delete a category, its feeds are automatically classified under <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Borrar caché',
 			'clear_cache_help' => 'Borrar la memoria caché de esta fuente.',
 			'reload_articles' => 'Recargar artículos',
-			'reload_articles_help' => 'Vuelva a cargar artículos y obtenga contenido completo si se define un selector.',
+			'reload_articles_help' => 'Vuelva a cargar artículos y obtenga contenido completo si se define un selector.',	// DIRTY
 			'title' => 'Mantenimiento',
 		),
 		'moved_category_deleted' => 'Al borrar una categoría todas sus fuentes pasan automáticamente a la categoría <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Vider le cache',
 			'clear_cache_help' => 'Supprime le cache de ce flux.',
 			'reload_articles' => 'Recharger les articles',
-			'reload_articles_help' => 'Recharge les articles et récupère le contenu complet si un sélecteur est défini.',
+			'reload_articles_help' => 'Recharge cette quantité d’articles et récupère le contenu complet si un sélecteur est défini.',
 			'title' => 'Maintenance',	// IGNORE
 		),
 		'moved_category_deleted' => 'Lors de la suppression d’une catégorie, ses flux seront automatiquement classés dans <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Clear cache',	// TODO
 			'clear_cache_help' => 'Clear the cache for this feed.',	// TODO
 			'reload_articles' => 'Reload articles',	// TODO
-			'reload_articles_help' => 'Reload articles and fetch complete content if a selector is defined.',	// TODO
+			'reload_articles_help' => 'Reload that many articles and fetch complete content if a selector is defined.',	// TODO
 			'title' => 'Maintenance',	// TODO
 		),
 		'moved_category_deleted' => 'כאשר הקטגוריה נמחקת ההזנות שבתוכה אוטומטית מקוטלגות תחת	<em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Clear cache',	// TODO
 			'clear_cache_help' => 'Clear the cache for this feed.',	// TODO
 			'reload_articles' => 'Reload articles',	// TODO
-			'reload_articles_help' => 'Reload articles and fetch complete content if a selector is defined.',	// TODO
+			'reload_articles_help' => 'Reload that many articles and fetch complete content if a selector is defined.',	// TODO
 			'title' => 'Maintenance',	// TODO
 		),
 		'moved_category_deleted' => 'Cancellando una categoria i feed al suo interno verranno classificati automaticamente come <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'キャッシュのクリア',
 			'clear_cache_help' => 'このフィードのキャッシュをクリアします。',
 			'reload_articles' => '記事を再読み込みする',
-			'reload_articles_help' => '記事を再読み込みして、セレクターが定義したコンテンツを完全に取得します。',
+			'reload_articles_help' => '記事を再読み込みして、セレクターが定義したコンテンツを完全に取得します。',	// DIRTY
 			'title' => 'メンテナンス',
 		),
 		'moved_category_deleted' => 'カテゴリを削除したとき、フィードは自動的に<em>%s</em>下に分類されます。',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => '캐쉬 지우기',
 			'clear_cache_help' => '이 피드의 캐쉬 지우기.',
 			'reload_articles' => '글 다시 로드',
-			'reload_articles_help' => '글 다시 로드하고 셀렉터가 정의 되었을 경우에 모든 컨텐츠 가져오기.',
+			'reload_articles_help' => '글 다시 로드하고 셀렉터가 정의 되었을 경우에 모든 컨텐츠 가져오기.',	// DIRTY
 			'title' => '유지 보수',
 		),
 		'moved_category_deleted' => '카테고리를 삭제하면, 해당 카테고리 아래에 있던 피드들은 자동적으로 <em>%s</em> 아래로 분류됩니다.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Cache leegmaken',
 			'clear_cache_help' => 'Cache voor deze feed leegmaken.',
 			'reload_articles' => 'Artikels herladen',
-			'reload_articles_help' => 'Artikels herladen en complete inhoud ophalen als een selector is gedefinieerd.',
+			'reload_articles_help' => 'Artikels herladen en complete inhoud ophalen als een selector is gedefinieerd.',	// DIRTY
 			'title' => 'Onderhoud',
 		),
 		'moved_category_deleted' => 'Als u een categorie verwijderd, worden de feeds automatisch geclassificeerd onder <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Escafar lo cache',
 			'clear_cache_help' => 'Escafar lo cache d’aqueste flux sul disc',
 			'reload_articles' => 'Recargar los articles',
-			'reload_articles_help' => 'Recargar los articles e recuperar lo contengut complet',
+			'reload_articles_help' => 'Recargar los articles e recuperar lo contengut complet',	// DIRTY
 			'title' => 'Mantenença',
 		),
 		'moved_category_deleted' => 'Quand escafatz una categoria, sos fluxes son automaticament classats dins <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Wyczyść pamięć podręczną',
 			'clear_cache_help' => 'Czyści pamięć podręczną tego kanału.',
 			'reload_articles' => 'Przeładuj wiadomości',
-			'reload_articles_help' => 'Ponownie pobiera wiadomości i przetwarza treść ze strony pierwotnej, jeżeli zdefiniowany został selektor CSS.',
+			'reload_articles_help' => 'Ponownie pobiera wiadomości i przetwarza treść ze strony pierwotnej, jeżeli zdefiniowany został selektor CSS.',	// DIRTY
 			'title' => 'Konserwacja',
 		),
 		'moved_category_deleted' => 'Po usunięciu kategorii znajdujące się w niej kanały zostaną automatycznie przeniesione do <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Limpar o cache',
 			'clear_cache_help' => 'Limpar o cache em disco deste feed',
 			'reload_articles' => 'Recarregar artigos',
-			'reload_articles_help' => 'Recarregar artigos e buscar conteúdo completo',
+			'reload_articles_help' => 'Recarregar artigos e buscar conteúdo completo',	// DIRTY
 			'title' => 'Manutenção',
 		),
 		'moved_category_deleted' => 'Quando você deleta uma categoria, seus feeds são automaticamente classificados como <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Очистить кэш',
 			'clear_cache_help' => 'Очистить кэш для этой ленты.',
 			'reload_articles' => 'Снова загрузить статьи',
-			'reload_articles_help' => 'Снова загрузить статьи и извлечь полное содержимое, если задан селектор.',
+			'reload_articles_help' => 'Снова загрузить статьи и извлечь полное содержимое, если задан селектор.',	// DIRTY
 			'title' => 'Обслуживание',
 		),
 		'moved_category_deleted' => 'Когда вы удаляете категорию, ленты категории автоматически попадают в категорию <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Vymazať vyrovnáciu pamäť',
 			'clear_cache_help' => 'Vymazať vyrovnáciu pamäť pre tento kanál.',
 			'reload_articles' => 'Obnoviť články',
-			'reload_articles_help' => 'Obnoviť články a stiahnuť kompletný obsah, ak je definovaný selektor.',
+			'reload_articles_help' => 'Obnoviť články a stiahnuť kompletný obsah, ak je definovaný selektor.',	// DIRTY
 			'title' => 'Údržba',
 		),
 		'moved_category_deleted' => 'Keď vymažete kategóriu, jej kanály sa automaticky zaradia pod <em>%s</em>.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => 'Önbelleği temizle',
 			'clear_cache_help' => 'Bu akışın önbelleğini temizler.',
 			'reload_articles' => 'Makaleleri yeniden yükle',
-			'reload_articles_help' => 'Reload articles and fetch complete content if a selector is defined.',	// TODO
+			'reload_articles_help' => 'Reload that many articles and fetch complete content if a selector is defined.',	// TODO
 			'title' => 'Bakım',
 		),
 		'moved_category_deleted' => 'Bir kategoriyi silerseniz, içerisindeki akışlar <em>%s</em> içerisine yerleşir.',

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

@@ -108,7 +108,7 @@ return array(
 			'clear_cache' => '清理缓存',
 			'clear_cache_help' => '清除该feed的缓存',
 			'reload_articles' => '重载文章',
-			'reload_articles_help' => '重新加载文章并获取完整内容',
+			'reload_articles_help' => '重新加载文章并获取完整内容',	// DIRTY
 			'title' => '维护',
 		),
 		'moved_category_deleted' => '删除分类时,其中的订阅源会自动归类到 <em>%s</em>',

+ 20 - 14
app/views/helpers/feed/update.phtml

@@ -478,7 +478,7 @@
 			<div class="group-controls">
 				<div class="stick w100">
 					<input type="text" name="path_entries" id="path_entries" class="w100" value="<?= $this->feed->pathEntries() ?>"
-						placeholder="<?= _t('gen.short.blank_to_disable') ?>" />
+						data-leave-validation="<?= $this->feed->pathEntries() ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />
 					<a id="popup-preview-selector" class="btn" href="<?=
 						_url('feed', 'contentSelectorPreview', 'id', $this->feed->id(), 'selector', 'selector-token') ?>"><?= _i('look') ?></a>
 				</div>
@@ -573,23 +573,29 @@
 				<button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
 			</div>
 		</div>
+	</form>
 
-		<legend><?= _t('sub.feed.maintenance.title') ?></legend>
-		<div class="form-group">
-			<div class="group-controls">
-				<a class="btn btn-important" href="<?= _url('feed', 'clearCache', 'id', $this->feed->id()) ?>">
-					<?= _t('sub.feed.maintenance.clear_cache') ?>
-				</a>
-				<p class="help"><?= _i('help') ?> <?= _t('sub.feed.maintenance.clear_cache_help') ?></p>
-			</div>
-			<div class="group-controls">
-				<a class="btn btn-important" href="<?= _url('feed', 'reload', 'id', $this->feed->id()) ?>">
+	<legend><?= _t('sub.feed.maintenance.title') ?></legend>
+	<div class="form-group">
+		<div class="group-controls">
+			<a class="btn btn-important" href="<?= _url('feed', 'clearCache', 'id', $this->feed->id()) ?>">
+				<?= _t('sub.feed.maintenance.clear_cache') ?>
+			</a>
+			<p class="help"><?= _i('help') ?> <?= _t('sub.feed.maintenance.clear_cache_help') ?></p>
+		</div>
+		<div class="group-controls">
+			<form method="post" action="<?= _url('feed', 'reload') ?>">
+				<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
+				<input type="hidden" name="id" value="<?= $this->feed->id() ?>" />
+				<button type="submit" class="btn btn-important">
 					<?= _t('sub.feed.maintenance.reload_articles') ?>
-				</a>
+				</button>
+				<input type="number" name="reload_limit" min="1" value="10" />
 				<p class="help"><?= _i('help') ?> <?= _t('sub.feed.maintenance.reload_articles_help') ?></p>
-			</div>
+			</form>
 		</div>
-	</form>
+	</div>
+
 </div>
 
 <div id="popup">

+ 9 - 2
p/scripts/extra.js

@@ -233,11 +233,18 @@ function init_select_observers() {
 	});
 }
 
-function data_leave_validation(parent) {
+/**
+ * Returns true when no input element is changed, false otherwise.
+ * When excludeForm is defined, will only report changes outside the specified form.
+ */
+function data_leave_validation(parent, excludeForm = null) {
 	const ds = parent.querySelectorAll('[data-leave-validation]');
 
 	for (let i = ds.length - 1; i >= 0; i--) {
 		const input = ds[i];
+		if (excludeForm && excludeForm === input.form) {
+			continue;
+		}
 		if (input.type === 'checkbox' || input.type === 'radio') {
 			if (input.checked != input.getAttribute('data-leave-validation')) {
 				return false;
@@ -251,7 +258,7 @@ function data_leave_validation(parent) {
 
 function init_configuration_alert() {
 	window.onsubmit = function (e) {
-		window.hasSubmit = true;
+		window.hasSubmit = data_leave_validation(document.body, e.submitter ? e.submitter.form : null);
 	};
 	window.onbeforeunload = function (e) {
 		if (window.hasSubmit) {

+ 3 - 1
p/scripts/feed.js

@@ -1,6 +1,6 @@
 // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
 'use strict';
-/* globals init_archiving, init_password_observers, init_slider */
+/* globals init_archiving, init_configuration_alert, init_password_observers, init_slider */
 
 // <popup>
 let popup = null;
@@ -134,6 +134,8 @@ function init_feed_afterDOM() {
 		init_valid_xpath(document.body);
 	}
 
+	init_configuration_alert();
+
 	if (window.console) {
 		console.log('FreshRSS feed init done.');
 	}