Compare commits

...

6 Commits

Author SHA1 Message Date
Giteabot
42f7c2ad89
Enable production source maps for index.js, fix CSS sourcemaps (#27291) (#27295)
Backport #27291 by @silverwind

Previously, the production build never output sourcemaps. Now we emit
one file for `index.js` because it is the most likely one where we need
to be able to better debug reported issues like
https://github.com/go-gitea/gitea/issues/27213. This will currently
increase the binary size of gitea by around 700kB which is what the
gzipped source map file has.

Also, I fixed the CSS sourcemap generation which was broken since the
introduction of lightningcss.

The chinese docs are machine-translated, please correct accordingly.

Co-authored-by: silverwind <me@silverwind.io>
2023-09-27 04:26:28 +02:00
Giteabot
fee8522052
Fix some animation bugs (#27287) (#27294)
Backport #27287

Fix #27286
Replace #27279

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-09-27 01:24:25 +00:00
Giteabot
34c440996d
Add missed return to actions view fetch (#27289) (#27293)
Backport #27289 by @silverwind

Should fix: https://github.com/go-gitea/gitea/issues/27213

@denyskon can you test this? I can not reproduce this error locally.

Co-authored-by: silverwind <me@silverwind.io>
2023-09-27 09:10:21 +08:00
Giteabot
283b19bad5
Fix more yaml lint errors (#27284) (#27288)
Backport #27284 by @lunny

Fix #27268

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-09-26 19:00:12 +02:00
Giteabot
f0045f4113
Add missing IconHTML size (#27269) (#27283)
Backport #27269 by @wxiaoguang

Fix #27223

Regression of #27122

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-09-26 15:10:41 +00:00
Giteabot
0abd78e6a8
Fix incorrect change from #27231 (#27275) (#27282)
Backport #27275 by @delvh

Co-authored-by: delvh <dev.lh@web.de>
2023-09-26 13:39:39 +00:00
22 changed files with 102 additions and 74 deletions

View File

@ -44,5 +44,3 @@ rules:
ignore: | ignore: |
.venv .venv
node_modules node_modules
/models/fixtures
/models/migrations/fixtures

View File

@ -128,8 +128,6 @@ If pre-built frontend files are present it is possible to only build the backend
TAGS="bindata" make backend TAGS="bindata" make backend
``` ```
Webpack source maps are by default enabled in development builds and disabled in production builds. They can be enabled by setting the `ENABLE_SOURCEMAP=true` environment variable.
## Test ## Test
After following the steps above, a `gitea` binary will be available in the working directory. After following the steps above, a `gitea` binary will be available in the working directory.
@ -260,3 +258,11 @@ GOARCH=amd64 \
TAGS="bindata sqlite sqlite_unlock_notify" \ TAGS="bindata sqlite sqlite_unlock_notify" \
make build make build
``` ```
## Source Maps
By default, gitea generates reduced source maps for frontend files to conserve space. This can be controlled with the `ENABLE_SOURCEMAP` environment variable:
- `ENABLE_SOURCEMAP=true` generates all source maps, the default for development builds
- `ENABLE_SOURCEMAP=reduced` generates limited source maps, the default for production builds
- `ENABLE_SOURCEMAP=false` generates no source maps

View File

@ -100,8 +100,6 @@ TAGS="bindata sqlite sqlite_unlock_notify" make build
TAGS="bindata" make backend TAGS="bindata" make backend
``` ```
在开发构建中,默认启用 Webpack 源映射,在生产构建中禁用。可以通过设置`ENABLE_SOURCEMAP=true`环境变量来启用它们。
## 测试 ## 测试
按照上述步骤完成后,工作目录中将会有一个`gitea`二进制文件。可以从该目录进行测试,或将其移动到带有测试数据的目录中。当手动从命令行启动 Gitea 时,可以通过按下`Ctrl + C`来停止程序。 按照上述步骤完成后,工作目录中将会有一个`gitea`二进制文件。可以从该目录进行测试,或将其移动到带有测试数据的目录中。当手动从命令行启动 Gitea 时,可以通过按下`Ctrl + C`来停止程序。
@ -221,3 +219,11 @@ GOARCH=amd64 \
TAGS="bindata sqlite sqlite_unlock_notify" \ TAGS="bindata sqlite sqlite_unlock_notify" \
make build make build
``` ```
## 源映射
默认情况下gitea 会为前端文件生成精简的源映射以节省空间。 这可以通过“ENABLE_SOURCEMAP”环境变量进行控制
- `ENABLE_SOURCEMAP=true` 生成所有源映射,这是开发版本的默认设置
- `ENABLE_SOURCEMAP=reduced` 生成有限的源映射,这是生产版本的默认设置
- `ENABLE_SOURCEMAP=false` 不生成源映射

View File

@ -135,4 +135,3 @@
user_id: 31 user_id: 31
repo_id: 28 repo_id: 28
mode: 4 mode: 4

View File

@ -2,7 +2,7 @@
id: 1 id: 1
uid: 1 uid: 1
name: Token A name: Token A
#token: d2c6c1ba3890b309189a8e618c72a162e4efbf36 # token: d2c6c1ba3890b309189a8e618c72a162e4efbf36
token_hash: 2b3668e11cb82d3af8c6e4524fc7841297668f5008d1626f0ad3417e9fa39af84c268248b78c481daa7e5dc437784003494f token_hash: 2b3668e11cb82d3af8c6e4524fc7841297668f5008d1626f0ad3417e9fa39af84c268248b78c481daa7e5dc437784003494f
token_salt: QuSiZr1byZ token_salt: QuSiZr1byZ
token_last_eight: e4efbf36 token_last_eight: e4efbf36
@ -13,7 +13,7 @@
id: 2 id: 2
uid: 1 uid: 1
name: Token B name: Token B
#token: 4c6f36e6cf498e2a448662f915d932c09c5a146c # token: 4c6f36e6cf498e2a448662f915d932c09c5a146c
token_hash: 1a0e32a231ebbd582dc626c1543a42d3c63d4fa76c07c72862721467c55e8f81c923d60700f0528b5f5f443f055559d3a279 token_hash: 1a0e32a231ebbd582dc626c1543a42d3c63d4fa76c07c72862721467c55e8f81c923d60700f0528b5f5f443f055559d3a279
token_salt: Lfwopukrq5 token_salt: Lfwopukrq5
token_last_eight: 9c5a146c token_last_eight: 9c5a146c
@ -24,10 +24,10 @@
id: 3 id: 3
uid: 2 uid: 2
name: Token A name: Token A
#token: 90a18faa671dc43924b795806ffe4fd169d28c91 # token: 90a18faa671dc43924b795806ffe4fd169d28c91
token_hash: d6d404048048812d9e911d93aefbe94fc768d4876fdf75e3bef0bdc67828e0af422846d3056f2f25ec35c51dc92075685ec5 token_hash: d6d404048048812d9e911d93aefbe94fc768d4876fdf75e3bef0bdc67828e0af422846d3056f2f25ec35c51dc92075685ec5
token_salt: 99ArgXKlQQ token_salt: 99ArgXKlQQ
token_last_eight: 69d28c91 token_last_eight: 69d28c91
created_unix: 946687980 created_unix: 946687980
updated_unix: 946687980 updated_unix: 946687980
#commented out tokens so you can see what they are in plaintext # commented out tokens so you can see what they are in plaintext

View File

@ -2,4 +2,4 @@
id: 1 id: 1
repo_id: 1 repo_id: 1
sha: "1234123412341234123412341234123412341234" sha: "1234123412341234123412341234123412341234"
max_index: 5 max_index: 5

View File

@ -8,4 +8,4 @@
type: 1 type: 1
created_unix: 1559593109 created_unix: 1559593109
updated_unix: 1565224552 updated_unix: 1565224552
login_source_id: 0 login_source_id: 0

View File

@ -97,4 +97,4 @@
issue_id: 20 issue_id: 20
index: 1 index: 1
head_repo_id: 23 head_repo_id: 23
base_repo_id: 23 base_repo_id: 23

View File

@ -1,5 +1,5 @@
- -
id: 1 #issue reaction id: 1 # issue reaction
type: zzz # not allowed reaction (added before allowed reaction list has changed) type: zzz # not allowed reaction (added before allowed reaction list has changed)
issue_id: 1 issue_id: 1
comment_id: 0 comment_id: 0
@ -7,7 +7,7 @@
created_unix: 1573248001 created_unix: 1573248001
- -
id: 2 #issue reaction id: 2 # issue reaction
type: zzz # not allowed reaction (added before allowed reaction list has changed) type: zzz # not allowed reaction (added before allowed reaction list has changed)
issue_id: 1 issue_id: 1
comment_id: 0 comment_id: 0
@ -15,7 +15,7 @@
created_unix: 1573248002 created_unix: 1573248002
- -
id: 3 #issue reaction id: 3 # issue reaction
type: eyes # allowed reaction type: eyes # allowed reaction
issue_id: 1 issue_id: 1
comment_id: 0 comment_id: 0
@ -23,7 +23,7 @@
created_unix: 1573248003 created_unix: 1573248003
- -
id: 4 #comment reaction id: 4 # comment reaction
type: laugh # allowed reaction type: laugh # allowed reaction
issue_id: 1 issue_id: 1
comment_id: 2 comment_id: 2
@ -31,7 +31,7 @@
created_unix: 1573248004 created_unix: 1573248004
- -
id: 5 #comment reaction id: 5 # comment reaction
type: laugh # allowed reaction type: laugh # allowed reaction
issue_id: 1 issue_id: 1
comment_id: 2 comment_id: 2

View File

@ -133,7 +133,7 @@
updated_unix: 946684831 updated_unix: 946684831
created_unix: 946684831 created_unix: 946684831
- -
id: 16 id: 16
type: 4 type: 4
reviewer_id: 20 reviewer_id: 20
@ -142,7 +142,7 @@
updated_unix: 946684832 updated_unix: 946684832
created_unix: 946684832 created_unix: 946684832
- -
id: 17 id: 17
type: 1 type: 1
reviewer_id: 20 reviewer_id: 20
@ -150,11 +150,12 @@
content: "review approved by user20" content: "review approved by user20"
updated_unix: 946684833 updated_unix: 946684833
created_unix: 946684833 created_unix: 946684833
-
-
id: 18 id: 18
type: 4 type: 4
reviewer_id: 0 reviewer_id: 0
reviewer_team_id: 5 reviewer_team_id: 5
issue_id: 20 issue_id: 20
content: "review request for team5" content: "review request for team5"
updated_unix: 946684834 updated_unix: 946684834
@ -169,4 +170,3 @@
content: "review request for user15" content: "review request for user15"
updated_unix: 946684835 updated_unix: 946684835
created_unix: 946684835 created_unix: 946684835

View File

@ -62,4 +62,4 @@
id: 11 id: 11
org_id: 17 org_id: 17
team_id: 9 team_id: 9
repo_id: 24 repo_id: 24

View File

@ -124,7 +124,7 @@
team_id: 20 team_id: 20
uid: 5 uid: 5
- -
id: 22 id: 22
org_id: 17 org_id: 17
team_id: 9 team_id: 9

View File

@ -26,4 +26,4 @@
id: 5 id: 5
user_id: 11 user_id: 11
repo_id: 1 repo_id: 1
mode: 3 # auto mode: 3 # auto

View File

@ -26,4 +26,3 @@
id: 5 id: 5
issue_id: 2 issue_id: 2
label_id: 87 label_id: 87

View File

@ -18,7 +18,7 @@
- -
id: 3 id: 3
repo_id: 0 repo_id: 0
org_id: 3 org_id: 3
name: orglabel3 name: orglabel3
color: '#abcdef' color: '#abcdef'
num_issues: 0 num_issues: 0

View File

@ -23,4 +23,3 @@
id: 5 id: 5
repo_id: 3 repo_id: 3
org_id: 0 org_id: 0

View File

@ -28,4 +28,3 @@
attestation_type: 'fido-u2f' attestation_type: 'fido-u2f'
sign_count: 1 sign_count: 1
clone_warning: false clone_warning: false

View File

@ -29,7 +29,7 @@
<div class="default text">{{ctx.Locale.Tr "repo.projects.template.desc_helper"}}</div> <div class="default text">{{ctx.Locale.Tr "repo.projects.template.desc_helper"}}</div>
<div class="menu"> <div class="menu">
{{range $element := .BoardTypes}} {{range $element := .BoardTypes}}
<div class="item" data-id="{{$element.BoardType}}" data-value="{{$element.BoardType}}">{{ctx.Locale.Tr ctx.Locale.Translation}}</div> <div class="item" data-id="{{$element.BoardType}}" data-value="{{$element.BoardType}}">{{ctx.Locale.Tr $element.Translation}}</div>
{{end}} {{end}}
</div> </div>
</div> </div>
@ -43,12 +43,12 @@
{{range $element := .CardTypes}} {{range $element := .CardTypes}}
{{if or (eq $.card_type $element.CardType) (and (not $.PageIsEditProjects) (eq $element.CardType 1))}} {{if or (eq $.card_type $element.CardType) (and (not $.PageIsEditProjects) (eq $element.CardType 1))}}
<input type="hidden" name="card_type" value="{{$element.CardType}}"> <input type="hidden" name="card_type" value="{{$element.CardType}}">
<div class="default text">{{ctx.Locale.Tr ctx.Locale.Translation}}</div> <div class="default text">{{ctx.Locale.Tr $element.Translation}}</div>
{{end}} {{end}}
{{end}} {{end}}
<div class="menu"> <div class="menu">
{{range $element := .CardTypes}} {{range $element := .CardTypes}}
<div class="item" data-id="{{$element.CardType}}" data-value="{{$element.CardType}}">{{ctx.Locale.Tr ctx.Locale.Translation}}</div> <div class="item" data-id="{{$element.CardType}}" data-value="{{$element.CardType}}">{{ctx.Locale.Tr $element.Translation}}</div>
{{end}} {{end}}
</div> </div>
</div> </div>

View File

@ -29,7 +29,7 @@
<div class="flex-item"> <div class="flex-item">
{{$providerData := index $.OAuth2Providers $loginSource.Name}} {{$providerData := index $.OAuth2Providers $loginSource.Name}}
<div class="flex-item-leading"> <div class="flex-item-leading">
{{$providerData.IconHTML}} {{$providerData.IconHTML 20}}
</div> </div>
<div class="flex-item-main"> <div class="flex-item-main">
<span class="flex-item-title" data-tooltip-content="{{$provider}}"> <span class="flex-item-title" data-tooltip-content="{{$provider}}">

View File

@ -225,7 +225,8 @@ const sfc = {
this.fetchArtifacts(), // refresh artifacts if upload-artifact step done this.fetchArtifacts(), // refresh artifacts if upload-artifact step done
]); ]);
} catch (err) { } catch (err) {
if (!(err instanceof TypeError)) throw err; // avoid network error while unloading page if (err instanceof TypeError) return; // avoid network error while unloading page
throw err;
} }
this.artifacts = artifacts['artifacts'] || []; this.artifacts = artifacts['artifacts'] || [];

