Some checks failed
Build and Release / Create Release (push) Successful in 0s
Trigger Vault Plugin Rebuild / Trigger Vault Rebuild (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m48s
Build and Release / Lint (push) Failing after 5m2s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux, linux-latest) (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 5m37s
Go's semantic import versioning requires v2+ modules to include the major version in the module path. This enables using proper version tags (v3.x.x) instead of pseudo-versions. Updated module path: code.gitcaddy.com/server/v3
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package misc
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"code.gitcaddy.com/server/v3/modules/optional"
|
|
"code.gitcaddy.com/server/v3/modules/templates"
|
|
"code.gitcaddy.com/server/v3/modules/util"
|
|
"code.gitcaddy.com/server/v3/modules/web/middleware"
|
|
"code.gitcaddy.com/server/v3/services/context"
|
|
user_service "code.gitcaddy.com/server/v3/services/user"
|
|
"code.gitcaddy.com/server/v3/services/webtheme"
|
|
)
|
|
|
|
func WebThemeList(ctx *context.Context) {
|
|
curWebTheme := ctx.TemplateContext.CurrentWebTheme()
|
|
renderUtils := templates.NewRenderUtils(ctx)
|
|
allThemes := webtheme.GetAvailableThemes()
|
|
|
|
var results []map[string]any
|
|
for _, theme := range allThemes {
|
|
results = append(results, map[string]any{
|
|
"name": renderUtils.RenderThemeItem(theme, 14),
|
|
"value": theme.InternalName,
|
|
"class": "item js-aria-clickable" + util.Iif(theme.InternalName == curWebTheme.InternalName, " selected", ""),
|
|
})
|
|
}
|
|
ctx.JSON(http.StatusOK, map[string]any{"results": results})
|
|
}
|
|
|
|
func WebThemeApply(ctx *context.Context) {
|
|
themeName := ctx.FormString("theme")
|
|
if ctx.Doer != nil {
|
|
opts := &user_service.UpdateOptions{Theme: optional.Some(themeName)}
|
|
_ = user_service.UpdateUser(ctx, ctx.Doer, opts)
|
|
} else {
|
|
middleware.SetSiteCookie(ctx.Resp, "gitea_theme", themeName, 0)
|
|
}
|
|
}
|