diff --git a/.gitignore b/.gitignore index c9a2389..3d7be86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ mlmym +VERSION *.toml *.txt diff --git a/Dockerfile b/Dockerfile index 1bd6c58..9b9ab73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ WORKDIR /app COPY go.* ./ RUN go mod download COPY . ./ +RUN git describe --tag > VERSION RUN go build -v -o mlmym FROM debian:bullseye-slim @@ -14,4 +15,5 @@ RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install - COPY --from=builder /app/mlmym /app/mlmym COPY --from=builder /app/templates /app/templates COPY --from=builder /app/public /app/public +COPY --from=builder /app/VERSION /app/VERSION CMD ["./mlmym", "--addr", "0.0.0.0:8080"] diff --git a/Makefile b/Makefile index 0ac9db1..701866f 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,18 @@ -.PHONY: dev reload serve style +.PHONY: dev reload serve VERSION -all: - $(MAKE) -j3 --no-print-directory dev +all: mlmym -dev: reload serve style +mlmym: + go build -v -o mlmym + +dev: + $(MAKE) -j2 --no-print-directory reload serve reload: - #websocketd --port=8080 watchexec -w public echo reload &>/dev/null - websocketd --loglevel=fatal --port=8009 watchexec --no-vcs-ignore -e html,css,js -d 500 -w public 'echo "$$WATCHEXEC_WRITTEN_PATH"' + websocketd --loglevel=fatal --port=8009 watchexec -e html,css,js -d 500 'echo "$$WATCHEXEC_WRITTEN_PATH"' -serve: - #python -m http.server --directory ./public 8081 &>/dev/null - DEBUG=true watchexec -e go -r "go run . --addr 0.0.0.0:8008 -w" +VERSION: + git describe --tag > $@ -style: - npm run watchcss > /dev/null 2>&1 +serve: VERSION + DEBUG=true watchexec --no-vcs-ignore -e go -r "go run . --addr 0.0.0.0:8008 -w" diff --git a/main.go b/main.go index a7aee4f..b38cc10 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ import ( "github.com/yuin/goldmark/extension" ) +var version string var watch = flag.Bool("w", false, "watch for file changes") var addr = flag.String("addr", ":80", "http service address") var md goldmark.Markdown @@ -68,6 +69,9 @@ func init() { if os.Getenv("DEBUG") != "" { test() } + if data, err := os.ReadFile("VERSION"); err == nil { + version = string(data) + } } func test() { links := [][]string{ diff --git a/public/style.css b/public/style.css index 4cef8b7..d3f0be1 100644 --- a/public/style.css +++ b/public/style.css @@ -1057,6 +1057,9 @@ form.create input[type=file], form.create select { font-size: 13px; margin: 10px; } +.preferences div:last-child label { + text-align: left; +} .preferences label{ display: inline-block; width: 130px; diff --git a/routes.go b/routes.go index eea125b..fbe20f4 100644 --- a/routes.go +++ b/routes.go @@ -198,9 +198,10 @@ func RegReplace(input string, match string, replace string) string { func Initialize(Host string, r *http.Request) (State, error) { state := State{ - Host: Host, - Page: 1, - Status: http.StatusOK, + Host: Host, + Page: 1, + Status: http.StatusOK, + Version: version, } lemmyDomain := os.Getenv("LEMMY_DOMAIN") if lemmyDomain != "" { diff --git a/state.go b/state.go index 630a9e1..0b8a6bc 100644 --- a/state.go +++ b/state.go @@ -64,6 +64,7 @@ type Session struct { } type State struct { + Version string Client *lemmy.Client HTTPClient *http.Client Session *Session diff --git a/templates/settings.html b/templates/settings.html index 655b61b..151e208 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -129,7 +129,7 @@
- + {{ if .XHR }}{{ end }}