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