Merge branch 'develop' into fix-code-style-for-pr-14688

This commit is contained in:
Art4 2025-01-22 09:07:59 +00:00
commit 6309d4c43d
3 changed files with 24 additions and 20 deletions

View file

@ -354,6 +354,10 @@ class Processor
'source' => json_encode($data), 'source' => json_encode($data),
]; ];
if ((time() - strtotime($item['created'])) > 600) {
$item['received'] = $item['created'];
}
if ($this->postExists($item['uri'], [$uid])) { if ($this->postExists($item['uri'], [$uid])) {
$this->logger->info('Post already exists for user', ['uri' => $item['uri'], 'uid' => $uid]); $this->logger->info('Post already exists for user', ['uri' => $item['uri'], 'uid' => $uid]);
return []; return [];

View file

@ -115,11 +115,7 @@ class ParseUrl
$urlHash = hash('sha256', $url); $urlHash = hash('sha256', $url);
$parsed_url = DBA::selectFirst( $parsed_url = DBA::selectFirst('parsed_url', ['content'], ['url_hash' => $urlHash, 'oembed' => false]);
'parsed_url',
['content'],
['url_hash' => $urlHash, 'oembed' => false]
);
if (!empty($parsed_url['content'])) { if (!empty($parsed_url['content'])) {
$data = unserialize($parsed_url['content']); $data = unserialize($parsed_url['content']);
return $data; return $data;
@ -247,11 +243,13 @@ class ParseUrl
if ($cacheControlHeader = $curlResult->getHeader('Cache-Control')[0] ?? '') { if ($cacheControlHeader = $curlResult->getHeader('Cache-Control')[0] ?? '') {
if (preg_match('/max-age=([0-9]+)/i', $cacheControlHeader, $matches)) { if (preg_match('/max-age=([0-9]+)/i', $cacheControlHeader, $matches)) {
$maxAge = max(86400, (int)array_pop($matches)); $maxAge = max(86400, (int)array_pop($matches));
$siteinfo['expires'] = DateTimeFormat::utc("now + $maxAge seconds"); $siteinfo['expires'] = DateTimeFormat::utc("now + $maxAge seconds");
} }
} }
$body = $curlResult->getBodyString(); $body = $curlResult->getBodyString();
$siteinfo['size'] = mb_strlen($body); $siteinfo['size'] = mb_strlen($body);
$charset = ''; $charset = '';
@ -309,9 +307,8 @@ class ParseUrl
if (@$meta_tag['http-equiv'] == 'refresh') { if (@$meta_tag['http-equiv'] == 'refresh') {
$path = $meta_tag['content']; $path = $meta_tag['content'];
$pathinfo = explode(';', $path);
$content = ''; $content = '';
foreach ($pathinfo as $value) { foreach (explode(';', $path) as $value) {
if (substr(strtolower($value), 0, 4) == 'url=') { if (substr(strtolower($value), 0, 4) == 'url=') {
$content = substr($value, 4); $content = substr($value, 4);
} }
@ -457,7 +454,8 @@ class ParseUrl
$list = $xpath->query("//script[@type='application/ld+json']"); $list = $xpath->query("//script[@type='application/ld+json']");
foreach ($list as $node) { foreach ($list as $node) {
if (!empty($node->nodeValue)) { if (!empty($node->nodeValue)) {
if ($jsonld = json_decode($node->nodeValue, true)) { $jsonld = json_decode($node->nodeValue, true);
if (is_array($jsonld)) {
$siteinfo = self::parseParts($siteinfo, $jsonld); $siteinfo = self::parseParts($siteinfo, $jsonld);
} }
} }
@ -490,6 +488,7 @@ class ParseUrl
if (!empty($siteinfo['text']) && mb_strlen($siteinfo['text']) > self::MAX_DESC_COUNT) { if (!empty($siteinfo['text']) && mb_strlen($siteinfo['text']) > self::MAX_DESC_COUNT) {
$siteinfo['text'] = mb_substr($siteinfo['text'], 0, self::MAX_DESC_COUNT) . '…'; $siteinfo['text'] = mb_substr($siteinfo['text'], 0, self::MAX_DESC_COUNT) . '…';
$pos = mb_strrpos($siteinfo['text'], '.'); $pos = mb_strrpos($siteinfo['text'], '.');
if ($pos > self::MIN_DESC_COUNT) { if ($pos > self::MIN_DESC_COUNT) {
$siteinfo['text'] = mb_substr($siteinfo['text'], 0, $pos + 1); $siteinfo['text'] = mb_substr($siteinfo['text'], 0, $pos + 1);
@ -524,6 +523,7 @@ class ParseUrl
*/ */
if (!empty($image['url'])) { if (!empty($image['url'])) {
$image['url'] = self::completeUrl($image['url'], $page_url); $image['url'] = self::completeUrl($image['url'], $page_url);
$photodata = Images::getInfoFromURLCached($image['url']); $photodata = Images::getInfoFromURLCached($image['url']);
if (($photodata) && ($photodata[0] > 50) && ($photodata[1] > 50)) { if (($photodata) && ($photodata[0] > 50) && ($photodata[1] > 50)) {
$image['src'] = $image['url']; $image['src'] = $image['url'];
@ -554,6 +554,7 @@ class ParseUrl
foreach (['embed', 'content', 'url'] as $field) { foreach (['embed', 'content', 'url'] as $field) {
if (!empty($media[$field])) { if (!empty($media[$field])) {
$media[$field] = self::completeUrl($media[$field], $page_url); $media[$field] = self::completeUrl($media[$field], $page_url);
$type = self::getContentType($media[$field]); $type = self::getContentType($media[$field]);
if (($type[0] ?? '') == 'text') { if (($type[0] ?? '') == 'text') {
if ($field == 'embed') { if ($field == 'embed') {
@ -956,8 +957,7 @@ class ParseUrl
$content = JsonLD::fetchElement($jsonld, 'keywords'); $content = JsonLD::fetchElement($jsonld, 'keywords');
if (!empty($content)) { if (!empty($content)) {
$siteinfo['keywords'] = []; $siteinfo['keywords'] = [];
$keywords = explode(',', $content); foreach (explode(',', $content) as $keyword) {
foreach ($keywords as $keyword) {
$siteinfo['keywords'][] = trim($keyword); $siteinfo['keywords'][] = trim($keyword);
} }
} }

View file

@ -40,7 +40,7 @@
<ul role="menu"> <ul role="menu">
{{foreach $folders as $folder}} {{foreach $folders as $folder}}
<li role="presentation"> <li role="presentation">
<button type="button" data-folder="{{$folder}}" role="menuitem">{{$folder}}</button> <button class="btn btn-default" type="button" data-folder="{{$folder}}" role="menuitem">{{$folder}}</button>
</li> </li>
{{/foreach}} {{/foreach}}
</ul> </ul>