almost there

This commit is contained in:
tavo 2025-06-30 23:51:37 -06:00
parent 72a0c64cd0
commit 513bcced9a
13 changed files with 146 additions and 11 deletions

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ go.work.sum
axiom axiom
db.db db.db
min/

40
Makefile Normal file
View file

@ -0,0 +1,40 @@
BIN = axiom
SRC = $(wildcard *.go)
GO = $(shell which go)
DOTENV = .env
-include $(DOTENV)
TEMPLATE_SRC = $(shell find templates -type f)
STATIC_SRC = $(shell find static -type f)
TEMPLATE_DST = min/views
STATIC_DST = min/static
all: $(BIN)
$(BIN): $(SRC) $(TEMPLATE_DST) $(STATIC_DST)
@echo "🔨 Building binary..."
@$(GO) build -o $(BIN)
$(TEMPLATE_DST): $(TEMPLATE_SRC) scripts/minify.go
@echo "🎨 Minifying templates..."
@$(GO) run scripts/minify.go -src=templates -dst=$(TEMPLATE_DST)
@touch $@
$(STATIC_DST): $(STATIC_SRC) scripts/minify.go
@echo "🎨 Minifying static files..."
@$(GO) run scripts/minify.go -src=static -dst=$(STATIC_DST)
@touch $@
run: $(BIN)
@PRODUCTION=${PRODUCTION} \
PORT=${PORT} \
APP_DATA_DIR=${APP_DATA_DIR} \
DB_CONNDVR=${DB_CONNDVR} \
DB_CONNSTR=${DB_CONNSTR} \
./$(BIN)
clean:
@echo "🧹 Cleaning..."
rm -rf $(BIN) $(TEMPLATE_DST) $(STATIC_DST)

View file

@ -5,23 +5,23 @@ import (
) )
var base = []string{ var base = []string{
"templates/baseof.html", "min/views/baseof.html",
"templates/_partials/head.html", "min/views/_partials/head.html",
"templates/_partials/header.html", "min/views/_partials/header.html",
"templates/_partials/footer.html", "min/views/_partials/footer.html",
} }
var ViewMap = map[string][]string{ var ViewMap = map[string][]string{
"login-page": append( "login-page": append(
base, base,
"templates/login.html", "min/views/login.html",
"templates/login-page.html", "min/views/login-page.html",
), ),
"index-page": append( "index-page": append(
base, base,
"templates/index.html", "min/views/index.html",
"templates/index-page.html", "min/views/index-page.html",
), ),
} }

View file

@ -16,10 +16,10 @@ import (
"git.tavo.one/tavo/axiom/views" "git.tavo.one/tavo/axiom/views"
) )
//go:embed static/* //go:embed min/static/*
var publicFS embed.FS var publicFS embed.FS
//go:embed templates/* //go:embed min/views/*
var viewFS embed.FS var viewFS embed.FS
func init() { func init() {
@ -65,7 +65,7 @@ func main() {
router := routes(handler) router := routes(handler)
staticFiles, err := fs.Sub(publicFS, "static") staticFiles, err := fs.Sub(publicFS, "min/static")
if err != nil { if err != nil {
log.Fatalf("failed to create static files filesystem: %v", err) log.Fatalf("failed to create static files filesystem: %v", err)
} }

14
static/icon.svg Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 320 320" xmlns="http://www.w3.org/2000/svg">
<g>
<circle cx="158.1" cy="160.38" r="59.521" fill="#56310c" stroke-width="1.0092"/>
<path d="m145.35 97.408s-11.795-14.459-12.556-38.43c-0.76099-23.971 13.317-24.732 17.122-39.572 3.805-14.839 4.1855-13.317 4.1855-13.317s17.883 32.342 21.308 48.704c3.4245 16.361-4.1855 57.075-9.893 35.767-5.7075-21.308-17.503-25.493-18.264-11.034s-1.9025 17.883-1.9025 17.883z" fill="#f2c31a"/>
<path d="m168.36 224.83s11.129 14.978 10.804 38.959c-0.32467 23.981-14.423 24.104-18.896 38.756-4.4727 14.652-4.7839 13.114-4.7839 13.114s-16.401-33.119-19.082-49.618c-2.6805-16.5 6.7642-56.827 11.502-35.283 4.7373 21.544 16.331 26.259 17.746 11.85 1.4146-14.41 2.7099-17.779 2.7099-17.779z" fill="#f2c31a"/>
<path d="m214.19 196.99s18.567 1.8607 36.076 18.252c17.509 16.391 8.1045 26.895 15.923 40.07 7.8187 13.174 6.4724 12.369 6.4724 12.369s-35.528-10.181-49.53-19.311c-14.002-9.1307-37.451-43.272-18.335-32.264 19.116 11.008 30.41 5.6129 20.711-5.1374-9.6991-10.75-11.317-13.977-11.317-13.977z" fill="#f2c31a"/>
<path d="m224.35 146.15s15.956-9.674 39.801-7.0997c23.845 2.5743 22.644 16.622 36.812 22.45 14.168 5.8283 12.607 5.9938 12.607 5.9938s-34.512 13.22-51.19 14.34c-16.678 1.1199-55.941-12.068-34.047-14.763 21.894-2.6941 27.676-13.794 13.463-16.555-14.213-2.7609-17.446-4.3668-17.446-4.3668z" fill="#f2c31a"/>
<path d="m197.71 104.33s4.6275-18.077 23.462-32.926c18.834-14.849 27.807-3.9741 42.006-9.7259 14.199-5.7519 13.2-4.5418 13.2-4.5418s-15.4 33.596-26.53 46.068c-11.13 12.472-48.405 30.529-34.651 13.283 13.753-17.247 10.116-29.222-1.9692-21.247-12.085 7.9749-15.518 9.0903-15.518 9.0903z" fill="#f2c31a"/>
<path d="m118.36 217.49s-4.9193 18-23.991 32.542c-19.072 14.542-27.868 3.5239-42.158 9.0453-14.29 5.5215-13.272 4.3277-13.272 4.3277s15.941-33.343 27.271-45.633c11.33-12.291 48.892-29.742 34.862-12.72-14.031 17.022-10.587 29.055 1.6254 21.277 12.212-7.7784 15.663-8.8382 15.663-8.8382z" fill="#f2c31a"/>
<path d="m102.89 123.2s-18.45-2.7882-35.116-20.035c-16.666-17.247-6.7473-27.268-13.896-40.817-7.1491-13.549-5.8448-12.677-5.8448-12.677s34.973 11.947 48.5 21.768c13.527 9.8205 35.237 45.093 16.696 33.142-18.541-11.951-30.091-7.1289-20.942 4.0936 9.1485 11.223 10.603 14.526 10.603 14.526z" fill="#f2c31a"/>
<path d="m91.664 173.68s-15.61 10.224-39.53 8.4825c-23.92-1.7417-23.21-15.823-37.572-21.154-14.362-5.331-12.809-5.5508-12.809-5.5508s34.03-14.415 50.66-16.115c16.629-1.7005 56.328 10.112 34.541 13.567-21.787 3.4555-27.179 14.75-12.878 17.014 14.301 2.2639 17.588 3.7561 17.588 3.7561z" fill="#f2c31a"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -0,0 +1,3 @@
{{ define "footer" }}
<p>Copyright &copy; 2025 Author</p>
{{ end }}

View file

@ -0,0 +1,8 @@
{{ define "head" }}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My App</title>
<link rel="canonical" href="/">
<link rel="icon" href="/s/icon.svg" type="image/x-icon">
<meta name="description" content="My App Description">
{{ end }}

View file

@ -0,0 +1,16 @@
{{ define "header" }}
<nav>
<div>
<img src="/s/icon.svg" style="padding: 0 0.2rem 0.2rem 0;" height="25rem" width="25rem"></img>
My App
<br>
<small>This is my App</small>
</div>
</nav>
<nav>
<ul>
<li><a href="/">App</a></li>
<li><a href="/login">Sign In</a></li>
</ul>
</nav>
{{ end }}

19
templates/baseof.html Normal file
View file

@ -0,0 +1,19 @@
{{ define "baseof" }}
<!DOCTYPE html>
<html lang="en">
<head>
{{ template "head" . }}
</head>
<body>
<header class="container">
{{ template "header" . }}
</header>
<main class="container">
{{ block "content" . }}{{ end }}
</main>
<footer class="container">
{{ template "footer" . }}
</footer>
</body>
</html>
{{ end }}

View file

@ -0,0 +1,3 @@
{{ define "content" }}
{{ template "index" . }}
{{ end }}

3
templates/index.html Normal file
View file

@ -0,0 +1,3 @@
{{ define "index" }}
<h1>Index</h1>
{{ end }}

View file

@ -0,0 +1,3 @@
{{ define "content" }}
{{ template "login" . }}
{{ end }}

25
templates/login.html Normal file
View file

@ -0,0 +1,25 @@
{{ define "login" }}
<form method="POST">
<label for="email">Email</label>
<input
id="email"
type="email"
name="email"
placeholder="user@example.com"
aria-label="Email"
autocomplete="email"
required
>
<label for="password">Password</label>
<input
id="password"
type="password"
name="password"
aria-label="Password"
required
>
<button type="submit">
Go
</button>
</form>
{{ end }}