Liveblog - start work

This commit is contained in:
NH Gooi
2026-02-08 20:43:55 +01:00
parent 733e18531f
commit b78379f268
7 changed files with 375 additions and 353 deletions

View File

@@ -16,6 +16,9 @@ class HomeController extends Controller
$news[] = new \Model\NewsItem($newsItem); $news[] = new \Model\NewsItem($newsItem);
} }
$apiResult = $this->API('nieuws/liveblogs');
$liveblogs = $apiResult->liveblogs;
$populair = []; $populair = [];
$apiResult = $this->API('nieuws/populair?pagina=' . (int) max(1, $page) . '&aantal=5'); $apiResult = $this->API('nieuws/populair?pagina=' . (int) max(1, $page) . '&aantal=5');
foreach ($apiResult->news as $newsItem) { foreach ($apiResult->news as $newsItem) {
@@ -25,6 +28,6 @@ class HomeController extends Controller
$apiResult = $this->API('podcast/overzicht?aantal=15'); $apiResult = $this->API('podcast/overzicht?aantal=15');
$index = array_rand($apiResult->podcasts); $index = array_rand($apiResult->podcasts);
$podcast = new \Model\Podcast($apiResult->podcasts[$index]); $podcast = new \Model\Podcast($apiResult->podcasts[$index]);
return view('home', ['populair' => $populair, 'podcast' => $podcast, 'title' => 'Home', 'news' => $news, 'searchURL' => 'nieuws/zoeken']); return view('home', ['populair' => $populair, 'podcast' => $podcast, 'title' => 'Home', 'news' => $news, 'liveblogs' => $liveblogs, 'searchURL' => 'nieuws/zoeken']);
} }
} }

View File

@@ -26,7 +26,8 @@ class NewsController extends Controller
switch ($apiResult->version) { switch ($apiResult->version) {
case 1: case 1:
if (!$newsItem->content) return redirect('//nhnieuws.nl/gooi'); if (!$newsItem->content)
return redirect('//nhnieuws.nl/gooi');
case 2: case 2:
if (isset($apiResult->source->article)) { if (isset($apiResult->source->article)) {
@@ -109,30 +110,19 @@ class NewsController extends Controller
return abort(404); return abort(404);
} }
public function blog(Request $request, $id) public function liveblog(Request $request, $id)
{ {
parent::registerView($request, 'blog', $id); parent::registerView($request, 'blog', $id);
$page = (int)$request->get('pagina', 1); $blog = $this->API('nieuws/liveblog/' . (int) $id);
$hasNext = true; foreach( $blog->artikelen as &$item ) {
while ($page > 0) { $item = new \Model\NewsItem( $item );
$apiResult = $this->API('blog/overzicht/' . (int)$id . '?pagina=' . (int)max(1, $page)); }
if (count($blog->artikelen)) {
$blog = new \Model\Blog($apiResult->blog); return view('blog', ['blog' => $blog]);
$items = [];
foreach ($apiResult->items as $blogItem) {
$items[] = new \Model\NewsItem($blogItem);
} }
if (count($items) || ($page == 1)) { return abort();
return view('blog', ['blog' => $blog, 'pagina' => $page, 'items' => $items, 'hasNext' => $hasNext && count($items) == 15]);
}
$hasNext = false;
--$page;
}
return abort(404);
} }
private function listNews(Request $request, $url, $title = null, $id = 'items', $total = null) private function listNews(Request $request, $url, $title = null, $id = 'items', $total = null)
@@ -154,8 +144,10 @@ class NewsController extends Controller
if ($title == null) { if ($title == null) {
$total = 5; $total = 5;
} }
$apiResult = $this->API('nieuws/populair?pagina=' . (int)max(1, $apiResult = $this->API('nieuws/populair?pagina=' . (int) max(
$page) . ($total ? '&aantal=' . $total : '')); 1,
$page
) . ($total ? '&aantal=' . $total : ''));
foreach ($apiResult->news as $newsItem) { foreach ($apiResult->news as $newsItem) {
$populair[] = new \Model\NewsItem($newsItem); $populair[] = new \Model\NewsItem($newsItem);
} }

View File

@@ -24,7 +24,7 @@ class NewsItem extends Model {
public $podcast; public $podcast;
public $images; public $images;
public $video; public $video;
public $type;
public $url; public $url;
public $metadata; public $metadata;

View File

@@ -1,52 +1,58 @@
@extends('layouts/sidebar') @extends('layouts/sidebar')
@section('title') @section('title')
@if($blog->title) {{$blog->title}} | Live blog @endif @if($blog->titel) {{$blog->titel}} | Live blog @endif
@endsection @endsection
@section('controls') @section('page_class')news_post post_container @endsection
{{-- @section('controls')
<p> <p>
<a href="{{Request::url()}}" class="action_button"><span class="fa fa-undo" class="action_button"></span><span>Verversen (nieuwste)</span></a> <a href="{{Request::url()}}" class="action_button"><span class="fa fa-undo"
class="action_button"></span><span>Verversen (nieuwste)</span></a>
@if($pagina > 1) @if($pagina > 1)
<a href="{{Request::url()}}?pagina={{$pagina - 1}}" class="action_button"><span class="fa fa-arrow-left"></span><span>Terug (nieuwer)</span></a> <a href="{{Request::url()}}?pagina={{$pagina - 1}}" class="action_button"><span
class="fa fa-arrow-left"></span><span>Terug (nieuwer)</span></a>
@else @else
<a href="#" class="action_button disabled"><span class="fa fa-arrow-left"></span><span>Terug (nieuwere berichten)</span></a> <a href="#" class="action_button disabled"><span class="fa fa-arrow-left"></span><span>Terug (nieuwere
berichten)</span></a>
@endif @endif
@if($hasNext) @if($hasNext)
<a href="{{Request::url()}}?pagina={{$pagina + 1}}" class="action_button"><span class="fa fa-arrow-right"></span><span>Verder (ouder)</span></a> <a href="{{Request::url()}}?pagina={{$pagina + 1}}" class="action_button"><span
class="fa fa-arrow-right"></span><span>Verder (ouder)</span></a>
@else @else
<a href="#" class="action_button disabled"><span class="fa fa-arrow-right"></span><span>Verder (ouder)</span></a> <a href="#" class="action_button disabled"><span class="fa fa-arrow-right"></span><span>Verder (ouder)</span></a>
@endif @endif
</p> </p>
@endsection @endsection --}}
@section('content') @section('content')
<h3 class="excerpt"> <h3 class="excerpt">
{!!$blog->description!!} @if($blog->is_actief)
<span style="font-size: 75%; margin: 5px; text-align: center"> <span style="font-family: sans-serif; padding: 3px; color: white; background-color: #BD0013; border-radius: 5px;"
@if($blog->is_active) titel="Dit blog wordt momenteel actief bijgewerkt.">
<span style="padding: 3px; color: white; background-color: #BD0013; border-radius: 5px;" title="Dit blog wordt momenteel actief bijgewerkt.">
Nu live! Nu live!
</span> </span>
@else @else
<span style="padding: 3px; background-color: #BDBDBD; border-radius: 5px;" title="Dit blog is gesloten en wordt hier getoond als archief."> <span style="font-family: sans-serif; padding: 3px; background-color: #BDBDBD; border-radius: 5px;"
titel="Dit blog is gesloten en wordt hier getoond als archief.">
Archief Archief
</span> </span>
@endif @endif
</span> </span>
</h3> </h3>
@yield('controls') {{-- @yield('controls') --}}
<div id="items"> <div id="items">
@include('partial/blogitems', ['items' => $items]) @include('partial/blogitems', ['items' => $blog->artikelen])
</div> </div>
@yield('controls') {{-- @yield('controls')
<p class="center">(Pagina {{$pagina}})</p> <p class="center">(Pagina {{$pagina}})</p> --}}
@endsection @endsection

View File

@@ -6,6 +6,19 @@
@section('content') @section('content')
<div class="clearfix"> <div class="clearfix">
{{-- Liveblogs --}}
@if(count($liveblogs))
<div class="box full-width">
@foreach($liveblogs as $liveblog)
<a href="/nieuws/liveblog/{{ $liveblog->id }}/{{ $liveblog->slug }}" class="liveblog"
title="{{$liveblog->titel}}">
<span class="bi bi-blog"></span>
<b>Liveblog: {{$liveblog->titel}}</b>
</a>
@endforeach
</div>
@endif
<div class="blog_grid" data-snapto="{}"> <div class="blog_grid" data-snapto="{}">
{{-- Desktop --}} {{-- Desktop --}}
<div class="grid_view"> <div class="grid_view">
@@ -19,21 +32,19 @@
@elseif($item->images && count($item->images) > 1) @elseif($item->images && count($item->images) > 1)
<span class="icon gallery"></span> <span class="icon gallery"></span>
@endif @endif
<img src='{{$item->images && count($item->images) ? $imgBase . $item->images[0]->url : '/images/noimage.png'}}' <img src='{{$item->images && count($item->images) ? $imgBase . $item->images[0]->url : '
alt='img'> /images/noimage.png'}}' alt='img'>
</a> </a>
<div class="slider_content_box"> <div class="slider_content_box">
<ul class="post_details simple"> <ul class="post_details simple">
@foreach($item->tags as $tag) @foreach($item->tags as $tag)
<li class="category"> <li class="category">
<a title="{{$tag->titel}}" <a title="{{$tag->titel}}" href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
class="over_image">{{$tag->titel}}</a> class="over_image">{{$tag->titel}}</a>
</li> </li>
@endforeach @endforeach
</ul> </ul>
<h2><a href="{{url($item->url)}}" <h2><a href="{{url($item->url)}}" title="{{$item->title}}">{!!$item->title!!}</a></h2>
title="{{$item->title}}">{!!$item->title!!}</a></h2>
<?php <?php
$time = Formatter::relativeDate($item->published) . ' om ' . $item->published->format('H:i'); $time = Formatter::relativeDate($item->published) . ' om ' . $item->published->format('H:i');
if ($item->edited && ($item->edited->format('d m H i') != $item->published->format('d m H i'))) { if ($item->edited && ($item->edited->format('d m H i') != $item->published->format('d m H i'))) {
@@ -56,21 +67,19 @@
@elseif($item->images && count($item->images) > 1) @elseif($item->images && count($item->images) > 1)
<span class="icon gallery"></span> <span class="icon gallery"></span>
@endif @endif
<img src='{{$item->images && count($item->images) ? $imgBase . $item->images[0]->url : '/images/noimage.png'}}' <img src='{{$item->images && count($item->images) ? $imgBase . $item->images[0]->url : '
alt='img'> /images/noimage.png'}}' alt='img'>
</a> </a>
<div class="slider_content_box"> <div class="slider_content_box">
<ul class="post_details simple"> <ul class="post_details simple">
@foreach($item->tags as $tag) @foreach($item->tags as $tag)
<li class="category"> <li class="category">
<a title="{{$tag->titel}}" <a title="{{$tag->titel}}" href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
class="over_image">{{$tag->titel}}</a> class="over_image">{{$tag->titel}}</a>
</li> </li>
@endforeach @endforeach
</ul> </ul>
<h2><a href="{{url($item->url)}}" <h2><a href="{{url($item->url)}}" title="{{$item->title}}">{!!$item->title!!}</a></h2>
title="{{$item->title}}">{!!$item->title!!}</a></h2>
<?php <?php
$time = Formatter::relativeDate($item->published) . ' om ' . $item->published->format('H:i'); $time = Formatter::relativeDate($item->published) . ' om ' . $item->published->format('H:i');
if ($item->edited && ($item->edited->format('d m H i') != $item->published->format('d m H i'))) { if ($item->edited && ($item->edited->format('d m H i') != $item->published->format('d m H i'))) {
@@ -89,23 +98,22 @@
<div class="col-8 col-md-6"> <div class="col-8 col-md-6">
<div class="row"> <div class="row">
@php(prev($news)) @php(prev($news))
@for($i = 0; ($i < 5) && ($item = next($news)); ++$i) @for($i = 0; ($i < 5) && ($item=next($news)); ++$i) <div
<div class="post small col-6{{$i == 0 ? ' d-none d-md-block' : ''}}{{$i == 4 ? ' d-block d-md-none' : ''}}"> class="post small col-6{{$i == 0 ? ' d-none d-md-block' : ''}}{{$i == 4 ? ' d-block d-md-none' : ''}}">
<a href="{{url($item->url)}}" title="{{$item->title}}"> <a href="{{url($item->url)}}" title="{{$item->title}}">
@if($item->video) @if($item->video)
<span class="icon video"></span> <span class="icon video"></span>
@elseif($item->images && count($item->images) > 1) @elseif($item->images && count($item->images) > 1)
<span class="icon gallery"></span> <span class="icon gallery"></span>
@endif @endif
<img src='{{$item->images && count($item->images) ? $imgBase . $item->images[0]->url : '/images/noimage.png'}}' <img src='{{$item->images && count($item->images) ? $imgBase . $item->images[0]->url : '
alt='img'> /images/noimage.png'}}' alt='img'>
</a> </a>
<div class="slider_content_box"> <div class="slider_content_box">
<ul class="post_details simple"> <ul class="post_details simple">
@foreach($item->tags as $tag) @foreach($item->tags as $tag)
<li class="category"> <li class="category">
<a title="{{$tag->titel}}" <a title="{{$tag->titel}}" href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
class="over_image">{{$tag->titel}}</a> class="over_image">{{$tag->titel}}</a>
</li> </li>
@endforeach @endforeach
@@ -146,7 +154,8 @@
<div class="col-md-6 col-12"> <div class="col-md-6 col-12">
<h4 class="box_header"><span>Meer nieuws</span></h4> <h4 class="box_header"><span>Meer nieuws</span></h4>
<div class="box full-width"> <div class="box full-width">
@include('partial/newslist_small', ['id' => 'items-more-news', 'news' => array_slice($news, 5, 5)]) @include('partial/newslist_small', ['id' => 'items-more-news', 'news' => array_slice($news, 5,
5)])
</div> </div>
</div> </div>
@@ -172,7 +181,8 @@
<div class="row"> <div class="row">
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<a href="{{$url}}" title="{{$podcast->title}}"> <a href="{{$url}}" title="{{$podcast->title}}">
<img src="{{($hasImage = $podcast->image && $podcast->image->url) ? $imgBase . $podcast->image->url : '/images/noimage.png'}}"/> <img
src="{{($hasImage = $podcast->image && $podcast->image->url) ? $imgBase . $podcast->image->url : '/images/noimage.png'}}" />
<div class="sentence"> <div class="sentence">
<?php <?php
$sentence = []; $sentence = [];
@@ -192,12 +202,11 @@
</a> </a>
</div> </div>
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<h2 class="post_title"><a href="{{$url}}" <h2 class="post_title"><a href="{{$url}}" title="{{$podcast->title}}">{!!$podcast->title!!}</a>
title="{{$podcast->title}}">{!!$podcast->title!!}</a></h2> </h2>
<div class="sub_title"> <div class="sub_title">
@if ($podcast->program) @if ($podcast->program)
<a class="program_name" <a class="program_name" href="{{ route('programma') . $podcast->program->url }}"
href="{{ route('programma') . $podcast->program->url }}"
title="{{$podcast->program->name}}">{{$podcast->program->name}}</a> title="{{$podcast->program->name}}">{{$podcast->program->name}}</a>
@endif @endif
<span class="post_date" title="{{Formatter::relativeDate($podcast->created)}}"> <span class="post_date" title="{{Formatter::relativeDate($podcast->created)}}">
@@ -224,4 +233,3 @@
</div> </div>
</div> </div>
@endsection @endsection

View File

@@ -1,89 +1,101 @@
@foreach($items as $item) @foreach($items as $news)
<div class="row"> <div class="post_body">
<div class="post single small_image"> <h2>{{ $news->title }}</h2>
<ul class="post_details clearfix"> <ul class="post_details clearfix">
<li class="detail date"> <li class="detail date">
<i class="fa-regular fa-clock"></i> <i class="fa-regular fa-clock"></i>
{{Formatter::relativeDate($item->published)}} om {{$item->published->format("H:i")}} {{Formatter::relativeDate($news->published)}} om {{$news->published->format('H:i')}}
@if($item->edited && ($item->edited->format("d m H i") != $item->published->format("d m H i"))) @if($news->edited && ($news->edited->format('d m H i') != $news->published->format('d m H i')))
| <em>bijgewerkt</em>: | bijgewerkt:
@if($item->edited->format("d m") != $item->published->format("d m")) @if($news->edited->format('d m') != $news->published->format('d m'))
{{strtolower(Formatter::relativeDate($item->edited))}} {{strtolower(Formatter::relativeDate($news->edited))}}
@endif @endif
om {{$item->edited->format("H:i")}} uur om {{$news->edited->format('H:i')}} uur
@endif @endif
</li> </li>
@if($item->author) @if($news->author)
<li class="detail author">{{$item->author}}</li> <li class="detail author"><i class="fa-solid fa-pen"></i> {{$news->author}}</li>
@endif @endif
</ul> </ul>
<div class="post_content page_margin_top clearfix"> <div class="post_content clearfix">
<div class="content_box"> <div class="content_box">
@if($item->images) @if($news->images)
@if(count($item->images) == 1) @if(count($news->images) == 1)
@if(!$item->images[0]->title) @php($item->images[0]->title = $item->title) @endif
<div class="post_image_box"> <div class="post_image_box">
<a href="{{$imgBase . $item->images[0]->url}}" class="post_image prettyPhoto" rel="prettyPhoto" title="{{$item->images[0]->title}}"> <a href="{{$imgBase . $news->images[0]->url}}" class="post_image prettyPhoto" rel="prettyPhoto"
<img src="{{$imgBase . $item->images[0]->url}}" alt="{{$item->images[0]->title}}"> title="{{$news->images[0]->title}}">
<img src='{{$imgBase . $news->images[0]->url}}' alt='{{$news->images[0]->title}}'>
</a> </a>
<div class="sentence"> <div class="sentence">
<span class="text">{{$item->images[0]->title}}</span> <span class="text">{{$news->images[0]->title}}</span>
@if(isset($item->images[0]->author)) @if(isset($news->images[0]->author))
<span class="author">{{$item->images[0]->author}}</span> <span class="author">{{$news->images[0]->author}}</span>
@endif @endif
</div> </div>
</div> </div>
@else @else
<div class="horizontal_carousel_container gallery"> <div class="horizontal_carousel_container thin page_margin_top gallery_control">
<ul class="horizontal_carousel visible-5 autoplay-1 scroll-1 navigation-1 easing-easeInOutQuint duration-750"> <ul
@foreach($item->images as $image) class="horizontal_carousel control-for-post-gallery visible-5 autoplay-0 scroll-1 navigation-1 easing-easeInOutQuint duration-750">
@if(!$image->title) @php($image->title = $item->title) @endif @foreach($news->images as $image)
<li> <li>
<a href="{{$imgBase . $image->url}}" class="post_image prettyPhoto" rel="prettyPhoto[gallery-{{$item->id}}]" title="{{$image->title}}"> <a href="#"><img src='{{$imgBase . $image->url}}'></a>
<img src="{{$imgBase . $image->url}}" alt="{{$image->title}}" title="{{$image->title}}">
</a>
</li> </li>
@endforeach @endforeach
</ul> </ul>
</div> </div>
@endif <div id="control-by-post-gallery" class="horizontal_carousel_container big margin_top_10">
@endif <ul id="post-gallery"
class="horizontal_carousel visible-1 autoplay-0 scroll-1 navigation-1 easing-easeInOutQuint duration-750">
<h3>{{$item->title}}</h3> @foreach($news->images as $image)
<li>
@if(is_array($item->content)) <a href="{{$imgBase . $image->url}}" data-rel="gallery" title="{{$image->title}}">
@include("partial/nh_story", ["content" => $item->content]); <span class="icon fullscreen animated"></span>
@else <img src='{{$imgBase . $image->url}}' alt='{{$image->title}}'>
<div class="text"> </a>
<p>{!!$item->content!!}</p> </li>
</div> </ul>
@endif @endforeach
</div>
@if($item->video) @endif
@include('widgets/mediaplayer') @endif
@php(createVideoElement($item->video))
@endif {{-- @if($news->type == "nhnieuws") --}}
{{-- @include('partial/nh_story', ['content' => $news->content]) --}}
@if($item->source && $item->source->show) {{-- @elseif($news->type == "artikel") --}}
<div class="post-source"> {{-- @include('partial/block_story', ['content' => $news->content]) --}}
<p>Bron: {{$item->source->title}}</p> {{-- @else --}}
</div> <div class="text">
@endif <p>{!!$news->content!!}</p>
</div> </div>
</div> {{-- @endif --}}
@if($item->podcast)
@include("widgets/mediaplayer") @if($news->podcast)
<div class="announcement"> @include('widgets/podcastplayer', ['podcast' => $news->podcast])
<div> @endif
<audio controls>
<source src="{{ $url = url( $apiUrl . "podcast/stream" . $item->podcast->url . "?auth=" . $item->podcast->auth )}}" type="audio/mpeg" /> @if($news->source && $news->source->show)
</audio> <div class="post-source">
</div> <p>Bron: {{$news->source->title}}</p>
</div> </div>
@endif @endif
</div>
</div> {{--
@include('widgets/share')
--}}
{{-- <div class="share_buttons row">
<div class="col-12 col-md-auto">
<a data-share="native" href="javascript:void(0)" class="btn">
<i class="fa-solid fa-share"></i>
Delen
</a>
</div>
</div> --}}
</div>
</div>
</div>
<hr />
@endforeach @endforeach

View File

@@ -27,6 +27,7 @@ Route::get('/nieuws/zoeken', function(Illuminate\Http\Request $request) {
} }
return redirect('/nieuws'); return redirect('/nieuws');
}); });
Route::get('/nieuws/liveblog/{id}/{title}', 'NewsController@liveblog')->where(['id' => '\d+'])->name('nieuws.liveblog');
Route::get('/blog/{id}/{title}', 'NewsController@blog')->where(['id' => '\d+'])->name('blog'); Route::get('/blog/{id}/{title}', 'NewsController@blog')->where(['id' => '\d+'])->name('blog');
Route::get('/blog', 'NewsController@activeblog'); Route::get('/blog', 'NewsController@activeblog');