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
Branches
No related tags found
No related merge requests found
......@@ -46,4 +46,6 @@ __sapper__/
# Frontend specific
frontend/dist
*.bak
\ No newline at end of file
*.bak
*_templ.go
*.out.css
\ No newline at end of file
......@@ -380,6 +380,7 @@ tasks:
vars:
BUILD_FLAGS: "{{.BUILD_FLAGS}}"
cmds:
- templ generate
- bun run build
generate:bindings:
......@@ -434,6 +435,7 @@ tasks:
dev:
summary: Runs the application in development mode
cmds:
- task: build:frontend
- wails3 dev -config ./build/devmode.config.yaml -port {{.VITE_PORT}}
dev:reload:
......
package main
import (
"net/http"
"github.com/a-h/templ"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
func NewChiRouter() {
func NewChiRouter() *chi.Mux {
r := chi.NewRouter()
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello world"))
})
r.Get("/test", templ.Handler(Hello()).ServeHTTP)
return r
}
<!DOCTYPE html>
<html lang="en">
<html
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>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AstroProject</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://unpkg.com/htmx.org"></script>
<link rel="stylesheet" href="/index.css" />
<title>Wails</title>
</head>
<body>
<div id="app"></div>
<body class="m-0 flex place-items-center min-w-[320px] min-h-screen">
<!-- 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>
</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" />
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./index.html"],
content: [ "./index.html"],
theme: {
extend: {},
},
......
......@@ -3,6 +3,7 @@ module changeme
go 1.22.4
require (
github.com/a-h/templ v0.2.747
github.com/go-chi/chi/v5 v5.1.0
github.com/go-faker/faker/v4 v4.4.2
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
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/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/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
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
import (
"embed"
"log"
"net/http"
"github.com/wailsapp/wails/v3/pkg/application"
......@@ -13,7 +14,7 @@ var assets embed.FS
func main() {
NewChiRouter()
r := NewChiRouter()
session := services.Session{}
......@@ -29,6 +30,10 @@ func main() {
},
Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(assets),
Middleware: func(next http.Handler) http.Handler {
r.NotFound(next.ServeHTTP)
return r
},
},
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment