diff --git a/.gitignore b/.gitignore index ca77a4b..44ab167 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ go.work.sum axiom db.db +min/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a05d653 --- /dev/null +++ b/Makefile @@ -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) diff --git a/config/config.go b/config/config.go index 906ae13..1d37b5e 100644 --- a/config/config.go +++ b/config/config.go @@ -5,23 +5,23 @@ import ( ) var base = []string{ - "templates/baseof.html", - "templates/_partials/head.html", - "templates/_partials/header.html", - "templates/_partials/footer.html", + "min/views/baseof.html", + "min/views/_partials/head.html", + "min/views/_partials/header.html", + "min/views/_partials/footer.html", } var ViewMap = map[string][]string{ "login-page": append( base, - "templates/login.html", - "templates/login-page.html", + "min/views/login.html", + "min/views/login-page.html", ), "index-page": append( base, - "templates/index.html", - "templates/index-page.html", + "min/views/index.html", + "min/views/index-page.html", ), } diff --git a/main.go b/main.go index 7d4d3c5..5167a7f 100644 --- a/main.go +++ b/main.go @@ -16,10 +16,10 @@ import ( "git.tavo.one/tavo/axiom/views" ) -//go:embed static/* +//go:embed min/static/* var publicFS embed.FS -//go:embed templates/* +//go:embed min/views/* var viewFS embed.FS func init() { @@ -65,7 +65,7 @@ func main() { router := routes(handler) - staticFiles, err := fs.Sub(publicFS, "static") + staticFiles, err := fs.Sub(publicFS, "min/static") if err != nil { log.Fatalf("failed to create static files filesystem: %v", err) } diff --git a/static/icon.svg b/static/icon.svg new file mode 100644 index 0000000..ff0fcf2 --- /dev/null +++ b/static/icon.svg @@ -0,0 +1,14 @@ + + diff --git a/templates/_partials/footer.html b/templates/_partials/footer.html new file mode 100644 index 0000000..aede37b --- /dev/null +++ b/templates/_partials/footer.html @@ -0,0 +1,3 @@ +{{ define "footer" }} +
Copyright © 2025 Author
+{{ end }} diff --git a/templates/_partials/head.html b/templates/_partials/head.html new file mode 100644 index 0000000..5cf29ca --- /dev/null +++ b/templates/_partials/head.html @@ -0,0 +1,8 @@ +{{ define "head" }} + + +