View File

@ -25,41 +25,55 @@ export function initGiteaFomantic() {
return escape(text, preserveHTML) + svg('octicon-x', 16, `${className.delete} icon`); return escape(text, preserveHTML) + svg('octicon-x', 16, `${className.delete} icon`);
}; };
const transitionNopBehaviors = new Set([
'clear queue', 'stop', 'stop all', 'destroy',
'force repaint', 'repaint', 'reset',
'looping', 'remove looping', 'disable', 'enable',
'set duration', 'save conditions', 'restore conditions',
]);
// stand-in for removed transition module // stand-in for removed transition module
$.fn.transition = function (arg) { $.fn.transition = function (arg0, arg1, arg2) {
if (arg === 'is supported') return true; if (arg0 === 'is supported') return true;
if (arg === 'is animating') return false; if (arg0 === 'is animating') return false;
if (arg === 'is inward') return false; if (arg0 === 'is inward') return false;
if (arg === 'is outward') return false; if (arg0 === 'is outward') return false;
if (arg === 'stop all') return;
const isIn = arg?.animation?.endsWith(' in'); let argObj;
const isOut = arg?.animation?.endsWith(' out'); if (typeof arg0 === 'string') {
// many behaviors are no-op now. https://fomantic-ui.com/modules/transition.html#/usage
let ret; if (transitionNopBehaviors.has(arg0)) return this;
if (arg === 'show' || isIn) { // now, the arg0 is an animation name, the syntax: (animation, duration, complete)
arg?.onStart?.(this); argObj = {animation: arg0, ...(arg1 && {duration: arg1}), ...(arg2 && {onComplete: arg2})};
ret = this.each((_, el) => { } else if (typeof arg0 === 'object') {
el.classList.remove('hidden'); argObj = arg0;
el.classList.add('visible'); } else {
if (isIn) el.classList.add('transition'); throw new Error(`invalid argument: ${arg0}`);
if (arg?.displayType) el.style.setProperty('display', arg.displayType, 'important');
arg?.onShow?.(this);
});
arg?.onComplete?.(this);
} else if (arg === 'hide' || isOut) {
arg?.onStart?.(this);
ret = this.each((_, el) => {
el.classList.add('hidden');
el.classList.remove('visible');
// don't remove the transition class because fomantic didn't do it either
el.style.removeProperty('display');
arg?.onHidden?.(this);
});
arg?.onComplete?.(this);
} }
return ret; const isAnimationIn = argObj.animation?.startsWith('show') || argObj.animation?.endsWith(' in');
const isAnimationOut = argObj.animation?.startsWith('hide') || argObj.animation?.endsWith(' out');
this.each((_, el) => {
let toShow = isAnimationIn;
if (!isAnimationIn && !isAnimationOut) {
// If the animation is not in/out, then it must be a toggle animation.
// Fomantic uses computed styles to check "visibility", but to avoid unnecessary arguments, here it only checks the class.
toShow = this.hasClass('hidden'); // maybe it could also check "!this.hasClass('visible')", leave it to the future until there is a real problem.
}
argObj.onStart?.call(el);
if (toShow) {
el.classList.remove('hidden');
el.classList.add('visible', 'transition');
if (argObj.displayType) el.style.setProperty('display', argObj.displayType, 'important');
argObj.onShow?.call(el);
} else {
el.classList.add('hidden');
el.classList.remove('visible'); // don't remove the transition class because the Fomantic animation style is `.hidden.transition`.
el.style.removeProperty('display');
argObj.onHidden?.call(el);
}
argObj.onComplete?.call(el);
});
return this;
}; };
initFomanticApiPatch(); initFomanticApiPatch();

