Skip to content

Commit 671fbf4

Browse files
authored
Merge branch 'go-gitea:main' into add-runstatus-component
2 parents e3e2d3a + e080013 commit 671fbf4

File tree

142 files changed

+1821
-634
lines changed

Some content is hidden

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

142 files changed

+1821
-634
lines changed

build/update-locales.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,50 @@
11
#!/bin/sh
22

3+
# this script runs in alpine image which only has `sh` shell
4+
5+
set +e
6+
if sed --version 2>/dev/null | grep -q GNU; then
7+
SED_INPLACE="sed -i"
8+
else
9+
SED_INPLACE="sed -i ''"
10+
fi
11+
set -e
12+
13+
if [ ! -f ./options/locale/locale_en-US.ini ]; then
14+
echo "please run this script in the root directory of the project"
15+
exit 1
16+
fi
17+
318
mv ./options/locale/locale_en-US.ini ./options/
419

5-
# Make sure to only change lines that have the translation enclosed between quotes
6-
sed -i -r -e '/^[a-zA-Z0-9_.-]+[ ]*=[ ]*".*"$/ {
7-
s/^([a-zA-Z0-9_.-]+)[ ]*="/\1=/
8-
s/\\"/"/g
20+
# the "ini" library for locale has many quirks
21+
# * `a="xx"` gets `xx` (no quote)
22+
# * `a=x\"y` gets `x\"y` (no unescaping)
23+
# * `a="x\"y"` gets `"x\"y"` (no unescaping, the quotes are still there)
24+
# * `a='x\"y'` gets `x\"y` (no unescaping, no quote)
25+
# * `a="foo` gets `"foo` (although the quote is not closed)
26+
# * 'a=`foo`' works like single-quote
27+
# crowdin needs the strings to be quoted correctly and doesn't like incomplete quotes
28+
# crowdin always outputs quoted strings if there are quotes in the strings.
29+
30+
# this script helps to unquote the crowdin outputs for the quirky ini library
31+
# * find all `key="...\"..."` lines
32+
# * remove the leading quote
33+
# * remove the trailing quote
34+
# * unescape the quotes
35+
# * eg: key="...\"..." => key=..."...
36+
$SED_INPLACE -r -e '/^[-.A-Za-z0-9_]+[ ]*=[ ]*".*"$/ {
37+
s/^([-.A-Za-z0-9_]+)[ ]*=[ ]*"/\1=/
938
s/"$//
39+
s/\\"/"/g
1040
}' ./options/locale/*.ini
1141

42+
# * if the escaped line is incomplete like `key="...` or `key=..."`, quote it with backticks
43+
# * eg: key="... => key=`"...`
44+
# * eg: key=..." => key=`..."`
45+
$SED_INPLACE -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*(".*[^"])$/\1=`\2`/' ./options/locale/*.ini
46+
$SED_INPLACE -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*([^"].*")$/\1=`\2`/' ./options/locale/*.ini
47+
1248
# Remove translation under 25% of en_us
1349
baselines=$(wc -l "./options/locale_en-US.ini" | cut -d" " -f1)
1450
baselines=$((baselines / 4))

cmd/dump.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func runDump(ctx *cli.Context) error {
272272
fatal("Failed to create tmp file: %v", err)
273273
}
274274
defer func() {
275+
_ = dbDump.Close()
275276
if err := util.Remove(dbDump.Name()); err != nil {
276277
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
277278
}

docs/content/doc/developers/guidelines-frontend.en-us.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h
4747
7. Clarify variable types, prefer `elem.disabled = true` instead of `elem.setAttribute('disabled', 'anything')`, prefer `$el.prop('checked', var === 'yes')` instead of `$el.prop('checked', var)`.
4848
8. Use semantic elements, prefer `<button class="ui button">` instead of `<div class="ui button">`.
4949
9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided.
50+
10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event.
51+
11. Custom event names are recommended to use `ce-` prefix.
5052

5153
### Accessibility / ARIA
5254

@@ -83,6 +85,9 @@ It's not recommended to use `async` event listeners, which may lead to problems.
8385
The reason is that the code after await is executed outside the event dispatch.
8486
Reference: https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md
8587

88+
If an event listener must be `async`, the `e.preventDefault()` should be before any `await`,
89+
it's recommended to put it at the beginning of the function.
90+
8691
If we want to call an `async` function in a non-async context,
8792
it's recommended to use `const _promise = asyncFoo()` to tell readers
8893
that this is done by purpose, we want to call the async function and ignore the Promise.
@@ -106,6 +111,22 @@ However, there are still some special cases, so the current guideline is:
106111
* Vue components are recommended to use `v-if` and `v-show` to show/hide elements.
107112
* Go template code should use Gitea's `.gt-hidden` and `showElem()/hideElem()/toggleElem()`, see more details in `.gt-hidden`'s comment.
108113

114+
### Styles and Attributes in Go HTML Template
115+
116+
It's recommended to use:
117+
118+
```html
119+
<div class="gt-name1 gt-name2 {{if .IsFoo}}gt-foo{{end}}" {{if .IsFoo}}data-foo{{end}}></div>
120+
```
121+
122+
instead of:
123+
124+
```html
125+
<div class="gt-name1 gt-name2{{if .IsFoo}} gt-foo{{end}}"{{if .IsFoo}} data-foo{{end}}></div>
126+
```
127+
128+
to make the code more readable.
129+
109130
### Legacy Code
110131

111132
A lot of legacy code already existed before this document's written. It's recommended to refactor legacy code to follow the guidelines.

0 commit comments

Comments
 (0)