rollback: go:embed for static files
This commit is contained in:
parent
70b329c902
commit
ef3f3c5428
5 changed files with 15 additions and 11 deletions
2
Makefile
2
Makefile
|
|
@ -6,7 +6,7 @@ build:
|
|||
GOOS=linux GOARCH=amd64 go build -o $(EXEC)
|
||||
|
||||
bundle: build
|
||||
tar czf $(EXEC).tar.gz $(EXEC) admin/components/ admin/views/ admin/static/ views/ public/ schema-migration/
|
||||
tar czf $(EXEC).tar.gz $(EXEC) admin/static/ public/
|
||||
|
||||
clean:
|
||||
rm $(EXEC) $(EXEC).tar.gz
|
||||
|
|
|
|||
|
|
@ -3,13 +3,9 @@ package admin
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"embed"
|
||||
"fmt"
|
||||
"mime"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -17,6 +13,7 @@ import (
|
|||
"arimelody-web/controller"
|
||||
"arimelody-web/log"
|
||||
"arimelody-web/model"
|
||||
"arimelody-web/view"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
|
@ -58,7 +55,9 @@ func Handler(app *model.AppState) http.Handler {
|
|||
mux.Handle("/tracks", requireAccount(serveTracks(app)))
|
||||
mux.Handle("/tracks/", requireAccount(serveTracks(app)))
|
||||
|
||||
mux.Handle("/static/", staticHandler())
|
||||
mux.Handle("/static/", requireAccount(
|
||||
http.StripPrefix("/static",
|
||||
view.ServeFiles("./admin/static"))))
|
||||
|
||||
mux.Handle("/", requireAccount(AdminIndexHandler(app)))
|
||||
|
||||
|
|
@ -484,6 +483,7 @@ func requireAccount(next http.Handler) http.HandlerFunc {
|
|||
})
|
||||
}
|
||||
|
||||
/*
|
||||
//go:embed "static"
|
||||
var staticFS embed.FS
|
||||
|
||||
|
|
@ -502,6 +502,7 @@ func staticHandler() http.Handler {
|
|||
w.Write(file)
|
||||
})
|
||||
}
|
||||
*/
|
||||
|
||||
func enforceSession(app *model.AppState, next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@
|
|||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
img.icon {
|
||||
-webkit-filter: invert(1);
|
||||
filter: invert(1);
|
||||
-webkit-filter: invert(.9);
|
||||
filter: invert(.9);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,13 +217,16 @@ nav .section-label {
|
|||
transform: translate(1px, 1px);
|
||||
}
|
||||
#toggle-nav img:hover {
|
||||
-webkit-filter: invert(.9);
|
||||
filter: invert(.9);
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
#toggle-nav img {
|
||||
-webkit-filter: invert(.9);
|
||||
filter: invert(.9);
|
||||
}
|
||||
#toggle-nav img:hover {
|
||||
-webkit-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ function update_extras_buttons() {
|
|||
const info_container = document.getElementById("info")
|
||||
info_container.addEventListener("scroll", update_extras_buttons);
|
||||
const info_rect = info_container.getBoundingClientRect();
|
||||
const info_y = info_rect.y;
|
||||
const font_size = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||
let current = extras_pairs[0];
|
||||
extras_pairs.forEach(pair => {
|
||||
|
|
@ -53,7 +52,7 @@ function bind_go_back_btn() {
|
|||
function bind_share_btn() {
|
||||
const share_btn = document.getElementById("share");
|
||||
if (navigator.clipboard === undefined) {
|
||||
share_btn.onclick = event => {
|
||||
share_btn.onclick = () => {
|
||||
console.error("clipboard is not supported by this browser!");
|
||||
};
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ func IndexHandler(app *model.AppState) http.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
ServeEmbedFS(app.PublicFS, "public").ServeHTTP(w, r)
|
||||
http.FileServer(http.Dir("./public")).ServeHTTP(w, r)
|
||||
//ServeEmbedFS(app.PublicFS, "public").ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue