Skip to content

Commit ca5dc31

Browse files
committed
Merge branch 'main' into refactor-jwt
2 parents a1e2a08 + 5e1bf3e commit ca5dc31

File tree

22 files changed

+80
-101
lines changed

22 files changed

+80
-101
lines changed

.markdownlint.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ heading-increment: false
55
line-length: {code_blocks: false, tables: false, stern: true, line_length: -1}
66
no-alt-text: false
77
no-bare-urls: false
8-
no-blanks-blockquote: false
98
no-emphasis-as-heading: false
109
no-empty-links: false
1110
no-hard-tabs: {code_blocks: false}
1211
no-inline-html: false
1312
no-space-in-code: false
1413
no-space-in-emphasis: false
15-
no-trailing-punctuation: false
1614
no-trailing-spaces: {br_spaces: 0}
1715
single-h1: false

docs/content/administration/customizing-gitea.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ syntax and shouldn't be touched without fully understanding these components.
284284

285285
Google Analytics, Matomo (previously Piwik), and other analytics services can be added to Gitea. To add the tracking code, refer to the `Other additions to the page` section of this document, and add the JavaScript to the `$GITEA_CUSTOM/templates/custom/header.tmpl` file.
286286

287-
## Customizing gitignores, labels, licenses, locales, and readmes.
287+
## Customizing gitignores, labels, licenses, locales, and readmes
288288

289289
Place custom files in corresponding sub-folder under `custom/options`.
290290

docs/content/administration/https-support.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ CERT_FILE = cert.pem
3535
KEY_FILE = key.pem
3636
```
3737

38-
Note that if your certificate is signed by a third party certificate authority (i.e. not self-signed), then cert.pem should contain the certificate chain. The server certificate must be the first entry in cert.pem, followed by the intermediaries in order (if any). The root certificate does not have to be included because the connecting client must already have it in order to estalbish the trust relationship.
38+
Note that if your certificate is signed by a third party certificate authority (i.e. not self-signed), then cert.pem should contain the certificate chain. The server certificate must be the first entry in cert.pem, followed by the intermediaries in order (if any). The root certificate does not have to be included because the connecting client must already have it in order to establish the trust relationship.
3939
To learn more about the config values, please checkout the [Config Cheat Sheet](administration/config-cheat-sheet.md#server-server).
4040

4141
For the `CERT_FILE` or `KEY_FILE` field, the file path is relative to the `GITEA_CUSTOM` environment variable when it is a relative path. It can be an absolute path as well.

docs/content/administration/mail-templates.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Please check [Gitea's logs](administration/logging-config.md) for error messages
222222
<a href="{{.Link}}">{{.Repo}}#{{.Issue.Index}}</a>.
223223
</p>
224224
{{if not (eq .Body "")}}
225-
<h3>Message content:</h3>
225+
<h3>Message content</h3>
226226
<hr>
227227
{{.Body | Str2html}}
228228
{{end}}
@@ -245,7 +245,7 @@ This template produces something along these lines:
245245

246246
> [@rhonda](#) (Rhonda Myers) updated [mike/stuff#38](#).
247247
>
248-
> #### Message content:
248+
> #### Message content
249249
>
250250
> \_********************************\_********************************
251251
>

docs/content/administration/mail-templates.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ _主题_ 和 _邮件正文_ 由 [Golang的模板引擎](https://go.dev/pkg/text/
228228

229229
> [@rhonda](#)(Rhonda Myers)更新了 [mike/stuff#38](#)
230230
>
231-
> #### 消息内容
231+
> #### 消息内容
232232
>
233233
> \_********************************\_********************************
234234
>

docs/content/contributing/guidelines-frontend.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The source files can be found in the following directories:
3434

3535
We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html) and [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)
3636

37-
### Gitea specific guidelines:
37+
### Gitea specific guidelines
3838

3939
1. Every feature (Fomantic-UI/jQuery module) should be put in separate files/directories.
4040
2. HTML ids and classes should use kebab-case, it's preferred to contain 2-3 feature related keywords.

docs/content/contributing/guidelines-frontend.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ HTML 页面由[Go HTML Template](https://pkg.go.dev/html/template)渲染。
3434

3535
我们推荐使用[Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html)[Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)
3636

37-
## Gitea 特定准则
37+
## Gitea 特定准则
3838

3939
1. 每个功能(Fomantic-UI/jQuery 模块)应放在单独的文件/目录中。
4040
2. HTML 的 id 和 class 应使用 kebab-case,最好包含2-3个与功能相关的关键词。

docs/content/development/api-usage.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ curl "http://localhost:4000/api/v1/repos/test1/test1/issues" \
6060
`/users/:name/tokens` 是一个特殊的接口,需要您使用 basic authentication 进行认证,具体原因在 issue 中
6161
[#3842](https://github.com/go-gitea/gitea/issues/3842#issuecomment-397743346) 有所提及,使用方法如下所示:
6262

63-
### 使用 Basic authentication 认证
63+
### 使用 Basic authentication 认证
6464

6565
```
6666
$ curl --url https://yourusername:[email protected]/api/v1/users/yourusername/tokens

