Skip to content
Snippets Groups Projects
Commit 052ff219 authored by ForkBench's avatar ForkBench
Browse files

Modifying taskfile, adding template : base Templ working

parent 14810e58
No related branches found
No related tags found
No related merge requests found
...@@ -47,3 +47,5 @@ __sapper__/ ...@@ -47,3 +47,5 @@ __sapper__/
frontend/dist frontend/dist
*.bak *.bak
*_templ.go
*.out.css
\ No newline at end of file
...@@ -380,6 +380,7 @@ tasks: ...@@ -380,6 +380,7 @@ tasks:
vars: vars:
BUILD_FLAGS: "{{.BUILD_FLAGS}}" BUILD_FLAGS: "{{.BUILD_FLAGS}}"
cmds: cmds:
- templ generate
- bun run build - bun run build
generate:bindings: generate:bindings:
...@@ -434,6 +435,7 @@ tasks: ...@@ -434,6 +435,7 @@ tasks:
dev: dev:
summary: Runs the application in development mode summary: Runs the application in development mode
cmds: cmds:
- task: build:frontend
- wails3 dev -config ./build/devmode.config.yaml -port {{.VITE_PORT}} - wails3 dev -config ./build/devmode.config.yaml -port {{.VITE_PORT}}
dev:reload: dev:reload:
......
package main package main
import ( import (
"net/http" "github.com/a-h/templ"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5/middleware"
) )
func NewChiRouter() { func NewChiRouter() *chi.Mux {
r := chi.NewRouter() r := chi.NewRouter()
r.Use(middleware.Logger) r.Use(middleware.Logger)
r.Use(middleware.Recoverer) r.Use(middleware.Recoverer)
r.Get("/", func(w http.ResponseWriter, r *http.Request) { r.Get("/test", templ.Handler(Hello()).ServeHTTP)
w.Write([]byte("hello world"))
}) return r
} }
<!DOCTYPE html> <html
<html lang="en"> class="font-[Inter,_Avenir,_Helvetica,_Arial,_sans-serif] text-[16px] leading-[24px] font-normal [color-scheme:light_dark] text-[rgba(255,_255,_255,_0.87)] bg-[#242424] antialiased"
lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AstroProject</title> <script src="https://unpkg.com/htmx.org"></script>
<link rel="stylesheet" href="/index.css" />
<title>Wails</title>
</head> </head>
<body> <body class="m-0 flex place-items-center min-w-[320px] min-h-screen">
<div id="app"></div> <!-- On load, get /test and replace the content of the div with the response -->
<div id="me" hx-get="/test" hx-trigger="load" hx-target="#me" hx-swap="outerHTML"></div>
</body> </body>
</html> </html>
\ No newline at end of file
import type { Nation } from "../bindings/changeme/astro/services/models";
export function randomColor(brightness: number): string {
function randomChannel(brightness: number): string {
var r = 255-brightness;
var n = 0|((Math.random() * r) + brightness);
var s = n.toString(16);
return (s.length==1) ? '0'+s : s;
}
return '#' + randomChannel(brightness) + randomChannel(brightness) + randomChannel(brightness);
}
export const rightBrighness = 240;
export function getNationFlag(nation: Nation | null): string {
if (!nation) {
return "https://flagsapi.com/FR/flat/64.png";
}
console.log(`"${nation.nation_code}"`);
return `https://flagsapi.com/${nation.nation_code}/flat/64.png`
}
export function getNationFlatAlt(nation: Nation | null): string {
if (!nation) {
return "FR";
}
return nation.nation_code;
}
\ No newline at end of file
/// <reference types="svelte" />
/// <reference types="vite/client" />
...@@ -3,6 +3,7 @@ module changeme ...@@ -3,6 +3,7 @@ module changeme
go 1.22.4 go 1.22.4
require ( require (
github.com/a-h/templ v0.2.747
github.com/go-chi/chi/v5 v5.1.0 github.com/go-chi/chi/v5 v5.1.0
github.com/go-faker/faker/v4 v4.4.2 github.com/go-faker/faker/v4 v4.4.2
github.com/wailsapp/wails/v3 v3.0.0-alpha.0 github.com/wailsapp/wails/v3 v3.0.0-alpha.0
......
...@@ -5,6 +5,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc ...@@ -5,6 +5,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/a-h/templ v0.2.747 h1:D0dQ2lxC3W7Dxl6fxQ/1zZHBQslSkTSvl5FxP/CfdKg=
github.com/a-h/templ v0.2.747/go.mod h1:69ObQIbrcuwPCU32ohNaWce3Cb7qM5GMiqN1K+2yop4=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
......
package main
templ Hello() {
<div>Hello</div>
}
...@@ -3,6 +3,7 @@ package main ...@@ -3,6 +3,7 @@ package main
import ( import (
"embed" "embed"
"log" "log"
"net/http"
"github.com/wailsapp/wails/v3/pkg/application" "github.com/wailsapp/wails/v3/pkg/application"
...@@ -13,7 +14,7 @@ var assets embed.FS ...@@ -13,7 +14,7 @@ var assets embed.FS
func main() { func main() {
NewChiRouter() r := NewChiRouter()
session := services.Session{} session := services.Session{}
...@@ -29,6 +30,10 @@ func main() { ...@@ -29,6 +30,10 @@ func main() {
}, },
Assets: application.AssetOptions{ Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(assets), Handler: application.AssetFileServerFS(assets),
Middleware: func(next http.Handler) http.Handler {
r.NotFound(next.ServeHTTP)
return r
},
}, },
Mac: application.MacOptions{ Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true, ApplicationShouldTerminateAfterLastWindowClosed: true,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment