Improved links testing and displaying
This commit is contained in:
parent
b8d39081c6
commit
78fdaa6485
|
@ -29,7 +29,7 @@ class Link
|
||||||
|
|
||||||
private string $title;
|
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
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
if ($this->bundle !== null) {
|
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())) {
|
if (!empty($existingData['checked']) && Carbon::parse($existingData['checked'])->gt(now()->subMonth())) {
|
||||||
return $existingData;
|
return $existingData;
|
||||||
|
@ -191,7 +191,7 @@ public function toHtmlElement(): HtmlElement
|
||||||
'rel' => $data['rel'],
|
'rel' => $data['rel'],
|
||||||
'title' => $data['title'],
|
'title' => $data['title'],
|
||||||
'class' => $data['classes'],
|
'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.
|
* @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.
|
* @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)
|
||||||
{
|
{
|
||||||
return data_get($this->content, $key, $default);
|
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\AttachmentsManager;
|
||||||
use App\Classes\Bundle;
|
use App\Classes\Bundle;
|
||||||
|
use App\Classes\Link;
|
||||||
use App\Services\BundleRenderers\Contracts\RendersBundle;
|
use App\Services\BundleRenderers\Contracts\RendersBundle;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
@ -93,6 +94,15 @@ protected function shareCommonDataWithView(): void
|
||||||
data_set($this->viewData, 'siteTitle', $this->bundle->getSiteTitle());
|
data_set($this->viewData, 'siteTitle', $this->bundle->getSiteTitle());
|
||||||
data_set($this->viewData, 'articleTitle', $this->bundle->getArticleTitle());
|
data_set($this->viewData, 'articleTitle', $this->bundle->getArticleTitle());
|
||||||
data_set($this->viewData, 'bundle', $this->bundle);
|
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()
|
protected function handlePagination()
|
||||||
|
|
|
@ -13,6 +13,7 @@ .article-list {
|
||||||
color: #6c7a89;
|
color: #6c7a89;
|
||||||
box-shadow: 0 1px 1rem #000;
|
box-shadow: 0 1px 1rem #000;
|
||||||
background: #01010c radial-gradient(at bottom center, #00101f, #000614, #01010c) no-repeat;
|
background: #01010c radial-gradient(at bottom center, #00101f, #000614, #01010c) no-repeat;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
.article-card {
|
.article-card {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
|
|
|
@ -3,14 +3,21 @@
|
||||||
@if (!empty($cover))
|
@if (!empty($cover))
|
||||||
{!! $cover !!}
|
{!! $cover !!}
|
||||||
@endif
|
@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>
|
<h2>{!! $bundle->getArticleTitle() !!}</h2>
|
||||||
<section class="article-card-body">
|
<section class="article-card-body">
|
||||||
@if (!empty($date))
|
@if (!empty($date))
|
||||||
<p><time datetime="{{ $date->toIso8601String() }}">{{ $date->isoFormat('LL') }}</time></p>
|
<p><time datetime="{{ $date->toIso8601String() }}">{{ $date->isoFormat('LL') }}</time></p>
|
||||||
@endif
|
@endif
|
||||||
@if (!empty($section))
|
@if (!empty($section))
|
||||||
<p>{!! $section->getArticleTitle() !!}</p>
|
<p>{!! $section->getArticleTitle() !!}</p>
|
||||||
@endif
|
@endif
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -6,6 +6,15 @@
|
||||||
@if (empty($bundle->metadata()->get('hide_title')))
|
@if (empty($bundle->metadata()->get('hide_title')))
|
||||||
<h1>{{ $articleTitle }}</h1>
|
<h1>{{ $articleTitle }}</h1>
|
||||||
@endif
|
@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))
|
@if (!empty($date))
|
||||||
<time datetime="{{ $date->toIso8601String() }}">{{ $date->isoFormat('LL') }}</time>
|
<time datetime="{{ $date->toIso8601String() }}">{{ $date->isoFormat('LL') }}</time>
|
||||||
@endif
|
@endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user