From 6e0f2683cb7699239baae6181d14408fa0f5718f Mon Sep 17 00:00:00 2001 From: clerie Date: Sat, 27 Jul 2024 21:57:33 +0200 Subject: [PATCH] Link departures to bahn.expert --- src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index a06e93a..48b7614 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,6 +36,7 @@ struct DepartureInfo { #[derive(Deserialize)] struct Departure { departure: Option, + initialDeparture: String, route: Vec, train: Train, destination: String, @@ -156,7 +157,7 @@ async fn route_station_overview( out.push_str(&format!("
  • {}
  • \n", station, dest_station_id, dest_station.name)); } - out.push_str("
      \n"); + out.push_str("
    \n"); return Ok(Html(out)); } @@ -164,7 +165,7 @@ async fn route_station_overview( async fn route_station_to_dest_station( State(state): State, Path((station_id, dest_station_id)): Path<(String, String)> -) -> Result { +) -> Result, (StatusCode, String)> { if !state.stations.contains_key(&station_id) { return Err((StatusCode::NOT_FOUND, String::from("Unknown departing station"))); } @@ -201,6 +202,7 @@ async fn route_station_to_dest_station( let mut out = String::new(); + out.push_str("
      \n"); for departure in stationdata.departures { let departure_info = match departure.departure { @@ -233,10 +235,12 @@ async fn route_station_to_dest_station( } if stops_at_destination { - out.push_str(&format!("{}: {} ({} {}) [{}]-> {}\n", departure_info.time, &departure.train.name, &departure.train.r#type, &departure.train.number, departure_info.platform, &departure.destination)); + out.push_str(&format!("
    • {}: {} ({} {}) [{}]-> {}\n", departure_info.time, &departure.train.r#type, &departure.train.number, &departure.initialDeparture, station_properties.code, &departure.train.name, &departure.train.r#type, &departure.train.number, departure_info.platform, &departure.destination)); } } - return Ok(out); + out.push_str("
    \n"); + + return Ok(Html(out)); }