Skip to content

Commit

Permalink
refactor: move nebula assets to hway build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
prnk28 committed Oct 9, 2024
1 parent a3edb65 commit 5df9d4a
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 213 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ gen-pkl:
### motr, hway & nebula ###
###############################################################################

.PHONY: build-motr build-hway build-nebula
.PHONY: motr-build hway-build nebula-build nebula-copy

hway-build: gen-templ
hway-build: nebula-build nebula-copy gen-templ
@echo "(motr) Building Highway gateway"
GOOS=js GOARCH=wasm go build -o ./cmd/hway/build/app.wasm ./cmd/hway/server.go

Expand All @@ -329,6 +329,10 @@ 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 ###
Expand Down
1 change: 0 additions & 1 deletion cmd/hway/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
func main() {
s := echo.New()
s.Use(ctx.UseSession)

s.GET("/", routes.Home)
s.GET("/login", routes.LoginStart)
s.GET("/register", routes.RegisterStart)
Expand Down
53 changes: 12 additions & 41 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,18 @@
},
"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"
],
"gen:proto": [
"rm -rf ./pkg/nebula/node_modules",
"make proto-gen"
],
"gen:pkl": [
"make gen-pkl"
],
"gen:templ": [
"make gen-templ"
],
"start": [
"process-compose up -f ./deploy/process-compose.yaml"
],
"stop": [
"process-compose down -f ./deploy/process-compose.yaml"
],
"start:testnet": [
"make sh-testnet"
]
"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"],
"gen:proto": ["rm -rf ./pkg/nebula/node_modules", "make proto-gen"],
"gen:pkl": ["make gen-pkl"],
"gen:templ": ["make gen-templ"],
"start": ["process-compose up -f ./deploy/process-compose.yaml"],
"stop": ["process-compose down -f ./deploy/process-compose.yaml"],
"start:testnet": ["make sh-testnet"]
}
}
}
16 changes: 4 additions & 12 deletions pkg/nebula/assets/scripts.templ
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,17 @@ var (
)

templ Styles() {
@stylesHandle.Once() {
<link href={ "https://cdn.sonr.id/css/styles.css" } rel="stylesheet"/>
}
<link href={ "/css/styles.css" } rel="stylesheet"/>
}

templ Alpine() {
@alpineHandle.Once() {
<script src={ "https://cdn.sonr.id/js/alpine.min.js" } defer></script>
}
<script src={ "/js/alpine.min.js" } defer></script>
}

templ Dexie() {
@dexieHandle.Once() {
<script src={ "https://cdn.sonr.id/js/dexie.min.js" }></script>
}
<script src={ "/js/dexie.min.js" }></script>
}

templ Htmx() {
@htmxHandle.Once() {
<script src={ "https://cdn.sonr.id/js/htmx.min.js" }></script>
}
<script src={ "/js/htmx.min.js" }></script>
}
194 changes: 61 additions & 133 deletions pkg/nebula/assets/scripts_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/nebula/global/styles/layout.templ
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ templ Layout(title string, remote bool) {
<!DOCTYPE html>
<html lang="en">
<head>
@cdn.Alpine()
@cdn.Htmx()
@cdn.Styles()
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
Expand All @@ -49,6 +47,8 @@ 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>
}
Expand All @@ -57,8 +57,6 @@ templ LayoutNoBody(title string, remote bool) {
<!DOCTYPE html>
<html lang="en">
<head>
@cdn.Alpine()
@cdn.Htmx()
@cdn.Styles()
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
Expand All @@ -74,6 +72,8 @@ 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>
Expand Down
Loading

0 comments on commit 5df9d4a

Please sign in to comment.