Skip to content

Commit 6f8f906

Browse files
Merge branch 'main' into main
2 parents 4c1e07a + 27ba7ff commit 6f8f906

File tree

119 files changed

+1574
-545
lines changed

Some content is hidden

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

119 files changed

+1574
-545
lines changed

build/update-locales.sh

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

3-
set -e
4-
5-
SED=sed
3+
# this script runs in alpine image which only has `sh` shell
64

7-
if [[ $OSTYPE == 'darwin'* ]]; then
8-
# for macOS developers, use "brew install gnu-sed"
9-
SED=gsed
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 ''"
1010
fi
11+
set -e
1112

1213
if [ ! -f ./options/locale/locale_en-US.ini ]; then
1314
echo "please run this script in the root directory of the project"
@@ -32,7 +33,7 @@ mv ./options/locale/locale_en-US.ini ./options/
3233
# * remove the trailing quote
3334
# * unescape the quotes
3435
# * eg: key="...\"..." => key=..."...
35-
$SED -i -r -e '/^[-.A-Za-z0-9_]+[ ]*=[ ]*".*"$/ {
36+
$SED_INPLACE -r -e '/^[-.A-Za-z0-9_]+[ ]*=[ ]*".*"$/ {
3637
s/^([-.A-Za-z0-9_]+)[ ]*=[ ]*"/\1=/
3738
s/"$//
3839
s/\\"/"/g
@@ -41,8 +42,8 @@ $SED -i -r -e '/^[-.A-Za-z0-9_]+[ ]*=[ ]*".*"$/ {
4142
# * if the escaped line is incomplete like `key="...` or `key=..."`, quote it with backticks
4243
# * eg: key="... => key=`"...`
4344
# * eg: key=..." => key=`..."`
44-
$SED -i -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*(".*[^"])$/\1=`\2`/' ./options/locale/*.ini
45-
$SED -i -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*([^"].*")$/\1=`\2`/' ./options/locale/*.ini
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
4647

4748
# Remove translation under 25% of en_us
4849
baselines=$(wc -l "./options/locale_en-US.ini" | cut -d" " -f1)

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

+18
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

@@ -109,6 +111,22 @@ However, there are still some special cases, so the current guideline is:
109111
* Vue components are recommended to use `v-if` and `v-show` to show/hide elements.
110112
* Go template code should use Gitea's `.gt-hidden` and `showElem()/hideElem()/toggleElem()`, see more details in `.gt-hidden`'s comment.
111113

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+
112130
### Legacy Code
113131

114132
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)