Improved links testing and displaying
This commit is contained in:
parent
b8d39081c6
commit
78fdaa6485
|
@ -29,7 +29,7 @@ class Link
|
|||
|
||||
private string $title;
|
||||
|
||||
public function __construct(protected string $url, protected ?string $innerHtml, protected ?Bundle $bundle = null)
|
||||
public function __construct(protected string $url, protected ?string $innerHtml = null, protected ?Bundle $bundle = null)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public function title(): string
|
|||
public function toArray(): array
|
||||
{
|
||||
if ($this->bundle !== null) {
|
||||
$existingData = $this->bundle->metadata('links')->get($this->url, []);
|
||||
$existingData = $this->bundle->metadata('links')->get($this->url, [], false);
|
||||
|
||||
if (!empty($existingData['checked']) && Carbon::parse($existingData['checked'])->gt(now()->subMonth())) {
|
||||
return $existingData;
|
||||
|
@ -191,7 +191,7 @@ public function toHtmlElement(): HtmlElement
|
|||
'rel' => $data['rel'],
|
||||
'title' => $data['title'],
|
||||
'class' => $data['classes'],
|
||||
], $this->innerHtml);
|
||||
], $this->innerHtml ?? $this->url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,9 +117,13 @@ public function merge(array $array)
|
|||
* @param mixed $default The default value to return if the key does not exist.
|
||||
* @return mixed The value of the specified key, or the default value.
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
public function get($key, $default = null, bool $respectDots = true)
|
||||
{
|
||||
if ($respectDots) {
|
||||
return data_get($this->content, $key, $default);
|
||||
} else {
|
||||
return $this->content[$key] ?? $default;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use App\Classes\AttachmentsManager;
|
||||
use App\Classes\Bundle;
|
||||
use App\Classes\Link;
|
||||
use App\Services\BundleRenderers\Contracts\RendersBundle;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
|
@ -93,6 +94,15 @@ protected function shareCommonDataWithView(): void
|
|||
data_set($this->viewData, 'siteTitle', $this->bundle->getSiteTitle());
|
||||
data_set($this->viewData, 'articleTitle', $this->bundle->getArticleTitle());
|
||||
data_set($this->viewData, 'bundle', $this->bundle);
|
||||
|
||||
if (!empty($this->bundle->metadata('metadata')->get('links.Page originale'))) {
|
||||
$url = $this->bundle->metadata('metadata')->get('links.Page originale')[0];
|
||||
$link = (new Link($url, null, $this->bundle))->toArray();
|
||||
|
||||
$link['url'] = $url;
|
||||
|
||||
data_set($this->viewData, 'mainLink', $link);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handlePagination()
|
||||
|
|
|
@ -13,6 +13,7 @@ .article-list {
|
|||
color: #6c7a89;
|
||||
box-shadow: 0 1px 1rem #000;
|
||||
background: #01010c radial-gradient(at bottom center, #00101f, #000614, #01010c) no-repeat;
|
||||
position: relative;
|
||||
|
||||
.article-card {
|
||||
font-size: 1rem;
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
@if (!empty($cover))
|
||||
{!! $cover !!}
|
||||
@endif
|
||||
|
||||
@if(!empty($mainLink) && $mainLink['isDead'])
|
||||
<div class="ribbon dead" title="{{ $mainLink['reason'] }}">
|
||||
Lien mort depuis le {{ Carbon\Carbon::parse($mainLink['checked'])->format('d/m/Y') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<h2>{!! $bundle->getArticleTitle() !!}</h2>
|
||||
<section class="article-card-body">
|
||||
@if (!empty($date))
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
@if (empty($bundle->metadata()->get('hide_title')))
|
||||
<h1>{{ $articleTitle }}</h1>
|
||||
@endif
|
||||
|
||||
@if(!empty($mainLink))
|
||||
<p><a
|
||||
href="{!! $mainLink['finalUrl'] !!}"
|
||||
rel="{!! $mainLink['rel'] !!}"
|
||||
class="{!! $mainLink['classes'] !!}"
|
||||
title="{!! $mainLink['title'] !!}">{!! $mainLink['url'] !!}</a></p>
|
||||
@endif
|
||||
|
||||
@if (!empty($date))
|
||||
<time datetime="{{ $date->toIso8601String() }}">{{ $date->isoFormat('LL') }}</time>
|
||||
@endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user