splitted Level2 information from events added way to get ical feed from our server
parent
dad50602e3
commit
840ca668a9
|
@ -25,7 +25,9 @@
|
|||
'twig.path' => __DIR__ . '/views',
|
||||
));
|
||||
|
||||
$app->mount( '/', new level2\WebControllerProvider() );
|
||||
$app->mount( '/', new level2\Level2ControllerProvider() );
|
||||
|
||||
$app->mount( '/events', new level2\EventsControllerProvider() );
|
||||
|
||||
$app->error(function (\Exception $e, $code) use ( $app ) {
|
||||
switch ($code) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
|
||||
class WebControllerProvider implements ControllerProviderInterface {
|
||||
class EventsControllerProvider implements ControllerProviderInterface {
|
||||
|
||||
public function connect ( Application $app ) {
|
||||
|
||||
|
@ -13,23 +13,6 @@
|
|||
|
||||
$ctr->get('/', function() use ( $app ) {
|
||||
|
||||
return $app['twig']->render(
|
||||
'level2.twig',
|
||||
array(
|
||||
'page' => 'home',
|
||||
'level2' => Level2::getStatus( $app ),
|
||||
'events' => array_slice(
|
||||
Level2::getEvents( $app ),
|
||||
0,
|
||||
1
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
$ctr->get('/events/', function() use ( $app ) {
|
||||
|
||||
$eventsToReturn = Level2::getEventsByMonth(
|
||||
Level2::getEvents( $app ),
|
||||
date( 'Y' ),
|
||||
|
@ -47,7 +30,7 @@
|
|||
|
||||
});
|
||||
|
||||
$ctr->get('/events/{year}/{month}', function( $year, $month ) use ( $app ) {
|
||||
$ctr->get('/{year}/{month}', function( $year, $month ) use ( $app ) {
|
||||
|
||||
if ( strpos( $month, '.' ) !== false ) {
|
||||
|
||||
|
@ -84,15 +67,7 @@
|
|||
|
||||
});
|
||||
|
||||
$ctr->get('/spaceapi', function( ) use ( $app ) {
|
||||
|
||||
return $app->json(
|
||||
Helpers::spaceAPI( $app )
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
$ctr->get('/events/{parameter}', function( $parameter ) use ( $app ) {
|
||||
$ctr->get('/{parameter}', function( $parameter ) use ( $app ) {
|
||||
|
||||
if ( $parameter == 'json' ) {
|
||||
|
||||
|
@ -100,6 +75,13 @@
|
|||
Level2::getEvents( $app )
|
||||
);
|
||||
|
||||
} else if ( $parameter == 'ical' ) {
|
||||
|
||||
header('Content-type: text/calendar; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename=calendar.ics');
|
||||
|
||||
return file_get_contents( $app[ 'cache' ][ 'calendar' ][ 'ical' ] );
|
||||
|
||||
} else if ( strpos( $parameter, '.' ) !== false ) {
|
||||
|
||||
$arguments = explode( '.', $parameter );
|
||||
|
@ -135,15 +117,6 @@
|
|||
|
||||
});
|
||||
|
||||
$ctr->get('/scrape', function() use ( $app ) {
|
||||
|
||||
Helpers::saveFile ( json_encode( Level2::getJSONCalendar( $app ) ), 'cache/calendar.json' );
|
||||
Helpers::saveFile ( file_get_contents( $app[ 'google' ][ 'ical' ] ) , 'cache/calendar.ics' );
|
||||
|
||||
return true;
|
||||
|
||||
});
|
||||
|
||||
return $ctr;
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace level2;
|
||||
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
|
||||
class Level2ControllerProvider implements ControllerProviderInterface {
|
||||
|
||||
public function connect ( Application $app ) {
|
||||
|
||||
$ctr = $app['controllers_factory'];
|
||||
|
||||
$ctr->get('/', function() use ( $app ) {
|
||||
|
||||
return $app['twig']->render(
|
||||
'level2.twig',
|
||||
array(
|
||||
'page' => 'home',
|
||||
'level2' => Level2::getStatus( $app ),
|
||||
'events' => array_slice(
|
||||
Level2::getEvents( $app ),
|
||||
0,
|
||||
1
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
$ctr->get('/spaceapi', function( ) use ( $app ) {
|
||||
|
||||
return $app->json(
|
||||
Helpers::spaceAPI( $app )
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
$ctr->get('/openingTimes', function( ) use ( $app ) {
|
||||
|
||||
return $app['twig']->render(
|
||||
'openingTimes.twig',
|
||||
array(
|
||||
'page' => 'chart',
|
||||
'level2' => Level2::getStatus( $app )
|
||||
)
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
$ctr->get('/scrape', function() use ( $app ) {
|
||||
|
||||
Helpers::saveFile ( json_encode( Level2::getJSONCalendar( $app ) ), $app[ 'cache' ][ 'calendar' ][ 'json' ] );
|
||||
Helpers::saveFile ( file_get_contents( $app[ 'google' ][ 'ical' ] ) , $app[ 'cache' ][ 'calendar' ][ 'ical' ] );
|
||||
|
||||
return true;
|
||||
|
||||
});
|
||||
|
||||
return $ctr;
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue