From 2e1f496eea060b5f2ab38684671680862b719744 Mon Sep 17 00:00:00 2001 From: NH Gooi Date: Tue, 18 Mar 2025 21:51:18 +0100 Subject: [PATCH 1/2] Render articles directly from block source instead of prerendered text --- app/Http/Controllers/NewsController.php | 16 +++++++++------- resources/views/newsitem.blade.php | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/NewsController.php b/app/Http/Controllers/NewsController.php index 247d5720..fab80ecc 100644 --- a/app/Http/Controllers/NewsController.php +++ b/app/Http/Controllers/NewsController.php @@ -22,22 +22,24 @@ class NewsController extends Controller switch ($apiResult->version) { case 1: - if (!$newsItem->content) return redirect('//nhnieuws.nl/gooi'); - return view('newsitem', ['news' => $newsItem, 'metadata' => $newsItem->metadata]); - break; + if (!$newsItem->content) return redirect('//nhnieuws.nl/gooi'); - case 2: + case 2: + if(isset($apiResult->source->article)) { $source = $apiResult->source->article; $newsItem->published = self::TimestampToDateTime($source->created); $newsItem->edited = self::TimestampToDateTime($source->updated); $newsItem->author = $source->author; $newsItem->images = null; // Images will be embedded $newsItem->video = null; // Videos will be embedded - $newsItem->content = $source->blocks; + $newsItem->content = $source->blocks; + } elseif(isset($apiResult->source->blocks)) { + $newsItem->content = $apiResult->source->blocks; + } + - - return view('newsitem', array_merge($this->getSidebareData(), ['news' => $newsItem, 'metadata' => $newsItem->metadata, 'searchURL' => 'nieuws/zoeken'])); + return view('newsitem', array_merge($this->getSidebareData(), ['type' => $apiResult->type, 'news' => $newsItem, 'metadata' => $newsItem->metadata, 'searchURL' => 'nieuws/zoeken'])); } } diff --git a/resources/views/newsitem.blade.php b/resources/views/newsitem.blade.php index 6b2b81a2..5302ca44 100644 --- a/resources/views/newsitem.blade.php +++ b/resources/views/newsitem.blade.php @@ -87,8 +87,10 @@ @endif @endif - @if(is_array($news->content)) - @include('partial/nh_story', ['content' => $news->content]) + @if($type == "nhnieuws") + @include('partial/nh_story', ['content' => $news->content]) + @elseif($type == "artikel") + @include('partial/block_story', ['content' => $news->content]) @else

{!!$news->content!!}

From c7243f31a0914d61b6abc1a125ec4ccd0be75ccb Mon Sep 17 00:00:00 2001 From: NH Gooi Date: Tue, 18 Mar 2025 21:53:01 +0100 Subject: [PATCH 2/2] Render articles directly from block source instead of prerendered text --- resources/views/partial/block_story.blade.php | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 resources/views/partial/block_story.blade.php diff --git a/resources/views/partial/block_story.blade.php b/resources/views/partial/block_story.blade.php new file mode 100644 index 00000000..b79c6aa0 --- /dev/null +++ b/resources/views/partial/block_story.blade.php @@ -0,0 +1,161 @@ +@foreach($content as $block) +@if($block->type == "headerRichA") +@php($block->data->image->url = isset($block->data->image->crops) +? $block->data->image->crops->{'16:9'}->{'1600'} +: $block->data->image->crop) + + {{$block->data->image->title}} + +
+ {{$block->data->image->title}} + @if($block->data->image->author) + {{$block->data->image->author}} + @endif +
+@elseif($block->type == "paragraph") +
{!!$block->data->text!!}
+@elseif($block->type == "intro") +

{!!strip_tags($block->data->text)!!}

+@elseif($block->type == "info") +@if(strpos($block->data->text, "Meer nieuws uit 't Gooi?") === false) +
{!!($block->data->text)!!}
+@endif +@elseif($block->type == "quote") +
+ {!!$block->data->text!!} +
{{$block->data->caption}}
+
+@elseif($block->type == "image") +data->image->imageWide)) + $image = $block->data->image->imageWide; + else if(isset($block->data->image->crop)) + $image = $block->data->image->crop; + else if(isset($block->data->image->crops) && isset($block->data->image->crops->{'16:9'})) + foreach($block->data->image->crops->{'16:9'} as $image) break; + else if(isset($block->data->image->imageHigh)) + $image = $block->data->image->imageHigh; + else $image = null; + ?> +@if($image) + + {{$block->data->image->title}} + +
+ data->image->caption) && $block->data->image->caption) { + $sentence[] = '' . $block->data->image->caption . ''; + } elseif (isset($block->data->image->title) && $block->data->image->title) { + $sentence[] = '' . $block->data->image->title . ''; + } + if (isset($block->data->image->author) && $block->data->image->author) { + $sentence[] = '' . $block->data->image->author . ''; + } + $sentence = join('|', $sentence); + ?> + {!!$sentence!!} +
+@endif +@elseif($block->type == "video" || $block->type == "headerVideo") +@include('widgets/mediaplayer') +data->video->images[0]->imageMedia) && $block->data->video->images[0]->imageMedia) { + $attr = ' poster="' . $block->data->video->images[0]->imageMedia . '"'; + } + ?> + +
+ {{$block->data->video->author}} +
+@elseif($block->type == "carousel") + +@elseif($block->type == "oembed") +
{!!$block->data->html!!}
+@elseif($block->type == "podcast" && $block->data->id == $news->podcast?->id) +@include('widgets/podcastplayer', ['podcast' => $news->podcast]) +podcast = null; // Avoid adding the player again ?> +@elseif($block->type == 'article' && count($block->data->articles) && $block->data->articles[0]->published) +
+

{{ $block->data->title }}

+
+
    + @foreach($block->data->articles as $article) + published)) continue; + $article->published = new \DateTime($article->published); ?> +
  • +
    + @if($article->image) +
    + + {{ $article->image_title }} + +
    + @endif +
    +

    {!! $article->title !!}

    + +
    +
    +
  • + @endforeach +
+
+
+@elseif($block->type == 'iframe') + + +@endif +@endforeach