Skip to content

Commit bdaae5f

Browse files
authored
Merge branch 'main' into fix-issue-sugg
2 parents c518073 + 58eb16e commit bdaae5f

File tree

7 files changed

+28
-39
lines changed

7 files changed

+28
-39
lines changed

package-lock.json

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"sortablejs": "1.15.2",
4747
"swagger-ui-dist": "5.17.14",
4848
"tailwindcss": "3.4.10",
49-
"temporal-polyfill": "0.2.5",
5049
"throttle-debounce": "5.0.2",
5150
"tinycolor2": "1.6.0",
5251
"tippy.js": "6.3.7",

routers/web/explore/org.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"code.gitea.io/gitea/modules/container"
1010
"code.gitea.io/gitea/modules/setting"
1111
"code.gitea.io/gitea/modules/structs"
12+
"code.gitea.io/gitea/modules/util"
1213
"code.gitea.io/gitea/services/context"
1314
)
1415

@@ -39,7 +40,7 @@ func Organizations(ctx *context.Context) {
3940
)
4041
sortOrder := ctx.FormString("sort")
4142
if sortOrder == "" {
42-
sortOrder = "newest"
43+
sortOrder = util.Iif(supportedSortOrders.Contains(setting.UI.ExploreDefaultSort), setting.UI.ExploreDefaultSort, "newest")
4344
ctx.SetFormString("sort", sortOrder)
4445
}
4546

routers/web/explore/user.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/modules/setting"
1717
"code.gitea.io/gitea/modules/sitemap"
1818
"code.gitea.io/gitea/modules/structs"
19+
"code.gitea.io/gitea/modules/util"
1920
"code.gitea.io/gitea/services/context"
2021
)
2122

@@ -149,7 +150,7 @@ func Users(ctx *context.Context) {
149150
)
150151
sortOrder := ctx.FormString("sort")
151152
if sortOrder == "" {
152-
sortOrder = "newest"
153+
sortOrder = util.Iif(supportedSortOrders.Contains(setting.UI.ExploreDefaultSort), setting.UI.ExploreDefaultSort, "newest")
153154
ctx.SetFormString("sort", sortOrder)
154155
}
155156

web_src/js/components/RepoActivityTopAuthors.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const colors = ref({
1717
const activityTopAuthors = window.config.pageData.repoActivityTopAuthors || [];
1818
1919
const graphPoints = computed(() => {
20-
return activityTopAuthors.value.map((item) => {
20+
return activityTopAuthors.map((item) => {
2121
return {
2222
value: item.commits,
2323
label: item.name,
@@ -26,7 +26,7 @@ const graphPoints = computed(() => {
2626
});
2727
2828
const graphAuthors = computed(() => {
29-
return activityTopAuthors.value.map((item, idx) => {
29+
return activityTopAuthors.map((item, idx) => {
3030
return {
3131
position: idx + 1,
3232
...item,
@@ -35,7 +35,7 @@ const graphAuthors = computed(() => {
3535
});
3636
3737
const graphWidth = computed(() => {
38-
return activityTopAuthors.value.length * 40;
38+
return activityTopAuthors.length * 40;
3939
});
4040
4141
const styleElement = ref<HTMLElement | null>(null);

web_src/js/webcomponents/absolute-date.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ test('toAbsoluteLocaleDate', () => {
77
day: 'numeric',
88
})).toEqual('March 15, 2024');
99

10-
expect(toAbsoluteLocaleDate('2024-03-15', 'de-DE', {
10+
expect(toAbsoluteLocaleDate('2024-03-15T01:02:03', 'de-DE', {
1111
year: 'numeric',
1212
month: 'long',
1313
day: 'numeric',
1414
})).toEqual('15. März 2024');
15+
16+
expect(toAbsoluteLocaleDate('12345-03-15 01:02:03', '', {
17+
year: 'numeric',
18+
month: 'short',
19+
day: 'numeric',
20+
})).toEqual('Mar 15, 12345');
1521
});

web_src/js/webcomponents/absolute-date.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
import {Temporal} from 'temporal-polyfill';
2-
3-
export function toAbsoluteLocaleDate(dateStr, lang, opts) {
4-
return Temporal.PlainDate.from(dateStr).toLocaleString(lang ?? [], opts);
1+
export function toAbsoluteLocaleDate(date: string, lang: string, opts: Intl.DateTimeFormatOptions) {
2+
return new Date(date).toLocaleString(lang || [], opts);
53
}
64

75
window.customElements.define('absolute-date', class extends HTMLElement {
86
static observedAttributes = ['date', 'year', 'month', 'weekday', 'day'];
97

8+
initialized = false;
9+
1010
update = () => {
11-
const year = this.getAttribute('year') ?? '';
12-
const month = this.getAttribute('month') ?? '';
13-
const weekday = this.getAttribute('weekday') ?? '';
14-
const day = this.getAttribute('day') ?? '';
11+
const opt: Intl.DateTimeFormatOptions = {};
12+
for (const attr of ['year', 'month', 'weekday', 'day']) {
13+
if (this.getAttribute(attr)) opt[attr] = this.getAttribute(attr);
14+
}
1515
const lang = this.closest('[lang]')?.getAttribute('lang') ||
1616
this.ownerDocument.documentElement.getAttribute('lang') || '';
1717

18-
// only use the first 10 characters, e.g. the `yyyy-mm-dd` part
19-
const dateStr = this.getAttribute('date').substring(0, 10);
18+
// only use the date part, it is guaranteed to be in ISO format (YYYY-MM-DDTHH:mm:ss.sssZ)
19+
let date = this.getAttribute('date');
20+
let dateSep = date.indexOf('T');
21+
dateSep = dateSep === -1 ? date.indexOf(' ') : dateSep;
22+
date = dateSep === -1 ? date : date.substring(0, dateSep);
2023

2124
if (!this.shadowRoot) this.attachShadow({mode: 'open'});
22-
this.shadowRoot.textContent = toAbsoluteLocaleDate(dateStr, lang, {
23-
...(year && {year}),
24-
...(month && {month}),
25-
...(weekday && {weekday}),
26-
...(day && {day}),
27-
});
25+
this.shadowRoot.textContent = toAbsoluteLocaleDate(date, lang, opt);
2826
};
2927

3028
attributeChangedCallback(_name, oldValue, newValue) {

0 commit comments

Comments
 (0)