Skip to content

Commit 5447ef0

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Refactor names (go-gitea#31405) Update JS dependencies, remove `eslint-plugin-jquery` (go-gitea#31402) Switch to upstream of `gorilla/feeds` (go-gitea#31400)
2 parents b815a27 + 7adf8d7 commit 5447ef0

File tree

185 files changed

+1332
-1368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+1332
-1368
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ plugins:
1616
- eslint-plugin-array-func
1717
- eslint-plugin-github
1818
- eslint-plugin-i
19-
- eslint-plugin-jquery
2019
- eslint-plugin-no-jquery
2120
- eslint-plugin-no-use-extend-native
2221
- eslint-plugin-regexp
@@ -282,55 +281,6 @@ rules:
282281
i/prefer-default-export: [0]
283282
i/unambiguous: [0]
284283
init-declarations: [0]
285-
jquery/no-ajax-events: [2]
286-
jquery/no-ajax: [2]
287-
jquery/no-animate: [2]
288-
jquery/no-attr: [2]
289-
jquery/no-bind: [2]
290-
jquery/no-class: [0]
291-
jquery/no-clone: [2]
292-
jquery/no-closest: [0]
293-
jquery/no-css: [2]
294-
jquery/no-data: [0]
295-
jquery/no-deferred: [2]
296-
jquery/no-delegate: [2]
297-
jquery/no-each: [0]
298-
jquery/no-extend: [2]
299-
jquery/no-fade: [2]
300-
jquery/no-filter: [0]
301-
jquery/no-find: [0]
302-
jquery/no-global-eval: [2]
303-
jquery/no-grep: [2]
304-
jquery/no-has: [2]
305-
jquery/no-hide: [2]
306-
jquery/no-html: [0]
307-
jquery/no-in-array: [2]
308-
jquery/no-is-array: [2]
309-
jquery/no-is-function: [2]
310-
jquery/no-is: [2]
311-
jquery/no-load: [2]
312-
jquery/no-map: [2]
313-
jquery/no-merge: [2]
314-
jquery/no-param: [2]
315-
jquery/no-parent: [0]
316-
jquery/no-parents: [2]
317-
jquery/no-parse-html: [2]
318-
jquery/no-prop: [2]
319-
jquery/no-proxy: [2]
320-
jquery/no-ready: [2]
321-
jquery/no-serialize: [2]
322-
jquery/no-show: [2]
323-
jquery/no-size: [2]
324-
jquery/no-sizzle: [2]
325-
jquery/no-slide: [2]
326-
jquery/no-submit: [2]
327-
jquery/no-text: [2]
328-
jquery/no-toggle: [2]
329-
jquery/no-trigger: [0]
330-
jquery/no-trim: [2]
331-
jquery/no-val: [0]
332-
jquery/no-when: [2]
333-
jquery/no-wrap: [2]
334284
line-comment-position: [0]
335285
logical-assignment-operators: [0]
336286
max-classes-per-file: [0]
@@ -740,6 +690,7 @@ rules:
740690
unicorn/no-lonely-if: [2]
741691
unicorn/no-magic-array-flat-depth: [0]
742692
unicorn/no-negated-condition: [0]
693+
unicorn/no-negation-in-equality-check: [2]
743694
unicorn/no-nested-ternary: [0]
744695
unicorn/no-new-array: [0]
745696
unicorn/no-new-buffer: [0]

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ require (
5959
github.com/google/go-github/v61 v61.0.0
6060
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7
6161
github.com/google/uuid v1.6.0
62-
github.com/gorilla/feeds v1.1.2
62+
github.com/gorilla/feeds v1.2.0
6363
github.com/gorilla/sessions v1.2.2
6464
github.com/h2non/gock v1.2.0
6565
github.com/hashicorp/go-version v1.6.0
@@ -309,8 +309,6 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
309309

310310
replace github.com/nektos/act => gitea.com/gitea/act v0.259.1
311311

312-
replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5
313-
314312
// TODO: This could be removed after https://github.com/mholt/archiver/pull/396 merged
315313
replace github.com/mholt/archiver/v3 => github.com/anchore/archiver/v3 v3.5.2
316314

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8
426426
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
427427
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
428428
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
429+
github.com/gorilla/feeds v1.2.0 h1:O6pBiXJ5JHhPvqy53NsjKOThq+dNFm8+DFrxBEdzSCc=
430+
github.com/gorilla/feeds v1.2.0/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
429431
github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
430432
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
431433
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
@@ -811,8 +813,6 @@ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMx
811813
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
812814
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
813815
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
814-
github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5 h1:3seWKGVhGoc66Ht5QlhQsr4xT2caDnFegsnh2NqvENU=
815-
github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
816816
github.com/yohcop/openid-go v1.0.1 h1:DPRd3iPO5F6O5zX2e62XpVAbPT6wV51cuucH0z9g3js=
817817
github.com/yohcop/openid-go v1.0.1/go.mod h1:b/AvD03P0KHj4yuihb+VtLD6bYYgsy0zqBzPCRjkCNs=
818818
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=

modules/templates/helper.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ func NewFuncMap() template.FuncMap {
3636
// -----------------------------------------------------------------
3737
// html/template related functions
3838
"dict": dict, // it's lowercase because this name has been widely used. Our other functions should have uppercase names.
39-
"Iif": Iif,
40-
"Eval": Eval,
41-
"SafeHTML": SafeHTML,
39+
"Iif": iif,
40+
"Eval": evalTokens,
41+
"SafeHTML": safeHTML,
4242
"HTMLFormat": HTMLFormat,
43-
"HTMLEscape": HTMLEscape,
44-
"QueryEscape": QueryEscape,
45-
"JSEscape": JSEscapeSafe,
43+
"HTMLEscape": htmlEscape,
44+
"QueryEscape": queryEscape,
45+
"JSEscape": jsEscapeSafe,
4646
"SanitizeHTML": SanitizeHTML,
4747
"URLJoin": util.URLJoin,
48-
"DotEscape": DotEscape,
48+
"DotEscape": dotEscape,
4949

5050
"PathEscape": url.PathEscape,
5151
"PathEscapeSegments": util.PathEscapeSegments,
@@ -59,9 +59,9 @@ func NewFuncMap() template.FuncMap {
5959
// svg / avatar / icon / color
6060
"svg": svg.RenderHTML,
6161
"EntryIcon": base.EntryIcon,
62-
"MigrationIcon": MigrationIcon,
63-
"ActionIcon": ActionIcon,
64-
"SortArrow": SortArrow,
62+
"MigrationIcon": migrationIcon,
63+
"ActionIcon": actionIcon,
64+
"SortArrow": sortArrow,
6565
"ContrastColor": util.ContrastColor,
6666

6767
// -----------------------------------------------------------------
@@ -139,7 +139,7 @@ func NewFuncMap() template.FuncMap {
139139
"DisableImportLocal": func() bool {
140140
return !setting.ImportLocalPaths
141141
},
142-
"UserThemeName": UserThemeName,
142+
"UserThemeName": userThemeName,
143143
"NotificationSettings": func() map[string]any {
144144
return map[string]any{
145145
"MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond),
@@ -155,28 +155,28 @@ func NewFuncMap() template.FuncMap {
155155
// -----------------------------------------------------------------
156156
// render
157157
"RenderCommitMessage": RenderCommitMessage,
158-
"RenderCommitMessageLinkSubject": RenderCommitMessageLinkSubject,
158+
"RenderCommitMessageLinkSubject": renderCommitMessageLinkSubject,
159159

160-
"RenderCommitBody": RenderCommitBody,
161-
"RenderCodeBlock": RenderCodeBlock,
162-
"RenderIssueTitle": RenderIssueTitle,
163-
"RenderEmoji": RenderEmoji,
164-
"ReactionToEmoji": ReactionToEmoji,
160+
"RenderCommitBody": renderCommitBody,
161+
"RenderCodeBlock": renderCodeBlock,
162+
"RenderIssueTitle": renderIssueTitle,
163+
"RenderEmoji": renderEmoji,
164+
"ReactionToEmoji": reactionToEmoji,
165165

166166
"RenderMarkdownToHtml": RenderMarkdownToHtml,
167-
"RenderLabel": RenderLabel,
167+
"RenderLabel": renderLabel,
168168
"RenderLabels": RenderLabels,
169169

170170
// -----------------------------------------------------------------
171171
// misc
172172
"ShortSha": base.ShortSha,
173173
"ActionContent2Commits": ActionContent2Commits,
174-
"IsMultilineCommitMessage": IsMultilineCommitMessage,
174+
"IsMultilineCommitMessage": isMultilineCommitMessage,
175175
"CommentMustAsDiff": gitdiff.CommentMustAsDiff,
176176
"MirrorRemoteAddress": mirrorRemoteAddress,
177177

178-
"FilenameIsImage": FilenameIsImage,
179-
"TabSizeClass": TabSizeClass,
178+
"FilenameIsImage": filenameIsImage,
179+
"TabSizeClass": tabSizeClass,
180180
}
181181
}
182182

@@ -197,8 +197,8 @@ func HTMLFormat(s string, rawArgs ...any) template.HTML {
197197
return template.HTML(fmt.Sprintf(s, args...))
198198
}
199199

200-
// SafeHTML render raw as HTML
201-
func SafeHTML(s any) template.HTML {
200+
// safeHTML render raw as HTML
201+
func safeHTML(s any) template.HTML {
202202
switch v := s.(type) {
203203
case string:
204204
return template.HTML(v)
@@ -213,7 +213,7 @@ func SanitizeHTML(s string) template.HTML {
213213
return template.HTML(markup.Sanitize(s))
214214
}
215215

216-
func HTMLEscape(s any) template.HTML {
216+
func htmlEscape(s any) template.HTML {
217217
switch v := s.(type) {
218218
case string:
219219
return template.HTML(html.EscapeString(v))
@@ -223,22 +223,22 @@ func HTMLEscape(s any) template.HTML {
223223
panic(fmt.Sprintf("unexpected type %T", s))
224224
}
225225

226-
func JSEscapeSafe(s string) template.HTML {
226+
func jsEscapeSafe(s string) template.HTML {
227227
return template.HTML(template.JSEscapeString(s))
228228
}
229229

230-
func QueryEscape(s string) template.URL {
230+
func queryEscape(s string) template.URL {
231231
return template.URL(url.QueryEscape(s))
232232
}
233233

234-
// DotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent autolinkers from detecting these as urls
235-
func DotEscape(raw string) string {
234+
// dotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent auto-linkers from detecting these as urls
235+
func dotEscape(raw string) string {
236236
return strings.ReplaceAll(raw, ".", "\u200d.\u200d")
237237
}
238238

239-
// Iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version,
240-
// and it could be simply used as "{{Iif expr trueVal}}" (omit the falseVal).
241-
func Iif(condition any, vals ...any) any {
239+
// iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version,
240+
// and it could be simply used as "{{iif expr trueVal}}" (omit the falseVal).
241+
func iif(condition any, vals ...any) any {
242242
if isTemplateTruthy(condition) {
243243
return vals[0]
244244
} else if len(vals) > 1 {
@@ -273,19 +273,19 @@ func isTemplateTruthy(v any) bool {
273273
}
274274
}
275275

276-
// Eval the expression and return the result, see the comment of eval.Expr for details.
276+
// evalTokens evaluates the expression by tokens and returns the result, see the comment of eval.Expr for details.
277277
// To use this helper function in templates, pass each token as a separate parameter.
278278
//
279279
// {{ $int64 := Eval $var "+" 1 }}
280280
// {{ $float64 := Eval $var "+" 1.0 }}
281281
//
282282
// Golang's template supports comparable int types, so the int64 result can be used in later statements like {{if lt $int64 10}}
283-
func Eval(tokens ...any) (any, error) {
283+
func evalTokens(tokens ...any) (any, error) {
284284
n, err := eval.Expr(tokens...)
285285
return n.Value, err
286286
}
287287

288-
func UserThemeName(user *user_model.User) string {
288+
func userThemeName(user *user_model.User) string {
289289
if user == nil || user.Theme == "" {
290290
return setting.UI.DefaultTheme
291291
}

modules/templates/helper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestSubjectBodySeparator(t *testing.T) {
5858
}
5959

6060
func TestJSEscapeSafe(t *testing.T) {
61-
assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, JSEscapeSafe(`&<>'"`))
61+
assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, jsEscapeSafe(`&<>'"`))
6262
}
6363

6464
func TestHTMLFormat(t *testing.T) {
@@ -71,7 +71,7 @@ func TestSanitizeHTML(t *testing.T) {
7171

7272
func TestTemplateTruthy(t *testing.T) {
7373
tmpl := template.New("test")
74-
tmpl.Funcs(template.FuncMap{"Iif": Iif})
74+
tmpl.Funcs(template.FuncMap{"Iif": iif})
7575
template.Must(tmpl.Parse(`{{if .Value}}true{{else}}false{{end}}:{{Iif .Value "true" "false"}}`))
7676

7777
cases := []any{

modules/templates/mailer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}\s*$`)
2222
func mailSubjectTextFuncMap() texttmpl.FuncMap {
2323
return texttmpl.FuncMap{
2424
"dict": dict,
25-
"Eval": Eval,
25+
"Eval": evalTokens,
2626

2727
"EllipsisString": base.EllipsisString,
2828
"AppName": func() string {

modules/templates/util_misc.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/editorconfig/editorconfig-core-go/v2"
2525
)
2626

27-
func SortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML {
27+
func sortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML {
2828
// if needed
2929
if len(normSort) == 0 || len(urlSort) == 0 {
3030
return ""
@@ -50,8 +50,8 @@ func SortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML
5050
return ""
5151
}
5252

53-
// IsMultilineCommitMessage checks to see if a commit message contains multiple lines.
54-
func IsMultilineCommitMessage(msg string) bool {
53+
// isMultilineCommitMessage checks to see if a commit message contains multiple lines.
54+
func isMultilineCommitMessage(msg string) bool {
5555
return strings.Count(strings.TrimSpace(msg), "\n") >= 1
5656
}
5757

@@ -69,8 +69,8 @@ type Actioner interface {
6969
GetIssueInfos() []string
7070
}
7171

72-
// ActionIcon accepts an action operation type and returns an icon class name.
73-
func ActionIcon(opType activities_model.ActionType) string {
72+
// actionIcon accepts an action operation type and returns an icon class name.
73+
func actionIcon(opType activities_model.ActionType) string {
7474
switch opType {
7575
case activities_model.ActionCreateRepo, activities_model.ActionTransferRepo, activities_model.ActionRenameRepo:
7676
return "repo"
@@ -126,8 +126,8 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
126126
return push
127127
}
128128

129-
// MigrationIcon returns a SVG name matching the service an issue/comment was migrated from
130-
func MigrationIcon(hostname string) string {
129+
// migrationIcon returns a SVG name matching the service an issue/comment was migrated from
130+
func migrationIcon(hostname string) string {
131131
switch hostname {
132132
case "github.com":
133133
return "octicon-mark-github"
@@ -177,12 +177,12 @@ func mirrorRemoteAddress(ctx context.Context, m *repo_model.Repository, remoteNa
177177
return ret
178178
}
179179

180-
func FilenameIsImage(filename string) bool {
180+
func filenameIsImage(filename string) bool {
181181
mimeType := mime.TypeByExtension(filepath.Ext(filename))
182182
return strings.HasPrefix(mimeType, "image/")
183183
}
184184

185-
func TabSizeClass(ec *editorconfig.Editorconfig, filename string) string {
185+
func tabSizeClass(ec *editorconfig.Editorconfig, filename string) string {
186186
if ec != nil {
187187
def, err := ec.GetDefinitionForFilename(filename)
188188
if err == nil && def.TabWidth >= 1 && def.TabWidth <= 16 {

0 commit comments

Comments
 (0)