show mlmym version

This commit is contained in:
Ryan Stafford 2023-07-23 18:19:53 -04:00
parent 3ce346d815
commit 3ebf9b3793
8 changed files with 28 additions and 15 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
mlmym
VERSION
*.toml
*.txt

View file

@ -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"]

View file

@ -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"

View file

@ -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{

View file

@ -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;

View file

@ -201,6 +201,7 @@ func Initialize(Host string, r *http.Request) (State, error) {
Host: Host,
Page: 1,
Status: http.StatusOK,
Version: version,
}
lemmyDomain := os.Getenv("LEMMY_DOMAIN")
if lemmyDomain != "" {

View file

@ -64,6 +64,7 @@ type Session struct {
}
type State struct {
Version string
Client *lemmy.Client
HTTPClient *http.Client
Session *Session

View file

@ -129,7 +129,7 @@
<input type="checkbox" name="hideInstanceNames" {{ if .HideInstanceNames }}checked{{end}}>
</div>
<div>
<label></label>
<label>mlmym: {{ .Version }}</label>
<input type="submit" value="save">
{{ if .XHR }}<input id="closesettings" type="submit" value="close">{{ end }}
</div>