View File

@ -28,11 +28,15 @@ for (const path of glob('web_src/css/themes/*.css')) {
const isProduction = env.NODE_ENV !== 'development'; const isProduction = env.NODE_ENV !== 'development';
let sourceMapEnabled; // ENABLE_SOURCEMAP accepts the following values:
// true - all enabled, the default in development
// reduced - minimal sourcemaps, the default in production
// false - all disabled
let sourceMaps;
if ('ENABLE_SOURCEMAP' in env) { if ('ENABLE_SOURCEMAP' in env) {
sourceMapEnabled = env.ENABLE_SOURCEMAP === 'true'; sourceMaps = ['true', 'false'].includes(env.ENABLE_SOURCEMAP) ? env.ENABLE_SOURCEMAP : 'reduced';
} else { } else {
sourceMapEnabled = !isProduction; sourceMaps = isProduction ? 'reduced' : 'true';
} }
const filterCssImport = (url, ...args) => { const filterCssImport = (url, ...args) => {
@ -105,7 +109,9 @@ export default {
css: !LightningCssMinifyPlugin, css: !LightningCssMinifyPlugin,
legalComments: 'none', legalComments: 'none',
}), }),
LightningCssMinifyPlugin && new LightningCssMinifyPlugin(), LightningCssMinifyPlugin && new LightningCssMinifyPlugin({
sourceMap: sourceMaps === 'true',
}),
], ],
splitChunks: { splitChunks: {
chunks: 'async', chunks: 'async',
@ -143,7 +149,7 @@ export default {
{ {
loader: 'css-loader', loader: 'css-loader',
options: { options: {
sourceMap: sourceMapEnabled, sourceMap: sourceMaps === 'true',
url: {filter: filterCssImport}, url: {filter: filterCssImport},
import: {filter: filterCssImport}, import: {filter: filterCssImport},
}, },
@ -181,9 +187,10 @@ export default {
filename: 'css/[name].css', filename: 'css/[name].css',
chunkFilename: 'css/[name].[contenthash:8].css', chunkFilename: 'css/[name].[contenthash:8].css',
}), }),
sourceMapEnabled && (new SourceMapDevToolPlugin({ sourceMaps !== 'false' && new SourceMapDevToolPlugin({
filename: '[file].[contenthash:8].map', filename: '[file].[contenthash:8].map',
})), ...(sourceMaps === 'reduced' && {include: /^js\/index\.js$/}),
}),
new MonacoWebpackPlugin({ new MonacoWebpackPlugin({
filename: 'js/monaco-[name].[contenthash:8].worker.js', filename: 'js/monaco-[name].[contenthash:8].worker.js',
}), }),