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] *.. 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.
[ ] **. Show max two departures per line per stop. [ ] **. Show max two departures per line per stop.
[ ] **. Add Connexxion departures. [ ] **. Add Connexxion departures.
[ ] **. Make the page look nice (also on mobile). [ ] **. Make the page look nice (also on mobile).
@ -12,8 +11,5 @@
[ ] *.. Add robots.txt. [ ] *.. Add robots.txt.
[ ] *.. Compile static files into the binary. [ ] *.. Compile static files into the binary.
[ ] *** Read route preferences from env/config. [ ] *** 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 ## Backlog

View File

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

View File

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