moved static into source
@@ -10,20 +10,20 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:embed source static
|
||||
//go:embed source
|
||||
var sourceFS embed.FS
|
||||
|
||||
func main() {
|
||||
port := flag.Int("port", 8081, "port to listen on")
|
||||
flag.Parse()
|
||||
|
||||
staticRoot, err := fs.Sub(sourceFS, "source")
|
||||
sourceRoot, err := fs.Sub(sourceFS, "source")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// print exactly what got embedded
|
||||
fs.WalkDir(staticRoot, ".", func(path string, d fs.DirEntry, err error) error {
|
||||
fs.WalkDir(sourceRoot, ".", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
log.Println("walk error:", err)
|
||||
return nil
|
||||
@@ -34,7 +34,7 @@ func main() {
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFS(staticRoot, "templates/main.html", "pages/index.html")
|
||||
tmpl, err := template.ParseFS(sourceRoot, "templates/main.html", "pages/index.html")
|
||||
if err != nil {
|
||||
log.Println("parse error:", err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
@@ -58,7 +58,7 @@ func main() {
|
||||
})
|
||||
|
||||
mux.HandleFunc("GET /research", func(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFS(staticRoot, "templates/main.html", "pages/research.html")
|
||||
tmpl, err := template.ParseFS(sourceRoot, "templates/main.html", "pages/research.html")
|
||||
if err != nil {
|
||||
log.Println("parse error:", err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
@@ -82,7 +82,7 @@ func main() {
|
||||
})
|
||||
|
||||
mux.HandleFunc("GET /bookkeeping", func(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFS(staticRoot, "templates/main.html", "pages/bookkeeping.html")
|
||||
tmpl, err := template.ParseFS(sourceRoot, "templates/main.html", "pages/bookkeeping.html")
|
||||
if err != nil {
|
||||
log.Println("parse error:", err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
@@ -106,7 +106,7 @@ func main() {
|
||||
})
|
||||
|
||||
mux.HandleFunc("GET /personal", func(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFS(staticRoot, "templates/main.html", "pages/interests.html")
|
||||
tmpl, err := template.ParseFS(sourceRoot, "templates/main.html", "pages/interests.html")
|
||||
if err != nil {
|
||||
log.Println("parse error:", err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
@@ -129,9 +129,16 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
assetsRoot, err := fs.Sub(sourceFS, "static")
|
||||
staticRoot, err := fs.Sub(sourceFS, "source/static")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServerFS(assetsRoot)))
|
||||
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServerFS(staticRoot)))
|
||||
|
||||
mux.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFileFS(w, r, staticRoot, "favicon.ico")
|
||||
})
|
||||
|
||||
addr := fmt.Sprintf(":%d", *port)
|
||||
log.Printf("running on http://localhost%s/\n", addr)
|
||||
|
||||
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 6.8 MiB After Width: | Height: | Size: 6.8 MiB |
|
Before Width: | Height: | Size: 331 KiB After Width: | Height: | Size: 331 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 734 KiB After Width: | Height: | Size: 734 KiB |
|
Before Width: | Height: | Size: 287 KiB After Width: | Height: | Size: 287 KiB |
|
Before Width: | Height: | Size: 727 KiB After Width: | Height: | Size: 727 KiB |
|
Before Width: | Height: | Size: 373 KiB After Width: | Height: | Size: 373 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 7.6 MiB After Width: | Height: | Size: 7.6 MiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 780 B After Width: | Height: | Size: 780 B |
|
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 438 B |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 632 KiB After Width: | Height: | Size: 632 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 131 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 544 KiB After Width: | Height: | Size: 544 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 537 KiB After Width: | Height: | Size: 537 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 533 KiB After Width: | Height: | Size: 533 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 798 KiB After Width: | Height: | Size: 798 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 710 KiB After Width: | Height: | Size: 710 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 929 KiB After Width: | Height: | Size: 929 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 939 KiB After Width: | Height: | Size: 939 KiB |
|
Before Width: | Height: | Size: 624 KiB After Width: | Height: | Size: 624 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |