Skip to content

Instantly share code, notes, and snippets.

@SirPolaris
Created May 5, 2023 12:27
Show Gist options
  • Select an option

  • Save SirPolaris/516c89bcfebab53f7bd4b39e4091f414 to your computer and use it in GitHub Desktop.

Select an option

Save SirPolaris/516c89bcfebab53f7bd4b39e4091f414 to your computer and use it in GitHub Desktop.
extends layout
block content
<!-- Navigation -->
nav.navbar.navbar-expand-lg.bg-secondary.text-uppercase.fixed-top(id="mainNav")
.container
span.h5.text-white
if datablock.pageType == 'R'
| Route #{datablock.routeId}
else if datablock.pageType == 'S'
| Stop #{datablock.stopId} #{datablock.liveData.StopLabel}
else if datablock.pageType == 'SR'
| Route #{datablock.routeId} X Stop #{datablock.stopId}
else
| Err: Missing Param S/R
span.h5.text-white NEXT ARRIVALS
<!-- Masthead -->
- var css = "mastheadLite text-white text-center bg-primary"
- var text1 = ""
- var text2 = ""
- var img = ""
if currentStatus.overallStatus == "success"
- css = "mastheadTV text-white text-center bg-primary"
- text1 = `The ${datablock.statusText} is ${datablock.statusVerb.success}`
- text2 = "We report fast. The Mayor reports furious."
- img = "success"
else if currentStatus.overallStatus == "warning"
- css = "mastheadLite text-white text-center bg-warning"
- text1 = `The ${datablock.statusText} is ${datablock.statusVerb.success}`
- text2 = undefined
- img = "warning"
else if currentStatus.overallStatus == "danger"
- css = "mastheadLite text-white text-center bg-danger"
- text1 = `The ${datablock.statusText} is ${datablock.statusVerb.success}`
- text2 = undefined
- img = "danger"
else
- css = "mastheadLite text-white text-center bg-info"
- text1 = `The ${datablock.statusText} is running???`
- text2 = "We are having trouble figuring out whats going right now \n Check back shortly"
- img = "info"
header(class=css)
.container.m-1
<!-- Alert Line -->
if datablock.liveData
if datablock.alert.system["1s"]
.row.mb-1
.col
for x in datablock.alert.system["1s"]
.row
.col
.alert(class="alert-" + x.Status) System: #{x.Text}
if datablock.pageType == 'R'
if datablock.alert.route[datablock.routeId]
.row.mb-2
.col
for x in datablock.alert.route[datablock.routeId]
.row
.col
.alert(class="alert-" + x.Status) Route: #{x.Text}
.row
.col-12
a(href=`/live?s=${datablock.liveData[0].stop_code}`)
.input-group.mb-1.d-flex.justify-content-center
button.btn.btn-danger #{datablock.liveData[0].stop_code}
button.btn.btn-secondary #{datablock.liveData[0].stop_name}
h6.m-2 To
a(href=`/live?s=${datablock.liveData[datablock.liveData.length-1].stop_code}`)
.input-group.mb-1.d-flex.justify-content-center
button.btn.btn-danger #{datablock.liveData[datablock.liveData.length-1].stop_code}
button.btn.btn-secondary #{datablock.liveData[datablock.liveData.length-1].stop_name}
.row.text-start.mt-2
.col
if datablock.pageType == 'R'
h6 Details for Route #{datablock.routeId}
else if datablock.pageType == 'S'
else if datablock.pageType == 'SR'
h6 Next Arrivals to #{datablock.stopId} showing only route #{datablock.routeId}
a.link-light(href=`/live?s=${datablock.stopId}`) Show All
br
a.link-light(href=`/live?r=${datablock.routeId}`) Route Page for #{datablock.routeId}
// Route listing page
if datablock.pageType == 'R'
.row.text-start
.col
each value in datablock.liveData
a(href=`/live?s=${value.stop_code}`)
.input-group.mb-1
button.btn.btn-danger #{value.stop_code}
button.btn.btn-secondary #{value.stop_name}
// Stop layout page
if datablock.pageType == 'SR' || datablock.pageType == 'S'
.row.text-start.bg-white.text-black
.col
.row
.col.border-3.border-bottom.border-dark.mb-3
h6 Last
.col.border-3.border-bottom.border-dark.mb-3
h6 Next
.col.border-3.border-bottom.border-dark.mb-3
h6 +1
.col.border-3.border-bottom.border-dark.mb-3
h6 +2
each value, key in datablock.liveData.Route.RouteDirection
.row.mb-5
.col
// Trip ROW
.row.mb-3
.col-lg-3.col-sm-5
if value.RouteNo
if value.alert
// Route level alert icon
span(class=`btn btn-${value.alert.route[0].Status || 'success'}`) #{value.RouteNo}
else
span(class=`btn btn-success`) #{value.RouteNo}
span.ms-2 #{value.RouteLabel || "Route " + value.RouteNo}
else
span.btn.btn-info XX
span.ms-2 No route number was found
if value.alert
.col
for x in value.alert.route
.row
.col
.alert(class="alert-" + x.Status) #{x.Text}
// If no trips
if !value.Trips
.row
.col.m-1
.row
span.alert.alert-info
h3 No Next Trips Found
else
.row(id=`accordionParent${key}`)
// Per Trip on Route Block Generator
each trip, tripKey in value.Trips.Trip
.col.m-1
// TRIP ALERT BAR ROW
.row
if trip.Alert
span(class=`btn-${trip.Alert[0].Status}`)
i(class=`${trip.Alert[0].Icon} btn-${trip.Alert[0].Status}`)
span.ms-2 #{trip.Alert[0].Text}
if (trip.AdjustmentAge == -1)
span(class=`btn-success`)
i(class=`far fa-check-square btn-success`)
span.ms-2 Scheduled
else if (trip.AdjustmentAge > -1)
span(class=`btn-primary`)
i(class=`far fa-check-square btn-primary`)
span.ms-2 GPS
else
// Display nothing
if (trip.LastTripOfSchedule)
span(class=`btn-info`)
i(class=`far fa-calendar-times btn-info`)
span.ms-2 LAST
// Ghost bus colouring switch
- var css2 = ''
if trip.Alert && trip.Alert[0].Type == "ghost"
- css2 = 'btn-light'
else
- css2 = 'btn-light'
// TRIP DETAILS ROW
a.row(class=css2 id=`${value.RouteNo}${key}` data-routeno=`${value.RouteNo}` data-tripstart=`${trip.TripStartTime}` data-bs-toggle="collapse" data-bs-target=`#collapse${value.RouteNo}${tripKey}` aria-expanded="true" aria-controls="collapseOne")
// COL 1 - ARRIVAL TIME
.col.text-start
if trip.AdjustedScheduleTime
if trip.Alert && trip.Alert[0].Type == "cancel"
h1(style="background: linear-gradient(to left top, transparent 57.75%, currentColor 59.5%, currentColor 62.5%, transparent 52.25%)") #{trip.AdjustedScheduleTime}
else if trip.Alert && trip.Alert[0].Type == "ghost"
h1.text-muted #{trip.AdjustedScheduleTime}
else
if trip.ScheduleTime
h1 #{trip.AdjustedScheduleTime}#{trip.delta}
else
h1 #{trip.AdjustedScheduleTime}
else
if trip.AdjustedScheduleTime == 0
h1 0
else
h1 -
p.small #{trip.TripStartTime || "----"}
// COL 2 - DETAILS
.col.p-1.text-end
// Fullness Indicators
if trip.fullness
-var i = trip.fullness;
// If terrible warn
-if (i == 5)
i.far.fa-times-circle.text-danger.alert-danger
-else if (i == 4)
-while (i--)
i.fas.fa-user-circle.text-danger.alert-danger
-else if (i > 1 && i < 4)
-while (i--)
i.fas.fa-user-circle.text-warning
-else if (i == 1)
i.fas.fa-user-circle
// 0 is left out as it is a no show - Many seats available
// Unknown status
else
i.fas.fa-user-circle.text-muted
//TODO: Change to stats->fullness/disabled/ect
if (trip.disabled > 0 && trip.disabled <= 4)
.row
.col
-var m = Math.floor(trip.disabled / 2);
-var n = Math.floor(trip.disabled % 2);
// If packed warn
-if (m == 2)
-while (m--)
i.fas.fa-wheelchair.text-danger.alert-danger
-else
-while (m--)
i.fas.fa-wheelchair
-while (n--)
i.fas.fa-crutch
else
.row
.col
i.fas.fa-wheelchair.text-muted
// Text Area
if trip.BusType
.row
p.small Bus Type #{trip.BusType}
else
.row
.col
if datablock.pageType == 'R'
p Live Data Not Implemented For This Route Yet
else
P No data was given by OC API. If this stop is known true, then it means most likely OC API is down. Nothing to show here as this is powered by OC's API. We are working to provide the API service in house, but it will take a few months 🥰
p If it continues to be down for a long time contact #[b #[a(class="text-white" href="https://twitter.com/OccTranspo") @OCCTranspo]] on twitter or email #[b Control.Ottawa@Gmail.com]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment