Explorar o código

Share in GReader JSON format (#6655)

fix https://github.com/FreshRSS/FreshRSS/discussions/6654#discussioncomment-10128309
Alexandre Alapetite hai 1 ano
pai
achega
5267db88ab

+ 7 - 0
app/Models/UserQuery.php

@@ -278,6 +278,13 @@ class FreshRSS_UserQuery {
 		return '';
 	}
 
+	public function sharedUrlGreader(bool $xmlEscaped = true): string {
+		if ($this->shareRss && $this->token !== '') {
+			return $this->sharedUrl($xmlEscaped) . ($xmlEscaped ? '&' : '&') . 'f=greader';
+		}
+		return '';
+	}
+
 	public function sharedUrlHtml(bool $xmlEscaped = true): string {
 		if ($this->shareRss && $this->token !== '') {
 			return $this->sharedUrl($xmlEscaped) . ($xmlEscaped ? '&' : '&') . 'f=html';

+ 1 - 0
app/i18n/cs/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Hledat „%s“',
 		'share' => array(
 			'_' => 'Sdílet tento dotaz pomocí odkazu',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Pokud chcete tento dotaz s někým sdílet, uveďte tento odkaz.',
 			'html' => 'Odkaz na stránku HTML, který lze sdílet',
 			'opml' => 'Odkaz na seznam kanálů OPML, který lze sdílet',

+ 1 - 0
app/i18n/de/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Suche nach „%s“',
 		'share' => array(
 			'_' => 'Diese Benutzerabfrage per Link teilen',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Diesen Link verteilen, um in mit Jedem zu teilen',
 			'html' => 'Verteilbarer Link zur HTML-Seite',
 			'opml' => 'Verteilbarer Link zur OPML Liste der Feeds',

+ 1 - 0
app/i18n/el/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Search for “%s”',	// TODO
 		'share' => array(
 			'_' => 'Share this query by link',	// TODO
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Give this link if you want to share this query with anyone',	// TODO
 			'html' => 'Shareable link to the HTML page',	// TODO
 			'opml' => 'Shareable link to the OPML list of feeds',	// TODO

+ 1 - 0
app/i18n/en-us/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Search for “%s”',	// IGNORE
 		'share' => array(
 			'_' => 'Share this query by link',	// IGNORE
+			'greader' => 'Shareable link to the GReader JSON',	// IGNORE
 			'help' => 'Give this link if you want to share this query with anyone',	// IGNORE
 			'html' => 'Shareable link to the HTML page',	// IGNORE
 			'opml' => 'Shareable link to the OPML list of feeds',	// IGNORE

+ 1 - 0
app/i18n/en/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Search for “%s”',
 		'share' => array(
 			'_' => 'Share this query by link',
+			'greader' => 'Shareable link to the GReader JSON',
 			'help' => 'Give this link if you want to share this query with anyone',
 			'html' => 'Shareable link to the HTML page',
 			'opml' => 'Shareable link to the OPML list of feeds',

+ 1 - 0
app/i18n/es/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Buscar “%s”',
 		'share' => array(
 			'_' => 'Comparte esta consulta por enlace',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Dale este enlace si quieres compartir esta consulta con alguien',
 			'html' => 'Enlace para compartir a la página HTML',
 			'opml' => 'Enlace para compartir a la lista de fuentes de OPML',

+ 1 - 0
app/i18n/fa/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => ' «%s» را جستجو کنید',
 		'share' => array(
 			'_' => 'Share this query by link',	// TODO
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Give this link if you want to share this query with anyone',	// TODO
 			'html' => 'Shareable link to the HTML page',	// TODO
 			'opml' => 'Shareable link to the OPML list of feeds',	// TODO

+ 1 - 0
app/i18n/fr/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Recherche de « %s »',
 		'share' => array(
 			'_' => 'Partager ce filtre par lien',
+			'greader' => 'Lien partageable au format JSON GReader',
 			'help' => 'Donner ce lien pour partager le contenu du filtre avec d’autres personnes',
 			'html' => 'Lien partageable de la page HTML',
 			'opml' => 'Lien partageable de la liste des flux au format OPML',

+ 1 - 0
app/i18n/he/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'חיפוש “%s”',
 		'share' => array(
 			'_' => 'Share this query by link',	// TODO
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Give this link if you want to share this query with anyone',	// TODO
 			'html' => 'Shareable link to the HTML page',	// TODO
 			'opml' => 'Shareable link to the OPML list of feeds',	// TODO

+ 1 - 0
app/i18n/hu/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Keresés erre „%s”',
 		'share' => array(
 			'_' => 'Lekérdezés megosztása linkkel',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Ezt a linket küldd el hogy megoszd a lekérdezést bárkivel',
 			'html' => 'Megosztható link a HTML oldalhoz',
 			'opml' => 'Megosztható link az OPML hírforrás listához',

+ 1 - 0
app/i18n/id/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Cari untuk "%s"',
 		'share' => array(
 			'_' => 'Bagikan permintaan ini melalui tautan',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Berikan tautan ini jika Anda ingin berbagi permintaan ini dengan siapa pun',
 			'html' => 'Tautan dapat dibagikan ke halaman HTML',
 			'opml' => 'Tautan dapat dibagikan ke daftar OPML dari feed',

+ 1 - 0
app/i18n/it/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Cerca per “%s”',
 		'share' => array(
 			'_' => 'Condividi questa query tramite un link',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Fornisci questo link se vuoi condividere questa query con altre persone',
 			'html' => 'Link condivisibile alla pagina HTML',
 			'opml' => 'Link condivisibile alla lista OPML dei feed',

+ 1 - 0
app/i18n/ja/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => '“%s”で検索する',
 		'share' => array(
 			'_' => 'このクエリをリンクで共有する',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'このクエリを誰かと共有したい場合は、このリンクを提供してください',
 			'html' => 'HTMLページへの共有リンク',
 			'opml' => 'フィードのOPMLリストへの共有リンク',

+ 1 - 0
app/i18n/ko/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => '“%s”의 검색 결과',
 		'share' => array(
 			'_' => '링크로 쿼리 공유',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => '링크를 사용해서 쿼리를 공유하세요',
 			'html' => 'HTML 공유 링크',
 			'opml' => 'OPML 피드 목록 공유 링크',

+ 1 - 0
app/i18n/lv/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Meklēt “%s”',
 		'share' => array(
 			'_' => 'Share this query by link',	// TODO
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Give this link if you want to share this query with anyone',	// TODO
 			'html' => 'Shareable link to the HTML page',	// TODO
 			'opml' => 'Shareable link to the OPML list of feeds',	// TODO

+ 1 - 0
app/i18n/nl/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Zoek naar „%s”',
 		'share' => array(
 			'_' => 'Deze query delen via een link',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Geef deze link als je deze query met iemand wilt delen',
 			'html' => 'Deelbare link naar de HTML-pagina',
 			'opml' => 'Deelbare link naar de OPML-lijst van feeds',

+ 1 - 0
app/i18n/oc/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Recèrca de « %s »',
 		'share' => array(
 			'_' => 'Share this query by link',	// TODO
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Give this link if you want to share this query with anyone',	// TODO
 			'html' => 'Shareable link to the HTML page',	// TODO
 			'opml' => 'Shareable link to the OPML list of feeds',	// TODO

+ 1 - 0
app/i18n/pl/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Szukaj “%s”',
 		'share' => array(
 			'_' => 'Udostępnij to zapytanie',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Posłuż się tym odnośnikiem, aby podzielić się zapytaniem',
 			'html' => 'Odnośnik do strony HTML',
 			'opml' => 'Odnośnik do listy kanałów (OPML)',

+ 1 - 0
app/i18n/pt-br/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Busca por “%s”',
 		'share' => array(
 			'_' => 'Compartilhar esta consulta por link',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Forneça este link se quiser compartilhar esta consulta com alguém',
 			'html' => 'Link compartilhável para a página HTML',
 			'opml' => 'Link compartilhável para a lista de feeds OPML',

+ 1 - 0
app/i18n/ru/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Искать “%s”',
 		'share' => array(
 			'_' => 'Поделиться запросом по ссылке',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Дайте эту ссылку, если хотите поделиться этим запросом с кем-либо',
 			'html' => 'Ссылка доступа на HTML-страницу',
 			'opml' => 'Ссылка доступа на список лент в формате OPML',

+ 1 - 0
app/i18n/sk/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => 'Vyhľadáva sa: “%s”',
 		'share' => array(
 			'_' => 'Zdieľať odkaz pre tento dopyt',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Pošlite tento odkaz ak chcete zdielať dopyt s kýmkoľvek',
 			'html' => 'Zdielateľný odkaz na HTML stránku',
 			'opml' => 'Zdielateľný odkaz na OPML zoznam kanálov',

+ 1 - 0
app/i18n/tr/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => '“%s” için arama',
 		'share' => array(
 			'_' => 'Bu aramayı linkle paylaşın',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => 'Bu aramayı herhangi biriyle paylaşmak istiyorsanız bu bağlantıyı verin',
 			'html' => 'HTML sayfasına paylaşılabilir bağlantı',
 			'opml' => 'OMPL listesine paylaşılabilir bağlantı',

+ 1 - 0
app/i18n/zh-cn/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => '搜索 “%s”',
 		'share' => array(
 			'_' => '分享您的自定义查询',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => '获取此自定义查询的分享链接',
 			'html' => 'HTML 页面的分享链接',
 			'opml' => '订阅源 OPML 的分享链接',

+ 1 - 0
app/i18n/zh-tw/conf.php

@@ -145,6 +145,7 @@ return array(
 		'search' => '搜尋 “%s”',
 		'share' => array(
 			'_' => '透過連結分享此查詢',
+			'greader' => 'Shareable link to the GReader JSON',	// TODO
 			'help' => '如果您想與任何人分享此查詢,請提供此連結',
 			'html' => 'HTML 頁面的可共享連結',
 			'opml' => 'OPML 源列表的可共享連結',

+ 1 - 0
app/views/helpers/configure/query.phtml

@@ -42,6 +42,7 @@
 					<ul>
 						<li><a href="<?= $this->query->sharedUrlHtml() ?>"><?= _i('link') ?> <?= _t('conf.query.share.html') ?></a></li>
 						<li><a href="<?= $this->query->sharedUrlRss() ?>"><?= _i('link') ?> <?= _t('conf.query.share.rss') ?></a></li>
+						<li><a href="<?= $this->query->sharedUrlGreader() ?>"><?= _i('link') ?> <?= _t('conf.query.share.greader') ?></a></li>
 					</ul>
 					<?php endif; ?>
 				</div>

+ 4 - 0
app/views/helpers/export/articles.phtml

@@ -20,6 +20,10 @@ if (empty($this->entryIdsTagNames)) {
 }
 
 foreach ($this->entries as $entry) {
+	if (!$this->internal_rendering) {
+		/** @var FreshRSS_Entry */
+		$entry = Minz_ExtensionManager::callHook('entry_before_display', $entry);
+	}
 	if ($entry == null) {
 		continue;
 	}

+ 10 - 1
p/api/query.php

@@ -13,7 +13,7 @@ if (!ctype_alnum($token)) {
 }
 
 $format = Minz_Request::paramString('f');
-if (!in_array($format, ['atom', 'html', 'opml', 'rss'], true)) {
+if (!in_array($format, ['atom', 'greader', 'html', 'json', 'opml', 'rss'], true)) {
 	header('HTTP/1.1 422 Unprocessable Entity');
 	header('Content-Type: text/plain; charset=UTF-8');
 	die('Invalid format `f`!');
@@ -63,7 +63,9 @@ foreach (FreshRSS_Context::userConf()->queries as $raw_query) {
 	if (!empty($raw_query['token']) && $raw_query['token'] === $token) {
 		switch ($format) {
 			case 'atom':
+			case 'greader':
 			case 'html':
+			case 'json':
 			case 'rss':
 				if (empty($raw_query['shareRss'])) {
 					continue 2;
@@ -161,6 +163,13 @@ if (in_array($format, ['rss', 'atom'], true)) {
 	header('Content-Type: application/rss+xml; charset=utf-8');
 	$view->_layout(null);
 	$view->_path('index/rss.phtml');
+} elseif (in_array($format, ['greader', 'json'], true)) {
+	header('Content-Type: application/json; charset=utf-8');
+	$view->_layout(null);
+	$view->type = 'query/' . $token;
+	$view->list_title = $query->getName();
+	$view->entryIdsTagNames = [];	// Do not export user labels for privacy
+	$view->_path('helpers/export/articles.phtml');
 } elseif ($format === 'opml') {
 	if (!$query->safeForOpml()) {
 		Minz_Error::error(404, 'OPML not allowed for this user query!');