Skip to content

Commit

Permalink
Fixes #340
Browse files Browse the repository at this point in the history
* Version is now in footer and passed during build
* "Contact" has been removed, I mostly get E-Mails I wish i wouldn't
  receive. For issues the "feedback" link should be used. All others
  have to be smart enough to navigate to where my E-Mail can be found ;)
  • Loading branch information
Bios-Marcel committed Oct 19, 2024
1 parent 8e548d2 commit 06ec42f
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker-image-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
max-parallel: 3
matrix:
os: [ubuntu-latest, windows-2022]
buildArgs: VERSION=${{ github.ref_name }}
include:
- os: ubuntu-latest
platforms: linux/amd64,linux/arm/v7,linux/arm64
Expand All @@ -39,6 +40,7 @@ jobs:

dockerfile: ${{ matrix.file }}
image: biosmarcel/scribble.rs
buildArgs: ${{ matrix.buildArgs }}
platform: ${{ matrix.platforms }}
tags: ${{ matrix.tags }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build artifact
shell: bash
run: |
go build -trimpath -ldflags "-w -s" -o ${{ matrix.binary_name }} ./cmd/scribblers
go build -trimpath -ldflags "-w -s -X 'github.com/scribble-rs/scribble.rs/internal/version.Version=$VERSION'" -o ${{ matrix.binary_name }} ./cmd/scribblers
- name: Upload build artifact
uses: actions/upload-artifact@v4
Expand Down
3 changes: 3 additions & 0 deletions cmd/scribblers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/scribble-rs/scribble.rs/internal/config"
"github.com/scribble-rs/scribble.rs/internal/frontend"
"github.com/scribble-rs/scribble.rs/internal/state"
"github.com/scribble-rs/scribble.rs/internal/version"
)

func main() {
Expand All @@ -26,6 +27,8 @@ func main() {
log.Fatalln("error loading configuration:", err)
}

log.Printf("Starting Scribble.rs version '%s'\n", version.Version)

if cfg.CPUProfilePath != "" {
log.Println("Starting CPU profiling ....")
cpuProfileFile, err := os.Create(cfg.CPUProfilePath)
Expand Down
5 changes: 4 additions & 1 deletion internal/frontend/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/scribble-rs/scribble.rs/internal/game"
"github.com/scribble-rs/scribble.rs/internal/state"
"github.com/scribble-rs/scribble.rs/internal/translations"
"github.com/scribble-rs/scribble.rs/internal/version"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
Expand All @@ -26,7 +27,9 @@ type SSRHandler struct {
}

func NewHandler(cfg *config.Config) (*SSRHandler, error) {
basePageConfig := &BasePageConfig{}
basePageConfig := &BasePageConfig{
Version: version.Version,
}
if cfg.RootPath != "" {
basePageConfig.RootPath = "/" + cfg.RootPath
}
Expand Down
2 changes: 2 additions & 0 deletions internal/frontend/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func init() {
// BasePageConfig is data that all pages require to function correctly, no matter
// whether error page or lobby page.
type BasePageConfig struct {
// Version is the source code version of this build.
Version string `json:"version"`
// RootPath is the path directly after the domain and before the
// scribble.rs paths. For example if you host scribblers on painting.com
// but already host a different website, then your API paths might have to
Expand Down
7 changes: 6 additions & 1 deletion internal/frontend/templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{{define "footer"}}
{{if eq .Version "dev"}}
<a class="footer-item" href="https://github.com/scribble-rs/scribble.rs" target="_blank">{{.Version}}</a>
{{else}}
<a class="footer-item" href="https://github.com/scribble-rs/scribble.rs/releases/tag/{{.Version}}"
target="_blank">{{.Version}}</a>
{{end}}
<a class="footer-item" href="https://github.com/scribble-rs/scribble.rs"
target="_blank">{{.Translation.Get "source-code"}}</a>
<a class="footer-item" href="https://github.com/scribble-rs/scribble.rs/wiki"
target="_blank">{{.Translation.Get "help"}}</a>
<a class="footer-item" href="mailto:[email protected]" target="_blank">{{.Translation.Get "contact"}}</a>
<a class="footer-item" href="https://github.com/scribble-rs/scribble.rs/issues/new"
target="_blank">{{.Translation.Get "submit-feedback"}}</a>
<a class="footer-item" href="{{.RootPath}}/v1/stats" target="_blank">{{.Translation.Get "stats"}}</a>
Expand Down
1 change: 0 additions & 1 deletion internal/translations/de_DE.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func initGermanTranslation() {
// Footer
translation.put("source-code", "Source Code")
translation.put("help", "Hilfe")
translation.put("contact", "Kontakt")
translation.put("submit-feedback", "Feedback")
translation.put("stats", "Status")

Expand Down
1 change: 0 additions & 1 deletion internal/translations/en_us.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func initEnglishTranslation() Translation {

translation.put("source-code", "Source Code")
translation.put("help", "Help")
translation.put("contact", "Contact")
translation.put("submit-feedback", "Feedback")
translation.put("stats", "Status")

Expand Down
6 changes: 6 additions & 0 deletions internal/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// version holds the git that this version was built from. In development
// scearios, it will default to "dev".
package version

// Version of the application.
var Version = "dev"
6 changes: 5 additions & 1 deletion linux.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# with a newer verison than we are using for CI tests, as we don't directly
# test the produced binary but from source code directly.
FROM docker.io/golang:1.22.1 AS builder

WORKDIR /app

# This causes caching of the downloaded go modules and makes repeated local
Expand All @@ -13,10 +14,13 @@ WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download -x

# Import that this comes after mod download, as it breaks caching.
ARG VERSION="dev"

# Copy actual codebase, since we only have the go.mod and go.sum so far.
COPY . /app/
ENV CGO_ENABLED=0
RUN go build -trimpath -ldflags "-w -s" -tags timetzdata -o ./scribblers ./cmd/scribblers
RUN go build -trimpath -ldflags "-w -s -X 'github.com/scribble-rs/scribble.rs/internal/version.Version=${VERSION}'" -tags timetzdata -o ./scribblers ./cmd/scribblers

#
# Runner
Expand Down
5 changes: 4 additions & 1 deletion windows.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download -x

# Import that this comes after mod download, as it breaks caching.
ARG VERSION="dev"

# Copy actual codebase, since we only have the go.mod and go.sum so far.
COPY . /app/
ENV CGO_ENABLED=0
RUN go build -trimpath -ldflags "-w -s" -tags timetzdata -o ./scribblers ./cmd/scribblers
RUN go build -trimpath -ldflags "-w -s -X 'github.com/scribble-rs/scribble.rs/internal/version.Version=$VERSION'" -tags timetzdata -o ./scribblers ./cmd/scribblers

#
# Runner
Expand Down

0 comments on commit 06ec42f

Please sign in to comment.