Compare commits

...

3 Commits

Author SHA1 Message Date
Jasper Bok 8df1ac94b5 Move `Quay` and `Route` to their own files 2023-08-20 19:37:41 +02:00
Jasper Bok be4b6d8aa2 Add 'robots' meta tag 2023-08-18 18:05:53 +02:00
Jasper Bok 30db593e2a Rearrange to do 2023-08-18 18:05:19 +02:00
5 changed files with 40 additions and 34 deletions

10
TODO
View File

@ -2,19 +2,19 @@
## 1.0.0 ## 1.0.0
[ ] *** Show max two departures per line per stop.
[ ] *** Read route preferences from env/config.
[ ] *.. Make the stop name link to Breng's page for that stop.
[ ] *.. Make the route name link to Breng's page for that route.
[x] *.. Print times in human-readable format. [x] *.. Print times in human-readable format.
[x] **. Always parse times in Dutch timezone. [x] **. Always parse times in Dutch timezone.
[x] *.. Show max three departures per stop. [x] *.. Show max three departures per stop.
[ ] *** Show max two departures per line per stop.
[x] **. Add Connexxion departures. [x] **. Add Connexxion departures.
[x] **. Make the page look nice (also on mobile). [x] **. Make the page look nice (also on mobile).
[x] **. Add a favicon. [x] **. Add a favicon.
[ ] *.. Add robots.txt.
[x] *.. Compile static files into the binary. [x] *.. Compile static files into the binary.
[ ] *** Read route preferences from env/config.
[x] *.. Make the port configurable via CLI option. [x] *.. Make the port configurable via CLI option.
[ ] *.. Make the stop name link to Breng's page for that stop. [x] *.. Add robots.txt.
[ ] *.. Make the route name link to Breng's page for that route.
## Backlog ## Backlog

View File

@ -3,6 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex">
<link rel="icon" type="img/png" href="/static/img/bus16x16.png" sizes="16x16"> <link rel="icon" type="img/png" href="/static/img/bus16x16.png" sizes="16x16">
<link rel="icon" type="img/png" href="/static/img/bus32x32.png" sizes="32x32"> <link rel="icon" type="img/png" href="/static/img/bus32x32.png" sizes="32x32">

29
main.go
View File

@ -2,38 +2,9 @@ package main
import ( import (
"flag" "flag"
"fmt"
"net/http" "net/http"
"net/url"
) )
type Route struct {
RouteShortName string `json:"route_short_name"`
RouteLongName string `json:"route_long_name"`
}
type Quay struct {
ID string `json:"quayid"`
Name string `json:"name"`
Town string `json:"town"`
RoutesOfInterest []Route
}
func (q Quay) IsInterestingDeparture(d Departure) bool {
for _, route := range q.RoutesOfInterest {
if (route.RouteShortName == d.RouteShortName) && (route.RouteLongName == d.StopHeadsign) {
return true
}
}
return false
}
func (q Quay) GetBrengUrl() string {
param := fmt.Sprintf("{\"quayid\":\"%s\",\"name\":\"%s\",\"town\":\"%s\"}", q.ID, q.Name, q.Town)
return fmt.Sprint("https://www.breng.nl/nl/resultaten/halte-informatie/?stop=%s", url.QueryEscape(param))
}
var BusClient *http.Client var BusClient *http.Client
var Quays []Quay = []Quay{} var Quays []Quay = []Quay{}

28
quay.go 100644
View File

@ -0,0 +1,28 @@
package main
import (
"fmt"
"net/url"
)
type Quay struct {
ID string `json:"quayid"`
Name string `json:"name"`
Town string `json:"town"`
RoutesOfInterest []Route
}
func (q Quay) IsInterestingDeparture(d Departure) bool {
for _, route := range q.RoutesOfInterest {
if (route.RouteShortName == d.RouteShortName) && (route.RouteLongName == d.StopHeadsign) {
return true
}
}
return false
}
func (q Quay) GetBrengUrl() string {
param := fmt.Sprintf("{\"quayid\":\"%s\",\"name\":\"%s\",\"town\":\"%s\"}", q.ID, q.Name, q.Town)
return fmt.Sprintf("https://www.breng.nl/nl/resultaten/halte-informatie/?stop=%s", url.QueryEscape(param))
}

6
route.go 100644
View File

@ -0,0 +1,6 @@
package main
type Route struct {
RouteShortName string `json:"route_short_name"`
RouteLongName string `json:"route_long_name"`
}