Skip to content

Commit fbaa6a3

Browse files
Added final changes for soft launch
1 parent 7a91446 commit fbaa6a3

27 files changed

+256
-195
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ Data returned through the API (when specifically requesting `application/ld+json
3535
3636
### Data dumps
3737

38-
Data dumps and the data that is used (and will be used and queryable in the future) are available at <a href="http://archive.irail.be">http://archive.irail.be</a>.
38+
Data dumps and the data that is used (and will be used and queryable in the future) are available at <a href="http://archive.irail.be">http://archive.irail.be</a>.
39+
40+
41+
### Thanks to
42+
43+
Special attribution to Melih Bilgil for the icon set. (http://picol.org/icon_library.php)

app/config/app.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
|
2727
*/
2828

29-
'url' => 'http://irail.dev',
29+
'url' => 'http://irail.dev', // with http
30+
'url-short' => 'irail.dev', // without http
3031

3132
/*
3233
|--------------------------------------------------------------------------

app/controllers/ApiController.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/controllers/StationController.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,50 @@ public function liveboard($id){
3939
break;
4040
}
4141
}
42+
43+
public function specificTrain($station_id, $liveboard_id){
44+
$negotiator = new \Negotiation\FormatNegotiator();
45+
$acceptHeader = Request::header('accept');
46+
$priorities = array('text/html', 'application/json', '*/*');
47+
$result = $negotiator->getBest($acceptHeader, $priorities);
48+
$val = $result->getValue();
49+
switch ($val){
50+
case "text/html":
51+
$stationStringName = \hyperRail\StationString::convertToString($station_id);
52+
$URL = "http://api.irail.be/liveboard/?station=" . $stationStringName->name . "&fast=true&lang=nl&format=json";
53+
$data = file_get_contents($URL);
54+
$newData = \hyperRail\iRailFormatConverter::convertLiveboardData($data, $station_id);
55+
foreach ($newData['@graph'] as $graph){
56+
if (strpos($graph['@id'],$liveboard_id) !== false) {
57+
return View::make('stations.departuredetail')->with('station', $graph)->with('departureStation', $stationStringName);
58+
}
59+
}
60+
return View::make('stations.expired');
61+
break;
62+
case "application/ld+json":
63+
$stationStringName = \hyperRail\StationString::convertToString($station_id);
64+
$URL = "http://api.irail.be/liveboard/?station=" . $stationStringName->name . "&fast=true&lang=nl&format=json";
65+
$data = file_get_contents($URL);
66+
$newData = \hyperRail\iRailFormatConverter::convertLiveboardData($data, $station_id);
67+
foreach ($newData['@graph'] as $graph){
68+
if (strpos($graph['@id'],$liveboard_id) !== false) {
69+
return $graph;
70+
}
71+
}
72+
return View::make('stations.expired');
73+
break;
74+
default:
75+
$stationStringName = \hyperRail\StationString::convertToString($station_id);
76+
$URL = "http://api.irail.be/liveboard/?station=" . $stationStringName->name . "&fast=true&lang=nl&format=json";
77+
$data = file_get_contents($URL);
78+
$newData = \hyperRail\iRailFormatConverter::convertLiveboardData($data, $station_id);
79+
foreach ($newData['@graph'] as $graph){
80+
if (strpos($graph['@id'],$liveboard_id) !== false) {
81+
return View::make('stations.departuredetail')->with('station', $graph)->with('departureStation', $stationStringName);
82+
}
83+
}
84+
return View::make('stations.expired');
85+
break;
86+
}
87+
}
4288
}

app/filters.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
if (App::environment()=='production'){
1717
if (!Request::secure()) return Redirect::secure(Request::getRequestUri());
1818
}
19-
2019
// TODO: implement language negotiation as an alternative to get('lang')
21-
2220
if (Input::get('lang')){
2321
$languages = array('nl', 'en', 'fr');
2422
$locale = Input::get('lang');
@@ -37,8 +35,6 @@
3735
$locale = null;
3836
}
3937
}
40-
41-
4238
});
4339

4440
App::after(function($request, $response)

app/hyperRail/StationString.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace hyperRail;
44

55
class StationString {
6-
76
/**
87
* Converts a station string to a station id. If the string cannot be converted,
98
* null is returned.

app/hyperRail/Tests/JsonLDTest.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

app/hyperRail/iRailFormatConverter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public static function convertLiveboardData($json, $station_id, $format = "jsonl
2121
// Set globals
2222
// (which data applies to all possible LiveboardItems we are going to create?)
2323
$stationName = $initialData->stationinfo->name;
24-
$timestamp = $initialData->timestamp;
2524
// Convert timestamp to date
26-
$date = date('Ymd', $timestamp);
27-
$time = date('His', $timestamp);
2825
foreach ($initialData->departures->departure as $departure){
26+
$time = $departure->time;
2927
$liveboardItem = new LiveboardItem();
28+
$date = date('Ymd', $time);
29+
$time = date('His', $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/lang/en/client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
"404ErrorTitle" => "Page not found",
4646
"404Explanation" => "We could not find this page. If you think this was a mistake, ",
4747
"goHome" => "Go back to the homepage",
48+
"ExpiredErrorTitle" => "This train has left the station!",
49+
"ExpiredExplanation" => "This train has left the station, and is no longer available. To learn more about this train, visit ",
50+
"delay" => "delay",
4851
// END OF NEW TRANSLATION STRINGS
4952
"search"=>"Search",
5053
"departure_at" => "Departure",

app/lang/fr/client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
"404ErrorTitle" => "Page pas trouvé",
4646
"404Explanation" => "Nous n'avons pas trouvé ce page. Si le problème persiste et vous pensez que c'est un erreur, ",
4747
"goHome" => "Retournez à page d’accueil",
48+
"ExpiredErrorTitle" => "Ce train a déjà quitté la gare!",
49+
"ExpiredExplanation" => "Ce train a déjà quitté la gare, et n'est plus disponible. Pour obtenir plus d'information sur ce train vous pouvez consulter nos archives de données à ",
50+
"delay" => "retard",
4851
// END OF NEW TRANSLATION STRINGS
4952
"search"=>"Chercher",
5053
"departure_at" => "Départ",

0 commit comments

Comments
 (0)