Compare commits

..

No commits in common. "48697c5fc9aaccdd2bf4e2b4dabe700c11e5f028" and "e9dc032c88fdaa1373f6f5d8b20de182355b53df" have entirely different histories.

7 changed files with 9 additions and 32 deletions

4
TODO
View File

@ -4,7 +4,6 @@
[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).
@ -12,8 +11,5 @@
[ ] *.. 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,13 +2,11 @@
<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 }}
@ -16,14 +14,12 @@
<h2>{{ .Name }}</h2>
<p>{{ .Town }}</p>
{{ range .Departures }}
<dl>
{{ range $i, $val := .Departures }}
{{ if lt $i 3 }}
<dt>{{ $val.RouteShortName }} | {{ $val.StopHeadsign }}</dt>
<dd><time>{{ formatTime $val.DepartureTime }}</time></dd>
{{ end }}
{{ end }}
<dt>{{ .RouteShortName }} | {{ .StopHeadsign }}</dt>
<dd><time>{{ formatTime .DepartureTime }}</time></dd>
</dl>
{{ end }}
</article>
{{ end }}
</body>

View File

@ -1,19 +1,12 @@
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
@ -32,7 +25,6 @@ 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")
@ -56,7 +48,7 @@ func handleIndex(w http.ResponseWriter, r *http.Request) {
}
tpl := template.New("index.html").Funcs(tplFunctions)
tpl, _ = tpl.Parse(indexTemplate)
tpl, _ = tpl.ParseFiles("index.html")
_ = tpl.Execute(w, ctxt)
}

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B