Skip to content

Commit 7cf892a

Browse files
Fixed stations url + improvements to JS
1 parent fbaa6a3 commit 7cf892a

File tree

6 files changed

+10
-24
lines changed

6 files changed

+10
-24
lines changed

app/hyperRail/Models/LiveboardItem.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ class LiveboardItem {
1616

1717
public function fill($stationId, $requestDate, $requestTime, $routeLabel, $headSign,
1818
$delay, $time, $platform){
19-
$md5hash = md5($routeLabel . $headSign);
20-
$this->stationURL = "http://" . _DOMAIN_ . "/NMBS/stations/" . $stationId . "/" . $requestDate . $requestTime . $md5hash;
19+
$this->headsign = $headSign;
20+
$this->routeLabel = preg_replace("/([A-Z]{1,2})(\d+)/", "$1 $2", $routeLabel);
21+
$md5hash = md5($this->routeLabel . $this->headsign);
22+
$this->stationURL = "http://" . _DOMAIN_ . "/stations/NMBS/" . $stationId . "/departures/" . $requestDate . $requestTime . $md5hash;
2123
$this->delay = $delay;
2224
$this->scheduledDepartureTime = $time;
2325
$this->platform = $platform;
24-
$this->destinationURL = "http://" . _DOMAIN_ . "/NMBS/stations/" . $stationId;
25-
$this->headsign = $headSign;
26-
$this->routeLabel = $routeLabel;
26+
$this->destinationURL = "http://" . _DOMAIN_ . "/stations/NMBS/" . $stationId . "/departures/";
2727
}
2828

2929
public function toArray(){

app/hyperRail/iRailFormatConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static function convertLiveboardData($json, $station_id, $format = "jsonl
2626
$time = $departure->time;
2727
$liveboardItem = new LiveboardItem();
2828
$date = date('Ymd', $time);
29-
$time = date('His', $time);
29+
$time = date('Hi', $time);
3030
$vehicleShort = explode("BE.NMBS.", $departure->vehicle);
3131
$liveboardItem->fill($station_id, $date, $time, $vehicleShort[1], $departure->station, $departure->delay, date('c', $departure->time), $departure->platform);
3232
array_push($liveboardCollection, $liveboardItem->toArray());

app/routes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
Route::get('/language', 'LanguageController@index');
2020
Route::get('/stations', 'StationController@redirectToNMBSStations');
21-
Route::get('/NMBS/stations/{id}', 'StationController@liveboard');
22-
Route::get('/NMBS/stations/{id}/{trainHash}', 'StationController@specificTrain');
21+
Route::get('/stations/NMBS/{id}', 'StationController@liveboard');
22+
Route::get('/stations/NMBS/{id}/departures/{trainHash}', 'StationController@specificTrain');
2323

2424
/*
2525
|--------------------------------------------------------------------------

app/views/stations/search.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<label for="departure">{{Lang::get('client.stationName')}}</label>
1818
<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">
1919
</div>
20-
<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>
20+
<a href="{{ URL::to('stations/NMBS') }}/@{{departure.id}}" ng-show="departure.id" class="btn btn-primary btn-wide btn-lg bounceIn">{{Lang::get('client.viewLiveboard')}}</a>
2121
</div>
2222
</div>
2323
</div>

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"easyrdf/easyrdf": "*",
99
"semsol/arc2": "*",
1010
"ml/json-ld": "1.*",
11-
"willdurand/negotiation": "@stable",
12-
"fzaninotto/faker": "1.3"
11+
"willdurand/negotiation": "@stable"
1312
},
1413
"require-dev": {
1514
"phpunit/phpunit": "4.0.*",

public/js/irailapp/app.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,6 @@
272272
$http.get('../../data/stations.json').success(function(data) {
273273
$scope.stations = data;
274274
var location = document.URL;
275-
// Figure out what the station name is
276-
var split = location.split('NMBS/stations/');
277-
var id = split[1].split('?');
278-
try{
279-
var stationName = $scope.findStationById(id[0]).name;
280-
}
281-
catch(ex){
282-
$scope.results = false;
283-
$scope.loading = false;
284-
$scope.error = true;
285-
}
286-
// Set up the request path
287-
// url = "http://api.irail.be/liveboard/?station=" + stationName + "&lang=nl&format=json";
288275
// Request the URL
289276
$http.get(document.URL, config)
290277
// If it works, show data

0 commit comments

Comments
 (0)