Added description for the API, changed the event controller
parent
86a61d1f18
commit
84b221cac9
28
README.md
28
README.md
|
@ -1,2 +1,30 @@
|
||||||
# Level2.lu
|
# Level2.lu
|
||||||
A website for the Level2 Hackspace
|
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
|
||||||
|
|
|
@ -57,8 +57,6 @@
|
||||||
|
|
||||||
if ( $format == 'json' ) {
|
if ( $format == 'json' ) {
|
||||||
|
|
||||||
print_r( $eventsToReturn );
|
|
||||||
|
|
||||||
return $app->json(
|
return $app->json(
|
||||||
Level2::getEventsByMonth(
|
Level2::getEventsByMonth(
|
||||||
Level2::getEvents( $app ),
|
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 ];
|
$format = $arguments[ 1 ];
|
||||||
|
|
||||||
if ( $format == 'json' ) {
|
if ( $format == 'json' ) {
|
||||||
|
|
||||||
print_r( $eventsToReturn );
|
|
||||||
|
|
||||||
return $app->json(
|
return $app->json(
|
||||||
array_slice(
|
array_slice(
|
||||||
Level2::getEvents( $app ),
|
Level2::getEvents( $app ),
|
||||||
0,
|
0,
|
||||||
$count
|
$parameter
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -118,7 +128,7 @@
|
||||||
'events' => array_slice(
|
'events' => array_slice(
|
||||||
Level2::getEvents( $app ),
|
Level2::getEvents( $app ),
|
||||||
0,
|
0,
|
||||||
$count
|
$parameter
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
<ul class="nav navbar-nav">
|
<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 == '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>
|
||||||
<ul class="nav navbar-nav navbar-right hidden-xs">
|
<ul class="nav navbar-nav navbar-right hidden-xs">
|
||||||
{% if level2.open %}
|
{% if level2.open %}
|
||||||
|
|
Loading…
Reference in New Issue