diff --git a/README.md b/README.md index e06d60d..a9193b4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ # Level2.lu A website for the Level2 Hackspace + +mobiliteit +========== + +Gathering bus information from a specific station in Luxembourg is hard +This tool helps you to just get back the json that mobiliteit.lu should give you back + +##Usage +- **[GET events/json](https://level2.lu/events/json)** +- **[GET events/:COUNT.json](https://level2.lu/events/42.json)** +- **[GET events/:YEAR/:MONTH.json](https://level2.lu/events/2015/03.json)** +- **[GET spaceapi](https://level2.lu/spaceapi)** + +every event includes the following information: +- start the unix timestamp of when the event starts +- end the unix timestamp of when the event ends +- date A pre-formatted date that is used on the Level2.lu website +- location The location of the event +- image url to an image for the event, false when missing +- url url to more information about the event, false when missing +- description description of the event + +## Examples + + https://level2.lu/events/json + https://level2.lu/events/42.json + https://level2.lu/events/2015/03.json + https://level2.lu/spaceapi diff --git a/src/app/level2/WebControllerProvider.php b/src/app/level2/WebControllerProvider.php index a394cfb..700fd28 100644 --- a/src/app/level2/WebControllerProvider.php +++ b/src/app/level2/WebControllerProvider.php @@ -57,8 +57,6 @@ if ( $format == 'json' ) { - print_r( $eventsToReturn ); - return $app->json( Level2::getEventsByMonth( Level2::getEvents( $app ), @@ -86,23 +84,35 @@ }); - $ctr->get('/events/{count}', function( $count ) use ( $app ) { + $ctr->get('/spaceapi', function( ) use ( $app ) { - if ( strpos( $count, '.' ) !== false ) { + return $app->json( + Helpers::spaceAPI( $app ) + ); - $arguments = explode( '.', $count ); - $count = $arguments[ 0 ]; + }); + + $ctr->get('/events/{parameter}', function( $parameter ) use ( $app ) { + + if ( $parameter == 'json' ) { + + return $app->json( + Level2::getEvents( $app ) + ); + + } else if ( strpos( $parameter, '.' ) !== false ) { + + $arguments = explode( '.', $parameter ); + $parameter = $arguments[ 0 ]; $format = $arguments[ 1 ]; if ( $format == 'json' ) { - print_r( $eventsToReturn ); - return $app->json( array_slice( Level2::getEvents( $app ), 0, - $count + $parameter ) ); @@ -118,7 +128,7 @@ 'events' => array_slice( Level2::getEvents( $app ), 0, - $count + $parameter ) ) ); diff --git a/src/app/views/base.twig b/src/app/views/base.twig index 66d78e6..ef15d85 100644 --- a/src/app/views/base.twig +++ b/src/app/views/base.twig @@ -38,8 +38,9 @@