Add blog functionality

This commit is contained in:
2020-03-22 19:44:44 +01:00
parent 6409267670
commit 3b8c85215f
15 changed files with 235 additions and 9 deletions

View File

@@ -1 +0,0 @@
../api-dev

View File

@@ -50,6 +50,11 @@ class Kernel extends ConsoleKernel
$schedule->call(function() { $schedule->call(function() {
Storage::disk('local')->put('regioagenda.json', file_get_contents($this->API_URL . 'agenda/overzicht')); Storage::disk('local')->put('regioagenda.json', file_get_contents($this->API_URL . 'agenda/overzicht'));
})->everyMinute(); })->everyMinute();
// Update blogs
$schedule->call(function() {
Storage::disk('local')->put('blogs.json', file_get_contents($this->API_URL . 'blog/overzicht'));
})->everyMinute();
} }
/** /**

View File

@@ -77,6 +77,7 @@ class Controller extends BaseController
}); });
View::composer('widgets.menu', function($view) { View::composer('widgets.menu', function($view) {
$view->with('news', $this->getDataFromFileAndConvert('laatste_nieuws.json', ['news'], '\Model\NewsItem')) $view->with('news', $this->getDataFromFileAndConvert('laatste_nieuws.json', ['news'], '\Model\NewsItem'))
->with('blogs', $this->getDataFromFileAndConvert('blogs.json', [], '\Model\Blog', 1))
->with('popular', $this->getDataFromFileAndConvert('populair_nieuws.json', [], '\Model\NewsItem', 3)) ->with('popular', $this->getDataFromFileAndConvert('populair_nieuws.json', [], '\Model\NewsItem', 3))
->with('podcasts', $this->getDataFromFileAndConvert('laatste_podcasts.json', ['podcasts'], '\Model\Podcast')); ->with('podcasts', $this->getDataFromFileAndConvert('laatste_podcasts.json', ['podcasts'], '\Model\Podcast'));
}); });

View File

@@ -55,7 +55,47 @@ class NewsController extends Controller
{ {
return $this->listNews($request, 'zoeken/' . $query, 'Zoekresultaat')->with('query', urldecode($query)); return $this->listNews($request, 'zoeken/' . $query, 'Zoekresultaat')->with('query', urldecode($query));
} }
public function activeblog()
{
$apiResult = $this->API('blog/overzicht');
if(count($apiResult)) {
$blog = new \Model\Blog($apiResult[0]);
if($blog->is_active) {
return redirect($blog->url);
}
}
return abort(404);
}
public function blog(Request $request, $id)
{
$page = (int)$request->get('pagina', 1);
$hasNext = true;
while($page > 0) {
$apiResult = $this->API('blog/overzicht/' . (int)$id . '?pagina=' . (int)max(1, $page));
$blog = new \Model\Blog($apiResult->blog);
$items = [];
foreach($apiResult->items as $blogItem)
{
$items[] = new \Model\NewsItem($blogItem);
}
if(count($items) || ($page == 1))
{
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) private function listNews(Request $request, $url, $title = null)
{ {
$page = (int)$request->get('pagina', 1); $page = (int)$request->get('pagina', 1);

View File

@@ -351,7 +351,23 @@ button[disabled]:hover
width: 100%; width: 100%;
} }
.horizontal_carousel_container.gallery_control .horizontal_carousel > li {
position: relative;
width: 250px;
height: 133px;
}
.horizontal_carousel_container.gallery .horizontal_carousel > li {
width: auto;
height: 250px;
}
.horizontal_carousel_container.gallery .horizontal_carousel > li img {
height: 250px;
}
.mega_menu a.fixed-height { .mega_menu a.fixed-height {
width: auto;
height: 135px; height: 135px;
} }

View File

@@ -1204,7 +1204,7 @@ jQuery(document).ready(function($){
}); });
//fancybox //fancybox
$(".prettyPhoto").prettyPhoto({ $(".prettyPhoto[rel^='prettyPhoto']").prettyPhoto({
show_title: false, show_title: false,
slideshow: 3000, slideshow: 3000,
overlay_gallery: true, overlay_gallery: true,

View File

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

View File

@@ -57,7 +57,7 @@
@if($event->images) @if($event->images)
@if(count($event->images) == 1) @if(count($event->images) == 1)
<div class="post_image_box"> <div class="post_image_box">
<a href="{{$imgBase . $event->images[0]->url}}" class="post_image prettyPhoto" title="{{$event->images[0]->title}}"> <a href="{{$imgBase . $event->images[0]->url}}" class="post_image prettyPhoto" rel="prettyPhoto" title="{{$event->images[0]->title}}">
<img src='{{$imgBase . $event->images[0]->url}}' alt='{{$event->images[0]->title}}'> <img src='{{$imgBase . $event->images[0]->url}}' alt='{{$event->images[0]->title}}'>
</a> </a>
<div class="sentence"> <div class="sentence">

View File

@@ -46,7 +46,7 @@
<div class="announcement"> <div class="announcement">
<div> <div>
<audio controls> <audio controls>
<source src="{{ $url = url( $apiUrl . 'podcast/download/' . $news->podcast->url . "?auth=" . $news->podcast->auth )}}" type="audio/mpeg" /> <source src="{{ $url = url( $apiUrl . 'podcast/download' . $news->podcast->url . "?auth=" . $news->podcast->auth )}}" type="audio/mpeg" />
</audio> </audio>
</div> </div>
<ul class="post_details clearfix"> <ul class="post_details clearfix">
@@ -69,7 +69,7 @@
@if($news->images) @if($news->images)
@if(count($news->images) == 1) @if(count($news->images) == 1)
<div class="post_image_box"> <div class="post_image_box">
<a href="{{$imgBase . $news->images[0]->url}}" class="post_image prettyPhoto" title="{{$news->images[0]->title}}"> <a href="{{$imgBase . $news->images[0]->url}}" class="post_image prettyPhoto" rel="prettyPhoto" title="{{$news->images[0]->title}}">
<img src='{{$imgBase . $news->images[0]->url}}' alt='{{$news->images[0]->title}}'> <img src='{{$imgBase . $news->images[0]->url}}' alt='{{$news->images[0]->title}}'>
</a> </a>
<div class="sentence"> <div class="sentence">

View File

@@ -0,0 +1,90 @@
@foreach($items as $item)
<div class="row">
<div class="post single small_image">
<ul class="post_details clearfix">
<li class="detail date">
{{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")))
| bijgewerkt:
@if($item->edited->format("d m") != $item->published->format("d m"))
{{strtolower(Formatter::relativeDate($item->edited))}}
@endif
om {{$item->edited->format("H:i")}} uur
@endif
</li>
@if($item->author)
<li class="detail author">{{$item->author}}</li>
@endif
</ul>
<div class="post_content page_margin_top clearfix">
<div class="content_box">
@if($item->images)
@if(count($item->images) == 1)
@if(!$item->images[0]->title) @php($item->images[0]->title = $item->title) @endif
<div class="post_image_box">
<a href="{{$imgBase . $item->images[0]->url}}" class="post_image prettyPhoto" rel="prettyPhoto" title="{{$item->images[0]->title}}">
<img src="{{$imgBase . $item->images[0]->url}}" alt="{{$item->images[0]->title}}">
</a>
<div class="sentence">
<span class="text">{{$item->images[0]->title}}</span>
@if(isset($item->images[0]->author))
<span class="author">{{$item->images[0]->author}}</span>
@endif
</div>
</div>
@else
<div class="horizontal_carousel_container gallery">
<ul class="horizontal_carousel visible-5 autoplay-1 scroll-1 navigation-1 easing-easeInOutQuint duration-750">
@foreach($item->images as $image)
@if(!$image->title) @php($image->title = $item->title) @endif
<li>
<a href="{{$imgBase . $image->url}}" class="post_image prettyPhoto" rel="prettyPhoto[gallery-{{$item->id}}]" title="{{$image->title}}">
<img src="{{$imgBase . $image->url}}" alt="{{$image->title}}" title="{{$image->title}}">
</a>
</li>
@endforeach
</ul>
</div>
@endif
@endif
<h3>{{$item->title}}</h3>
@if(is_array($item->content))
@include("partial/nh_story", ["content" => $item->content]);
@else
<div class="text">
<p>{!!$item->content!!}</p>
</div>
@endif
@if($item->video)
@include('widgets/mediaplayer')
<video controls>
<source src="{!!$item->video!!}" type="application/x-mpegurl" />
</video>
@endif
@if($item->source && $item->source->show)
<div class="post-source">
<p>Bron: {{$item->source->title}}</p>
</div>
@endif
</div>
</div>
@if($item->podcast)
@include("widgets/mediaplayer")
<div class="announcement">
<div>
<audio controls>
<source src="{{ $url = url( $apiUrl . "podcast/download" . $item->podcast->url . "?auth=" . $item->podcast->auth )}}" type="audio/mpeg" />
</audio>
</div>
</div>
@endif
</div>
</div>
@endforeach

View File

@@ -1,7 +1,7 @@
@foreach($content as $block) @foreach($content as $block)
@if($block->type == "headerRichA") @if($block->type == "headerRichA")
@php($block->image->url = $block->image->crops->{'16:9'}->{'1600'}) @php($block->image->url = $block->image->crops->{'16:9'}->{'1600'})
<a href="{{$block->image->url}}" class="post_image page_margin_top prettyPhoto" title="{{$block->image->title}}"> <a href="{{$block->image->url}}" class="post_image page_margin_top prettyPhoto" rel="prettyPhoto" title="{{$block->image->title}}">
<img src="{{$block->image->url}}" alt="{{$block->image->title}}"> <img src="{{$block->image->url}}" alt="{{$block->image->title}}">
</a> </a>
<div class="sentence margin_top_10"> <div class="sentence margin_top_10">
@@ -20,7 +20,7 @@
<div class="author">{{$block->name}}</div> <div class="author">{{$block->name}}</div>
</blockquote> </blockquote>
@elseif($block->type == "image") @elseif($block->type == "image")
<a class="post_image page_margin_top prettyPhoto" href="{{$block->image->imageWide}}" title="{{$block->image->title}} &copy; {{$block->image->author}}"> <a class="post_image page_margin_top prettyPhoto" rel="prettyPhoto" href="{{$block->image->imageWide}}" title="{{$block->image->title}} &copy; {{$block->image->author}}">
<img src="{{$block->image->imageWide}}" class="attachment-small-slider-thumb size-small-slider-thumb wp-post-image" alt="{{$block->image->title}}" title="" style="display: block;"> <img src="{{$block->image->imageWide}}" class="attachment-small-slider-thumb size-small-slider-thumb wp-post-image" alt="{{$block->image->title}}" title="" style="display: block;">
</a> </a>
<div class="sentence"> <div class="sentence">

View File

@@ -108,7 +108,7 @@ $(".vertical_carousel").each(function() {
@if($podcast->image) @if($podcast->image)
<div class="post_image_box"> <div class="post_image_box">
<a href="{{$imgBase . $podcast->image->url}}" class="post_image prettyPhoto" title="{{$podcast->image->title}}"> <a href="{{$imgBase . $podcast->image->url}}" class="post_image prettyPhoto" rel="prettyPhoto" title="{{$podcast->image->title}}">
<img src="{{$imgBase . $podcast->image->url}}" title="{{$podcast->image->title}}" style="display: block;"/> <img src="{{$imgBase . $podcast->image->url}}" title="{{$podcast->image->title}}" style="display: block;"/>
</a> </a>
<div class="sentence"> <div class="sentence">

View File

@@ -11,6 +11,12 @@
@endsection @endsection
@section('content') @section('content')
<p style="border: red 1px dotted; padding: 1px; color: red;">
Hieronder vindt u onze reguliere radioprogrammering. <br/>
Ook bij NH Gooi is de hoogste prioriteit momenteel de gezondheid van onze medewerkers en gasten. <br/>
In overleg met de programmamakers worden sommige muziekprogramma's vervangen door herhalingen of komen deze te vervallen. Onze nieuwsuitzendingen zoals het regionieuws op het halve uur en de NH Gooi Zaterdag vinden zoveel mogelijk doorgang, waar nodig in aangepaste vorm. <br/>
</p>
<nav> <nav>
<ul class="pager"> <ul class="pager">
<li class="action_button previous-week"><a href="{{route('radio.gids', ($shift - 1))}}">&larr; Week eerder</a></li> <li class="action_button previous-week"><a href="{{route('radio.gids', ($shift - 1))}}">&larr; Week eerder</a></li>

View File

@@ -66,6 +66,13 @@ function buildMenu($menu, $ismobile) {
Nieuws Nieuws
</a> </a>
<ul> <ul>
@if(count($blogs) && $blogs[0]->is_active)
<li class="{{isActive($blogs[0]->url, false) ? "selected" : ""}}">
<a href="{{url($blogs[0]->url)}}" title="Liveblog: {{$blogs[0]->title}}">
<b>Live-blog</b> | {{$blogs[0]->title}}
</a>
</li>
@endif
<li class="submenu"> <li class="submenu">
<a href="{{$newsUrl}}" title="Laatste nieuws"> <a href="{{$newsUrl}}" title="Laatste nieuws">
Laatste nieuws Laatste nieuws
@@ -161,6 +168,13 @@ function buildMenu($menu, $ismobile) {
<div class="mobile-menu-divider"></div> <div class="mobile-menu-divider"></div>
<nav> <nav>
<ul class="mobile-menu"> <ul class="mobile-menu">
@if(count($blogs) && $blogs[0]->is_active)
<li class="{{isActive($blogs[0]->url, false) ? "selected" : ""}}">
<a href="{{url($blogs[0]->url)}}" title="Liveblog: {{$blogs[0]->title}}">
<b>Live-blog</b> | {{$blogs[0]->title}}
</a>
</li>
@endif
<li class="submenu {{isActive($newsUrl, false) ? "selected" : ""}}"> <li class="submenu {{isActive($newsUrl, false) ? "selected" : ""}}">
<a href="{{$newsUrl}}" title="Nieuws"> <a href="{{$newsUrl}}" title="Nieuws">
Nieuws Nieuws

View File

@@ -25,6 +25,9 @@ Route::get('/nieuws/zoeken', function(Illuminate\Http\Request $request) {
return redirect('/nieuws'); return redirect('/nieuws');
}); });
Route::get('/blog/{id}/{title}', 'NewsController@blog')->where(['id' => '\d+'])->name('blog');
Route::get('/blog', 'NewsController@activeblog');
Route::get('/onair', 'RadioController@onair')->name('onair'); Route::get('/onair', 'RadioController@onair')->name('onair');
Route::get('/agenda', 'CalendarController@overview')->name('agenda'); Route::get('/agenda', 'CalendarController@overview')->name('agenda');