From eca22df63a5f11f749dd7d782ff25e4ffbdd73fa Mon Sep 17 00:00:00 2001 From: logikonline Date: Fri, 6 Mar 2026 17:04:32 -0500 Subject: [PATCH] feat(admin): add configurable footer links for licenses and api Add theme configuration options to control visibility of Licenses and API links in the footer. Also add authentication token to vault version API requests in build workflow to prevent rate limiting issues. --- .gitea/workflows/build.yml | 12 ++++++------ modules/setting/config.go | 4 ++++ options/locale/locale_en-US.json | 4 ++++ routers/web/admin/config.go | 2 ++ templates/admin/config_settings/theme.tmpl | 14 ++++++++++++++ templates/base/footer_content.tmpl | 4 ++-- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 825d6839a5..00e55f168e 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -245,7 +245,7 @@ jobs: if: matrix.goos != 'windows' id: vault run: | - VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4) + VERSION=$(curl -sf -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4) echo "version=$VERSION" echo "version=$VERSION" >> "$GITHUB_OUTPUT" @@ -254,7 +254,7 @@ jobs: id: vault-win shell: pwsh run: | - $response = Invoke-RestMethod -Uri "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" + $response = Invoke-RestMethod -Uri "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" -Headers @{ Authorization = "token ${{ secrets.RELEASE_TOKEN }}" } $version = $response.tag_name Write-Host "version=$version" "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append @@ -422,7 +422,7 @@ jobs: TAGS: bindata sqlite sqlite_unlock_notify run: | VERSION=$(git describe --tags --always 2>/dev/null | sed "s/-gitcaddy//" || echo "dev") - VAULT_VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4 || echo "dev") + VAULT_VERSION=$(curl -sf -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4 || echo "dev") LDFLAGS="-X main.Version=${VERSION} -X git.marketally.com/gitcaddy/gitcaddy-vault.Version=${VAULT_VERSION}" OUTPUT="gitcaddy-server-${VERSION}-${GOOS}-${GOARCH}" @@ -458,7 +458,7 @@ jobs: $VERSION = (git describe --tags --always 2>$null) -replace '-gitcaddy','' if (-not $VERSION) { $VERSION = "dev" } - $VAULT_VERSION = (Invoke-RestMethod -Uri "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" -ErrorAction SilentlyContinue).tag_name + $VAULT_VERSION = (Invoke-RestMethod -Uri "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" -Headers @{ Authorization = "token ${{ secrets.RELEASE_TOKEN }}" } -ErrorAction SilentlyContinue).tag_name if (-not $VAULT_VERSION) { $VAULT_VERSION = "dev" } $LDFLAGS = "-X main.Version=$VERSION -X git.marketally.com/gitcaddy/gitcaddy-vault.Version=$VAULT_VERSION" $OUTPUT = "gitcaddy-server-$VERSION-$env:GOOS-$env:GOARCH.exe" @@ -585,7 +585,7 @@ jobs: - name: Get latest vault version id: vault run: | - VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4) + VERSION=$(curl -sf -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4) echo "version=$VERSION" echo "version=$VERSION" >> "$GITHUB_OUTPUT" @@ -648,7 +648,7 @@ jobs: - name: Build binary run: | VERSION=$(git describe --tags --always 2>/dev/null | sed "s/-gitcaddy//" || echo "dev") - VAULT_VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4 || echo "dev") + VAULT_VERSION=$(curl -sf -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4 || echo "dev") LDFLAGS="-X main.Version=${VERSION} -X git.marketally.com/gitcaddy/gitcaddy-vault.Version=${VAULT_VERSION}" OUTPUT="gitcaddy-server-${VERSION}-linux-arm64" TAGS="bindata sqlite sqlite_unlock_notify" diff --git a/modules/setting/config.go b/modules/setting/config.go index 69d6a1f30e..8a9505d22a 100644 --- a/modules/setting/config.go +++ b/modules/setting/config.go @@ -70,6 +70,8 @@ type ThemeStruct struct { EnableBlogs *config.Value[bool] BlogsInTopNav *config.Value[bool] ShowFooterPoweredBy *config.Value[bool] + ShowFooterLicenses *config.Value[bool] + ShowFooterAPI *config.Value[bool] } type ConfigStruct struct { @@ -111,6 +113,8 @@ func initDefaultConfig() { EnableBlogs: config.ValueJSON[bool]("theme.enable_blogs").WithDefault(false), BlogsInTopNav: config.ValueJSON[bool]("theme.blogs_in_top_nav").WithDefault(false), ShowFooterPoweredBy: config.ValueJSON[bool]("theme.show_footer_powered_by").WithFileConfig(config.CfgSecKey{Sec: "other", Key: "SHOW_FOOTER_POWERED_BY"}).WithDefault(true), + ShowFooterLicenses: config.ValueJSON[bool]("theme.show_footer_licenses").WithDefault(true), + ShowFooterAPI: config.ValueJSON[bool]("theme.show_footer_api").WithDefault(true), }, } } diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index 6d0fc34368..c4324bd51a 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -4246,6 +4246,10 @@ "admin.config.blogs_in_top_nav_desc": "Show a Blogs link in the site header navigation bar next to Explore", "admin.config.show_footer_powered_by": "Show Powered By", "admin.config.show_footer_powered_by_desc": "Show the \"Powered by GitCaddy Server\" message in the footer", + "admin.config.show_footer_licenses": "Show Licenses Link", + "admin.config.show_footer_licenses_desc": "Show the Licenses link in the footer", + "admin.config.show_footer_api": "Show API Link", + "admin.config.show_footer_api_desc": "Show the API (Swagger) link in the footer", "admin.config.custom_home_title": "Homepage Title", "admin.config.custom_home_title_placeholder": "Leave empty to use app name", "admin.config.custom_home_title_help": "Custom title displayed on the homepage. Leave empty to use the default app name.", diff --git a/routers/web/admin/config.go b/routers/web/admin/config.go index c88a3b1c21..50e0c738c2 100644 --- a/routers/web/admin/config.go +++ b/routers/web/admin/config.go @@ -252,6 +252,8 @@ func ChangeConfig(ctx *context.Context) { cfg.Theme.EnableBlogs.DynKey(): marshalBool, cfg.Theme.BlogsInTopNav.DynKey(): marshalBool, cfg.Theme.ShowFooterPoweredBy.DynKey(): marshalBool, + cfg.Theme.ShowFooterLicenses.DynKey(): marshalBool, + cfg.Theme.ShowFooterAPI.DynKey(): marshalBool, } _ = ctx.Req.ParseForm() diff --git a/templates/admin/config_settings/theme.tmpl b/templates/admin/config_settings/theme.tmpl index f871cd5afd..a8b3b4981f 100644 --- a/templates/admin/config_settings/theme.tmpl +++ b/templates/admin/config_settings/theme.tmpl @@ -176,6 +176,20 @@
+
{{ctx.Locale.Tr "admin.config.show_footer_licenses"}}
+
+
+ +
+
+
+
{{ctx.Locale.Tr "admin.config.show_footer_api"}}
+
+
+ +
+
+
{{ctx.Locale.Tr "admin.config.api_header_url"}}
diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index 0aea25f5e1..4ad6624faf 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -30,8 +30,8 @@ {{end -}} - {{ctx.Locale.Tr "licenses"}} - {{if .EnableSwagger}}API{{end}} + {{if .SystemConfig.Theme.ShowFooterLicenses.Value ctx}}{{ctx.Locale.Tr "licenses"}}{{end}} + {{if and .EnableSwagger (.SystemConfig.Theme.ShowFooterAPI.Value ctx)}}API{{end}} {{template "custom/extra_links_footer" .}}