added staging banner
This commit is contained in:
@@ -14,6 +14,7 @@ type Flags struct {
|
||||
GenEnv string
|
||||
EnvFile string
|
||||
DevMode bool
|
||||
Staging bool
|
||||
|
||||
// Database reset (destructive)
|
||||
ResetDB bool
|
||||
@@ -36,6 +37,7 @@ func SetupFlags() (*Flags, error) {
|
||||
genEnv := flag.String("genenv", "", "Generate a .env file with all environment variables (specify filename)")
|
||||
envfile := flag.String("envfile", ".env", "Specify a .env file to use for the configuration")
|
||||
devMode := flag.Bool("dev", false, "Run the server in dev mode")
|
||||
staging := flag.Bool("staging", false, "Show a staging banner")
|
||||
|
||||
// Database reset (destructive)
|
||||
resetDB := flag.Bool("reset-db", false, "⚠️ DESTRUCTIVE: Drop and recreate all tables (dev only)")
|
||||
@@ -92,6 +94,7 @@ func SetupFlags() (*Flags, error) {
|
||||
GenEnv: *genEnv,
|
||||
EnvFile: *envfile,
|
||||
DevMode: *devMode,
|
||||
Staging: *staging,
|
||||
ResetDB: *resetDB,
|
||||
MigrateUp: *migrateUp,
|
||||
MigrateRollback: *migrateRollback,
|
||||
|
||||
@@ -13,4 +13,5 @@ func DevMode(ctx context.Context) DevInfo {
|
||||
type DevInfo struct {
|
||||
WebsocketBase string
|
||||
HTMXLog bool
|
||||
StagingBanner bool
|
||||
}
|
||||
|
||||
@@ -2344,11 +2344,6 @@
|
||||
align-items: flex-end;
|
||||
}
|
||||
}
|
||||
.lg\:items-start {
|
||||
@media (width >= 64rem) {
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
.lg\:justify-between {
|
||||
@media (width >= 64rem) {
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -44,17 +44,21 @@ func addMiddleware(
|
||||
func devMode(cfg *config.Config) hws.Middleware {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if cfg.Flags.DevMode {
|
||||
devInfo := contexts.DevInfo{
|
||||
WebsocketBase: "ws://" + cfg.HWS.Host + ":" + strconv.FormatUint(cfg.HWS.Port, 10),
|
||||
HTMXLog: true,
|
||||
}
|
||||
ctx := context.WithValue(r.Context(), contexts.DevModeKey, devInfo)
|
||||
req := r.WithContext(ctx)
|
||||
next.ServeHTTP(w, req)
|
||||
if !cfg.Flags.DevMode && !cfg.Flags.Staging {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
devInfo := contexts.DevInfo{}
|
||||
if cfg.Flags.DevMode {
|
||||
devInfo.WebsocketBase = "ws://" + cfg.HWS.Host + ":" + strconv.FormatUint(cfg.HWS.Port, 10)
|
||||
devInfo.HTMXLog = true
|
||||
}
|
||||
if cfg.Flags.Staging {
|
||||
devInfo.StagingBanner = true
|
||||
}
|
||||
ctx := context.WithValue(r.Context(), contexts.DevModeKey, devInfo)
|
||||
req := r.WithContext(ctx)
|
||||
next.ServeHTTP(w, req)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ templ Layout(title string) {
|
||||
id="main-content"
|
||||
class="flex flex-col h-screen"
|
||||
>
|
||||
if devInfo.StagingBanner {
|
||||
@stagingBanner()
|
||||
}
|
||||
@Navbar()
|
||||
if previewRole != nil {
|
||||
@previewModeBanner(previewRole)
|
||||
@@ -57,6 +60,12 @@ templ Layout(title string) {
|
||||
</html>
|
||||
}
|
||||
|
||||
templ stagingBanner() {
|
||||
<div class="bg-peach text-crust text-center text-xs font-bold py-1 tracking-wider uppercase">
|
||||
Staging Environment - For Testing Only
|
||||
</div>
|
||||
}
|
||||
|
||||
// Preview mode banner (private helper)
|
||||
templ previewModeBanner(previewRole *db.Role) {
|
||||
<div class="bg-yellow/20 border-b border-yellow/40 px-4 py-3">
|
||||
|
||||
Reference in New Issue
Block a user