Added description for the API, changed the event controller

master
Tezza 2015-03-01 12:33:18 +01:00
parent 86a61d1f18
commit 84b221cac9
3 changed files with 50 additions and 11 deletions

View File

@ -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
- **[<code>GET</code> events/json](https://level2.lu/events/json)**
- **[<code>GET</code> events/:COUNT.json](https://level2.lu/events/42.json)**
- **[<code>GET</code> events/:YEAR/:MONTH.json](https://level2.lu/events/2015/03.json)**
- **[<code>GET</code> spaceapi](https://level2.lu/spaceapi)**
every event includes the following information:
- <code>start</code> the unix timestamp of when the event starts
- <code>end</code> the unix timestamp of when the event ends
- <code>date</code> A pre-formatted date that is used on the Level2.lu website
- <code>location</code> The location of the event
- <code>image</code> url to an image for the event, false when missing
- <code>url</code> url to more information about the event, false when missing
- <code>description</code> 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

View File

@ -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
)
)
);

View File

@ -38,8 +38,9 @@
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li {% if page == 'home' %} class="active" {% endif %} ><a href="/">Level2</a></li>
<li {% if page == 'home' %} class="active" {% endif %} ><a href="/">Level2</a></li>
<li {% if page == 'events' %} class="active" {% endif %} ><a href="/events">Events</a></li>
<li {% if page == 'api' %} class="active" {% endif %} ><a href="https://github.com/Kaweechelchen/Level2.lu/blob/master/README.md">API</a></li>
</ul>
<ul class="nav navbar-nav navbar-right hidden-xs">
{% if level2.open %}