mirror of https://github.com/go-gitea/gitea.git
Merge branch 'main' into htmx-2-0-5
This commit is contained in:
commit
f99e4cc6d6
|
|
@ -831,6 +831,20 @@ type CountUserFilter struct {
|
||||||
IsActive optional.Option[bool]
|
IsActive optional.Option[bool]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasUsers checks whether there are any users in the database, or only one user exists.
|
||||||
|
func HasUsers(ctx context.Context) (ret struct {
|
||||||
|
HasAnyUser, HasOnlyOneUser bool
|
||||||
|
}, err error,
|
||||||
|
) {
|
||||||
|
res, err := db.GetEngine(ctx).Table(&User{}).Cols("id").Limit(2).Query()
|
||||||
|
if err != nil {
|
||||||
|
return ret, fmt.Errorf("error checking user existence: %w", err)
|
||||||
|
}
|
||||||
|
ret.HasAnyUser = len(res) != 0
|
||||||
|
ret.HasOnlyOneUser = len(res) == 1
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
|
|
||||||
// CountUsers returns number of users.
|
// CountUsers returns number of users.
|
||||||
func CountUsers(ctx context.Context, opts *CountUserFilter) int64 {
|
func CountUsers(ctx context.Context, opts *CountUserFilter) int64 {
|
||||||
return countUsers(ctx, opts)
|
return countUsers(ctx, opts)
|
||||||
|
|
|
||||||
|
|
@ -421,6 +421,7 @@ remember_me.compromised = The login token is not valid anymore which may indicat
|
||||||
forgot_password_title= Forgot Password
|
forgot_password_title= Forgot Password
|
||||||
forgot_password = Forgot password?
|
forgot_password = Forgot password?
|
||||||
need_account = Need an account?
|
need_account = Need an account?
|
||||||
|
sign_up_tip = You are registering the first account in the system, which has administrator privileges. Please carefully remember your username and password. If you forget the username or password, please refer to the Gitea documentation to recover the account.
|
||||||
sign_up_now = Register now.
|
sign_up_now = Register now.
|
||||||
sign_up_successful = Account was successfully created. Welcome!
|
sign_up_successful = Account was successfully created. Welcome!
|
||||||
confirmation_mail_sent_prompt_ex = A new confirmation email has been sent to <b>%s</b>. Please check your inbox within the next %s to complete the registration process. If your registration email address is incorrect, you can sign in again and change it.
|
confirmation_mail_sent_prompt_ex = A new confirmation email has been sent to <b>%s</b>. Please check your inbox within the next %s to complete the registration process. If your registration email address is incorrect, you can sign in again and change it.
|
||||||
|
|
|
||||||
|
|
@ -601,5 +601,7 @@ func SubmitInstall(ctx *context.Context) {
|
||||||
// InstallDone shows the "post-install" page, makes it easier to develop the page.
|
// InstallDone shows the "post-install" page, makes it easier to develop the page.
|
||||||
// The name is not called as "PostInstall" to avoid misinterpretation as a handler for "POST /install"
|
// The name is not called as "PostInstall" to avoid misinterpretation as a handler for "POST /install"
|
||||||
func InstallDone(ctx *context.Context) { //nolint
|
func InstallDone(ctx *context.Context) { //nolint
|
||||||
|
hasUsers, _ := user_model.HasUsers(ctx)
|
||||||
|
ctx.Data["IsAccountCreated"] = hasUsers.HasAnyUser
|
||||||
ctx.HTML(http.StatusOK, tplPostInstall)
|
ctx.HTML(http.StatusOK, tplPostInstall)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -421,9 +421,11 @@ func SignOut(ctx *context.Context) {
|
||||||
// SignUp render the register page
|
// SignUp render the register page
|
||||||
func SignUp(ctx *context.Context) {
|
func SignUp(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("sign_up")
|
ctx.Data["Title"] = ctx.Tr("sign_up")
|
||||||
|
|
||||||
ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up"
|
ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up"
|
||||||
|
|
||||||
|
hasUsers, _ := user_model.HasUsers(ctx)
|
||||||
|
ctx.Data["IsFirstTimeRegistration"] = !hasUsers.HasAnyUser
|
||||||
|
|
||||||
oauth2Providers, err := oauth2.GetOAuth2Providers(ctx, optional.Some(true))
|
oauth2Providers, err := oauth2.GetOAuth2Providers(ctx, optional.Some(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("UserSignUp", err)
|
ctx.ServerError("UserSignUp", err)
|
||||||
|
|
@ -610,7 +612,13 @@ func createUserInContext(ctx *context.Context, tpl templates.TplName, form any,
|
||||||
// sends a confirmation email if required.
|
// sends a confirmation email if required.
|
||||||
func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth.User) (ok bool) {
|
func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth.User) (ok bool) {
|
||||||
// Auto-set admin for the only user.
|
// Auto-set admin for the only user.
|
||||||
if user_model.CountUsers(ctx, nil) == 1 {
|
hasUsers, err := user_model.HasUsers(ctx)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("HasUsers", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if hasUsers.HasOnlyOneUser {
|
||||||
|
// the only user is the one just created, will set it as admin
|
||||||
opts := &user_service.UpdateOptions{
|
opts := &user_service.UpdateOptions{
|
||||||
IsActive: optional.Some(true),
|
IsActive: optional.Some(true),
|
||||||
IsAdmin: user_service.UpdateOptionFieldFromValue(true),
|
IsAdmin: user_service.UpdateOptionFieldFromValue(true),
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ func Repos(ctx *context.Context) {
|
||||||
ctx.Data["CodePageIsDisabled"] = setting.Service.Explore.DisableCodePage
|
ctx.Data["CodePageIsDisabled"] = setting.Service.Explore.DisableCodePage
|
||||||
ctx.Data["Title"] = ctx.Tr("explore")
|
ctx.Data["Title"] = ctx.Tr("explore")
|
||||||
ctx.Data["PageIsExplore"] = true
|
ctx.Data["PageIsExplore"] = true
|
||||||
|
ctx.Data["ShowRepoOwnerOnList"] = true
|
||||||
ctx.Data["PageIsExploreRepositories"] = true
|
ctx.Data["PageIsExploreRepositories"] = true
|
||||||
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -394,9 +394,10 @@ func Forks(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pager := context.NewPagination(int(total), pageSize, page, 5)
|
pager := context.NewPagination(int(total), pageSize, page, 5)
|
||||||
|
ctx.Data["ShowRepoOwnerAvatar"] = true
|
||||||
|
ctx.Data["ShowRepoOwnerOnList"] = true
|
||||||
ctx.Data["Page"] = pager
|
ctx.Data["Page"] = pager
|
||||||
|
ctx.Data["Repos"] = forks
|
||||||
ctx.Data["Forks"] = forks
|
|
||||||
|
|
||||||
ctx.HTML(http.StatusOK, tplForks)
|
ctx.HTML(http.StatusOK, tplForks)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,7 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R
|
||||||
total = int(count)
|
total = int(count)
|
||||||
case "stars":
|
case "stars":
|
||||||
ctx.Data["PageIsProfileStarList"] = true
|
ctx.Data["PageIsProfileStarList"] = true
|
||||||
|
ctx.Data["ShowRepoOwnerOnList"] = true
|
||||||
repos, count, err = repo_model.SearchRepository(ctx, repo_model.SearchRepoOptions{
|
repos, count, err = repo_model.SearchRepository(ctx, repo_model.SearchRepoOptions{
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptions{
|
||||||
PageSize: pagingNum,
|
PageSize: pagingNum,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
{{ctx.Locale.Tr "admin.repositories"}} ({{ctx.Locale.Tr "admin.total" .ReposTotal}})
|
{{ctx.Locale.Tr "admin.repositories"}} ({{ctx.Locale.Tr "admin.total" .ReposTotal}})
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
{{template "explore/repo_list" .}}
|
{{template "shared/repo/list" .}}
|
||||||
</div>
|
</div>
|
||||||
<h4 class="ui top attached header">
|
<h4 class="ui top attached header">
|
||||||
{{ctx.Locale.Tr "settings.organization"}} ({{ctx.Locale.Tr "admin.total" .OrgsTotal}})
|
{{ctx.Locale.Tr "settings.organization"}} ({{ctx.Locale.Tr "admin.total" .OrgsTotal}})
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
<div role="main" aria-label="{{.Title}}" class="page-content explore repositories">
|
<div role="main" aria-label="{{.Title}}" class="page-content explore repositories">
|
||||||
{{template "explore/navbar" .}}
|
{{template "explore/navbar" .}}
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
{{template "shared/repo_search" .}}
|
{{template "shared/repo/search" .}}
|
||||||
{{template "explore/repo_list" .}}
|
{{template "shared/repo/list" .}}
|
||||||
{{template "base/paginate" .}}
|
{{template "base/paginate" .}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
{{if .ProfileReadmeContent}}
|
{{if .ProfileReadmeContent}}
|
||||||
<div id="readme_profile" class="render-content markup" data-profile-view-as-member="{{.IsViewingOrgAsMember}}">{{.ProfileReadmeContent}}</div>
|
<div id="readme_profile" class="render-content markup" data-profile-view-as-member="{{.IsViewingOrgAsMember}}">{{.ProfileReadmeContent}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{template "shared/repo_search" .}}
|
{{template "shared/repo/search" .}}
|
||||||
{{template "explore/repo_list" .}}
|
{{template "shared/repo/list" .}}
|
||||||
{{template "base/paginate" .}}
|
{{template "base/paginate" .}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<!-- the "cup" has a handler, so move it a little leftward to make it visually in the center -->
|
<!-- the "cup" has a handler, so move it a little leftward to make it visually in the center -->
|
||||||
<div class="tw-ml-[-30px]"><img width="160" src="{{AssetUrlPrefix}}/img/loading.png" alt aria-hidden="true"></div>
|
<div class="tw-ml-[-30px]"><img width="160" src="{{AssetUrlPrefix}}/img/loading.png" alt aria-hidden="true"></div>
|
||||||
<div class="tw-my-[2em] tw-text-[18px]">
|
<div class="tw-my-[2em] tw-text-[18px]">
|
||||||
<a id="goto-user-login" href="{{AppSubUrl}}/user/login">{{ctx.Locale.Tr "install.installing_desc"}}</a>
|
<a id="goto-after-install" href="{{AppSubUrl}}{{Iif .IsAccountCreated "/user/login" "/user/sign_up"}}">{{ctx.Locale.Tr "install.installing_desc"}}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
{{template "base/head" .}}
|
{{template "base/head" .}}
|
||||||
<div role="main" aria-label="{{.Title}}" class="page-content repository forks">
|
<div role="main" aria-label="{{.Title}}" class="page-content repository forks">
|
||||||
{{template "repo/header" .}}
|
{{template "repo/header" .}}
|
||||||
<div class="ui container">
|
<div class="ui container fork-list">
|
||||||
<h2 class="ui dividing header">
|
<h2 class="ui dividing header">
|
||||||
{{ctx.Locale.Tr "repo.forks"}}
|
{{ctx.Locale.Tr "repo.forks"}}
|
||||||
</h2>
|
</h2>
|
||||||
<div class="flex-list">
|
{{template "shared/repo/list" .}}
|
||||||
{{range .Forks}}
|
{{template "base/paginate" .}}
|
||||||
<div class="flex-item tw-border-0 repo-fork-item">
|
|
||||||
<span>{{ctx.AvatarUtils.Avatar .Owner}}</span>
|
|
||||||
<span><a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / <a href="{{.Link}}">{{.Name}}</a></span>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{template "base/paginate" .}}
|
|
||||||
</div>
|
</div>
|
||||||
{{template "base/footer" .}}
|
{{template "base/footer" .}}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,16 @@
|
||||||
{{range .Repos}}
|
{{range .Repos}}
|
||||||
<div class="flex-item">
|
<div class="flex-item">
|
||||||
<div class="flex-item-leading">
|
<div class="flex-item-leading">
|
||||||
{{template "repo/icon" .}}
|
{{if $.ShowRepoOwnerAvatar}}
|
||||||
|
{{ctx.AvatarUtils.Avatar .Owner 24}}
|
||||||
|
{{else}}
|
||||||
|
{{template "repo/icon" .}}
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-item-main">
|
<div class="flex-item-main">
|
||||||
<div class="flex-item-header">
|
<div class="flex-item-header">
|
||||||
<div class="flex-item-title">
|
<div class="flex-item-title">
|
||||||
{{if and (or $.PageIsExplore $.PageIsProfileStarList) .Owner}}
|
{{if and $.ShowRepoOwnerOnList .Owner}}
|
||||||
<a class="text primary name" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>/
|
<a class="text primary name" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>/
|
||||||
{{end}}
|
{{end}}
|
||||||
<a class="text primary name" href="{{.Link}}">{{.Name}}</a>
|
<a class="text primary name" href="{{.Link}}">{{.Name}}</a>
|
||||||
|
|
@ -7,6 +7,9 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
|
{{if .IsFirstTimeRegistration}}
|
||||||
|
<p>{{ctx.Locale.Tr "auth.sign_up_tip"}}</p>
|
||||||
|
{{end}}
|
||||||
<form class="ui form" action="{{.SignUpLink}}" method="post">
|
<form class="ui form" action="{{.SignUpLink}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister)}}
|
{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister)}}
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,8 @@
|
||||||
{{template "shared/issuelist" dict "." . "listType" "dashboard"}}
|
{{template "shared/issuelist" dict "." . "listType" "dashboard"}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{template "shared/repo_search" .}}
|
{{template "shared/repo/search" .}}
|
||||||
{{template "explore/repo_list" .}}
|
{{template "shared/repo/list" .}}
|
||||||
{{template "base/paginate" .}}
|
{{template "base/paginate" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
{{template "user/dashboard/feeds" .}}
|
{{template "user/dashboard/feeds" .}}
|
||||||
{{else if eq .TabName "stars"}}
|
{{else if eq .TabName "stars"}}
|
||||||
<div class="stars">
|
<div class="stars">
|
||||||
{{template "shared/repo_search" .}}
|
{{template "shared/repo/search" .}}
|
||||||
{{template "explore/repo_list" .}}
|
{{template "shared/repo/list" .}}
|
||||||
{{template "base/paginate" .}}
|
{{template "base/paginate" .}}
|
||||||
</div>
|
</div>
|
||||||
{{else if eq .TabName "following"}}
|
{{else if eq .TabName "following"}}
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
{{else if eq .TabName "organizations"}}
|
{{else if eq .TabName "organizations"}}
|
||||||
{{template "repo/user_cards" .}}
|
{{template "repo/user_cards" .}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{template "shared/repo_search" .}}
|
{{template "shared/repo/search" .}}
|
||||||
{{template "explore/repo_list" .}}
|
{{template "shared/repo/list" .}}
|
||||||
{{template "base/paginate" .}}
|
{{template "base/paginate" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ func TestRepoForkToOrg(t *testing.T) {
|
||||||
|
|
||||||
func TestForkListLimitedAndPrivateRepos(t *testing.T) {
|
func TestForkListLimitedAndPrivateRepos(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
forkItemSelector := ".repo-fork-item"
|
forkItemSelector := ".fork-list .flex-item"
|
||||||
|
|
||||||
user1Sess := loginUser(t, "user1")
|
user1Sess := loginUser(t, "user1")
|
||||||
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"})
|
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"})
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ function initPreInstall() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initPostInstall() {
|
function initPostInstall() {
|
||||||
const el = document.querySelector('#goto-user-login');
|
const el = document.querySelector('#goto-after-install');
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
|
|
||||||
const targetUrl = el.getAttribute('href');
|
const targetUrl = el.getAttribute('href');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue