Skip to content

Commit 4fec29d

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix date rendering by adding `<gitea-absolute-date>` (go-gitea#29725) Update to labeler v5 (go-gitea#29721) Update Chroma to v2.13.0 (go-gitea#29732) Highlight archived labels (go-gitea#29680)
2 parents 7b9bd02 + 857243b commit 4fec29d

File tree

18 files changed

+184
-68
lines changed

18 files changed

+184
-68
lines changed

.github/labeler.yml

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,84 @@
11
modifies/docs:
2-
- "**/*.md"
3-
- "docs/**"
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- "**/*.md"
5+
- "docs/**"
46

57
modifies/frontend:
6-
- "web_src/**/*"
8+
- changed-files:
9+
- any-glob-to-any-file:
10+
- "web_src/**"
11+
- "tailwind.config.js"
12+
- "webpack.config.js"
713

814
modifies/templates:
9-
- all: ["templates/**", "!templates/swagger/v1_json.tmpl"]
15+
- changed-files:
16+
- all-globs-to-any-file:
17+
- "templates/**"
18+
- "!templates/swagger/v1_json.tmpl"
1019

1120
modifies/api:
12-
- "routers/api/**"
13-
- "templates/swagger/v1_json.tmpl"
21+
- changed-files:
22+
- any-glob-to-any-file:
23+
- "routers/api/**"
24+
- "templates/swagger/v1_json.tmpl"
1425

1526
modifies/cli:
16-
- "cmd/**"
27+
- changed-files:
28+
- any-glob-to-any-file:
29+
- "cmd/**"
1730

1831
modifies/translation:
19-
- "options/locale/*.ini"
32+
- changed-files:
33+
- any-glob-to-any-file:
34+
- "options/locale/*.ini"
2035

2136
modifies/migrations:
22-
- "models/migrations/**/*"
37+
- changed-files:
38+
- any-glob-to-any-file:
39+
- "models/migrations/**"
2340

2441
modifies/internal:
25-
- "Makefile"
26-
- "Dockerfile"
27-
- "Dockerfile.rootless"
28-
- "docker/**"
29-
- "webpack.config.js"
30-
- ".eslintrc.yaml"
31-
- ".golangci.yml"
32-
- ".markdownlint.yaml"
33-
- ".spectral.yaml"
34-
- ".stylelintrc.yaml"
35-
- ".yamllint.yaml"
36-
- ".github/**"
42+
- changed-files:
43+
- any-glob-to-any-file:
44+
- ".air.toml"
45+
- "Makefile"
46+
- "Dockerfile"
47+
- "Dockerfile.rootless"
48+
- ".dockerignore"
49+
- "docker/**"
50+
- ".editorconfig"
51+
- ".eslintrc.yaml"
52+
- ".golangci.yml"
53+
- ".gitpod.yml"
54+
- ".markdownlint.yaml"
55+
- ".spectral.yaml"
56+
- ".stylelintrc.yaml"
57+
- ".yamllint.yaml"
58+
- ".github/**"
59+
- ".gitea/"
60+
- ".devcontainer/**"
61+
- "build.go"
62+
- "build/**"
63+
- "contrib/**"
64+
65+
modifies/dependencies:
66+
- changed-files:
67+
- any-glob-to-any-file:
68+
- "package.json"
69+
- "package-lock.json"
70+
- "poetry.toml"
71+
- "poetry.lock"
72+
- "go.mod"
73+
- "go.sum"
74+
- "pyproject.toml"
75+
76+
modifies/go:
77+
- changed-files:
78+
- any-glob-to-any-file:
79+
- "**/*.go"
80+
81+
modifies/js:
82+
- changed-files:
83+
- any-glob-to-any-file:
84+
- "**/*.js"

.github/workflows/pull-labeler.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
label:
12+
labeler:
1313
runs-on: ubuntu-latest
1414
permissions:
1515
contents: read
1616
pull-requests: write
1717
steps:
18-
- uses: actions/labeler@v4
18+
- uses: actions/labeler@v5
1919
with:
20-
dot: true
20+
sync-labels: true

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
1818
github.com/NYTimes/gziphandler v1.1.1
1919
github.com/PuerkitoBio/goquery v1.8.1
20-
github.com/alecthomas/chroma/v2 v2.12.0
20+
github.com/alecthomas/chroma/v2 v2.13.0
2121
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
2222
github.com/blevesearch/bleve/v2 v2.3.10
2323
github.com/bufbuild/connect-go v1.10.0
@@ -172,7 +172,7 @@ require (
172172
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
173173
github.com/davidmz/go-pageant v1.0.2 // indirect
174174
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
175-
github.com/dlclark/regexp2 v1.10.0 // indirect
175+
github.com/dlclark/regexp2 v1.11.0 // indirect
176176
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 // indirect
177177
github.com/fatih/color v1.16.0 // indirect
178178
github.com/felixge/httpsnoop v1.0.4 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06
104104
github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I=
105105
github.com/RoaringBitmap/roaring v1.7.0 h1:OZF303tJCER1Tj3x+aArx/S5X7hrT186ri6JjrGvG68=
106106
github.com/RoaringBitmap/roaring v1.7.0/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
107-
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
108-
github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
107+
github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
108+
github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
109109
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
110-
github.com/alecthomas/chroma/v2 v2.12.0 h1:Wh8qLEgMMsN7mgyG8/qIpegky2Hvzr4By6gEF7cmWgw=
111-
github.com/alecthomas/chroma/v2 v2.12.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
110+
github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
111+
github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
112112
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
113-
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
114-
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
113+
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
114+
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
115115
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA=
116116
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
117117
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
@@ -260,8 +260,8 @@ github.com/djherbis/nio/v3 v3.0.1/go.mod h1:Ng4h80pbZFMla1yKzm61cF0tqqilXZYrogmW
260260
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
261261
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
262262
github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
263-
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
264-
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
263+
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
264+
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
265265
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
266266
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY=
267267
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s=

modules/templates/util_render.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"code.gitea.io/gitea/modules/markup"
2121
"code.gitea.io/gitea/modules/markup/markdown"
2222
"code.gitea.io/gitea/modules/setting"
23+
"code.gitea.io/gitea/modules/translation"
2324
"code.gitea.io/gitea/modules/util"
2425
)
2526

@@ -118,10 +119,15 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string)
118119
}
119120

