Skip to content

Commit

Permalink
hack the env vars for registration and app environ, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
krustowski committed Jul 8, 2024
1 parent 7eda440 commit 100bb2e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#

APP_NAME=litter-go
APP_VERSION=0.35.4
APP_VERSION=0.35.5
GOLANG_VERSION=1.22
4 changes: 2 additions & 2 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "MIT",
"url": "https://github.com/krustowski/litter-go/blob/master/LICENSE"
},
"version": "0.35.3"
"version": "0.35.5"
},
"host": "littr.n0p.cz",
"basePath": "/api/v1",
Expand Down Expand Up @@ -1505,7 +1505,7 @@
"type": "boolean"
},
"registered_time": {
"description": "RegisteredTime is an UNIX timestamp of the user's registeration.",
"description": "RegisteredTime is an UNIX timestamp of the user's registration.",
"type": "string"
},
"request_list": {
Expand Down
8 changes: 5 additions & 3 deletions configs/backend.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package configs

import (
"strconv"
"os"
"strconv"
)

const (
Expand All @@ -21,8 +21,9 @@ var REGISTRATION_ENABLED bool = func() bool {
return false
}
return boolVal
} else {
return true
}
return true
}()

/*
Expand All @@ -32,8 +33,9 @@ var REGISTRATION_ENABLED bool = func() bool {
var APP_ENVIRONMENT string = func() string {
if os.Getenv("APP_ENVIRONMENT") != "" {
return os.Getenv("APP_ENVIRONMENT")
} else {
return "dev"
}
return "dev"
}()

/*
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/router.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @title litter-go
// @version 0.35.4
// @version 0.35.5
// @description nanoblogging platform as PWA built on go-app framework
// @termsOfService https://littr.n0p.cz/tos

Expand Down
5 changes: 4 additions & 1 deletion pkg/frontend/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/sha512"
"encoding/json"
"fmt"
"os"
"strings"

"go.savla.dev/littr/configs"
Expand Down Expand Up @@ -172,6 +173,8 @@ func (c *loginContent) dismissToast(ctx app.Context, e app.Event) {
}

func (c *loginContent) Render() app.UI {
registration := os.Getenv("REGISTRATION_ENABLED")

return app.Main().Class("responsive").Body(
app.Div().Class("row").Body(
app.Div().Class("max padding").Body(
Expand Down Expand Up @@ -227,7 +230,7 @@ func (c *loginContent) Render() app.UI {
),

// register button
app.If(configs.REGISTRATION_ENABLED,
app.If(registration == "true",
app.Button().Class("max deep-orange7 white-text bold").Style("border-radius", "8px").TabIndex(5).OnClick(c.onClickRegister).Disabled(c.loginButtonDisabled).Body(
app.Text("register"),
),
Expand Down
15 changes: 10 additions & 5 deletions pkg/frontend/navbars.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"encoding/base64"
"encoding/json"
"log"
"os"
"strconv"
"time"

"go.savla.dev/littr/configs"
//"go.savla.dev/littr/configs"
"go.savla.dev/littr/pkg/models"

"github.com/maxence-charriere/go-app/v9/pkg/app"
Expand Down Expand Up @@ -256,6 +257,8 @@ func (h *header) Render() app.UI {
// a very nasty way on how to store the timestamp...
var last int64 = 0

environ := os.Getenv("APP_ENVIRONMENT")

beat := app.Window().Get("localStorage")
if !beat.IsNull() && !beat.Call("getItem", "lastEventTime").IsNull() {
str := beat.Call("getItem", "lastEventTime").String()
Expand Down Expand Up @@ -325,7 +328,7 @@ func (h *header) Render() app.UI {
app.H4().Class("center-align deep-orange-text").OnClick(h.onClickHeadline).ID("top-header").Body(
app.Span().Body(
app.Text(headerString),
app.If(configs.APP_ENVIRONMENT == "dev",
app.If(environ == "dev",
app.Span().Class("col").Body(
app.Sup().Body(
app.Text(" (beta) "),
Expand Down Expand Up @@ -360,9 +363,11 @@ func (h *header) Render() app.UI {
app.H4().Body(
app.Span().Body(
app.Text("littr"),
app.Span().Class("col").Body(
app.Sup().Body(
app.Text(" (beta) "),
app.If(environ == "dev",
app.Span().Class("col").Body(
app.Sup().Body(
app.Text(" (beta) "),
),
),
),
),
Expand Down
5 changes: 4 additions & 1 deletion pkg/frontend/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"net/mail"
"os"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -210,6 +211,8 @@ func (c *registerContent) dismissToast(ctx app.Context, e app.Event) {
}

func (c *registerContent) Render() app.UI {
registration := os.Getenv("REGISTRATION_ENABLED")

return app.Main().Class("responsive").Body(
app.Div().Class("row").Body(
app.Div().Class("max padding").Body(
Expand Down Expand Up @@ -296,7 +299,7 @@ func (c *registerContent) Render() app.UI {

// register button
app.Div().Class("row").Body(
app.If(configs.REGISTRATION_ENABLED,
app.If(registration == "true",
app.Button().Class("max deep-orange7 white-text bold").Style("border-radius", "8px").OnClick(c.onClickRegister).Disabled(c.registerButtonDisabled).Body(
app.Text("register"),
),
Expand Down

0 comments on commit 100bb2e

Please sign in to comment.