diff --git a/Caddyfile b/bank/Caddyfile similarity index 100% rename from Caddyfile rename to bank/Caddyfile diff --git a/README.md b/bank/README.md similarity index 100% rename from README.md rename to bank/README.md diff --git a/bank/build.sh b/bank/build.sh new file mode 100644 index 0000000..ae91220 --- /dev/null +++ b/bank/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# SecureBank - Build Script +# Ustvari standalone izvršilne datoteke z vključenimi resources + +echo "🏗️ SecureBank - Build processo" +echo "================================" + +# Preveri če obstajajo potrebni direktoriji +if [ ! -d "templates" ] || [ ! -d "static" ]; then + echo "❌ Napaka: Manjkajo templates/ vagy static/ direktoriji!" + echo " Poženite script iz /bank direktorija" + exit 1 +fi + +# Ustvari build direktorij +mkdir -p dist + +echo "📦 Building za Linux (amd64)..." +GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/securebank-linux ./ +echo "✅ Linux binary: dist/securebank-linux" + +echo "📦 Building za Windows (amd64)..." +GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/securebank-windows.exe ./ +echo "✅ Windows binary: dist/securebank-windows.exe" + +echo "📦 Building za macOS (amd64)..." +GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/securebank-macos ./ +echo "✅ macOS binary: dist/securebank-macos" + +echo "📦 Building za macOS (ARM64 - M1/M2)..." +GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o dist/securebank-macos-arm64 ./ +echo "✅ macOS ARM binary: dist/securebank-macos-arm64" + +echo "" +echo "🎉 Build process končan!" +echo "" +echo "📁 Izvršilne datoteke v dist/ direktoriju:" +ls -la dist/ +echo "" +echo "🚀 Testiranje:" +echo " ./dist/securebank-linux -port 8080" +echo "" +echo "📋 Opozorilo:" +echo " - Vsi HTML, CSS in JS fajli so vključeni v binary" +echo " - Binary lahko kopirate kjerkoli - ne potrebuje dodatnih datotek" +echo " - Za deployment samo kopirajte binary datoteko" \ No newline at end of file diff --git a/bank/dist/securebank-embedded b/bank/dist/securebank-embedded new file mode 100755 index 0000000..07fee85 Binary files /dev/null and b/bank/dist/securebank-embedded differ diff --git a/bank/dist/securebank-windows.exe b/bank/dist/securebank-windows.exe new file mode 100755 index 0000000..e950063 Binary files /dev/null and b/bank/dist/securebank-windows.exe differ diff --git a/go.mod b/bank/go.mod similarity index 100% rename from go.mod rename to bank/go.mod diff --git a/launch_browsers.sh b/bank/launch_browsers.sh similarity index 100% rename from launch_browsers.sh rename to bank/launch_browsers.sh diff --git a/main.go b/bank/main.go similarity index 86% rename from main.go rename to bank/main.go index 49ca72e..c04fbba 100644 --- a/main.go +++ b/bank/main.go @@ -1,14 +1,22 @@ package main import ( + "embed" "flag" "fmt" "html/template" + "io/fs" "log" "net/http" "sync" ) +//go:embed templates/* +var templatesFS embed.FS + +//go:embed static/* +var staticFS embed.FS + // User struktura za uporabniške podatke type User struct { ID int @@ -52,15 +60,19 @@ func main() { var port = flag.String("port", "8080", "Port na katerem se bo zagnal server") flag.Parse() - // Naložimo HTML predloge + // Naložimo HTML predloge iz embedded FS var err error - templates, err = template.ParseGlob("templates/*.html") + templates, err = template.ParseFS(templatesFS, "templates/*.html") if err != nil { - log.Fatal("Napaka pri nalaganju predlog:", err) + log.Fatal("Napaka pri nalaganju embedded predlog:", err) } - // Statične datoteke (CSS) - http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/")))) + // Statične datoteke iz embedded FS + staticSubFS, err := fs.Sub(staticFS, "static") + if err != nil { + log.Fatal("Napaka pri ustvarjanju static subFS:", err) + } + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSubFS)))) // Routes http.HandleFunc("/", homeHandler) @@ -70,8 +82,11 @@ func main() { http.HandleFunc("/logout", logoutHandler) // Zagon strežnika - fmt.Printf("SecureBank aplikacija se zaganja na portu %s\n", *port) - fmt.Printf("Dostop: http://localhost:%s\n", *port) + fmt.Printf("🏦 SecureBank aplikacija (embedded build)\n") + fmt.Printf("Port: %s\n", *port) + fmt.Printf("HTTP: http://localhost:%s\n", *port) + fmt.Printf("📦 Vsi fajli so vključeni v binary!\n") + fmt.Println() serverAddr := ":" + *port log.Fatal(http.ListenAndServe(serverAddr, nil)) diff --git a/static/style.css b/bank/static/style.css similarity index 100% rename from static/style.css rename to bank/static/style.css diff --git a/templates/dashboard.html b/bank/templates/dashboard.html similarity index 100% rename from templates/dashboard.html rename to bank/templates/dashboard.html diff --git a/templates/home.html b/bank/templates/home.html similarity index 100% rename from templates/home.html rename to bank/templates/home.html diff --git a/templates/login.html b/bank/templates/login.html similarity index 100% rename from templates/login.html rename to bank/templates/login.html diff --git a/templates/register.html b/bank/templates/register.html similarity index 100% rename from templates/register.html rename to bank/templates/register.html