mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 15:27:54 +01:00
Unified link creation. (#15619)
This commit is contained in:
parent
1456978246
commit
c80d7f33b6
@ -301,7 +301,7 @@ func (u *User) CanImportLocal() bool {
|
|||||||
// DashboardLink returns the user dashboard page link.
|
// DashboardLink returns the user dashboard page link.
|
||||||
func (u *User) DashboardLink() string {
|
func (u *User) DashboardLink() string {
|
||||||
if u.IsOrganization() {
|
if u.IsOrganization() {
|
||||||
return setting.AppSubURL + "/org/" + u.Name + "/dashboard/"
|
return u.OrganisationLink() + "/dashboard/"
|
||||||
}
|
}
|
||||||
return setting.AppSubURL + "/"
|
return setting.AppSubURL + "/"
|
||||||
}
|
}
|
||||||
@ -316,6 +316,11 @@ func (u *User) HTMLURL() string {
|
|||||||
return setting.AppURL + u.Name
|
return setting.AppURL + u.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OrganisationLink returns the organization sub page link.
|
||||||
|
func (u *User) OrganisationLink() string {
|
||||||
|
return setting.AppSubURL + "/org/" + u.Name
|
||||||
|
}
|
||||||
|
|
||||||
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
|
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
|
||||||
func (u *User) GenerateEmailActivateCode(email string) string {
|
func (u *User) GenerateEmailActivateCode(email string) string {
|
||||||
code := base.CreateTimeLimitCode(
|
code := base.CreateTimeLimitCode(
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Organization contains organization context
|
// Organization contains organization context
|
||||||
@ -70,7 +69,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
|||||||
|
|
||||||
// Force redirection when username is actually a user.
|
// Force redirection when username is actually a user.
|
||||||
if !org.IsOrganization() {
|
if !org.IsOrganization() {
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + org.Name)
|
ctx.Redirect(org.HomeLink())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +117,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
|||||||
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember
|
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember
|
||||||
ctx.Data["CanCreateOrgRepo"] = ctx.Org.CanCreateOrgRepo
|
ctx.Data["CanCreateOrgRepo"] = ctx.Org.CanCreateOrgRepo
|
||||||
|
|
||||||
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + org.Name
|
ctx.Org.OrgLink = org.OrganisationLink()
|
||||||
ctx.Data["OrgLink"] = ctx.Org.OrgLink
|
ctx.Data["OrgLink"] = ctx.Org.OrgLink
|
||||||
|
|
||||||
// Team.
|
// Team.
|
||||||
|
@ -75,5 +75,5 @@ func CreatePost(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
log.Trace("Organization created: %s", org.Name)
|
log.Trace("Organization created: %s", org.Name)
|
||||||
|
|
||||||
ctx.Redirect(setting.AppSubURL + "/org/" + form.OrgName + "/dashboard")
|
ctx.Redirect(org.DashboardLink())
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/services/forms"
|
"code.gitea.io/gitea/services/forms"
|
||||||
issue_service "code.gitea.io/gitea/services/issue"
|
issue_service "code.gitea.io/gitea/services/issue"
|
||||||
@ -88,7 +87,7 @@ func RetrieveLabels(ctx *context.Context) {
|
|||||||
ctx.ServerError("org.IsOwnedBy", err)
|
ctx.ServerError("org.IsOwnedBy", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + org.LowerName
|
ctx.Org.OrgLink = org.OrganisationLink()
|
||||||
ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
|
ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
|
||||||
ctx.Data["OrganizationLink"] = ctx.Org.OrgLink
|
ctx.Data["OrganizationLink"] = ctx.Org.OrgLink
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ func MigratePost(ctx *context.Context) {
|
|||||||
|
|
||||||
err = task.MigrateRepository(ctx.User, ctxUser, opts)
|
err = task.MigrateRepository(ctx.User, ctxUser, opts)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + opts.RepoName)
|
ctx.Redirect(ctxUser.HomeLink() + "/" + opts.RepoName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ func ForkPost(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
repo, has := models.HasForkedRepo(ctxUser.ID, traverseParentRepo.ID)
|
repo, has := models.HasForkedRepo(ctxUser.ID, traverseParentRepo.ID)
|
||||||
if has {
|
if has {
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
|
ctx.Redirect(ctxUser.HomeLink() + "/" + repo.Name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !traverseParentRepo.IsFork {
|
if !traverseParentRepo.IsFork {
|
||||||
@ -243,7 +243,7 @@ func ForkPost(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Trace("Repository forked[%d]: %s/%s", forkRepo.ID, ctxUser.Name, repo.Name)
|
log.Trace("Repository forked[%d]: %s/%s", forkRepo.ID, ctxUser.Name, repo.Name)
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
|
ctx.Redirect(ctxUser.HomeLink() + "/" + repo.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPullInfo(ctx *context.Context) *models.Issue {
|
func checkPullInfo(ctx *context.Context) *models.Issue {
|
||||||
|
@ -240,7 +240,7 @@ func CreatePost(ctx *context.Context) {
|
|||||||
repo, err = repo_service.GenerateRepository(ctx.User, ctxUser, templateRepo, opts)
|
repo, err = repo_service.GenerateRepository(ctx.User, ctxUser, templateRepo, opts)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Trace("Repository generated [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
|
log.Trace("Repository generated [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
|
ctx.Redirect(ctxUser.HomeLink() + "/" + repo.Name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -259,7 +259,7 @@ func CreatePost(ctx *context.Context) {
|
|||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
|
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
|
ctx.Redirect(ctxUser.HomeLink() + "/" + repo.Name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,7 @@ func SettingsPost(ctx *context.Context) {
|
|||||||
|
|
||||||
log.Trace("Repository transfer process was started: %s/%s -> %s", ctx.Repo.Owner.Name, repo.Name, newOwner)
|
log.Trace("Repository transfer process was started: %s/%s -> %s", ctx.Repo.Owner.Name, repo.Name, newOwner)
|
||||||
ctx.Flash.Success(ctx.Tr("repo.settings.transfer_started", newOwner.DisplayName()))
|
ctx.Flash.Success(ctx.Tr("repo.settings.transfer_started", newOwner.DisplayName()))
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctx.Repo.Owner.Name + "/" + repo.Name + "/settings")
|
ctx.Redirect(ctx.Repo.Owner.HomeLink() + "/" + repo.Name + "/settings")
|
||||||
|
|
||||||
case "cancel_transfer":
|
case "cancel_transfer":
|
||||||
if !ctx.Repo.IsOwner() {
|
if !ctx.Repo.IsOwner() {
|
||||||
@ -512,7 +512,7 @@ func SettingsPost(ctx *context.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrNoPendingTransfer(err) {
|
if models.IsErrNoPendingTransfer(err) {
|
||||||
ctx.Flash.Error("repo.settings.transfer_abort_invalid")
|
ctx.Flash.Error("repo.settings.transfer_abort_invalid")
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctx.User.Name + "/" + repo.Name + "/settings")
|
ctx.Redirect(ctx.User.HomeLink() + "/" + repo.Name + "/settings")
|
||||||
} else {
|
} else {
|
||||||
ctx.ServerError("GetPendingRepositoryTransfer", err)
|
ctx.ServerError("GetPendingRepositoryTransfer", err)
|
||||||
}
|
}
|
||||||
@ -532,7 +532,7 @@ func SettingsPost(ctx *context.Context) {
|
|||||||
|
|
||||||
log.Trace("Repository transfer process was cancelled: %s/%s ", ctx.Repo.Owner.Name, repo.Name)
|
log.Trace("Repository transfer process was cancelled: %s/%s ", ctx.Repo.Owner.Name, repo.Name)
|
||||||
ctx.Flash.Success(ctx.Tr("repo.settings.transfer_abort_success", repoTransfer.Recipient.Name))
|
ctx.Flash.Success(ctx.Tr("repo.settings.transfer_abort_success", repoTransfer.Recipient.Name))
|
||||||
ctx.Redirect(setting.AppSubURL + "/" + ctx.Repo.Owner.Name + "/" + repo.Name + "/settings")
|
ctx.Redirect(ctx.Repo.Owner.HomeLink() + "/" + repo.Name + "/settings")
|
||||||
|
|
||||||
case "delete":
|
case "delete":
|
||||||
if !ctx.Repo.IsOwner() {
|
if !ctx.Repo.IsOwner() {
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<td>{{.NumMembers}}</td>
|
<td>{{.NumMembers}}</td>
|
||||||
<td>{{.NumRepos}}</td>
|
<td>{{.NumRepos}}</td>
|
||||||
<td><span title="{{.CreatedUnix.FormatLong}}">{{.CreatedUnix.FormatShort}}</span></td>
|
<td><span title="{{.CreatedUnix.FormatLong}}">{{.CreatedUnix.FormatShort}}</span></td>
|
||||||
<td><a href="{{AppSubUrl}}/org/{{.Name}}/settings">{{svg "octicon-pencil"}}</a></td>
|
<td><a href="{{.OrganisationLink}}/settings">{{svg "octicon-pencil"}}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
|
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
|
||||||
</a>
|
</a>
|
||||||
{{range .Orgs}}
|
{{range .Orgs}}
|
||||||
<a class="{{if eq $.ContextUser.ID .ID}}active selected{{end}} item truncated-item-container" title="{{.Name}}" href="{{AppSubUrl}}/org/{{.Name}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else if $.PageIsMilestonesDashboard}}milestones{{else}}dashboard{{end}}">
|
<a class="{{if eq $.ContextUser.ID .ID}}active selected{{end}} item truncated-item-container" title="{{.Name}}" href="{{.OrganisationLink}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else if $.PageIsMilestonesDashboard}}milestones{{else}}dashboard{{end}}">
|
||||||
{{avatar .}}
|
{{avatar .}}
|
||||||
<span class="truncated-item-name">{{.ShortName 40}}</span>
|
<span class="truncated-item-name">{{.ShortName 40}}</span>
|
||||||
<span class="org-visibility">
|
<span class="org-visibility">
|
||||||
@ -58,12 +58,12 @@
|
|||||||
{{.i18n.Tr "home.filter_by_team_repositories"}}
|
{{.i18n.Tr "home.filter_by_team_repositories"}}
|
||||||
</div>
|
</div>
|
||||||
<div class="scrolling menu items">
|
<div class="scrolling menu items">
|
||||||
<a class="{{if not $.Team}}active selected{{end}} item" title="{{.i18n.Tr "all"}}" href="{{AppSubUrl}}/org/{{$.Org.Name}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else if $.PageIsMilestonesDashboard}}milestones{{else}}dashboard{{end}}">
|
<a class="{{if not $.Team}}active selected{{end}} item" title="{{.i18n.Tr "all"}}" href="{{$.Org.OrganisationLink}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else if $.PageIsMilestonesDashboard}}milestones{{else}}dashboard{{end}}">
|
||||||
{{.i18n.Tr "all"}}
|
{{.i18n.Tr "all"}}
|
||||||
</a>
|
</a>
|
||||||
{{range .Org.Teams}}
|
{{range .Org.Teams}}
|
||||||
{{if not .IncludesAllRepositories}}
|
{{if not .IncludesAllRepositories}}
|
||||||
<a class="{{if $.Team}}{{if eq $.Team.ID .ID}}active selected{{end}}{{end}} item" title="{{.Name}}" href="{{AppSubUrl}}/org/{{$.Org.Name}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else if $.PageIsMilestonesDashboard}}milestones{{else}}dashboard{{end}}/{{.Name}}">
|
<a class="{{if $.Team}}{{if eq $.Team.ID .ID}}active selected{{end}}{{end}} item" title="{{.Name}}" href="{{$.Org.OrganisationLink}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else if $.PageIsMilestonesDashboard}}milestones{{else}}dashboard{{end}}/{{.Name}}">
|
||||||
{{.Name}}
|
{{.Name}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -76,21 +76,21 @@
|
|||||||
|
|
||||||
{{if .ContextUser.IsOrganization}}
|
{{if .ContextUser.IsOrganization}}
|
||||||
<div class="right stackable menu">
|
<div class="right stackable menu">
|
||||||
<a class="{{if .PageIsNews}}active{{end}} item" style="margin-left: auto" href="{{AppSubUrl}}/org/{{.ContextUser.Name}}/dashboard{{if .Team}}/{{.Team.Name}}{{end}}">
|
<a class="{{if .PageIsNews}}active{{end}} item" style="margin-left: auto" href="{{.ContextUser.DashboardLink}}{{if .Team}}/{{.Team.Name}}{{end}}">
|
||||||
{{svg "octicon-rss"}} {{.i18n.Tr "activities"}}
|
{{svg "octicon-rss"}} {{.i18n.Tr "activities"}}
|
||||||
</a>
|
</a>
|
||||||
{{if not .UnitIssuesGlobalDisabled}}
|
{{if not .UnitIssuesGlobalDisabled}}
|
||||||
<a class="{{if .PageIsIssues}}active{{end}} item" href="{{AppSubUrl}}/org/{{.ContextUser.Name}}/issues{{if .Team}}/{{.Team.Name}}{{end}}">
|
<a class="{{if .PageIsIssues}}active{{end}} item" href="{{.ContextUser.OrganisationLink}}/issues{{if .Team}}/{{.Team.Name}}{{end}}">
|
||||||
{{svg "octicon-issue-opened"}} {{.i18n.Tr "issues"}}
|
{{svg "octicon-issue-opened"}} {{.i18n.Tr "issues"}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if not .UnitPullsGlobalDisabled}}
|
{{if not .UnitPullsGlobalDisabled}}
|
||||||
<a class="{{if .PageIsPulls}}active{{end}} item" href="{{AppSubUrl}}/org/{{.ContextUser.Name}}/pulls{{if .Team}}/{{.Team.Name}}{{end}}">
|
<a class="{{if .PageIsPulls}}active{{end}} item" href="{{.ContextUser.OrganisationLink}}/pulls{{if .Team}}/{{.Team.Name}}{{end}}">
|
||||||
{{svg "octicon-git-pull-request"}} {{.i18n.Tr "pull_requests"}}
|
{{svg "octicon-git-pull-request"}} {{.i18n.Tr "pull_requests"}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and .ShowMilestonesDashboardPage (not (and .UnitIssuesGlobalDisabled .UnitPullsGlobalDisabled))}}
|
{{if and .ShowMilestonesDashboardPage (not (and .UnitIssuesGlobalDisabled .UnitPullsGlobalDisabled))}}
|
||||||
<a class="{{if .PageIsMilestonesDashboard}}active{{end}} item" href="{{AppSubUrl}}/org/{{.ContextUser.Name}}/milestones{{if .Team}}/{{.Team.Name}}{{end}}">
|
<a class="{{if .PageIsMilestonesDashboard}}active{{end}} item" href="{{.ContextUser.OrganisationLink}}/milestones{{if .Team}}/{{.Team.Name}}{{end}}">
|
||||||
{{svg "octicon-milestone"}} {{.i18n.Tr "milestones"}}
|
{{svg "octicon-milestone"}} {{.i18n.Tr "milestones"}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
{{range .Orgs}}
|
{{range .Orgs}}
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="right floated content">
|
<div class="right floated content">
|
||||||
<form method="post" action="{{AppSubUrl}}/org/{{.Name}}/members/action/leave">
|
<form method="post" action="{{.OrganisationLink}}/members/action/leave">
|
||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
<button type="submit" class="ui blue small button" name="uid" value="{{.ID}}">{{$.i18n.Tr "org.members.leave"}}</button>
|
<button type="submit" class="ui blue small button" name="uid" value="{{.ID}}">{{$.i18n.Tr "org.members.leave"}}</button>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user