forked from forgejo/forgejo
Use link in UI which returned a relative url but not html_url which contains an absolute url (#21986)
partially fix #19345 This PR add some `Link` methods for different objects. The `Link` methods are not different from `HTMLURL`, they are lack of the absolute URL. And most of UI `HTMLURL` have been replaced to `Link` so that users can visit them from a different domain or IP. This PR also introduces a new javascript configuration `window.config.reqAppUrl` which is different from `appUrl` which is still an absolute url but the domain has been replaced to the current requested domain.
This commit is contained in:
parent
189d5b7045
commit
769be877f2
43 changed files with 191 additions and 83 deletions
|
@ -16,11 +16,11 @@
|
|||
{{else}}
|
||||
<div class="ui top tabular menu" data-write="write" data-preview="preview">
|
||||
<a class="active item" data-tab="write">{{.locale.Tr "write"}}</a>
|
||||
<a class="item" data-tab="preview" data-url="{{.Repository.HTMLURL}}/markdown" data-context="{{.RepoLink}}">{{.locale.Tr "preview"}}</a>
|
||||
<a class="item" data-tab="preview" data-url="{{.Repository.Link}}/markdown" data-context="{{.RepoLink}}">{{.locale.Tr "preview"}}</a>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui bottom active tab" data-tab="write">
|
||||
<textarea id="content" class="edit_area js-quick-submit" name="content" tabindex="4" data-id="issue-{{.RepoName}}" data-url="{{.Repository.HTMLURL}}/markdown" data-context="{{.Repo.RepoLink}}">
|
||||
<textarea id="content" class="edit_area js-quick-submit" name="content" tabindex="4" data-id="issue-{{.RepoName}}" data-url="{{.Repository.Link}}/markdown" data-context="{{.Repo.RepoLink}}">
|
||||
{{- if .BodyQuery}}{{.BodyQuery}}{{else if .IssueTemplate}}{{.IssueTemplate}}{{else if .PullRequestTemplate}}{{.PullRequestTemplate}}{{else}}{{.content}}{{end -}}
|
||||
</textarea>
|
||||
</div>
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
<div class="ui comment form">
|
||||
<div class="ui top tabular menu">
|
||||
<a class="active write item">{{$.locale.Tr "write"}}</a>
|
||||
<a class="preview item" data-url="{{$.Repository.HTMLURL}}/markdown" data-context="{{$.RepoLink}}">{{$.locale.Tr "preview"}}</a>
|
||||
<a class="preview item" data-url="{{$.Repository.Link}}/markdown" data-context="{{$.RepoLink}}">{{$.locale.Tr "preview"}}</a>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui bottom active tab write">
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
{{template "shared/user/avatarlink" .Poster}}
|
||||
<span class="text grey muted-links">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{$link := printf "%s/commit/%s" $.Repository.HTMLURL ($.Issue.PullRequest.MergedCommitID|PathEscape)}}
|
||||
{{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}}
|
||||
{{if eq $.Issue.PullRequest.Status 3}}
|
||||
{{$.locale.Tr "repo.issues.manually_pull_merged_at" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID) ($.BaseTarget|Escape) $createdStr | Str2html}}
|
||||
{{else}}
|
||||
|
@ -329,7 +329,7 @@
|
|||
<div class="detail">
|
||||
{{svg "octicon-plus"}}
|
||||
<span class="text grey muted-links">
|
||||
<a href="{{.DependentIssue.HTMLURL}}">
|
||||
<a href="{{.DependentIssue.Link}}">
|
||||
{{if eq .DependentIssue.RepoID .Issue.RepoID}}
|
||||
#{{.DependentIssue.Index}} {{.DependentIssue.Title}}
|
||||
{{else}}
|
||||
|
@ -352,7 +352,7 @@
|
|||
<div class="detail">
|
||||
<span class="text grey muted-links">{{svg "octicon-trash"}}</span>
|
||||
<span class="text grey muted-links">
|
||||
<a href="{{.DependentIssue.HTMLURL}}">
|
||||
<a href="{{.DependentIssue.Link}}">
|
||||
{{if eq .DependentIssue.RepoID .Issue.RepoID}}
|
||||
#{{.DependentIssue.Index}} {{.DependentIssue.Title}}
|
||||
{{else}}
|
||||
|
@ -476,7 +476,7 @@
|
|||
{{$resolveDoer := (index $comms 0).ResolveDoer}}
|
||||
{{$isNotPending := (not (eq (index $comms 0).Review.Type 0))}}
|
||||
<div class="df ac">
|
||||
<a href="{{(index $comms 0).CodeCommentURL}}" class="file-comment ml-3 word-break">{{$filename}}</a>
|
||||
<a href="{{(index $comms 0).CodeCommentLink}}" class="file-comment ml-3 word-break">{{$filename}}</a>
|
||||
{{if $invalid}}
|
||||
<span class="ui label basic small ml-3">
|
||||
{{$.locale.Tr "repo.issues.review.outdated"}}
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
<div class="menu">
|
||||
{{$referenceUrl := ""}}
|
||||
{{if .issue}}
|
||||
{{$referenceUrl = Printf "%s#%s" .ctx.Issue.HTMLURL .item.HashTag}}
|
||||
{{$referenceUrl = Printf "%s#%s" .ctx.Issue.Link .item.HashTag}}
|
||||
{{else}}
|
||||
{{$referenceUrl = Printf "%s/files#%s" .ctx.Issue.HTMLURL .item.HashTag}}
|
||||
{{$referenceUrl = Printf "%s/files#%s" .ctx.Issue.Link .item.HashTag}}
|
||||
{{end}}
|
||||
<div class="item context" data-clipboard-text="{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.copy_link"}}</div>
|
||||
<div class="item context" data-clipboard-text-type="url" data-clipboard-text="{{AppSubUrl}}{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.copy_link"}}</div>
|
||||
<div class="item context quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.HashTag}}-raw">{{.ctx.locale.Tr "repo.issues.context.quote_reply"}}</div>
|
||||
{{if not .ctx.UnitIssuesGlobalDisabled}}
|
||||
<div class="item context reference-issue" data-target="{{.item.HashTag}}-raw" data-modal="#reference-issue-modal" data-poster="{{.item.Poster.GetDisplayName}}" data-poster-username="{{.item.Poster.Name}}" data-reference="{{$referenceUrl}}">{{.ctx.locale.Tr "repo.issues.context.reference_issue"}}</div>
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
{{if .Issue.PullRequest.HasMerged}}
|
||||
<div class="item text">
|
||||
{{if .Issue.PullRequest.MergedCommitID}}
|
||||
{{$link := printf "%s/commit/%s" $.Repository.HTMLURL (.Issue.PullRequest.MergedCommitID|PathEscape)}}
|
||||
{{$link := printf "%s/commit/%s" $.Repository.Link (.Issue.PullRequest.MergedCommitID|PathEscape)}}
|
||||
{{if eq $.Issue.PullRequest.Status 3}}
|
||||
{{$.locale.Tr "repo.pulls.manually_merged_as" ($link|Escape) (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}}
|
||||
{{else}}
|
||||
|
|
|
@ -35,13 +35,13 @@
|
|||
|
||||
{{if .Issue.IsPull}}
|
||||
{{$headHref := .HeadTarget|Escape}}
|
||||
{{if .HeadBranchHTMLURL}}
|
||||
{{$headHref = printf "<a href=\"%s\">%s</a>" (.HeadBranchHTMLURL | Escape) $headHref}}
|
||||
{{if .HeadBranchLink}}
|
||||
{{$headHref = printf "<a href=\"%s\">%s</a>" (.HeadBranchLink | Escape) $headHref}}
|
||||
{{end}}
|
||||
{{$headHref = printf "%s <a class=\"tooltip\" data-content=\"%s\" data-clipboard-text=\"%s\">%s</a>" $headHref (.locale.Tr "copy_branch") (.HeadTarget | Escape) (svg "octicon-copy" 14)}}
|
||||
{{$baseHref := .BaseTarget|Escape}}
|
||||
{{if .BaseBranchHTMLURL}}
|
||||
{{$baseHref = printf "<a href=\"%s\">%s</a>" (.BaseBranchHTMLURL | Escape) $baseHref}}
|
||||
{{if .BaseBranchLink}}
|
||||
{{$baseHref = printf "<a href=\"%s\">%s</a>" (.BaseBranchLink | Escape) $baseHref}}
|
||||
{{end}}
|
||||
{{if .Issue.PullRequest.HasMerged}}
|
||||
{{$mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix $.locale}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue