Rework frontend asset structure

This commit is contained in:
Tom Wiesing 2023-01-04 12:57:59 +01:00
parent 11f7749c1d
commit bc0e92bdac
No known key found for this signature in database
50 changed files with 93 additions and 70 deletions

File diff suppressed because one or more lines are too long

View file

@ -12,7 +12,7 @@ import (
//go:embed "templates/home.html" //go:embed "templates/home.html"
var homeHTMLStr string var homeHTMLStr string
var homeTemplate = static.AssetsAuthHome.MustParseShared( var homeTemplate = static.AssetsHome.MustParseShared(
"home.html", "home.html",
homeHTMLStr, homeHTMLStr,
) )
@ -26,7 +26,7 @@ func (auth *Auth) authHome(ctx context.Context) http.Handler {
//go:embed "templates/password.html" //go:embed "templates/password.html"
var passwordHTMLString string var passwordHTMLString string
var passwordTemplate = static.AssetsAuthLogin.MustParseShared("password.html", passwordHTMLString) var passwordTemplate = static.AssetsUser.MustParseShared("password.html", passwordHTMLString)
var ( var (
errPasswordsNotIdentical = errors.New("passwords are not identical") errPasswordsNotIdentical = errors.New("passwords are not identical")

View file

@ -103,7 +103,7 @@ func (auth *Auth) Logout(w http.ResponseWriter, r *http.Request) error {
//go:embed "templates/login.html" //go:embed "templates/login.html"
var loginHTMLStr string var loginHTMLStr string
var loginTemplate = static.AssetsAuthLogin.MustParseShared("login.html", loginHTMLStr) var loginTemplate = static.AssetsUser.MustParseShared("login.html", loginHTMLStr)
var loginResponse = httpx.Response{ var loginResponse = httpx.Response{
ContentType: "text/plain", ContentType: "text/plain",

View file

@ -13,7 +13,7 @@ import (
//go:embed "templates/totp_enable.html" //go:embed "templates/totp_enable.html"
var totpEnableStr string var totpEnableStr string
var totpEnableTemplate = static.AssetsAuthLogin.MustParseShared("totp_enable.html", totpEnableStr) var totpEnableTemplate = static.AssetsUser.MustParseShared("totp_enable.html", totpEnableStr)
func (auth *Auth) authTOTPEnable(ctx context.Context) http.Handler { func (auth *Auth) authTOTPEnable(ctx context.Context) http.Handler {
return &httpx.Form[struct{}]{ return &httpx.Form[struct{}]{
@ -65,7 +65,7 @@ func (auth *Auth) authTOTPEnable(ctx context.Context) http.Handler {
//go:embed "templates/totp_enroll.html" //go:embed "templates/totp_enroll.html"
var totpEnrollStr string var totpEnrollStr string
var totpEnrollTemplate = static.AssetsAuthLogin.MustParseShared("totp_enroll.html", totpEnrollStr) var totpEnrollTemplate = static.AssetsUser.MustParseShared("totp_enroll.html", totpEnrollStr)
type totpEnrollContext struct { type totpEnrollContext struct {
userFormContext userFormContext
@ -142,7 +142,7 @@ func (auth *Auth) authTOTPEnroll(ctx context.Context) http.Handler {
//go:embed "templates/totp_disable.html" //go:embed "templates/totp_disable.html"
var totpDisableStr string var totpDisableStr string
var totpDisableTemplate = static.AssetsAuthLogin.MustParseShared("totp_disable.html", totpDisableStr) var totpDisableTemplate = static.AssetsUser.MustParseShared("totp_disable.html", totpDisableStr)
func (auth *Auth) authTOTPDisable(ctx context.Context) http.Handler { func (auth *Auth) authTOTPDisable(ctx context.Context) http.Handler {
return &httpx.Form[struct{}]{ return &httpx.Form[struct{}]{

View file

@ -16,7 +16,7 @@ import (
//go:embed "html/components.html" //go:embed "html/components.html"
var componentsTemplateString string var componentsTemplateString string
var componentsTemplate = static.AssetsComponentsIndex.MustParseShared( var componentsTemplate = static.AssetsAdmin.MustParseShared(
"components.html", "components.html",
componentsTemplateString, componentsTemplateString,
) )
@ -36,7 +36,7 @@ func (admin *Admin) components(r *http.Request) (cp componentContext, err error)
//go:embed "html/ingredients.html" //go:embed "html/ingredients.html"
var ingredientsTemplateString string var ingredientsTemplateString string
var ingredientsTemplate = static.AssetsInstanceComponentsIndex.MustParseShared( var ingredientsTemplate = static.AssetsAdmin.MustParseShared(
"ingredients.html", "ingredients.html",
ingredientsTemplateString, ingredientsTemplateString,
) )

View file

@ -15,7 +15,7 @@ import (
//go:embed "html/index.html" //go:embed "html/index.html"
var indexTemplateStr string var indexTemplateStr string
var indexTemplate = static.AssetsControlIndex.MustParseShared( var indexTemplate = static.AssetsAdmin.MustParseShared(
"index.html", "index.html",
indexTemplateStr, indexTemplateStr,
) )

View file

@ -15,7 +15,7 @@ import (
//go:embed "html/instance.html" //go:embed "html/instance.html"
var instanceTemplateString string var instanceTemplateString string
var instanceTemplate = static.AssetsControlInstance.MustParseShared( var instanceTemplate = static.AssetsAdmin.MustParseShared(
"instance.html", "instance.html",
instanceTemplateString, instanceTemplateString,
) )

View file

@ -27,7 +27,7 @@ func (home *Home) instanceMap(ctx context.Context) (map[string]struct{}, error)
//go:embed "home.html" //go:embed "home.html"
var homeHTMLStr string var homeHTMLStr string
var homeTemplate = static.AssetsHomeHome.MustParseShared("home.html", homeHTMLStr) var homeTemplate = static.AssetsHome.MustParseShared("home.html", homeHTMLStr)
func (home *Home) homeRender(ctx context.Context) ([]byte, error) { func (home *Home) homeRender(ctx context.Context) ([]byte, error) {
var context HomeContext var context HomeContext

View file

@ -21,7 +21,7 @@ type Assets struct {
Styles string // <link> tags inserted by the asset Styles string // <link> tags inserted by the asset
} }
//go:generate node build.mjs HomeHome ComponentsIndex ControlIndex ControlInstance InstanceComponentsIndex AuthLogin AuthHome AuthTOTP //go:generate node build.mjs Home User Admin
// MustParse parses a new template from the given source // MustParse parses a new template from the given source
// and calls [RegisterAssoc] on it. // and calls [RegisterAssoc] on it.

View file

@ -2,50 +2,20 @@ package static
// This file was automatically generated. Do not edit. // This file was automatically generated. Do not edit.
// AssetsHomeHome contains assets for the 'HomeHome' entrypoint. // AssetsHome contains assets for the 'Home' entrypoint.
var AssetsHomeHome = Assets{ var AssetsHome = Assets{
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script>`, Scripts: `<script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/HomeHome.4ec77c43.css"><link rel="stylesheet" href="/static/HomeHome.2353e048.css">`, Styles: `<link rel="stylesheet" href="/static/Home.4ec77c43.css"><link rel="stylesheet" href="/static/Home.2353e048.css">`,
} }
// AssetsComponentsIndex contains assets for the 'ComponentsIndex' entrypoint. // AssetsUser contains assets for the 'User' entrypoint.
var AssetsComponentsIndex = Assets{ var AssetsUser = Assets{
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/ComponentsIndex.38d394c2.js"></script><script src="/static/ComponentsIndex.38d394c2.js" nomodule="" defer></script>`, Scripts: `<script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/User.4197014b.js"></script><script src="/static/User.30d54198.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/HomeHome.4ec77c43.css"><link rel="stylesheet" href="/static/ComponentsIndex.38d394c2.css">`, Styles: `<link rel="stylesheet" href="/static/Home.4ec77c43.css"><link rel="stylesheet" href="/static/User.38d394c2.css">`,
} }
// AssetsControlIndex contains assets for the 'ControlIndex' entrypoint. // AssetsAdmin contains assets for the 'Admin' entrypoint.
var AssetsControlIndex = Assets{ var AssetsAdmin = Assets{
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/ControlIndex.a72fc239.js"></script><script src="/static/ControlIndex.75d2a312.js" nomodule="" defer></script>`, Scripts: `<script nomodule="" defer src="/static/User.30d54198.js"></script><script type="module" src="/static/User.4197014b.js"></script><script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/Admin.4ca3cb6f.js"></script><script src="/static/Admin.9750ba9c.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/HomeHome.4ec77c43.css"><link rel="stylesheet" href="/static/ControlIndex.6d59e220.css"><link rel="stylesheet" href="/static/ControlIndex.6d2ae968.css">`, Styles: `<link rel="stylesheet" href="/static/Home.4ec77c43.css"><link rel="stylesheet" href="/static/Admin.6d59e220.css"><link rel="stylesheet" href="/static/User.38d394c2.css"><link rel="stylesheet" href="/static/Admin.6d2ae968.css">`,
}
// AssetsControlInstance contains assets for the 'ControlInstance' entrypoint.
var AssetsControlInstance = Assets{
Scripts: `<script nomodule="" defer src="/static/ControlIndex.75d2a312.js"></script><script type="module" src="/static/ControlIndex.a72fc239.js"></script><script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/ControlInstance.66b95713.js"></script><script src="/static/ControlInstance.9cc7166d.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/HomeHome.4ec77c43.css"><link rel="stylesheet" href="/static/ControlIndex.6d59e220.css"><link rel="stylesheet" href="/static/ControlIndex.6d2ae968.css"><link rel="stylesheet" href="/static/ControlInstance.38d394c2.css">`,
}
// AssetsInstanceComponentsIndex contains assets for the 'InstanceComponentsIndex' entrypoint.
var AssetsInstanceComponentsIndex = Assets{
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/InstanceComponentsIndex.38d394c2.js"></script><script src="/static/InstanceComponentsIndex.38d394c2.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/HomeHome.4ec77c43.css"><link rel="stylesheet" href="/static/InstanceComponentsIndex.38d394c2.css">`,
}
// AssetsAuthLogin contains assets for the 'AuthLogin' entrypoint.
var AssetsAuthLogin = Assets{
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/AuthLogin.38d394c2.js"></script><script src="/static/AuthLogin.38d394c2.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/HomeHome.4ec77c43.css"><link rel="stylesheet" href="/static/AuthLogin.38d394c2.css">`,
}
// AssetsAuthHome contains assets for the 'AuthHome' entrypoint.
var AssetsAuthHome = Assets{
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/AuthHome.38d394c2.js"></script><script src="/static/AuthHome.38d394c2.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/HomeHome.4ec77c43.css"><link rel="stylesheet" href="/static/AuthHome.38d394c2.css">`,
}
// AssetsAuthTOTP contains assets for the 'AuthTOTP' entrypoint.
var AssetsAuthTOTP = Assets{
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/AuthTOTP.38d394c2.js"></script><script src="/static/AuthTOTP.38d394c2.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/HomeHome.4ec77c43.css"><link rel="stylesheet" href="/static/AuthTOTP.38d394c2.css">`,
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
!function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},n={},o={},r=e.parcelRequireafa4;null==r&&((r=function(e){if(e in n)return n[e].exports;if(e in o){var r=o[e];delete o[e];var i={id:e,exports:{}};return n[e]=i,r.call(i.exports,i,i.exports),i.exports}var f=new Error("Cannot find module '"+e+"'");throw f.code="MODULE_NOT_FOUND",f}).register=function(e,n){o[e]=n},e.parcelRequireafa4=r),r("8s4Fe")}();

View file

@ -0,0 +1 @@
!function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},n={},r={},o=e.parcelRequireafa4;null==o&&((o=function(e){if(e in n)return n[e].exports;if(e in r){var o=r[e];delete r[e];var i={id:e,exports:{}};return n[e]=i,o.call(i.exports,i,i.exports),i.exports}var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}).register=function(e,n){r[e]=n},e.parcelRequireafa4=o),o.register("kEAtK",(function(e,n){})),o("kEAtK")}();

View file

@ -1 +1 @@
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},n={},r={},o=e.parcelRequireafa4;null==o&&((o=function(e){if(e in n)return n[e].exports;if(e in r){var o=r[e];delete r[e];var i={id:e,exports:{}};return n[e]=i,o.call(i.exports,i,i.exports),i.exports}var l=new Error("Cannot find module '"+e+"'");throw l.code="MODULE_NOT_FOUND",l}).register=function(e,n){r[e]=n},e.parcelRequireafa4=o),o("gJkWt"); var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},n={},r={},o=e.parcelRequireafa4;null==o&&((o=function(e){if(e in n)return n[e].exports;if(e in r){var o=r[e];delete r[e];var i={id:e,exports:{}};return n[e]=i,o.call(i.exports,i,i.exports),i.exports}var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}).register=function(e,n){r[e]=n},e.parcelRequireafa4=o),o.register("gkpdw",(function(e,n){})),o("gkpdw");

View file

@ -0,0 +1,6 @@
import "~/src/lib/remote"
import "~/src/lib/highlight"
// include the user styles!
import "../User/index.ts"
import "../User/index.css"

View file

@ -1 +0,0 @@
/* nothing for now */

View file

@ -1 +0,0 @@
// nothing for now

View file

@ -1 +0,0 @@
/* nothing for now */

View file

@ -1 +0,0 @@
// nothing for now

View file

@ -1,2 +0,0 @@
import "~/src/lib/remote"
import "~/src/lib/highlight"

View file

@ -1 +0,0 @@
@import url("../ControlIndex/index.css")

View file

@ -1 +0,0 @@
import "../ControlIndex/index"