routers/web/repo/pull_review.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ func UpdateResolveConversation(ctx *context.Context) {
156156
func renderConversation(ctx *context.Context, comment *issues_model.Comment, origin string) {
157157
ctx.Data["PageIsPullFiles"] = origin == "diff"
158158

159-
comments, err := issues_model.FetchCodeCommentsByLine(ctx, comment.Issue, ctx.Doer, comment.TreePath, comment.Line, ctx.Data["ShowOutdatedComments"].(bool))
159+
showOutdatedComments := origin == "timeline" || ctx.Data["ShowOutdatedComments"].(bool)
160+
comments, err := issues_model.FetchCodeCommentsByLine(ctx, comment.Issue, ctx.Doer, comment.TreePath, comment.Line, showOutdatedComments)
160161
if err != nil {
161162
ctx.ServerError("FetchCodeCommentsByLine", err)
162163
return

routers/web/repo/pull_review_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ func TestRenderConversation(t *testing.T) {
6868
renderConversation(ctx, preparedComment, "timeline")
6969
assert.Contains(t, resp.Body.String(), `<div id="code-comments-`)
7070
})
71-
run("timeline without outdated", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
71+
run("timeline is not affected by ShowOutdatedComments=false", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
7272
ctx.Data["ShowOutdatedComments"] = false
7373
renderConversation(ctx, preparedComment, "timeline")
74-
assert.Contains(t, resp.Body.String(), `conversation-not-existing`)
74+
assert.Contains(t, resp.Body.String(), `<div id="code-comments-`)
7575
})
7676
}

routers/web/user/profile.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929

3030
const (
3131
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
32+
tplFollowUnfollow base.TplName = "org/follow_unfollow"
3233
)
3334

3435
// OwnerProfile render profile page for a user or a organization (aka, repo owner)
@@ -318,6 +319,15 @@ func Action(ctx *context.Context) {
318319
return
319320
}
320321

321-
shared_user.PrepareContextForProfileBigAvatar(ctx)
322-
ctx.HTML(http.StatusOK, tplProfileBigAvatar)
322+
if ctx.ContextUser.IsIndividual() {
323+
shared_user.PrepareContextForProfileBigAvatar(ctx)
324+
ctx.HTML(http.StatusOK, tplProfileBigAvatar)
325+
return
326+
} else if ctx.ContextUser.IsOrganization() {
327+
ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
328+
ctx.HTML(http.StatusOK, tplFollowUnfollow)
329+
return
330+
}
331+
log.Error("Failed to apply action %q: unsupport context user type: %s", ctx.FormString("action"), ctx.ContextUser.Type)
332+
ctx.Error(http.StatusBadRequest, fmt.Sprintf("Action %q failed", ctx.FormString("action")))
323333
}

services/packages/debian/repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func buildReleaseFiles(ctx context.Context, ownerID int64, repoVersion *packages
342342
fmt.Fprintf(w, "Components: %s\n", strings.Join(components, " "))
343343
fmt.Fprintf(w, "Architectures: %s\n", strings.Join(architectures, " "))
344344
fmt.Fprintf(w, "Date: %s\n", time.Now().UTC().Format(time.RFC1123))
345-
fmt.Fprint(w, "Acquire-By-Hash: yes")
345+
fmt.Fprint(w, "Acquire-By-Hash: yes\n")
346346

347347
pfds, err := packages_model.GetPackageFileDescriptors(ctx, pfs)
348348
if err != nil {

templates/org/follow_unfollow.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<button class="ui basic button gt-mr-0" hx-post="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
2+
{{if $.IsFollowing}}
3+
{{ctx.Locale.Tr "user.unfollow"}}
4+
{{else}}
5+
{{ctx.Locale.Tr "user.follow"}}
6+
{{end}}
7+
</button>

templates/org/home.tmpl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@
2525
{{svg "octicon-rss" 24}}
2626
</a>
2727
{{end}}
28-
<button class="link-action ui basic button gt-mr-0" data-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
29-
{{if $.IsFollowing}}
30-
{{ctx.Locale.Tr "user.unfollow"}}
31-
{{else}}
32-
{{ctx.Locale.Tr "user.follow"}}
33-
{{end}}
34-
</button>
28+
{{if .IsSigned}}
29+
{{template "org/follow_unfollow" .}}
30+
{{end}}
3531
</div>
3632
</div>
3733

templates/repo/settings/webhook/settings.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
<!-- Branch filter -->
255255
<div class="field">
256256
<label for="branch_filter">{{ctx.Locale.Tr "repo.settings.branch_filter"}}</label>
257-
<input name="branch_filter" type="text" value="{{or .Webhook.BranchFilter "*"}}">
257+
<input id="branch_filter" name="branch_filter" type="text" value="{{or .Webhook.BranchFilter "*"}}">
258258
<span class="help">{{ctx.Locale.Tr "repo.settings.branch_filter_desc" | Str2html}}</span>
259259
</div>
260260

templates/user/settings/profile.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<input id="full_name" name="full_name" value="{{.SignedUser.FullName}}" maxlength="100">
2323
</div>
2424
<div class="field {{if .Err_Email}}error{{end}}">
25-
<label for="email">{{ctx.Locale.Tr "email"}}</label>
26-
<p>{{.SignedUser.Email}}</p>
25+
<label>{{ctx.Locale.Tr "email"}}</label>
26+
<p id="signed-user-email">{{.SignedUser.Email}}</p>
2727
</div>
2828
<div class="field {{if .Err_Description}}error{{end}}">
2929
<label for="description">{{ctx.Locale.Tr "user.user_bio"}}</label>
@@ -42,11 +42,11 @@
4242
<!-- private block -->
4343

4444
<div class="field" id="privacy-user-settings">
45-
<label for="security-private"><strong>{{ctx.Locale.Tr "settings.privacy"}}</strong></label>
45+
<label><strong>{{ctx.Locale.Tr "settings.privacy"}}</strong></label>
4646
</div>
4747

4848
<div class="inline field {{if .Err_Visibility}}error{{end}}">
49-
<span class="inline required field"><label for="visibility">{{ctx.Locale.Tr "settings.visibility"}}</label></span>
49+
<span class="inline required field"><label>{{ctx.Locale.Tr "settings.visibility"}}</label></span>
5050
<div class="ui selection type dropdown">
5151
{{if .SignedUser.Visibility.IsPublic}}<input type="hidden" id="visibility" name="visibility" value="0">{{end}}
5252
{{if .SignedUser.Visibility.IsLimited}}<input type="hidden" id="visibility" name="visibility" value="1">{{end}}
@@ -120,8 +120,8 @@
120120
</div>
121121

122122
<div class="inline field gt-pl-4">
123-
<label for="avatar">{{ctx.Locale.Tr "settings.choose_new_avatar"}}</label>
124-
<input name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
123+
<label for="new-avatar">{{ctx.Locale.Tr "settings.choose_new_avatar"}}</label>
124+
<input id="new-avatar" name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
125125
</div>
126126

127127
<div class="field">

tests/integration/auth_ldap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func TestLDAPUserSignin(t *testing.T) {
179179

180180
assert.Equal(t, u.UserName, htmlDoc.GetInputValueByName("name"))
181181
assert.Equal(t, u.FullName, htmlDoc.GetInputValueByName("full_name"))
182-
assert.Equal(t, u.Email, htmlDoc.Find(`label[for="email"]`).Siblings().First().Text())
182+
assert.Equal(t, u.Email, htmlDoc.Find("#signed-user-email").Text())
183183
}
184184

185185
func TestLDAPAuthChange(t *testing.T) {
Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
1-
import $ from 'jquery';
1+
import {POST} from '../../modules/fetch.js';
22
import {hideElem, showElem, toggleElem} from '../../utils/dom.js';
33

4-
const {csrfToken} = window.config;
5-
64
export function initCompWebHookEditor() {
7-
if ($('.new.webhook').length === 0) {
5+
if (!document.querySelectorAll('.new.webhook').length) {
86
return;
97
}
108

11-
$('.events.checkbox input').on('change', function () {
12-
if ($(this).is(':checked')) {
13-
showElem($('.events.fields'));
14-
}
15-
});
16-
$('.non-events.checkbox input').on('change', function () {
17-
if ($(this).is(':checked')) {
18-
hideElem($('.events.fields'));
19-
}
20-
});
9+
for (const input of document.querySelectorAll('.events.checkbox input')) {
10+
input.addEventListener('change', function () {
11+
if (this.checked) {
12+
showElem('.events.fields');
13+
}
14+
});
15+
}
16+
17+
for (const input of document.querySelectorAll('.non-events.checkbox input')) {
18+
input.addEventListener('change', function () {
19+
if (this.checked) {
20+
hideElem('.events.fields');
21+
}
22+
});
23+
}
2124

2225
const updateContentType = function () {
23-
const visible = $('#http_method').val() === 'POST';
24-
toggleElem($('#content_type').parent().parent(), visible);
26+
const visible = document.getElementById('http_method').value === 'POST';
27+
toggleElem(document.getElementById('content_type').parentNode.parentNode, visible);
2528
};
2629
updateContentType();
27-
$('#http_method').on('change', () => {
28-
updateContentType();
29-
});
30+
31+
document.getElementById('http_method').addEventListener('change', updateContentType);
3032

3133
// Test delivery
32-
$('#test-delivery').on('click', function () {
33-
const $this = $(this);
34-
$this.addClass('loading disabled');
35-
$.post($this.data('link'), {
36-
_csrf: csrfToken
37-
}).done(
38-
setTimeout(() => {
39-
window.location.href = $this.data('redirect');
40-
}, 5000)
41-
);
34+
document.getElementById('test-delivery')?.addEventListener('click', async function () {
35+
this.classList.add('loading', 'disabled');
36+
await POST(this.getAttribute('data-link'));
37+
setTimeout(() => {
38+
window.location.href = this.getAttribute('data-redirect');
39+
}, 5000);
4240
});
4341
}

web_src/js/features/contextpopup.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import $ from 'jquery';
21
import {createApp} from 'vue';
32
import ContextPopup from '../components/ContextPopup.vue';
43
import {parseIssueHref} from '../utils.js';
54
import {createTippy} from '../modules/tippy.js';
65

76
export function initContextPopups() {
8-
const refIssues = $('.ref-issue');
7+
const refIssues = document.querySelectorAll('.ref-issue');
98
attachRefIssueContextPopup(refIssues);
109
}
1110

web_src/js/features/repo-migrate.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import $ from 'jquery';
21
import {hideElem, showElem} from '../utils/dom.js';
32
import {GET, POST} from '../modules/fetch.js';
43

54
const {appSubUrl} = window.config;
65

76
export function initRepoMigrationStatusChecker() {
8-
const $repoMigrating = $('#repo_migrating');
9-
if (!$repoMigrating.length) return;
7+
const repoMigrating = document.getElementById('repo_migrating');
8+
if (!repoMigrating) return;
109

11-
$('#repo_migrating_retry').on('click', doMigrationRetry);
10+
document.getElementById('repo_migrating_retry').addEventListener('click', doMigrationRetry);
1211

13-
const task = $repoMigrating.attr('data-migrating-task-id');
12+
const task = repoMigrating.getAttribute('data-migrating-task-id');
1413

15-
// returns true if the refresh still need to be called after a while
14+
// returns true if the refresh still needs to be called after a while
1615
const refresh = async () => {
1716
const res = await GET(`${appSubUrl}/user/task/${task}`);
1817
if (res.status !== 200) return true; // continue to refresh if network error occurs
@@ -21,7 +20,7 @@ export function initRepoMigrationStatusChecker() {
2120

2221
// for all status
2322
if (data.message) {
24-
$('#repo_migrating_progress_message').text(data.message);
23+
document.getElementById('repo_migrating_progress_message').textContent = data.message;
2524
}
2625

2726
// TaskStatusFinished
@@ -37,7 +36,7 @@ export function initRepoMigrationStatusChecker() {
3736
showElem('#repo_migrating_retry');
3837
showElem('#repo_migrating_failed');
3938
showElem('#repo_migrating_failed_image');
40-
$('#repo_migrating_failed_error').text(data.message);
39+
document.getElementById('repo_migrating_failed_error').textContent = data.message;
4140
return false;
4241
}
4342

@@ -59,6 +58,6 @@ export function initRepoMigrationStatusChecker() {
5958
}
6059

6160
async function doMigrationRetry(e) {
62-
await POST($(e.target).attr('data-migrating-task-retry-url'));
61+
await POST(e.target.getAttribute('data-migrating-task-retry-url'));
6362
window.location.reload();
6463
}

web_src/js/features/user-auth.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import $ from 'jquery';
21
import {checkAppUrl} from './common-global.js';
32

43
export function initUserAuthOauth2() {
@@ -21,30 +20,3 @@ export function initUserAuthOauth2() {
2120
});
2221
}
2322
}
24-
25-
export function initUserAuthLinkAccountView() {
26-
const $lnkUserPage = $('.page-content.user.link-account');
27-
if ($lnkUserPage.length === 0) {
28-
return false;
29-
}
30-
31-
const $signinTab = $lnkUserPage.find('.item[data-tab="auth-link-signin-tab"]');
32-
const $signUpTab = $lnkUserPage.find('.item[data-tab="auth-link-signup-tab"]');
33-
const $signInView = $lnkUserPage.find('.tab[data-tab="auth-link-signin-tab"]');
34-
const $signUpView = $lnkUserPage.find('.tab[data-tab="auth-link-signup-tab"]');
35-
36-
$signUpTab.on('click', () => {
37-
$signinTab.removeClass('active');
38-
$signInView.removeClass('active');
39-
$signUpTab.addClass('active');
40-
$signUpView.addClass('active');
41-
return false;
42-
});
43-
44-
$signinTab.on('click', () => {
45-
$signUpTab.removeClass('active');
46-
$signUpView.removeClass('active');
47-
$signinTab.addClass('active');
48-
$signInView.addClass('active');
49-
});
50-
}

0 commit comments

Comments
 (0)