Skip to content

Commit ecec556

Browse files
authored
Merge branch 'main' into deps-101
2 parents cba00d6 + 91839ca commit ecec556

38 files changed

+259
-64
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ TEST_TAGS ?= $(TAGS_SPLIT) sqlite sqlite_unlock_notify
163163

164164
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
165165

166-
GO_DIRS := build cmd models modules routers services tests
166+
GO_DIRS := build cmd models modules routers services tests tools
167167
WEB_DIRS := web_src/js web_src/css
168168

169169
ESLINT_FILES := web_src/js tools *.ts tests/e2e
170170
STYLELINT_FILES := web_src/css web_src/js/components/*.vue
171-
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard *.go *.md *.yml *.yaml *.toml)) $(filter-out tools/misspellings.csv, $(wildcard tools/*))
171+
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard *.go *.md *.yml *.yaml *.toml))
172172
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
173173

174174
GO_SOURCES := $(wildcard *.go)
@@ -376,11 +376,11 @@ lint-md: node_modules ## lint markdown files
376376

377377
.PHONY: lint-spell
378378
lint-spell: ## lint spelling
379-
@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -error $(SPELLCHECK_FILES)
379+
@go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -error $(SPELLCHECK_FILES)
380380

381381
.PHONY: lint-spell-fix
382382
lint-spell-fix: ## lint spelling and fix issues
383-
@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -w $(SPELLCHECK_FILES)
383+
@go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -w $(SPELLCHECK_FILES)
384384

385385
.PHONY: lint-go
386386
lint-go: ## lint go files
File renamed without changes.

modules/setting/session.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"code.gitea.io/gitea/modules/json"
1212
"code.gitea.io/gitea/modules/log"
13+
"code.gitea.io/gitea/modules/util"
1314
)
1415

1516
// SessionConfig defines Session settings
@@ -49,10 +50,8 @@ func loadSessionFrom(rootCfg ConfigProvider) {
4950
checkOverlappedPath("[session].PROVIDER_CONFIG", SessionConfig.ProviderConfig)
5051
}
5152
SessionConfig.CookieName = sec.Key("COOKIE_NAME").MustString("i_like_gitea")
52-
SessionConfig.CookiePath = AppSubURL
53-
if SessionConfig.CookiePath == "" {
54-
SessionConfig.CookiePath = "/"
55-
}
53+
// HINT: INSTALL-PAGE-COOKIE-INIT: the cookie system is not properly initialized on the Install page, so there is no CookiePath
54+
SessionConfig.CookiePath = util.IfZero(AppSubURL, "/")
5655
SessionConfig.Secure = sec.Key("COOKIE_SECURE").MustBool(strings.HasPrefix(strings.ToLower(AppURL), "https://"))
5756
SessionConfig.Gclifetime = sec.Key("GC_INTERVAL_TIME").MustInt64(86400)
5857
SessionConfig.Maxlifetime = sec.Key("SESSION_LIFE_TIME").MustInt64(86400)

modules/svg/svg.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func MockIcon(icon string) func() {
5858

5959
// RenderHTML renders icons - arguments icon name (string), size (int), class (string)
6060
func RenderHTML(icon string, others ...any) template.HTML {
61+
if icon == "" {
62+
return ""
63+
}
6164
size, class := gitea_html.ParseSizeAndClass(defaultSize, "", others...)
6265
if svgStr, ok := svgIcons[icon]; ok {
6366
// the code is somewhat hacky, but it just works, because the SVG contents are all normalized

modules/templates/helper.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"strings"
1313
"time"
1414

15-
user_model "code.gitea.io/gitea/models/user"
1615
"code.gitea.io/gitea/modules/base"
1716
"code.gitea.io/gitea/modules/htmlutil"
1817
"code.gitea.io/gitea/modules/markup"
@@ -21,7 +20,6 @@ import (
2120
"code.gitea.io/gitea/modules/templates/eval"
2221
"code.gitea.io/gitea/modules/util"
2322
"code.gitea.io/gitea/services/gitdiff"
24-
"code.gitea.io/gitea/services/webtheme"
2523
)
2624

2725
// NewFuncMap returns functions for injecting to templates
@@ -130,7 +128,6 @@ func NewFuncMap() template.FuncMap {
130128
"DisableWebhooks": func() bool {
131129
return setting.DisableWebhooks
132130
},
133-
"UserThemeName": userThemeName,
134131
"NotificationSettings": func() map[string]any {
135132
return map[string]any{
136133
"MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond),
@@ -217,16 +214,6 @@ func evalTokens(tokens ...any) (any, error) {
217214
return n.Value, err
218215
}
219216

220-
func userThemeName(user *user_model.User) string {
221-
if user == nil || user.Theme == "" {
222-
return setting.UI.DefaultTheme
223-
}
224-
if webtheme.IsThemeAvailable(user.Theme) {
225-
return user.Theme
226-
}
227-
return setting.UI.DefaultTheme
228-
}
229-
230217
func isQueryParamEmpty(v any) bool {
231218
return v == nil || v == false || v == 0 || v == int64(0) || v == ""
232219
}

modules/templates/util_render.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import (
2323
"code.gitea.io/gitea/modules/markup/markdown"
2424
"code.gitea.io/gitea/modules/reqctx"
2525
"code.gitea.io/gitea/modules/setting"
26+
"code.gitea.io/gitea/modules/svg"
2627
"code.gitea.io/gitea/modules/translation"
2728
"code.gitea.io/gitea/modules/util"
29+
"code.gitea.io/gitea/services/webtheme"
2830
)
2931

3032
type RenderUtils struct {
@@ -259,3 +261,18 @@ func (ut *RenderUtils) RenderLabels(labels []*issues_model.Label, repoLink strin
259261
htmlCode += "</span>"
260262
return template.HTML(htmlCode)
261263
}
264+
265+
func (ut *RenderUtils) RenderThemeItem(info *webtheme.ThemeMetaInfo, iconSize int) template.HTML {
266+
svgName := "octicon-paintbrush"
267+
switch info.ColorScheme {
268+
case "dark":
269+
svgName = "octicon-moon"
270+
case "light":
271+
svgName = "octicon-sun"
272+
case "auto":
273+
svgName = "gitea-eclipse"
274+
}
275+
icon := svg.RenderHTML(svgName, iconSize)
276+
extraIcon := svg.RenderHTML(info.GetExtraIconName(), iconSize)
277+
return htmlutil.HTMLFormat(`<div class="theme-menu-item" data-tooltip-content="%s">%s %s %s</div>`, info.GetDescription(), icon, info.DisplayName, extraIcon)
278+
}

modules/web/middleware/cookie.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"code.gitea.io/gitea/modules/session"
1313
"code.gitea.io/gitea/modules/setting"
14+
"code.gitea.io/gitea/modules/util"
1415
)
1516

1617
// SetRedirectToCookie convenience function to set the RedirectTo cookie consistently
@@ -39,11 +40,13 @@ func SetSiteCookie(resp http.ResponseWriter, name, value string, maxAge int) {
3940
// These are more specific than cookies without a trailing /, so
4041
// we need to delete these if they exist.
4142
deleteLegacySiteCookie(resp, name)
43+
44+
// HINT: INSTALL-PAGE-COOKIE-INIT: the cookie system is not properly initialized on the Install page, so there is no CookiePath
4245
cookie := &http.Cookie{
4346
Name: name,
4447
Value: url.QueryEscape(value),
4548
MaxAge: maxAge,
46-
Path: setting.SessionConfig.CookiePath,
49+
Path: util.IfZero(setting.SessionConfig.CookiePath, "/"),
4750
Domain: setting.SessionConfig.Domain,
4851
Secure: setting.SessionConfig.Secure,
4952
HttpOnly: true,

public/assets/img/svg/gitea-colorblind-redgreen.svg

Lines changed: 1 addition & 0 deletions
Loading

public/assets/img/svg/gitea-eclipse.svg

Lines changed: 1 addition & 0 deletions
Loading

routers/common/errpage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func RenderPanicErrorPage(w http.ResponseWriter, req *http.Request, err any) {
3535
httpcache.SetCacheControlInHeader(w.Header(), &httpcache.CacheControlOptions{NoTransform: true})
3636
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
3737

38-
tmplCtx := context.TemplateContext{}
38+
tmplCtx := context.NewTemplateContext(req.Context(), req)
3939
tmplCtx["Locale"] = middleware.Locale(w, req)
4040
ctxData := middleware.GetContextData(req.Context())
4141

0 commit comments

Comments
 (0)