Compare commits

...

8 Commits

7 changed files with 32 additions and 9 deletions

4
TODO
View File

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

View File

@ -2,11 +2,13 @@
<html lang="nl">
<head>
<meta charset="UTF-8">
<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/bus192x192.png" sizes="192x192">
<link rel="stylesheet" href="/static/css/busdepartures.css">
<title>Busvertrektijden</title>
<style>
h2 { margin-bottom: 2px; }
dt { font-weight: bold; }
</style>
</head>
<body>
{{ range .Quays }}
@ -14,12 +16,14 @@
<h2>{{ .Name }}</h2>
<p>{{ .Town }}</p>
{{ range .Departures }}
<dl>
<dt>{{ .RouteShortName }} | {{ .StopHeadsign }}</dt>
<dd><time>{{ formatTime .DepartureTime }}</time></dd>
</dl>
{{ range $i, $val := .Departures }}
{{ if lt $i 3 }}
<dt>{{ $val.RouteShortName }} | {{ $val.StopHeadsign }}</dt>
<dd><time>{{ formatTime $val.DepartureTime }}</time></dd>
{{ end }}
{{ end }}
</dl>
</article>
{{ end }}
</body>

View File

@ -1,12 +1,19 @@
package main
import (
"embed"
"html/template"
"log"
"net/http"
"time"
)
//go:embed static
var staticDir embed.FS
//go:embed index.html
var indexTemplate string
type TemplateQuay struct {
Name string
Town string
@ -25,6 +32,7 @@ var tplFunctions = template.FuncMap{"formatTime": formatTime}
func serveHttp() {
http.HandleFunc("/", handleIndex)
http.Handle("/static/", http.FileServer(http.FS(staticDir)))
log.Println("Serving on port 4444")
@ -48,7 +56,7 @@ func handleIndex(w http.ResponseWriter, r *http.Request) {
}
tpl := template.New("index.html").Funcs(tplFunctions)
tpl, _ = tpl.ParseFiles("index.html")
tpl, _ = tpl.Parse(indexTemplate)
_ = tpl.Execute(w, ctxt)
}

View File

@ -0,0 +1,7 @@
h2 {
margin-bottom: 2px;
}
dt {
font-weight: bold;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B