120121
// RenderLabel renders a label
121-
func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
122-
labelScope := label.ExclusiveScope()
122+
// locale is needed due to an import cycle with our context providing the `Tr` function
123+
func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML {
124+
var (
125+
archivedCSSClass string
126+
textColor = "#111"
127+
isArchived = !label.ArchivedUnix.IsZero()
128+
labelScope = label.ExclusiveScope()
129+
)
123130

124-
textColor := "#111"
125131
r, g, b := util.HexToRBGColor(label.Color)
126132
// Determine if label text should be light or dark to be readable on background color
127133
if util.UseLightTextOnBackground(r, g, b) {
@@ -130,10 +136,15 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
130136

131137
description := emoji.ReplaceAliases(template.HTMLEscapeString(label.Description))
132138

139+
if isArchived {
140+
archivedCSSClass = "archived-label"
141+
description = fmt.Sprintf("(%s) %s", locale.TrString("archived"), description)
142+
}
143+
133144
if labelScope == "" {
134145
// Regular label
135-
s := fmt.Sprintf("<div class='ui label' style='color: %s !important; background-color: %s !important' data-tooltip-content title='%s'>%s</div>",
136-
textColor, label.Color, description, RenderEmoji(ctx, label.Name))
146+
s := fmt.Sprintf("<div class='ui label %s' style='color: %s !important; background-color: %s !important;' data-tooltip-content title='%s'>%s</div>",
147+
archivedCSSClass, textColor, label.Color, description, RenderEmoji(ctx, label.Name))
137148
return template.HTML(s)
138149
}
139150

@@ -166,11 +177,11 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
166177
itemColor := "#" + hex.EncodeToString(itemBytes)
167178
scopeColor := "#" + hex.EncodeToString(scopeBytes)
168179

169-
s := fmt.Sprintf("<span class='ui label scope-parent' data-tooltip-content title='%s'>"+
180+
s := fmt.Sprintf("<span class='ui label %s scope-parent' data-tooltip-content title='%s'>"+
170181
"<div class='ui label scope-left' style='color: %s !important; background-color: %s !important'>%s</div>"+
171182
"<div class='ui label scope-right' style='color: %s !important; background-color: %s !important'>%s</div>"+
172183
"</span>",
173-
description,
184+
archivedCSSClass, description,
174185
textColor, scopeColor, scopeText,
175186
textColor, itemColor, itemText)
176187
return template.HTML(s)
@@ -211,15 +222,15 @@ func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML { //n
211222
return output
212223
}
213224

214-
func RenderLabels(ctx context.Context, labels []*issues_model.Label, repoLink string) template.HTML {
225+
func RenderLabels(ctx context.Context, locale translation.Locale, labels []*issues_model.Label, repoLink string) template.HTML {
215226
htmlCode := `<span class="labels-list">`
216227
for _, label := range labels {
217228
// Protect against nil value in labels - shouldn't happen but would cause a panic if so
218229
if label == nil {
219230
continue
220231
}
221232
htmlCode += fmt.Sprintf("<a href='%s/issues?labels=%d'>%s</a> ",
222-
repoLink, label.ID, RenderLabel(ctx, label))
233+
repoLink, label.ID, RenderLabel(ctx, locale, label))
223234
}
224235
htmlCode += "</span>"
225236
return template.HTML(htmlCode)

modules/timeutil/datetime.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,16 @@ func DateTime(format string, datetime any, extraAttrs ...string) template.HTML {
5151

5252
attrs := make([]string, 0, 10+len(extraAttrs))
5353
attrs = append(attrs, extraAttrs...)
54-
attrs = append(attrs, `data-tooltip-content`, `data-tooltip-interactive="true"`)
55-
attrs = append(attrs, `format="datetime"`, `weekday=""`, `year="numeric"`)
54+
attrs = append(attrs, `weekday=""`, `year="numeric"`)
5655

5756
switch format {
58-
case "short":
59-
attrs = append(attrs, `month="short"`, `day="numeric"`)
60-
case "long":
61-
attrs = append(attrs, `month="long"`, `day="numeric"`)
62-
case "full":
63-
attrs = append(attrs, `month="short"`, `day="numeric"`, `hour="numeric"`, `minute="numeric"`, `second="numeric"`)
57+
case "short", "long": // date only
58+
attrs = append(attrs, `month="`+format+`"`, `day="numeric"`)
59+
return template.HTML(fmt.Sprintf(`<gitea-absolute-date %s date="%s">%s</gitea-absolute-date>`, strings.Join(attrs, " "), datetimeEscaped, textEscaped))
60+
case "full": // full date including time
61+
attrs = append(attrs, `format="datetime"`, `month="short"`, `day="numeric"`, `hour="numeric"`, `minute="numeric"`, `second="numeric"`, `data-tooltip-content`, `data-tooltip-interactive="true"`)
62+
return template.HTML(fmt.Sprintf(`<relative-time %s datetime="%s">%s</relative-time>`, strings.Join(attrs, " "), datetimeEscaped, textEscaped))
6463
default:
6564
panic(fmt.Sprintf("Unsupported format %s", format))
6665
}
67-
return template.HTML(fmt.Sprintf(`<relative-time %s datetime="%s">%s</relative-time>`, strings.Join(attrs, " "), datetimeEscaped, textEscaped))
6866
}

modules/timeutil/datetime_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestDateTime(t *testing.T) {
1818
defer test.MockVariableValue(&setting.DefaultUILocation, testTz)()
1919

2020
refTimeStr := "2018-01-01T00:00:00Z"
21+
refDateStr := "2018-01-01"
2122
refTime, _ := time.Parse(time.RFC3339, refTimeStr)
2223
refTimeStamp := TimeStamp(refTime.Unix())
2324

@@ -27,17 +28,20 @@ func TestDateTime(t *testing.T) {
2728
assert.EqualValues(t, "-", DateTime("short", TimeStamp(0)))
2829

2930
actual := DateTime("short", "invalid")
30-
assert.EqualValues(t, `<relative-time data-tooltip-content data-tooltip-interactive="true" format="datetime" weekday="" year="numeric" month="short" day="numeric" datetime="invalid">invalid</relative-time>`, actual)
31+
assert.EqualValues(t, `<gitea-absolute-date weekday="" year="numeric" month="short" day="numeric" date="invalid">invalid</gitea-absolute-date>`, actual)
3132

3233
actual = DateTime("short", refTimeStr)
33-
assert.EqualValues(t, `<relative-time data-tooltip-content data-tooltip-interactive="true" format="datetime" weekday="" year="numeric" month="short" day="numeric" datetime="2018-01-01T00:00:00Z">2018-01-01T00:00:00Z</relative-time>`, actual)
34+
assert.EqualValues(t, `<gitea-absolute-date weekday="" year="numeric" month="short" day="numeric" date="2018-01-01T00:00:00Z">2018-01-01T00:00:00Z</gitea-absolute-date>`, actual)
3435

3536
actual = DateTime("short", refTime)
36-
assert.EqualValues(t, `<relative-time data-tooltip-content data-tooltip-interactive="true" format="datetime" weekday="" year="numeric" month="short" day="numeric" datetime="2018-01-01T00:00:00Z">2018-01-01</relative-time>`, actual)
37+
assert.EqualValues(t, `<gitea-absolute-date weekday="" year="numeric" month="short" day="numeric" date="2018-01-01T00:00:00Z">2018-01-01</gitea-absolute-date>`, actual)
38+
39+
actual = DateTime("short", refDateStr)
40+
assert.EqualValues(t, `<gitea-absolute-date weekday="" year="numeric" month="short" day="numeric" date="2018-01-01">2018-01-01</gitea-absolute-date>`, actual)
3741

3842
actual = DateTime("short", refTimeStamp)
39-
assert.EqualValues(t, `<relative-time data-tooltip-content data-tooltip-interactive="true" format="datetime" weekday="" year="numeric" month="short" day="numeric" datetime="2017-12-31T19:00:00-05:00">2017-12-31</relative-time>`, actual)
43+
assert.EqualValues(t, `<gitea-absolute-date weekday="" year="numeric" month="short" day="numeric" date="2017-12-31T19:00:00-05:00">2017-12-31</gitea-absolute-date>`, actual)
4044

4145
actual = DateTime("full", refTimeStamp)
42-
assert.EqualValues(t, `<relative-time data-tooltip-content data-tooltip-interactive="true" format="datetime" weekday="" year="numeric" month="short" day="numeric" hour="numeric" minute="numeric" second="numeric" datetime="2017-12-31T19:00:00-05:00">2017-12-31 19:00:00 -05:00</relative-time>`, actual)
46+
assert.EqualValues(t, `<relative-time weekday="" year="numeric" format="datetime" month="short" day="numeric" hour="numeric" minute="numeric" second="numeric" data-tooltip-content data-tooltip-interactive="true" datetime="2017-12-31T19:00:00-05:00">2017-12-31 19:00:00 -05:00</relative-time>`, actual)
4347
}

templates/devtest/gitea-ui.tmpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@
110110
<div><gitea-origin-url data-url="/test/url"></gitea-origin-url></div>
111111
</div>
112112

113+
<div>
114+
<h1>GiteaAbsoluteDate</h1>
115+
<div><gitea-absolute-date date="2024-03-11" year="numeric" day="numeric" month="short"></gitea-absolute-date></div>
116+
<div><gitea-absolute-date date="2024-03-11" year="numeric" day="numeric" month="long"></gitea-absolute-date></div>
117+
<div><gitea-absolute-date date="2024-03-11" year="" day="numeric" month="numeric"></gitea-absolute-date></div>
118+
<div><gitea-absolute-date date="2024-03-11" year="" day="numeric" month="numeric" weekday="long"></gitea-absolute-date></div>
119+
<div><gitea-absolute-date date="2024-03-11T19:00:00-05:00" year="" day="numeric" month="numeric" weekday="long"></gitea-absolute-date></div>
120+
<div class="tw-text-text-light-2">relative-time: <relative-time format="datetime" datetime="2024-03-11" year="" day="numeric" month="numeric"></relative-time></div>
121+
</div>
122+
113123
<div>
114124
<h1>LocaleNumber</h1>
115125
<div>{{ctx.Locale.PrettyNumber 1}}</div>

templates/repo/issue/filter_actions.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{{end}}
3131
{{$previousExclusiveScope = $exclusiveScope}}
3232
<div class="item issue-action gt-df gt-sb" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels">
33-
{{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context .}}
33+
{{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context ctx.Locale .}}
3434
{{template "repo/issue/labels/label_archived" .}}
3535
</div>
3636
{{end}}

templates/repo/issue/filter_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
{{svg "octicon-check"}}
4343
{{end}}
4444
{{end}}
45-
{{RenderLabel $.Context .}}
45+
{{RenderLabel $.Context ctx.Locale .}}
4646
<p class="gt-ml-auto">{{template "repo/issue/labels/label_archived" .}}</p>
4747
</a>
4848
{{end}}

0 commit comments

Comments
 (0)