diff --git a/display/web/embed.go b/display/web/embed.go new file mode 100644 index 0000000..2a15322 --- /dev/null +++ b/display/web/embed.go @@ -0,0 +1,12 @@ +package web + +import ( + "embed" + "io/fs" +) + +//go:embed all:static +var staticDir embed.FS + +// BuildDirFS contains the embedded dist directory files (without the "build" prefix) +var StaticDirFS, _ = fs.Sub(staticDir, "static") diff --git a/display/web/main.go b/display/web/main.go index b85a06b..02f88db 100644 --- a/display/web/main.go +++ b/display/web/main.go @@ -48,6 +48,12 @@ func StartWebServer(v string, port string) { return ctx.HTML(http.StatusOK, shared.SplashScreenTemplate) }) + staticGroup := e.Group("/static") + staticGroup.Use(middleware.StaticWithConfig(middleware.StaticConfig{ + Filesystem: http.FS(StaticDirFS), + HTML5: true, + })) + apiGroup := e.Group("/api") apiGroup.Use(middleware.CORS()) apiGroup.GET("/ping", pingRoute) diff --git a/display/web/main.templ b/display/web/main.templ index 9e82e3e..1885c95 100644 --- a/display/web/main.templ +++ b/display/web/main.templ @@ -7,8 +7,8 @@ templ indexTemplate() { PLG Connect Display - - + + ")}}function Zn(){const e=te().querySelector('meta[name="htmx-config"]');if(e){return v(e.content)}else{return null}}function Yn(){const e=Zn();if(e){Q.config=le(Q.config,e)}}Gn(function(){Yn();Wn();let e=te().body;Ft(e);const t=te().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.detail.elt||e.target;const n=oe(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){en();ie(t,function(e){ae(e,"htmx:restored",{document:te(),triggerEvent:ae})})}else{if(n){n(e)}}};b().setTimeout(function(){ae(e,"htmx:load",{});e=null},0)});return Q}(); \ No newline at end of file