<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function() { return redirect()->route('nieuws'); });

Route::get('/nieuws', ['as' => 'nieuws', 'uses' => 'NewsController@overview']);
Route::get('/nieuws/regio/{region}', 'NewsController@regionlist' )->where(['region' => '[a-z0-9]+']);
Route::get('/nieuws/thema/{theme}', 'NewsController@themelist' )->where(['themelist' => '[a-z0-9]+']);
Route::get('/nieuws/{id}/{title}', 'NewsController@show')->where(['id' => '\d+']);
Route::get('/nieuws/zoeken/{query}', 'NewsController@search');
Route::get('/nieuws/zoeken', function(Illuminate\Http\Request $request) { 
  if($query = $request->get('query', null)) { 
    return redirect('/nieuws/zoeken/' . urlencode($query));
  }
  return redirect('/nieuws');
});

Route::get('/onair', 'RadioController@onair');

Route::get('/agenda', 'CalendarController@overview');
Route::get('/agenda/{id}/{title}', 'CalendarController@show')->where(['id' => '\d+']);

Route::get('/radio/gids/{shift?}', 'RadioController@schedule')->where(['shift' => '-?\d+']);
Route::get('/radio/programma/{id}/{title}', 'RadioController@program')->where(['id' => '\d+']);

Route::get('/luister/live', 'StreamController@liveradio');
Route::get('/luister/fragment/{id}/{title}', 'StreamController@podcast')->where(['id' => '\d+']);
Route::get('/luister/programma/{year}/{month}/{day}/{hour}/{duration}/{offset?}', 'StreamController@program')
	->where(['id' => '\d+', 'year' => '20\d\d', 'month' => '\d\d?', 'day' => '\d\d?', 'hour' => '\d\d?', 'duration' => '\d\d?', 'offset' => '\d\d?']);

Route::get('/radio/gemist', ['as' => 'gemist', 'uses' => 'RadioController@podcasts']);
Route::get('/radio/gemist/zoeken/{query}', 'RadioController@searchpodcast');
Route::get('/radio/gemist/zoeken', function(Illuminate\Http\Request $request) { 
  if($query = $request->get('query', null)) { 
    return redirect('/gemist/zoeken/' . urlencode($query));
  }
  return redirect('/gemist');
});

Route::get('/radio/gemist/fragment/{id}/{title}', 'RadioController@podcast')->where(['id' => '\d+']);
Route::get('/radio/gemist/programma/{programma}/{title}', 'RadioController@podcasts')->where(['programma' => '\d+']);

Route::get('/kijk/live', 'StreamController@livetv');

Route::get('/kerkdienst', 'KerkdienstController@main');
Route::get('/kerkdienst/luister', 'StreamController@kerkdienst');

//Route::get('/6fm/over-6fm', function() { return view('about'); });
//Route::get('/6fm/contact', function() { return view('contact'); });
//Route::get('/6fm/adverteren', function() { return view('adverteren'); });

//Route::get('/special/stmaarten', function() { return file_get_contents('http://api-dev.6fm.nl/special/stmaarten'); });

//Route::get('/kabelkrant', function() { return view('kabelkrant'); });
