First go at it :) #1

Merged
atridad merged 12 commits from dev into main 2026-05-02 02:01:53 -06:00
5 changed files with 62 additions and 4 deletions
Showing only changes of commit 73aff92505 - Show all commits
+1
View File
@@ -0,0 +1 @@
use flake
+13
View File
@@ -0,0 +1,13 @@
.PHONY: dev build clean
# Run the development server
dev:
go run main.go
# Build the standalone binary
build:
go build -o sprintpadawan main.go
# Clean the compiled binary
clean:
rm -f sprintpadawan
+3 -3
View File
@@ -4,16 +4,16 @@ import (
"context"
"fmt"
"html/template"
"io/fs"
"log"
"net/http"
"path/filepath"
"sprintpadawan/lib"
)
var templates *template.Template
func init() {
func InitTemplates(fsys fs.FS) {
templates = template.Must(template.New("").Funcs(template.FuncMap{
"scaleToOptions": scaleToOptions,
"derefInt": func(i *int) int {
@@ -51,7 +51,7 @@ func init() {
}
return d, nil
},
}).ParseGlob(filepath.Join("templates", "*.html")))
}).ParseFS(fsys, "templates/*.html"))
}
func isHTMX(r *http.Request) bool {
+39
View File
@@ -0,0 +1,39 @@
{
description = "SprintPadawan Go 1.26 development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.go
pkgs.gopls
pkgs.gotools
pkgs.go-tools
pkgs.gnumake
];
shellHook = ''
echo "SprintPadawan Dev Environment Loaded"
go version
'';
};
}
);
}
+6 -1
View File
@@ -1,6 +1,7 @@
package main
import (
"embed"
"log"
"net/http"
@@ -8,13 +9,17 @@ import (
"sprintpadawan/lib"
)
//go:embed static templates
var embeddedFiles embed.FS
func main() {
lib.InitDB()
api.InitTemplates(embeddedFiles)
mux := http.NewServeMux()
// serve static assets
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
mux.Handle("/static/", http.FileServer(http.FS(embeddedFiles)))
api.SetupRoutes(mux)