mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
feat: nebula assets served from CDN
This commit is contained in:
parent
5df9d4a3e5
commit
58a02be5cf
25
Makefile
25
Makefile
@ -313,7 +313,17 @@ gen-pkl:
|
||||
|
||||
.PHONY: motr-build hway-build nebula-build nebula-copy
|
||||
|
||||
hway-build: nebula-build nebula-copy gen-templ
|
||||
nebula-build:
|
||||
@echo "(nebula) Building nebula"
|
||||
cd pkg/nebula && bun install && bun run build
|
||||
@echo "(nebula) Copying assets to hway"
|
||||
cp -r pkg/nebula/assets/js pkg/nebula/assets/css cmd/hway/build
|
||||
|
||||
motr-build: gen-templ gen-pkl
|
||||
@echo "(dwn) Building motr.wasm -> Service Worker IPFS Vault"
|
||||
GOOS=js GOARCH=wasm go build -o ./pkg/dwn/app.wasm ./cmd/motr/main.go
|
||||
|
||||
hway-build: nebula-build gen-templ
|
||||
@echo "(motr) Building Highway gateway"
|
||||
GOOS=js GOARCH=wasm go build -o ./cmd/hway/build/app.wasm ./cmd/hway/server.go
|
||||
|
||||
@ -321,19 +331,6 @@ hway-dev:
|
||||
@echo "(motr) Deploying Highway gateway"
|
||||
cd cmd/hway && bun run dev
|
||||
|
||||
motr-build: gen-templ gen-pkl
|
||||
@echo "(dwn) Building motr.wasm -> Service Worker IPFS Vault"
|
||||
GOOS=js GOARCH=wasm go build -o ./pkg/dwn/app.wasm ./cmd/motr/main.go
|
||||
|
||||
nebula-build:
|
||||
@echo "(nebula) Building nebula"
|
||||
cd pkg/nebula && bun install && bun run build
|
||||
|
||||
nebula-copy:
|
||||
@echo "(nebula) Copying assets to hway"
|
||||
cp -r pkg/nebula/assets/js pkg/nebula/assets/css cmd/hway/build
|
||||
|
||||
|
||||
###############################################################################
|
||||
### help ###
|
||||
###############################################################################
|
||||
|
@ -5,6 +5,7 @@ package main
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/ctx"
|
||||
"github.com/onsonr/sonr/pkg/nebula"
|
||||
"github.com/onsonr/sonr/pkg/nebula/routes"
|
||||
"github.com/syumai/workers"
|
||||
)
|
||||
@ -12,6 +13,7 @@ import (
|
||||
func main() {
|
||||
s := echo.New()
|
||||
s.Use(ctx.UseSession)
|
||||
nebula.UseAssets(s)
|
||||
s.GET("/", routes.Home)
|
||||
s.GET("/login", routes.LoginStart)
|
||||
s.GET("/register", routes.RegisterStart)
|
||||
|
10
devbox.json
10
devbox.json
@ -32,11 +32,11 @@
|
||||
"shell": {
|
||||
"scripts": {
|
||||
"build:docker": ["make local-image"],
|
||||
"build:hway": ["make build-nebula", "make build-hway"],
|
||||
"build:nebula": ["make build-nebula"],
|
||||
"build:motr": ["make build-motr"],
|
||||
"build:sonrd": ["make build-motr", "make build"],
|
||||
"build": ["make build-motr", "make build", "make build-hway"],
|
||||
"build:hway": ["make hway-build"],
|
||||
"build:nebula": ["make nebula-build"],
|
||||
"build:motr": ["make motr-build"],
|
||||
"build:sonrd": ["make motr-build", "make build"],
|
||||
"build": ["make motr-build", "make build", "make hway-build"],
|
||||
"gen:proto": ["rm -rf ./pkg/nebula/node_modules", "make proto-gen"],
|
||||
"gen:pkl": ["make gen-pkl"],
|
||||
"gen:templ": ["make gen-templ"],
|
||||
|
@ -1 +0,0 @@
|
||||
package idpvr
|
@ -1 +0,0 @@
|
||||
package idpvr
|
@ -12,17 +12,17 @@ var (
|
||||
)
|
||||
|
||||
templ Styles() {
|
||||
<link href={ "/css/styles.css" } rel="stylesheet"/>
|
||||
<link href={ "https://cdn.sonr.id/css/styles.css" } rel="stylesheet"/>
|
||||
}
|
||||
|
||||
templ Alpine() {
|
||||
<script src={ "/js/alpine.min.js" } defer></script>
|
||||
<script src={ "https://cdn.sonr.id/js/alpine.min.js" } defer></script>
|
||||
}
|
||||
|
||||
templ Dexie() {
|
||||
<script src={ "/js/dexie.min.js" }></script>
|
||||
<script src={ "https://cdn.sonr.id/js/dexie.min.js" }></script>
|
||||
}
|
||||
|
||||
templ Htmx() {
|
||||
<script src={ "/js/htmx.min.js" }></script>
|
||||
<script src={ "https://cdn.sonr.id/js/htmx.min.js" }></script>
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ func Styles() templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs("/css/styles.css")
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs("https://cdn.sonr.id/css/styles.css")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 15, Col: 31}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 15, Col: 50}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -87,9 +87,9 @@ func Alpine() templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs("/js/alpine.min.js")
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs("https://cdn.sonr.id/js/alpine.min.js")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 19, Col: 34}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 19, Col: 53}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -129,9 +129,9 @@ func Dexie() templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs("/js/dexie.min.js")
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs("https://cdn.sonr.id/js/dexie.min.js")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 23, Col: 33}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 23, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -171,9 +171,9 @@ func Htmx() templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs("/js/htmx.min.js")
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs("https://cdn.sonr.id/js/htmx.min.js")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 27, Col: 32}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/assets/scripts.templ`, Line: 27, Col: 51}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
@ -34,6 +34,8 @@ templ Layout(title string, remote bool) {
|
||||
<html lang="en">
|
||||
<head>
|
||||
@cdn.Styles()
|
||||
@cdn.Htmx()
|
||||
@cdn.Alpine()
|
||||
<meta charset="UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
@ -47,8 +49,6 @@ templ Layout(title string, remote bool) {
|
||||
<main class="flex-row items-center justify-center mx-auto w-fit max-w-screen-sm gap-y-3">
|
||||
{ children... }
|
||||
</main>
|
||||
@cdn.Alpine()
|
||||
@cdn.Htmx()
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
@ -58,6 +58,8 @@ templ LayoutNoBody(title string, remote bool) {
|
||||
<html lang="en">
|
||||
<head>
|
||||
@cdn.Styles()
|
||||
@cdn.Htmx()
|
||||
@cdn.Alpine()
|
||||
<meta charset="UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
@ -72,8 +74,6 @@ templ LayoutNoBody(title string, remote bool) {
|
||||
<div class="flex flex-col min-h-screen overflow-hidden supports-[overflow:clip]:overflow-clip">
|
||||
{ children... }
|
||||
</div>
|
||||
@cdn.Alpine()
|
||||
@cdn.Htmx()
|
||||
</body>
|
||||
</main>
|
||||
</html>
|
||||
|
@ -153,6 +153,14 @@ func Layout(title string, remote bool) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<meta charset=\"UTF-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
@ -160,7 +168,7 @@ func Layout(title string, remote bool) templ.Component {
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/styles/layout.templ`, Line: 40, Col: 17}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/styles/layout.templ`, Line: 42, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -174,19 +182,7 @@ func Layout(title string, remote bool) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</body></html>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</main></body></html>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@ -223,6 +219,14 @@ func LayoutNoBody(title string, remote bool) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<meta charset=\"UTF-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
@ -230,7 +234,7 @@ func LayoutNoBody(title string, remote bool) templ.Component {
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/styles/layout.templ`, Line: 64, Col: 17}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/global/styles/layout.templ`, Line: 66, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -244,19 +248,7 @@ func LayoutNoBody(title string, remote bool) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</body></main></html>")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></body></main></html>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user