Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
* upstream/main:
  Move `modules/mirror` to `services` (go-gitea#26737)
  [skip ci] Updated translations via Crowdin
  Fix template bugs in recently_pushed_new_branches.tmpl (go-gitea#26744)
  Fix incorrect "tabindex" attributes (go-gitea#26733)
  Simplify helper CSS classes and avoid abuse (go-gitea#26728)
  Remove fomantic loader module (go-gitea#26670)
  Fix link in mirror docs (go-gitea#26719)
  Add `eslint-plugin-vue-scoped-css` (go-gitea#26720)
  Fixed text overflow in dropdown menu (go-gitea#26694)
  Make web context initialize correctly for different cases (go-gitea#26726)
  Remove incorrect CSS helper classes (go-gitea#26712)
  Focus editor on "Write" tab click (go-gitea#26714)
  • Loading branch information
zjjhot committed Aug 27, 2023
2 parents 9a3215d + 4365274 commit 130bf51
Show file tree
Hide file tree
Showing 65 changed files with 462 additions and 1,230 deletions.
2 changes: 1 addition & 1 deletion models/repo/pushmirror.go
Expand Up @@ -128,7 +128,7 @@ func GetPushMirrorsByRepoID(ctx context.Context, repoID int64, listOptions db.Li
func GetPushMirrorsSyncedOnCommit(ctx context.Context, repoID int64) ([]*PushMirror, error) {
mirrors := make([]*PushMirror, 0, 10)
return mirrors, db.GetEngine(ctx).
Where("repo_id=? AND sync_on_commit=?", repoID, true).
Where("repo_id = ? AND sync_on_commit = ?", repoID, true).
Find(&mirrors)
}

Expand Down
41 changes: 25 additions & 16 deletions modules/context/context.go
Expand Up @@ -107,6 +107,29 @@ func GetValidateContext(req *http.Request) (ctx *ValidateContext) {
return ctx
}

func NewTemplateContextForWeb(ctx *Context) TemplateContext {
tmplCtx := NewTemplateContext(ctx)
tmplCtx["Locale"] = ctx.Base.Locale
tmplCtx["AvatarUtils"] = templates.NewAvatarUtils(ctx)
return tmplCtx
}

func NewWebContext(base *Base, render Render, session session.Store) *Context {
ctx := &Context{
Base: base,
Render: render,
Session: session,

Cache: mc.GetCache(),
Link: setting.AppSubURL + strings.TrimSuffix(base.Req.URL.EscapedPath(), "/"),
Repo: &Repository{PullRequest: &PullRequest{}},
Org: &Organization{},
}
ctx.TemplateContext = NewTemplateContextForWeb(ctx)
ctx.Flash = &middleware.Flash{DataStore: ctx, Values: url.Values{}}
return ctx
}

// Contexter initializes a classic context for a request.
func Contexter() func(next http.Handler) http.Handler {
rnd := templates.HTMLRenderer()
Expand All @@ -127,21 +150,8 @@ func Contexter() func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
base, baseCleanUp := NewBaseContext(resp, req)
ctx := &Context{
Base: base,
Cache: mc.GetCache(),
Link: setting.AppSubURL + strings.TrimSuffix(req.URL.EscapedPath(), "/"),
Render: rnd,
Session: session.GetSession(req),
Repo: &Repository{PullRequest: &PullRequest{}},
Org: &Organization{},
}
defer baseCleanUp()

// TODO: "install.go" also shares the same logic, which should be refactored to a general function
ctx.TemplateContext = NewTemplateContext(ctx)
ctx.TemplateContext["Locale"] = ctx.Locale
ctx.TemplateContext["AvatarUtils"] = templates.NewAvatarUtils(ctx)
ctx := NewWebContext(base, rnd, session.GetSession(req))

ctx.Data.MergeFrom(middleware.CommonTemplateContextData())
ctx.Data["Context"] = ctx // TODO: use "ctx" in template and remove this
Expand Down Expand Up @@ -172,8 +182,7 @@ func Contexter() func(next http.Handler) http.Handler {
}
}

// prepare an empty Flash message for current request
ctx.Flash = &middleware.Flash{DataStore: ctx, Values: url.Values{}}
// if there are new messages in the ctx.Flash, write them into cookie
ctx.Resp.Before(func(resp ResponseWriter) {
if val := ctx.Flash.Encode(); val != "" {
middleware.SetSiteCookie(ctx.Resp, CookieNameFlash, val, 0)
Expand Down
6 changes: 2 additions & 4 deletions modules/context/package.go
Expand Up @@ -154,12 +154,10 @@ func PackageContexter() func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
base, baseCleanUp := NewBaseContext(resp, req)
ctx := &Context{
Base: base,
Render: renderer, // it is still needed when rendering 500 page in a package handler
}
defer baseCleanUp()

// it is still needed when rendering 500 page in a package handler
ctx := NewWebContext(base, renderer, nil)
ctx.Base.AppendContextValue(WebContextKey, ctx)
next.ServeHTTP(ctx.Resp, ctx.Req)
})
Expand Down
2 changes: 0 additions & 2 deletions modules/notification/notification.go
Expand Up @@ -16,7 +16,6 @@ import (
"code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/notification/indexer"
"code.gitea.io/gitea/modules/notification/mail"
"code.gitea.io/gitea/modules/notification/mirror"
"code.gitea.io/gitea/modules/notification/ui"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
Expand All @@ -38,7 +37,6 @@ func NewContext() {
}
RegisterNotifier(indexer.NewNotifier())
RegisterNotifier(action.NewNotifier())
RegisterNotifier(mirror.NewNotifier())
}

// NotifyNewWikiPage notifies creating new wiki pages to notifiers
Expand Down
16 changes: 7 additions & 9 deletions modules/test/context_tests.go
Expand Up @@ -45,14 +45,12 @@ func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.Resp
resp := httptest.NewRecorder()
req := mockRequest(t, reqPath)
base, baseCleanUp := context.NewBaseContext(resp, req)
_ = baseCleanUp // during test, it doesn't need to do clean up. TODO: this can be improved later
base.Data = middleware.GetContextData(req.Context())
base.Locale = &translation.MockLocale{}
ctx := &context.Context{
Base: base,
Render: &mockRender{},
Flash: &middleware.Flash{Values: url.Values{}},
}
_ = baseCleanUp // during test, it doesn't need to do clean up. TODO: this can be improved later

ctx := context.NewWebContext(base, &MockRender{}, nil)
ctx.Flash = &middleware.Flash{Values: url.Values{}}

chiCtx := chi.NewRouteContext()
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
Expand Down Expand Up @@ -148,13 +146,13 @@ func LoadGitRepo(t *testing.T, ctx *context.Context) {
assert.NoError(t, err)
}

type mockRender struct{}
type MockRender struct{}

func (tr *mockRender) TemplateLookup(tmpl string, _ gocontext.Context) (templates.TemplateExecutor, error) {
func (tr *MockRender) TemplateLookup(tmpl string, _ gocontext.Context) (templates.TemplateExecutor, error) {
return nil, nil
}

func (tr *mockRender) HTML(w io.Writer, status int, _ string, _ any, _ gocontext.Context) error {
func (tr *MockRender) HTML(w io.Writer, status int, _ string, _ any, _ gocontext.Context) error {
if resp, ok := w.(http.ResponseWriter); ok {
resp.WriteHeader(status)
}
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_en-US.ini
Expand Up @@ -598,7 +598,6 @@ overview = Overview
following = Following
follow = Follow
unfollow = Unfollow
heatmap.loading = Loading Heatmap…
user_bio = Biography
disabled_public_activity = This user has disabled the public visibility of the activity.
email_visibility.limited = Your email address is visible to all authenticated users
Expand Down
23 changes: 23 additions & 0 deletions options/locale/locale_ja-JP.ini
Expand Up @@ -167,6 +167,7 @@ string.desc=Z - A

[error]
occurred=エラーが発生しました.
report_message=Gitea のバグが疑われる場合は、<a href="https://github.com/go-gitea/gitea/issues" target="_blank">GitHub</a>でIssueを検索して、見つからなければ新しいIssueを作成してください。
missing_csrf=不正なリクエスト: CSRFトークンが不明です
invalid_csrf=不正なリクエスト: CSRFトークンが無効です
not_found=ターゲットが見つかりませんでした。
Expand Down Expand Up @@ -353,13 +354,15 @@ remember_me=このデバイスで自動サインイン
forgot_password_title=パスワードを忘れた
forgot_password=パスワードをお忘れですか?
sign_up_now=アカウントが必要ですか? 今すぐ登録しましょう。
sign_up_successful=アカウントは無事に作成されました。ようこそ!
confirmation_mail_sent_prompt=<b>%s</b> に確認メールを送信しました。 %s以内に受信トレイを確認し、登録手続きを完了してください。
must_change_password=パスワードの更新
allow_password_change=ユーザーはパスワードの変更が必要 (推奨)
reset_password_mail_sent_prompt=<b>%s</b> に確認メールを送信しました。 %s以内に受信トレイを確認し、アカウント回復手続きを完了してください。
active_your_account=アカウントの有効化
account_activated=アカウントがアクティベートされました
prohibit_login=サインイン禁止
prohibit_login_desc=あなたのアカウントはサインインを禁止されています。 サイト管理者にお問い合わせください。
resent_limit_prompt=少し前に、あなたからアクティベーションメールが要求されています。 3分待ったのち、もう一度試してください。
has_unconfirmed_mail=こんにちは %s さん、あなたのメール アドレス (<b>%s</b>) は確認がとれていません。 確認メールを受け取っていない場合や、改めて送信したい場合は、下のボタンをクリックしてください。
resend_mail=アクティベーションメールを再送信するにはここをクリック
Expand All @@ -369,6 +372,7 @@ reset_password=アカウントの回復
invalid_code=確認コードが無効か期限切れです。
invalid_password=アカウントの作成に使用されたパスワードと一致しません。
reset_password_helper=アカウント回復
reset_password_wrong_user=あなたは %s でサインイン中ですが、アカウント回復のリンクは %s のものです。
password_too_short=%d文字未満のパスワードは設定できません。
non_local_account=ローカルユーザーでない場合はGiteaのWebインターフェースからパスワードを変更することはできません。
verify=確認
Expand All @@ -393,6 +397,7 @@ openid_connect_title=既存のアカウントに接続
openid_connect_desc=選択したOpenID URIは未登録です。 ここで新しいアカウントと関連付けます。
openid_register_title=アカウント新規作成
openid_register_desc=選択したOpenID URIは未登録です。 ここで新しいアカウントと関連付けます。
openid_signin_desc=OpenID URIを入力します。例: alice.openid.example.org または https://openid.example.org/alice
disable_forgot_password_mail=メール送信設定が無いためアカウントの回復は無効になっています。 サイト管理者にお問い合わせください。
disable_forgot_password_mail_admin=アカウントの回復はメール送信が設定済みの場合だけ使用できます。 アカウントの回復を有効にするにはメール送信を設定してください。
email_domain_blacklisted=あなたのメールアドレスでは登録することはできません。
Expand All @@ -403,6 +408,7 @@ authorize_application_description=アクセスを許可すると、このアプ
authorize_title=`"%s"にあなたのアカウントへのアクセスを許可しますか?`
authorization_failed=認可失敗
sspi_auth_failed=SSPI認証に失敗しました
password_pwned=あなたが選択したパスワードは、過去の情報漏洩事件で流出した<a target="_blank" rel="noopener noreferrer" href="https://haveibeenpwned.com/Passwords">盗まれたパスワードのリスト</a>に含まれています。 別のパスワードでもう一度試してください。 また他の登録でもこのパスワードからの変更を検討してください。
password_pwned_err=HaveIBeenPwnedへのリクエストを完了できませんでした

[mail]
Expand All @@ -417,6 +423,7 @@ activate_account.text_1=こんにちは、<b>%[1]s</b> さん。 %[2]s へのご
activate_account.text_2=あなたのアカウントを有効化するため、<b>%s</b>以内に次のリンクをクリックしてください:

activate_email=メール アドレスを確認します
activate_email.title=%s さん、メールアドレス確認をお願いします
activate_email.text=あなたのメールアドレスを確認するため、<b>%s</b>以内に次のリンクをクリックしてください:

register_notify=Giteaへようこそ
Expand Down Expand Up @@ -608,9 +615,12 @@ delete=アカウントを削除
twofa=2要素認証
account_link=連携アカウント
organization=組織
uid=UID
webauthn=セキュリティキー

public_profile=公開プロフィール
biography_placeholder=自己紹介してください!(Markdownを使うことができます)
profile_desc=あなたのプロフィールが他のユーザーにどのように表示されるかを制御します。あなたのプライマリメールアドレスは、通知、パスワードの回復、WebベースのGit操作に使用されます。
password_username_disabled=非ローカルユーザーのユーザー名は変更できません。詳細はサイト管理者にお問い合わせください。
full_name=フルネーム
website=Webサイト
Expand Down Expand Up @@ -662,6 +672,7 @@ update_user_avatar_success=ユーザーのアバターを更新しました。
change_password=パスワードを更新
old_password=現在のパスワード
new_password=新しいパスワード
retype_new_password=新しいパスワードの確認
password_incorrect=現在のパスワードが正しくありません。
change_password_success=パスワードを更新しました。 今後は新しいパスワードを使ってサインインしてください。
password_change_disabled=ローカルユーザーでない場合は、GiteaのWebインターフェースからパスワードを変更することはできません。
Expand All @@ -670,6 +681,7 @@ emails=メールアドレス
manage_emails=メールアドレスの管理
manage_themes=デフォルトのテーマを選択
manage_openid=OpenIDアドレスの管理
email_desc=プライマリメールアドレスは、通知、パスワードの回復、さらにメールアドレスを隠さない場合は、WebベースのGit操作にも使用されます。
theme_desc=この設定がサイト全体のデフォルトのテーマとなります。
primary=プライマリー
activated=アクティベート済み
Expand All @@ -695,6 +707,7 @@ add_email_success=新しいメールアドレスを追加しました。
email_preference_set_success=メール設定を保存しました。
add_openid_success=新しいOpenIDアドレスを追加しました。
keep_email_private=メールアドレスを隠す
keep_email_private_popup=これによりプロフィールでメールアドレスが隠され、Webインターフェースでのプルリクエスト作成やファイル編集でもメールアドレスが隠されます。 プッシュ済みのコミットは変更されません。
openid_desc=OpenIDを使うと外部プロバイダーに認証を委任することができます。

manage_ssh_keys=SSHキーの管理
Expand Down Expand Up @@ -773,7 +786,9 @@ ssh_disabled=SSHは無効です
ssh_signonly=SSHは現在無効になっているため、これらのキーはコミット署名の検証にのみ使用されます。
ssh_externally_managed=このユーザー用に外部で管理されているSSHキーです
manage_social=関連付けられているソーシャルアカウントを管理
social_desc=これらのソーシャルアカウントで、あなたのアカウントにサインインできます。 すべて自分が知っているものであることを確認してください。
unbind=連携の解除
unbind_success=ソーシャルアカウントの登録を削除しました。

manage_access_token=アクセストークンの管理
generate_new_token=新しいトークンを生成
Expand Down Expand Up @@ -805,6 +820,8 @@ remove_oauth2_application_desc=OAuth2アプリケーションを削除すると
remove_oauth2_application_success=アプリケーションを削除しました。
create_oauth2_application=新しいOAuth2アプリケーションの作成
create_oauth2_application_button=アプリケーション作成
create_oauth2_application_success=新しいOAuth2アプリケーションを作成しました。
update_oauth2_application_success=OAuth2アプリケーションを更新しました。
oauth2_application_name=アプリケーション名
oauth2_confidential_client=コンフィデンシャルクライアント。 ウェブアプリのように秘密情報を機密にできるアプリの場合に選択します。 デスクトップアプリやモバイルアプリなどのネイティブアプリには選択しないでください。
oauth2_redirect_uris=リダイレクトURI (複数可)。 URIごとに改行してください。
Expand All @@ -813,19 +830,24 @@ oauth2_client_id=クライアントID
oauth2_client_secret=クライアント シークレット
oauth2_regenerate_secret=シークレットを再生成
oauth2_regenerate_secret_hint=シークレットを紛失?
oauth2_client_secret_hint=このページから移動したりページを更新すると、二度とこのシークレットは表示されません。 シークレットを保存したことを確認してください。
oauth2_application_edit=編集
oauth2_application_create_description=OAuth2アプリケーションで、サードパーティアプリケーションがこのインスタンス上のユーザーアカウントにアクセスできるようになります。
oauth2_application_remove_description=OAuth2アプリケーションを削除すると、このインスタンス上の許可されたユーザーアカウントへのアクセスができなくなります。 続行しますか?

authorized_oauth2_applications=許可済みOAuth2アプリケーション
authorized_oauth2_applications_description=これらのサードパーティ アプリケーションに、あなたのGiteaアカウントへのアクセスを許可しています。 不要になったアプリケーションはアクセス権を取り消すようにしてください。
revoke_key=取り消し
revoke_oauth2_grant=アクセス権の取り消し
revoke_oauth2_grant_description=このサードパーティ アプリケーションのアクセス権を取り消し、アプリケーションがあなたのデータへアクセスすることを防ぎます。 続行しますか?
revoke_oauth2_grant_success=アクセス権を取り消しました。

twofa_desc=2要素認証はアカウントのセキュリティを強化します。
twofa_is_enrolled=このアカウントは2要素認証が<strong>有効</strong>になっています。
twofa_not_enrolled=このアカウントは2要素認証が設定されていません。
twofa_disable=2要素認証を無効にする
twofa_scratch_token_regenerate=スクラッチトークンを再生成
twofa_scratch_token_regenerated=あなたのスクラッチトークンは %s になりました。 安全な場所に保管してください。 二度と表示されません。
twofa_enroll=2要素認証の開始
twofa_disable_note=2要素認証は必要に応じて無効にできます。
twofa_disable_desc=2要素認証を無効にするとアカウントのセキュリティが低下します。 続行しますか?
Expand Down Expand Up @@ -1871,6 +1893,7 @@ settings.mirror_settings.last_update=最終更新
settings.mirror_settings.push_mirror.none=プッシュミラーは設定されていません
settings.mirror_settings.push_mirror.remote_url=リモートGitリポジトリのURL
settings.mirror_settings.push_mirror.add=プッシュミラーを追加
settings.mirror_settings.push_mirror.edit_sync_time=ミラー同期の間隔を編集

settings.sync_mirror=今すぐ同期
settings.mirror_sync_in_progress=ミラー同期を実行しています。 しばらくあとでまた確認してください。
Expand Down

0 comments on commit 130bf51

Please sign in to comment.