Skip to content

Commit b842d2a

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: [skip ci] Updated translations via Crowdin fix artifact merging chunks path with correct slash on Windows (go-gitea#26400) Use flex classes in package settings (go-gitea#26314) Improve multiple strings in en-US locale (go-gitea#26213) Refactor "editorconfig" (go-gitea#26391) fix generated source URL on rendered files (go-gitea#26364) Remove unnecessary template helper DisableGravatar (go-gitea#26386)
2 parents 7a94ddf + 906e253 commit b842d2a

File tree

18 files changed

+294
-242
lines changed

18 files changed

+294
-242
lines changed

models/fixtures/repo_unit.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,3 +637,15 @@
637637
repo_id: 58
638638
type: 5
639639
created_unix: 946684810
640+
641+
-
642+
id: 96
643+
repo_id: 49
644+
type: 1
645+
created_unix: 946684810
646+
647+
-
648+
id: 97
649+
repo_id: 49
650+
type: 2
651+
created_unix: 946684810

modules/templates/helper.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
package templates
66

77
import (
8-
"context"
98
"fmt"
109
"html"
1110
"html/template"
1211
"net/url"
1312
"strings"
1413
"time"
1514

16-
system_model "code.gitea.io/gitea/models/system"
1715
"code.gitea.io/gitea/modules/base"
1816
"code.gitea.io/gitea/modules/emoji"
1917
"code.gitea.io/gitea/modules/markup"
@@ -104,9 +102,6 @@ func NewFuncMap() template.FuncMap {
104102
"AssetVersion": func() string {
105103
return setting.AssetVersion
106104
},
107-
"DisableGravatar": func(ctx context.Context) bool {
108-
return system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
109-
},
110105
"DefaultShowFullName": func() bool {
111106
return setting.UI.DefaultShowFullName
112107
},

modules/templates/util_misc.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ package templates
55

66
import (
77
"context"
8-
"fmt"
98
"html/template"
109
"mime"
1110
"path/filepath"
11+
"strconv"
1212
"strings"
1313
"time"
1414

@@ -174,23 +174,12 @@ func FilenameIsImage(filename string) bool {
174174
return strings.HasPrefix(mimeType, "image/")
175175
}
176176

177-
func TabSizeClass(ec any, filename string) string {
178-
var (
179-
value *editorconfig.Editorconfig
180-
ok bool
181-
)
177+
func TabSizeClass(ec *editorconfig.Editorconfig, filename string) string {
182178
if ec != nil {
183-
if value, ok = ec.(*editorconfig.Editorconfig); !ok || value == nil {
184-
return "tab-size-8"
185-
}
186-
def, err := value.GetDefinitionForFilename(filename)
187-
if err != nil {
188-
log.Error("tab size class: getting definition for filename: %v", err)
189-
return "tab-size-8"
190-
}
191-
if def.TabWidth > 0 {
192-
return fmt.Sprintf("tab-size-%d", def.TabWidth)
179+
def, err := ec.GetDefinitionForFilename(filename)
180+
if err == nil && def.TabWidth >= 1 && def.TabWidth <= 16 {
181+
return "tab-size-" + strconv.Itoa(def.TabWidth)
193182
}
194183
}
195-
return "tab-size-8"
184+
return "tab-size-4"
196185
}

options/locale/locale_de-DE.ini

Lines changed: 101 additions & 101 deletions
Large diffs are not rendered by default.

options/locale/locale_en-US.ini

Lines changed: 80 additions & 78 deletions
Large diffs are not rendered by default.

routers/api/actions/artifacts_chunks.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/base64"
99
"fmt"
1010
"io"
11+
"path/filepath"
1112
"sort"
1213
"time"
1314

@@ -67,7 +68,7 @@ func listChunksByRunID(st storage.ObjectStorage, runID int64) (map[int64][]*chun
6768
var chunks []*chunkFileItem
6869
if err := st.IterateObjects(storageDir, func(path string, obj storage.Object) error {
6970
item := chunkFileItem{Path: path}
70-
if _, err := fmt.Sscanf(path, storageDir+"/%d-%d-%d.chunk", &item.ArtifactID, &item.Start, &item.End); err != nil {
71+
if _, err := fmt.Sscanf(path, filepath.Join(storageDir, "%d-%d-%d.chunk"), &item.ArtifactID, &item.Start, &item.End); err != nil {
7172
return fmt.Errorf("parse content range error: %v", err)
7273
}
7374
chunks = append(chunks, &item)

routers/web/admin/users.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"code.gitea.io/gitea/models"
1414
"code.gitea.io/gitea/models/auth"
1515
"code.gitea.io/gitea/models/db"
16+
system_model "code.gitea.io/gitea/models/system"
1617
user_model "code.gitea.io/gitea/models/user"
1718
"code.gitea.io/gitea/modules/auth/password"
1819
"code.gitea.io/gitea/modules/base"
@@ -255,6 +256,7 @@ func EditUser(ctx *context.Context) {
255256
ctx.Data["DisableRegularOrgCreation"] = setting.Admin.DisableRegularOrgCreation
256257
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
257258
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
259+
ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
258260

259261
prepareUserInfo(ctx)
260262
if ctx.Written() {
@@ -271,6 +273,7 @@ func EditUserPost(ctx *context.Context) {
271273
ctx.Data["PageIsAdminUsers"] = true
272274
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
273275
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
276+
ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
274277

275278
u := prepareUserInfo(ctx)
276279
if ctx.Written() {

routers/web/repo/editor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
191191
ctx.Data["last_commit"] = ctx.Repo.CommitID
192192
ctx.Data["PreviewableExtensions"] = strings.Join(markup.PreviewableExtensions(), ",")
193193
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
194-
ctx.Data["Editorconfig"] = GetEditorConfig(ctx, treePath)
194+
ctx.Data["EditorconfigJson"] = GetEditorConfig(ctx, treePath)
195195

196196
ctx.HTML(http.StatusOK, tplEditFile)
197197
}
@@ -242,7 +242,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
242242
ctx.Data["last_commit"] = ctx.Repo.CommitID
243243
ctx.Data["PreviewableExtensions"] = strings.Join(markup.PreviewableExtensions(), ",")
244244
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
245-
ctx.Data["Editorconfig"] = GetEditorConfig(ctx, form.TreePath)
245+
ctx.Data["EditorconfigJson"] = GetEditorConfig(ctx, form.TreePath)
246246

247247
if ctx.HasError() {
248248
ctx.HTML(http.StatusOK, tplEditFile)

routers/web/user/setting/profile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"code.gitea.io/gitea/models/db"
1818
"code.gitea.io/gitea/models/organization"
1919
repo_model "code.gitea.io/gitea/models/repo"
20+
system_model "code.gitea.io/gitea/models/system"
2021
user_model "code.gitea.io/gitea/models/user"
2122
"code.gitea.io/gitea/modules/base"
2223
"code.gitea.io/gitea/modules/context"
@@ -43,6 +44,7 @@ func Profile(ctx *context.Context) {
4344
ctx.Data["Title"] = ctx.Tr("settings.profile")
4445
ctx.Data["PageIsSettingsProfile"] = true
4546
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
47+
ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
4648

4749
ctx.HTML(http.StatusOK, tplSettingsProfile)
4850
}
@@ -83,6 +85,8 @@ func ProfilePost(ctx *context.Context) {
8385
form := web.GetForm(ctx).(*forms.UpdateProfileForm)
8486
ctx.Data["Title"] = ctx.Tr("settings")
8587
ctx.Data["PageIsSettingsProfile"] = true
88+
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
89+
ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
8690

8791
if ctx.HasError() {
8892
ctx.HTML(http.StatusOK, tplSettingsProfile)

templates/admin/user/edit.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<div class="ui attached segment">
160160
<form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data">
161161
{{.CsrfTokenHtml}}
162-
{{if not (DisableGravatar $.Context)}}
162+
{{if not .DisableGravatar}}
163163
<div class="inline field">
164164
<div class="ui radio checkbox">
165165
<input name="source" value="lookup" type="radio" {{if not .User.UseCustomAvatar}}checked{{end}}>

0 commit comments

Comments
 (0)