Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/edge' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
math-GH committed Apr 25, 2024
2 parents 1137dce + c47b785 commit bc4c996
Show file tree
Hide file tree
Showing 40 changed files with 319 additions and 253 deletions.
8 changes: 4 additions & 4 deletions app/Controllers/feedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function addAction(): void {
if (!empty($xPathSettings)) {
$attributes['xpath'] = $xPathSettings;
}
} elseif ($feed_kind === FreshRSS_Feed::KIND_JSON_DOTPATH) {
} elseif ($feed_kind === FreshRSS_Feed::KIND_JSON_DOTNOTATION) {
$jsonSettings = [];
if (Minz_Request::paramString('jsonFeedTitle') !== '') {
$jsonSettings['feedTitle'] = Minz_Request::paramString('jsonFeedTitle', true);
Expand Down Expand Up @@ -295,7 +295,7 @@ public function addAction(): void {
$jsonSettings['itemUid'] = Minz_Request::paramString('jsonItemUid', true);
}
if (!empty($jsonSettings)) {
$attributes['json_dotpath'] = $jsonSettings;
$attributes['json_dotnotation'] = $jsonSettings;
}
}

Expand Down Expand Up @@ -497,10 +497,10 @@ public static function actualizeFeeds(?int $feed_id = null, ?string $feed_url =
if ($simplePie === null) {
throw new FreshRSS_Feed_Exception('XML+XPath parsing failed for [' . $feed->url(false) . ']');
}
} elseif ($feed->kind() === FreshRSS_Feed::KIND_JSON_DOTPATH) {
} elseif ($feed->kind() === FreshRSS_Feed::KIND_JSON_DOTNOTATION) {
$simplePie = $feed->loadJson();
if ($simplePie === null) {
throw new FreshRSS_Feed_Exception('JSON dotpath parsing failed for [' . $feed->url(false) . ']');
throw new FreshRSS_Feed_Exception('JSON dot notation parsing failed for [' . $feed->url(false) . ']');
}
} elseif ($feed->kind() === FreshRSS_Feed::KIND_JSONFEED) {
$simplePie = $feed->loadJson();
Expand Down
4 changes: 2 additions & 2 deletions app/Controllers/subscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function feedAction(): void {
$xPathSettings['itemUid'] = Minz_Request::paramString('xPathItemUid', true);
if (!empty($xPathSettings))
$feed->_attribute('xpath', $xPathSettings);
} elseif ($feed->kind() === FreshRSS_Feed::KIND_JSON_DOTPATH) {
} elseif ($feed->kind() === FreshRSS_Feed::KIND_JSON_DOTNOTATION) {
$jsonSettings = [];
if (Minz_Request::paramString('jsonFeedTitle') !== '') {
$jsonSettings['feedTitle'] = Minz_Request::paramString('jsonFeedTitle', true);
Expand Down Expand Up @@ -274,7 +274,7 @@ public function feedAction(): void {
$jsonSettings['itemUid'] = Minz_Request::paramString('jsonItemUid', true);
}
if (!empty($jsonSettings)) {
$feed->_attribute('json_dotpath', $jsonSettings);
$feed->_attribute('json_dotnotation', $jsonSettings);
}
}

Expand Down
12 changes: 6 additions & 6 deletions app/Models/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FreshRSS_Feed extends Minz_Model {
public const KIND_JSON_XPATH = 20;

public const KIND_JSONFEED = 25;
public const KIND_JSON_DOTPATH = 30;
public const KIND_JSON_DOTNOTATION = 30;

public const PRIORITY_IMPORTANT = 20;
public const PRIORITY_MAIN_STREAM = 10;
Expand Down Expand Up @@ -621,7 +621,7 @@ private function simplePieFromContent(string $feedContent): SimplePie {
}

/** @return array<string,string> */
private function dotPathsForStandardJsonFeed(): array {
private function dotNotationForStandardJsonFeed(): array {
return [
'feedTitle' => 'title',
'item' => 'items',
Expand Down Expand Up @@ -662,11 +662,11 @@ public function loadJson(): ?SimplePie {
return null;
}

/** @var array<string,string> $json_dotpath */
$json_dotpath = $this->attributeArray('json_dotpath') ?? [];
$dotPaths = $this->kind() === FreshRSS_Feed::KIND_JSONFEED ? $this->dotPathsForStandardJsonFeed() : $json_dotpath;
/** @var array<string,string> $json_dotnotation */
$json_dotnotation = $this->attributeArray('json_dotnotation') ?? [];
$dotnotations = $this->kind() === FreshRSS_Feed::KIND_JSONFEED ? $this->dotNotationForStandardJsonFeed() : $json_dotnotation;

$feedContent = FreshRSS_dotNotation_Util::convertJsonToRss($jf, $feedSourceUrl, $dotPaths, $this->name());
$feedContent = FreshRSS_dotNotation_Util::convertJsonToRss($jf, $feedSourceUrl, $dotnotations, $this->name());
if ($feedContent == null) {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion app/Services/ExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class FreshRSS_Export_Service {
public const TYPE_HTML_XPATH = 'HTML+XPath';
public const TYPE_XML_XPATH = 'XML+XPath';
public const TYPE_RSS_ATOM = 'rss';
public const TYPE_JSON_DOTPATH = 'JSON+DotPath';
public const TYPE_JSON_DOTPATH = 'JSON+DotPath'; // Legacy 1.24.0-dev
public const TYPE_JSON_DOTNOTATION = 'JSON+DotNotation';
public const TYPE_JSONFEED = 'JSONFeed';

/**
Expand Down
5 changes: 3 additions & 2 deletions app/Services/ImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ private function createFeed(array $feed_elt, FreshRSS_Category $category, bool $
case strtolower(FreshRSS_Export_Service::TYPE_XML_XPATH):
$feed->_kind(FreshRSS_Feed::KIND_XML_XPATH);
break;
case strtolower(FreshRSS_Export_Service::TYPE_JSON_DOTNOTATION):
case strtolower(FreshRSS_Export_Service::TYPE_JSON_DOTPATH):
$feed->_kind(FreshRSS_Feed::KIND_JSON_DOTPATH);
$feed->_kind(FreshRSS_Feed::KIND_JSON_DOTNOTATION);
break;
case strtolower(FreshRSS_Export_Service::TYPE_JSONFEED):
$feed->_kind(FreshRSS_Feed::KIND_JSONFEED);
Expand Down Expand Up @@ -254,7 +255,7 @@ private function createFeed(array $feed_elt, FreshRSS_Category $category, bool $
$jsonSettings['itemUid'] = $feed_elt['frss:jsonItemUid'];
}
if (!empty($jsonSettings)) {
$feed->_attribute('json_dotpath', $jsonSettings);
$feed->_attribute('json_dotnotation', $jsonSettings);
}

$curl_params = [];
Expand Down
58 changes: 29 additions & 29 deletions app/Utils/dotNotationUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ private static function value($value): mixed {
*
* @param array<string> $jf json feed
* @param string $feedSourceUrl the source URL for the feed
* @param array<string,string> $dotPaths dot paths to map JSON into RSS
* @param string $defaultRssTitle Default title of the RSS feed, if not already provided in dotPath `feedTitle`
* @param array<string,string> $dotNotation dot notation to map JSON into RSS
* @param string $defaultRssTitle Default title of the RSS feed, if not already provided in dotNotation `feedTitle`
*/
public static function convertJsonToRss(array $jf, string $feedSourceUrl, array $dotPaths, string $defaultRssTitle = ''): ?string {
if (!isset($dotPaths['item']) || $dotPaths['item'] === '') {
public static function convertJsonToRss(array $jf, string $feedSourceUrl, array $dotNotation, string $defaultRssTitle = ''): ?string {
if (!isset($dotNotation['item']) || $dotNotation['item'] === '') {
return null; //no definition of item path, but we can't scrape anything without knowing this
}

Expand All @@ -112,40 +112,40 @@ public static function convertJsonToRss(array $jf, string $feedSourceUrl, array
$view->html_url = $view->rss_url;
$view->entries = [];

$view->rss_title = isset($dotPaths['feedTitle'])
? (htmlspecialchars(FreshRSS_dotNotation_Util::getString($jf, $dotPaths['feedTitle']) ?? '', ENT_COMPAT, 'UTF-8') ?: $defaultRssTitle)
$view->rss_title = isset($dotNotation['feedTitle'])
? (htmlspecialchars(FreshRSS_dotNotation_Util::getString($jf, $dotNotation['feedTitle']) ?? '', ENT_COMPAT, 'UTF-8') ?: $defaultRssTitle)
: $defaultRssTitle;

$jsonItems = FreshRSS_dotNotation_Util::get($jf, $dotPaths['item']);
$jsonItems = FreshRSS_dotNotation_Util::get($jf, $dotNotation['item']);
if (!is_array($jsonItems) || count($jsonItems) === 0) {
return null;
}

foreach ($jsonItems as $jsonItem) {
$rssItem = [];
$rssItem['link'] = isset($dotPaths['itemUri']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotPaths['itemUri']) ?? '' : '';
$rssItem['link'] = isset($dotNotation['itemUri']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotNotation['itemUri']) ?? '' : '';
if (empty($rssItem['link'])) {
continue;
}
$rssItem['title'] = isset($dotPaths['itemTitle']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotPaths['itemTitle']) ?? '' : '';
$rssItem['author'] = isset($dotPaths['itemAuthor']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotPaths['itemAuthor']) ?? '' : '';
$rssItem['timestamp'] = isset($dotPaths['itemTimestamp']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotPaths['itemTimestamp']) ?? '' : '';
$rssItem['title'] = isset($dotNotation['itemTitle']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotNotation['itemTitle']) ?? '' : '';
$rssItem['author'] = isset($dotNotation['itemAuthor']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotNotation['itemAuthor']) ?? '' : '';
$rssItem['timestamp'] = isset($dotNotation['itemTimestamp']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotNotation['itemTimestamp']) ?? '' : '';

//get simple content, but if a path for HTML content has been provided, replace the simple content with HTML content
$rssItem['content'] = isset($dotPaths['itemContent']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotPaths['itemContent']) ?? '' : '';
$rssItem['content'] = isset($dotPaths['itemContentHTML'])
? FreshRSS_dotNotation_Util::getString($jsonItem, $dotPaths['itemContentHTML']) ?? ''
$rssItem['content'] = isset($dotNotation['itemContent']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotNotation['itemContent']) ?? '' : '';
$rssItem['content'] = isset($dotNotation['itemContentHTML'])
? FreshRSS_dotNotation_Util::getString($jsonItem, $dotNotation['itemContentHTML']) ?? ''
: $rssItem['content'];

if (isset($dotPaths['itemTimeFormat']) && is_string($dotPaths['itemTimeFormat'])) {
$dateTime = DateTime::createFromFormat($dotPaths['itemTimeFormat'], $rssItem['timestamp']);
if (isset($dotNotation['itemTimeFormat']) && is_string($dotNotation['itemTimeFormat'])) {
$dateTime = DateTime::createFromFormat($dotNotation['itemTimeFormat'], $rssItem['timestamp']);
if ($dateTime != false) {
$rssItem['timestamp'] = $dateTime->format(DateTime::ATOM);
}
}

if (isset($dotPaths['itemCategories'])) {
$jsonItemCategories = FreshRSS_dotNotation_Util::get($jsonItem, $dotPaths['itemCategories']);
if (isset($dotNotation['itemCategories'])) {
$jsonItemCategories = FreshRSS_dotNotation_Util::get($jsonItem, $dotNotation['itemCategories']);
if (is_string($jsonItemCategories) && $jsonItemCategories !== '') {
$rssItem['tags'] = [$jsonItemCategories];
} elseif (is_array($jsonItemCategories) && count($jsonItemCategories) > 0) {
Expand All @@ -158,31 +158,31 @@ public static function convertJsonToRss(array $jf, string $feedSourceUrl, array
}
}

$rssItem['thumbnail'] = isset($dotPaths['itemThumbnail']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotPaths['itemThumbnail']) ?? '' : '';
$rssItem['thumbnail'] = isset($dotNotation['itemThumbnail']) ? FreshRSS_dotNotation_Util::getString($jsonItem, $dotNotation['itemThumbnail']) ?? '' : '';

//Enclosures?
if (isset($dotPaths['itemAttachment'])) {
$jsonItemAttachments = FreshRSS_dotNotation_Util::get($jsonItem, $dotPaths['itemAttachment']);
if (isset($dotNotation['itemAttachment'])) {
$jsonItemAttachments = FreshRSS_dotNotation_Util::get($jsonItem, $dotNotation['itemAttachment']);
if (is_array($jsonItemAttachments) && count($jsonItemAttachments) > 0) {
$rssItem['attachments'] = [];
foreach ($jsonItemAttachments as $attachment) {
$rssAttachment = [];
$rssAttachment['url'] = isset($dotPaths['itemAttachmentUrl'])
? FreshRSS_dotNotation_Util::getString($attachment, $dotPaths['itemAttachmentUrl'])
$rssAttachment['url'] = isset($dotNotation['itemAttachmentUrl'])
? FreshRSS_dotNotation_Util::getString($attachment, $dotNotation['itemAttachmentUrl'])
: '';
$rssAttachment['type'] = isset($dotPaths['itemAttachmentType'])
? FreshRSS_dotNotation_Util::getString($attachment, $dotPaths['itemAttachmentType'])
$rssAttachment['type'] = isset($dotNotation['itemAttachmentType'])
? FreshRSS_dotNotation_Util::getString($attachment, $dotNotation['itemAttachmentType'])
: '';
$rssAttachment['length'] = isset($dotPaths['itemAttachmentLength'])
? FreshRSS_dotNotation_Util::get($attachment, $dotPaths['itemAttachmentLength'])
$rssAttachment['length'] = isset($dotNotation['itemAttachmentLength'])
? FreshRSS_dotNotation_Util::get($attachment, $dotNotation['itemAttachmentLength'])
: '';
$rssItem['attachments'][] = $rssAttachment;
}
}
}

if (isset($dotPaths['itemUid'])) {
$rssItem['guid'] = FreshRSS_dotNotation_Util::getString($jsonItem, $dotPaths['itemUid']);
if (isset($dotNotation['itemUid'])) {
$rssItem['guid'] = FreshRSS_dotNotation_Util::getString($jsonItem, $dotNotation['itemUid']);
}

if (empty($rssItem['guid'])) {
Expand Down
4 changes: 2 additions & 2 deletions app/i18n/hu/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
'http' => 'HTTP (haladó felhasználóknak HTTPS-el)',
'none' => 'nincs (veszélyes)',
'title' => 'Hitelesítés',
'token' => 'Master authentication token', // TODO
'token_help' => 'Allows access to all RSS outputs of the user as well as refreshing feeds without authentication:', // TODO
'token' => 'Fő hitelesítési token',
'token_help' => 'Lehetővé teszi a hozzáférést a felhasználó összes RSS-kimenetéhez, valamint a hírfolyamok frissítéséhez hitelesítés nélkül:',
'type' => 'Hitelesítési módszer',
'unsafe_autologin' => 'Engedélyezze a nem biztonságos automata bejelentkezést a következő formátummal: ',
),
Expand Down
22 changes: 11 additions & 11 deletions app/i18n/hu/conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,32 +120,32 @@
'feeds' => 'Rendezés hírforrás szerint',
'order' => 'Rendezés dátum szerint',
'search' => 'Kifejezés',
'shareOpml' => 'Enable sharing by OPML of corresponding categories and feeds', // TODO
'shareRss' => 'Enable sharing by HTML &amp; RSS', // TODO
'shareOpml' => 'Engedélyezze a megfelelő kategóriák és hírcsatornák OPML-alapú megosztását',
'shareRss' => 'Engedélyezze a HTML &amp; RSS megosztást',
'state' => 'Státusz',
'tags' => 'Rendezés címke szerint',
'type' => 'Típus',
),
'get_all' => 'Minden cikk megjelenítése',
'get_all_labels' => 'Display articles with any label', // TODO
'get_all_labels' => 'Cikkek megjelenítése bármilyen címkével',
'get_category' => 'Listáz “%s” kategóriát',
'get_favorite' => 'Kedvenc cikkek megjelenítése',
'get_feed' => 'Listáz “%s” hírforrást',
'get_important' => 'Display articles from important feeds', // TODO
'get_label' => 'Display articles with “%s” label', // TODO
'help' => 'See the <a href="https://freshrss.github.io/FreshRSS/en/users/user_queries.html" target="_blank">documentation for user queries and resharing by HTML / RSS / OPML</a>.', // TODO
'get_important' => 'Cikkek megjelenítése fontos hírforrásokból',
'get_label' => ' “%s” címkével rendelkező cikkek megjelenítése',
'help' => 'Lásd a <a href="https://freshrss.github.io/FreshRSS/en/users/user_queries.html" target="_blank"> dokumentációt a felhasználói lekérdezések és HTML/RSS/OPML megosztás témákban</a>.',
'name' => 'Név',
'no_filter' => 'Nincs szűrés',
'number' => 'Lekérdezés %d',
'order_asc' => 'Régebbi cikkek előre',
'order_desc' => 'Újabb cikkek előre',
'search' => 'Keresse a “%s”',
'share' => array(
'_' => 'Share this query by link', // 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
'rss' => 'Shareable link to the RSS feed', // TODO
'_' => 'Lekérdezés megosztása linkkel',
'help' => 'Ezt a linket küldd el hogy megoszd a lekérdezést',
'html' => 'Megosztható link a HTML oldalhoz',
'opml' => 'Megosztható link az OPML hírforrás listához',
'rss' => 'Megosztható link az RSS hírforráshoz',
),
'state_0' => 'Minden cikk',
'state_1' => 'Olvasott cikkek',
Expand Down
4 changes: 2 additions & 2 deletions app/i18n/hu/feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@
),
'tag' => array(
'created' => 'Címke “%s” létrehozva.',
'error' => 'Label could not be updated!', // TODO
'error' => 'Nem sikerült a címke frissítése!',
'name_exists' => 'Címke név már létezik.',
'renamed' => 'Címke “%s” átnevezve “%s”.',
'updated' => 'Label has been updated.', // TODO
'updated' => 'Címke frissítése megtörtént.',
),
'update' => array(
'can_apply' => 'Egy FreshRSS frissítés elérhető : <strong>Verzió %s</strong>.',
Expand Down
Loading

0 comments on commit bc4c996

Please sign in to comment.