Skip to content

Commit

Permalink
go version
Browse files Browse the repository at this point in the history
  • Loading branch information
wkelly17 committed Nov 14, 2023
1 parent 993f70e commit 3ae0ba6
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion app.ini
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ IS_INPUT_FILE = false

[oauth2]
ENABLE = true
JWT_SECRET = u4MdWtHbCQRH_d_VPfwijAsIr2vaBf7y2OhrT1JN3Cs
JWT_SECRET = sTE2-4pYnp9VUhgIk1LTiT-nCEWl5nEXt_GUssKXYOo

[default]
RUN_MODE = dev
20 changes: 14 additions & 6 deletions wacs-gitea/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,34 @@ FROM gitea/gitea:${GITEA_VERSION}-rootless as LOCALE_SOURCE
RUN gitea embedded extract --destination /var/lib/gitea/ options/locale/**.*

# Build locale files from gitea, with WA's overrides and new keys
FROM node:20-slim as LOCALE_BUILDER
FROM golang:1.20 as LOCALE_BUILDER
# copy gitea's locale files
COPY --from=LOCALE_SOURCE /var/lib/gitea/options/locale /gitea-locale
WORKDIR /merge-locale
COPY --from=LOCALE_SOURCE /var/lib/gitea/options/locale /gitea-locale
COPY merge-locale /merge-locale
COPY custom/options/locale /wa-locale
# output files to /output-locale/*.ini
RUN mkdir /output-locale
RUN npm install -ci
RUN node localeMerge.js
RUN go build -o localeMerger

# RUN npm install -ci
# RUN node localeMerge.js

FROM gitea/gitea:${GITEA_VERSION}-rootless

ENV GITEA_CUSTOM=/custom
COPY --from=LOCALE_BUILDER /merge-locale/localeMerger /merge-locale/localeMerger
COPY --from=LOCALE_SOURCE /var/lib/gitea/options/locale /gitea-locale
COPY merge-locale /merge-locale
COPY custom/options/locale /wa-locale

COPY --chown=git:git --from=LOCALE_BUILDER /output-locale/*.ini /custom/options/locale/
# COPY --from=LOCALE_BUILDER /output-locale/*.ini /custom/options/locale/
COPY --chown=git:git ./custom/templates /custom/templates
COPY --chown=git:git ./custom/options/locale /custom/options/locale
COPY ./custom/public /custom/public


ENV READER_BASE_LINK=read-dev.bibleineverylanguage.org

ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["sh", "-c", "cat /custom/templates/custom/extra_tabs.tmpl | envsubst > /tmp/extra_tabs.tmpl && mv /tmp/extra_tabs.tmpl /custom/templates/custom/extra_tabs.tmpl && /usr/local/bin/docker-entrypoint.sh"]
CMD ["bash", "-c", "cat /custom/templates/custom/extra_tabs.tmpl | envsubst > /tmp/extra_tabs.tmpl && mv /tmp/extra_tabs.tmpl /custom/templates/custom/extra_tabs.tmpl && /merge-locale/localeMerger && /usr/local/bin/docker-entrypoint.sh"]
3 changes: 1 addition & 2 deletions wacs-gitea/custom/templates/custom/extra_links_footer.tmpl
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{
{.locale.Tr "wa.footer_agreement" | Str2html}}
{{.locale.Tr "wa.footer_agreement" | Str2html}}
5 changes: 5 additions & 0 deletions wacs-gitea/merge-locale/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module example/locale

go 1.20

require github.com/go-ini/ini v1.67.0 // indirect
2 changes: 2 additions & 0 deletions wacs-gitea/merge-locale/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
45 changes: 0 additions & 45 deletions wacs-gitea/merge-locale/localeMerge.js

This file was deleted.

71 changes: 71 additions & 0 deletions wacs-gitea/merge-locale/merge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package main

import (
"fmt"
"os"
"path"

"github.com/go-ini/ini"
)

func main() {

// Define directory paths
waLocalesDir := "/wa-locale"
giteaLocalesDir := "/gitea-locale"
outputDir := ("/custom/options/locale/")

// Read custom locales
customLocales, err := os.ReadDir(waLocalesDir)
if err != nil {
fmt.Println("Error reading custom locales directory:", err)
os.Exit(1)
}

// Loop through each custom locale
for _, waLocale := range customLocales {
waLocalePath := path.Join(waLocalesDir, waLocale.Name())
giteaLocalePath := path.Join(giteaLocalesDir, waLocale.Name())

// Check if the base locale file exists
if _, err := os.Stat(giteaLocalePath); err == nil {
// Read custom data
waLocaleData, err := ini.Load(waLocalePath)
if err != nil {
fmt.Println("Error loading custom data:", err)
continue
}

// Read base data
giteaLocaleData, err := ini.Load(giteaLocalePath)
if err != nil {
fmt.Println("Error loading base data:", err)
continue
}

// Combine keys as specified
for _, section := range waLocaleData.Sections() {
for _, key := range section.Keys() {
fmt.Println(key)
// Add if not exists, and overwrite if does
giteaLocaleData.Section(section.Name()).Key(key.Name()).SetValue(key.Value())
}
}

// Write the combined data to the output directory
outputPath := path.Join(outputDir, waLocale.Name())



err = giteaLocaleData.SaveTo(outputPath)
if err != nil {
fmt.Println("Error saving combined data:", err)
continue
}

fmt.Printf("Combined and saved %s to %s\n", waLocale.Name(), outputPath)
} else {
fmt.Printf("Base locale file not found for %s\n", waLocale.Name())
}
}
}
24 changes: 0 additions & 24 deletions wacs-gitea/merge-locale/package-lock.json

This file was deleted.

16 changes: 0 additions & 16 deletions wacs-gitea/merge-locale/package.json

This file was deleted.

0 comments on commit 3ae0ba6

Please sign in to comment.