Skip to content

Commit

Permalink
Framework set for the update for tomorrow
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoverbruggen committed Jun 3, 2014
1 parent d59b507 commit ec7a3dc
Show file tree
Hide file tree
Showing 36 changed files with 257 additions and 15 deletions.
16 changes: 14 additions & 2 deletions app/controllers/StationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ public function index(){
return View::make('stations.search');
}

public function redirectToNMBSStations(){
return Redirect::to('/NMBS/stations');
}

public function liveboard($id){

$negotiator = new \Negotiation\FormatNegotiator();
Expand All @@ -20,9 +24,18 @@ public function liveboard($id){
case "text/html":
return Response::view('stations.liveboard')->header('Content-Type', "text/html")->header('Vary', 'accept');
break;
case "application/ld+json":
$stationStringName = \hyperRail\StationString::convertToString($id);
$URL = "http://api.irail.be/liveboard/?station=" . $stationStringName->name . "&fast=true&lang=nl&format=json";
$data = file_get_contents($URL);
\hyperRail\iRailFormatConverter::convertLiveboardData($data, $id);
$response = Response::make($data, 200);
$response->header('Content-Type', 'application/ld+json');
$response->header('Vary', 'accept');
break;
case "application/json":
$stationStringName = \hyperRail\StationString::convertToString($id);
$URL = "http://api.irail.be/liveboard/?station=" . $stationStringName->name . "&lang=nl&format=json";
$URL = "http://api.irail.be/liveboard/?station=" . $stationStringName->name . "&fast=true&lang=nl&format=json";
$data = file_get_contents($URL);
$response = Response::make($data, 200);
$response->header('Content-Type', 'application/json');
Expand All @@ -34,5 +47,4 @@ public function liveboard($id){
break;
}
}

}
2 changes: 1 addition & 1 deletion app/hyperRail/StationString.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static function convertToString($string){
* TODO: check for multiple hits when using strpos()
*/

if ($station->id === $string) {
if (strpos($station->id,$string) !== false) {
return $station;
}
}
Expand Down
20 changes: 20 additions & 0 deletions app/hyperRail/iRailFormatConverter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace hyperRail;

/**
* Class iRailFormatConverter
* Converts the old JSON to new JSON.
* @package hyperRail
*/
class iRailFormatConverter {
public static function convertRoutePlanningData($json, $id, $format = "jsonld"){
}
public static function convertLiveboardData($json, $id, $format = "jsonld"){
// First, json_decode the data
$initialData = json_decode($json);
// $departures = array();
var_dump(json_decode($json));
exit;
}
}
2 changes: 2 additions & 0 deletions app/lang/en/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"platform" => "Platform",
"station" => "Station",
"liveboardDescription" => "Below you'll find a list of all trains departing for a certain station and their possible delay.",
"waitBetween" => "Wait",
"mins" => "minutes before departure",
//
"search"=>"Search",
"departure_at" => "Departure",
Expand Down
10 changes: 6 additions & 4 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

Route::get('/', 'HomeController@showWelcome');
Route::get('/route', 'RouteController@index');
Route::get('/stations', 'StationController@index');
Route::get('/NMBS/stations', 'StationController@index');

Route::get('/language', 'LanguageController@index');
Route::get('/stations/{id}', 'StationController@liveboard');
Route::get('/stations/{id}/arrivals', 'StationController@arrivals');
Route::get('/stations/{id}/departures', 'StationController@departures');
Route::get('/stations', 'StationController@redirectToNMBSStations');
Route::get('/NMBS/stations/{id}', 'StationController@liveboard');
Route::get('/NMBS/stations/{id}/{trainHash}', 'StationController@specificTrain');
Route::get('/NMBS/stations/{id}/arrivals', 'StationController@arrivals');
Route::get('/NMBS/stations/{id}/departures', 'StationController@departures');

/*
|--------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions app/views/route/planner.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@
</li>
<li class="list-group-item" ng-repeat="stop in conn.vias.via">
&darr; @{{stop.vehicle.replace("BE.NMBS.","")}} <span class="small">(@{{stop.direction.name}})</span>
<br/>
<span class="planner-time">
<strong>@{{(stop.arrival.time)*1000 | date:'HH:mm'}}</strong>
</span>
<br/>
&darr; @{{(stop.timeBetween/60)}} {{Lang::get('client.mins')}}

<br/>
<span class="badge">@{{ stop.departure.platform }}</span>
<span class="planner-time"><strong>
Expand Down
4 changes: 4 additions & 0 deletions app/views/stations/departure.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TRAIN DEPARTURE TEMPLATE
GENERATED BY PHP
GENERATED FOR TWITTER
This page is available as long as the train is available.
3 changes: 1 addition & 2 deletions app/views/stations/liveboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
&nbsp;&nbsp;+@{{dep.delay/60}}
</span>
</span>

</span>
</span>
</li>
</ul>
<div class="alert alert-info" ng-show="liveboardData.departures == null">
Expand Down
2 changes: 1 addition & 1 deletion app/views/stations/search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<label for="departure">{{Lang::get('client.stationName')}}</label>
<input type="text" ng-model="departure" placeholder="{{Lang::get('client.stationSearchPlaceholder')}}" typeahead="station as station.name for station in stations.stations | filter:{name:$viewValue} | limitTo:5" typeahead-template-url="customTemplate.html" class="form-control input-lg">
</div>
<a href="{{ URL::to('stations') }}/@{{departure.id}}" ng-show="departure.id" class="btn btn-primary btn-wide btn-lg bounceIn">{{Lang::get('client.viewLiveboard')}}</a>
<a href="{{ URL::to('NMBS/stations') }}/@{{departure.id}}" ng-show="departure.id" class="btn btn-primary btn-wide btn-lg bounceIn">{{Lang::get('client.viewLiveboard')}}</a>
</div>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions public/NMBS/template/accordion/accordion-group.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" ng-click="toggleOpen()" accordion-transclude="heading"><span ng-class="{'text-muted': isDisabled}">{{heading}}</span></a>
</h4>
</div>
<div class="panel-collapse" collapse="!isOpen">
<div class="panel-body" ng-transclude></div>
</div>
</div>
1 change: 1 addition & 0 deletions public/NMBS/template/accordion/accordion.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="panel-group" ng-transclude></div>
7 changes: 7 additions & 0 deletions public/NMBS/template/alert/alert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="alert" ng-class="['alert-' + (type || 'warning'), closeable ? 'alert-dismissable' : null]" role="alert">
<button ng-show="closeable" type="button" class="close" ng-click="close()">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<div ng-transclude></div>
</div>
8 changes: 8 additions & 0 deletions public/NMBS/template/carousel/carousel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div ng-mouseenter="pause()" ng-mouseleave="play()" class="carousel" ng-swipe-right="prev()" ng-swipe-left="next()">
<ol class="carousel-indicators" ng-show="slides.length > 1">
<li ng-repeat="slide in slides track by $index" ng-class="{active: isActive(slide)}" ng-click="select(slide)"></li>
</ol>
<div class="carousel-inner" ng-transclude></div>
<a class="left carousel-control" ng-click="prev()" ng-show="slides.length > 1"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" ng-click="next()" ng-show="slides.length > 1"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
7 changes: 7 additions & 0 deletions public/NMBS/template/carousel/slide.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div ng-class="{
'active': leaving || (active && !entering),
'prev': (next || active) && direction=='prev',
'next': (next || active) && direction=='next',
'right': direction=='prev',
'left': direction=='next'
}" class="item text-center" ng-transclude></div>
5 changes: 5 additions & 0 deletions public/NMBS/template/datepicker/datepicker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div ng-switch="datepickerMode" role="application" ng-keydown="keydown($event)">
<daypicker ng-switch-when="day" tabindex="0"></daypicker>
<monthpicker ng-switch-when="month" tabindex="0"></monthpicker>
<yearpicker ng-switch-when="year" tabindex="0"></yearpicker>
</div>
21 changes: 21 additions & 0 deletions public/NMBS/template/datepicker/day.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<table role="grid" aria-labelledby="{{uniqueId}}-title" aria-activedescendant="{{activeDateId}}">
<thead>
<tr>
<th><button type="button" class="btn btn-default btn-sm pull-left" ng-click="move(-1)" tabindex="-1"><i class="glyphicon glyphicon-chevron-left"></i></button></th>
<th colspan="{{5 + showWeeks}}"><button id="{{uniqueId}}-title" role="heading" aria-live="assertive" aria-atomic="true" type="button" class="btn btn-default btn-sm" ng-click="toggleMode()" tabindex="-1" style="width:100%;"><strong>{{title}}</strong></button></th>
<th><button type="button" class="btn btn-default btn-sm pull-right" ng-click="move(1)" tabindex="-1"><i class="glyphicon glyphicon-chevron-right"></i></button></th>
</tr>
<tr>
<th ng-show="showWeeks" class="text-center"></th>
<th ng-repeat="label in labels track by $index" class="text-center"><small aria-label="{{label.full}}">{{label.abbr}}</small></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rows track by $index">
<td ng-show="showWeeks" class="text-center h6"><em>{{ weekNumbers[$index] }}</em></td>
<td ng-repeat="dt in row track by dt.date" class="text-center" role="gridcell" id="{{dt.uid}}" aria-disabled="{{!!dt.disabled}}">
<button type="button" style="width:100%;" class="btn btn-default btn-sm" ng-class="{'btn-info': dt.selected, active: isActive(dt)}" ng-click="select(dt.date)" ng-disabled="dt.disabled" tabindex="-1"><span ng-class="{'text-muted': dt.secondary, 'text-info': dt.current}">{{dt.label}}</span></button>
</td>
</tr>
</tbody>
</table>
16 changes: 16 additions & 0 deletions public/NMBS/template/datepicker/month.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<table role="grid" aria-labelledby="{{uniqueId}}-title" aria-activedescendant="{{activeDateId}}">
<thead>
<tr>
<th><button type="button" class="btn btn-default btn-sm pull-left" ng-click="move(-1)" tabindex="-1"><i class="glyphicon glyphicon-chevron-left"></i></button></th>
<th><button id="{{uniqueId}}-title" role="heading" aria-live="assertive" aria-atomic="true" type="button" class="btn btn-default btn-sm" ng-click="toggleMode()" tabindex="-1" style="width:100%;"><strong>{{title}}</strong></button></th>
<th><button type="button" class="btn btn-default btn-sm pull-right" ng-click="move(1)" tabindex="-1"><i class="glyphicon glyphicon-chevron-right"></i></button></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rows track by $index">
<td ng-repeat="dt in row track by dt.date" class="text-center" role="gridcell" id="{{dt.uid}}" aria-disabled="{{!!dt.disabled}}">
<button type="button" style="width:100%;" class="btn btn-default" ng-class="{'btn-info': dt.selected, active: isActive(dt)}" ng-click="select(dt.date)" ng-disabled="dt.disabled" tabindex="-1"><span ng-class="{'text-info': dt.current}">{{dt.label}}</span></button>
</td>
</tr>
</tbody>
</table>
10 changes: 10 additions & 0 deletions public/NMBS/template/datepicker/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul class="dropdown-menu" ng-style="{display: (isOpen && 'block') || 'none', top: position.top+'px', left: position.left+'px'}" ng-keydown="keydown($event)">
<li ng-transclude></li>
<li ng-if="showButtonBar" style="padding:10px 9px 2px">
<span class="btn-group">
<button type="button" class="btn btn-sm btn-info" ng-click="select('today')">{{ getText('current') }}</button>
<button type="button" class="btn btn-sm btn-danger" ng-click="select(null)">{{ getText('clear') }}</button>
</span>
<button type="button" class="btn btn-sm btn-success pull-right" ng-click="close()">{{ getText('close') }}</button>
</li>
</ul>
16 changes: 16 additions & 0 deletions public/NMBS/template/datepicker/year.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<table role="grid" aria-labelledby="{{uniqueId}}-title" aria-activedescendant="{{activeDateId}}">
<thead>
<tr>
<th><button type="button" class="btn btn-default btn-sm pull-left" ng-click="move(-1)" tabindex="-1"><i class="glyphicon glyphicon-chevron-left"></i></button></th>
<th colspan="3"><button id="{{uniqueId}}-title" role="heading" aria-live="assertive" aria-atomic="true" type="button" class="btn btn-default btn-sm" ng-click="toggleMode()" tabindex="-1" style="width:100%;"><strong>{{title}}</strong></button></th>
<th><button type="button" class="btn btn-default btn-sm pull-right" ng-click="move(1)" tabindex="-1"><i class="glyphicon glyphicon-chevron-right"></i></button></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rows track by $index">
<td ng-repeat="dt in row track by dt.date" class="text-center" role="gridcell" id="{{dt.uid}}" aria-disabled="{{!!dt.disabled}}">
<button type="button" style="width:100%;" class="btn btn-default" ng-class="{'btn-info': dt.selected, active: isActive(dt)}" ng-click="select(dt.date)" ng-disabled="dt.disabled" tabindex="-1"><span ng-class="{'text-info': dt.current}">{{dt.label}}</span></button>
</td>
</tr>
</tbody>
</table>
4 changes: 4 additions & 0 deletions public/NMBS/template/modal/backdrop.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="modal-backdrop fade {{ backdropClass }}"
ng-class="{in: animate}"
ng-style="{'z-index': 1040 + (index && 1 || 0) + index*10}"
></div>
3 changes: 3 additions & 0 deletions public/NMBS/template/modal/window.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div tabindex="-1" role="dialog" class="modal fade" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)">
<div class="modal-dialog" ng-class="{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}"><div class="modal-content" modal-transclude></div></div>
</div>
4 changes: 4 additions & 0 deletions public/NMBS/template/pagination/pager.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ul class="pager">
<li ng-class="{disabled: noPrevious(), previous: align}"><a href ng-click="selectPage(page - 1)">{{getText('previous')}}</a></li>
<li ng-class="{disabled: noNext(), next: align}"><a href ng-click="selectPage(page + 1)">{{getText('next')}}</a></li>
</ul>
7 changes: 7 additions & 0 deletions public/NMBS/template/pagination/pagination.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ul class="pagination">
<li ng-if="boundaryLinks" ng-class="{disabled: noPrevious()}"><a href ng-click="selectPage(1)">{{getText('first')}}</a></li>
<li ng-if="directionLinks" ng-class="{disabled: noPrevious()}"><a href ng-click="selectPage(page - 1)">{{getText('previous')}}</a></li>
<li ng-repeat="page in pages track by $index" ng-class="{active: page.active}"><a href ng-click="selectPage(page.number)">{{page.text}}</a></li>
<li ng-if="directionLinks" ng-class="{disabled: noNext()}"><a href ng-click="selectPage(page + 1)">{{getText('next')}}</a></li>
<li ng-if="boundaryLinks" ng-class="{disabled: noNext()}"><a href ng-click="selectPage(totalPages)">{{getText('last')}}</a></li>
</ul>
8 changes: 8 additions & 0 deletions public/NMBS/template/popover/popover.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="popover {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
<div class="arrow"></div>

<div class="popover-inner">
<h3 class="popover-title" ng-bind="title" ng-show="title"></h3>
<div class="popover-content" ng-bind="content"></div>
</div>
</div>
1 change: 1 addition & 0 deletions public/NMBS/template/progressbar/bar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="progress-bar" ng-class="type && 'progress-bar-' + type" role="progressbar" aria-valuenow="{{value}}" aria-valuemin="0" aria-valuemax="{{max}}" ng-style="{width: percent + '%'}" aria-valuetext="{{percent | number:0}}%" ng-transclude></div>
1 change: 1 addition & 0 deletions public/NMBS/template/progressbar/progress.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="progress" ng-transclude></div>
3 changes: 3 additions & 0 deletions public/NMBS/template/progressbar/progressbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="progress">
<div class="progress-bar" ng-class="type && 'progress-bar-' + type" role="progressbar" aria-valuenow="{{value}}" aria-valuemin="0" aria-valuemax="{{max}}" ng-style="{width: percent + '%'}" aria-valuetext="{{percent | number:0}}%" ng-transclude></div>
</div>
5 changes: 5 additions & 0 deletions public/NMBS/template/rating/rating.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<span ng-mouseleave="reset()" ng-keydown="onKeydown($event)" tabindex="0" role="slider" aria-valuemin="0" aria-valuemax="{{range.length}}" aria-valuenow="{{value}}">
<i ng-repeat="r in range track by $index" ng-mouseenter="enter($index + 1)" ng-click="rate($index + 1)" class="glyphicon" ng-class="$index < value && (r.stateOn || 'glyphicon-star') || (r.stateOff || 'glyphicon-star-empty')">
<span class="sr-only">({{ $index < value ? '*' : ' ' }})</span>
</i>
</span>
3 changes: 3 additions & 0 deletions public/NMBS/template/tabs/tab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li ng-class="{active: active, disabled: disabled}">
<a ng-click="select()" tab-heading-transclude>{{heading}}</a>
</li>
10 changes: 10 additions & 0 deletions public/NMBS/template/tabs/tabset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div>
<ul class="nav nav-{{type || 'tabs'}}" ng-class="{'nav-stacked': vertical, 'nav-justified': justified}" ng-transclude></ul>
<div class="tab-content">
<div class="tab-pane"
ng-repeat="tab in tabs"
ng-class="{active: tab.active}"
tab-content-transclude="tab">
</div>
</div>
</div>
26 changes: 26 additions & 0 deletions public/NMBS/template/timepicker/timepicker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<table>
<tbody>
<tr class="text-center">
<td><a ng-click="incrementHours()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-up"></span></a></td>
<td>&nbsp;</td>
<td><a ng-click="incrementMinutes()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-up"></span></a></td>
<td ng-show="showMeridian"></td>
</tr>
<tr>
<td style="width:50px;" class="form-group" ng-class="{'has-error': invalidHours}">
<input type="text" ng-model="hours" ng-change="updateHours()" class="form-control text-center" ng-mousewheel="incrementHours()" ng-readonly="readonlyInput" maxlength="2">
</td>
<td>:</td>
<td style="width:50px;" class="form-group" ng-class="{'has-error': invalidMinutes}">
<input type="text" ng-model="minutes" ng-change="updateMinutes()" class="form-control text-center" ng-readonly="readonlyInput" maxlength="2">
</td>
<td ng-show="showMeridian"><button type="button" class="btn btn-default text-center" ng-click="toggleMeridian()">{{meridian}}</button></td>
</tr>
<tr class="text-center">
<td><a ng-click="decrementHours()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></a></td>
<td>&nbsp;</td>
<td><a ng-click="decrementMinutes()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></a></td>
<td ng-show="showMeridian"></td>
</tr>
</tbody>
</table>
4 changes: 4 additions & 0 deletions public/NMBS/template/tooltip/tooltip-html-unsafe-popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="tooltip {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
<div class="tooltip-arrow"></div>
<div class="tooltip-inner" bind-html-unsafe="content"></div>
</div>
4 changes: 4 additions & 0 deletions public/NMBS/template/tooltip/tooltip-popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="tooltip {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
<div class="tooltip-arrow"></div>
<div class="tooltip-inner" ng-bind="content"></div>
</div>
1 change: 1 addition & 0 deletions public/NMBS/template/typeahead/typeahead-match.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a tabindex="-1" bind-html-unsafe="match.label | typeaheadHighlight:query"></a>
5 changes: 5 additions & 0 deletions public/NMBS/template/typeahead/typeahead-popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul class="dropdown-menu" ng-if="isOpen()" ng-style="{top: position.top+'px', left: position.left+'px'}" style="display: block;" role="listbox" aria-hidden="{{!isOpen()}}">
<li ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)" role="option" id="{{match.id}}">
<div typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
</li>
</ul>
Loading

0 comments on commit ec7a3dc

Please sign in to comment.