From 769be877f2ce572b94b7c0a85853a2f7836075ac Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 7 Feb 2023 02:09:18 +0800 Subject: 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. --- templates/package/shared/list.tmpl | 4 ++-- templates/package/view.tmpl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'templates/package') diff --git a/templates/package/shared/list.tmpl b/templates/package/shared/list.tmpl index ec2e88c854..01e0cb49a6 100644 --- a/templates/package/shared/list.tmpl +++ b/templates/package/shared/list.tmpl @@ -28,7 +28,7 @@ {{$hasRepositoryAccess = index $.RepositoryAccessMap .Repository.ID}} {{end}} {{if $hasRepositoryAccess}} - {{$.locale.Tr "packages.published_by_in" $timeStr .Creator.HomeLink (.Creator.GetDisplayName | Escape) .Repository.HTMLURL (.Repository.FullName | Escape) | Safe}} + {{$.locale.Tr "packages.published_by_in" $timeStr .Creator.HomeLink (.Creator.GetDisplayName | Escape) .Repository.Link (.Repository.FullName | Escape) | Safe}} {{else}} {{$.locale.Tr "packages.published_by" $timeStr .Creator.HomeLink (.Creator.GetDisplayName | Escape) | Safe}} {{end}} @@ -41,7 +41,7 @@ {{svg "octicon-package" 32}}

{{.locale.Tr "packages.empty"}}

{{if and .Repository .CanWritePackages}} - {{$packagesUrl := URLJoin .Owner.HTMLURL "-" "packages"}} + {{$packagesUrl := URLJoin .Owner.HomeLink "-" "packages"}}

{{.locale.Tr "packages.empty.repo" $packagesUrl | Safe}}

{{end}}

{{.locale.Tr "packages.empty.documentation" | Safe}}

diff --git a/templates/package/view.tmpl b/templates/package/view.tmpl index a548d9e0b6..2b32139681 100644 --- a/templates/package/view.tmpl +++ b/templates/package/view.tmpl @@ -11,7 +11,7 @@
{{$timeStr := TimeSinceUnix .PackageDescriptor.Version.CreatedUnix $.locale}} {{if .HasRepositoryAccess}} - {{.locale.Tr "packages.published_by_in" $timeStr .PackageDescriptor.Creator.HomeLink (.PackageDescriptor.Creator.GetDisplayName | Escape) .PackageDescriptor.Repository.HTMLURL (.PackageDescriptor.Repository.FullName | Escape) | Safe}} + {{.locale.Tr "packages.published_by_in" $timeStr .PackageDescriptor.Creator.HomeLink (.PackageDescriptor.Creator.GetDisplayName | Escape) .PackageDescriptor.Repository.Link (.PackageDescriptor.Repository.FullName | Escape) | Safe}} {{else}} {{.locale.Tr "packages.published_by" $timeStr .PackageDescriptor.Creator.HomeLink (.PackageDescriptor.Creator.GetDisplayName | Escape) | Safe}} {{end}} @@ -41,7 +41,7 @@
{{svg .PackageDescriptor.Package.Type.SVGName 16 "mr-3"}} {{.PackageDescriptor.Package.Type.Name}}
{{if .HasRepositoryAccess}} -
{{svg "octicon-repo" 16 "mr-3"}} {{.PackageDescriptor.Repository.FullName}}
+
{{svg "octicon-repo" 16 "mr-3"}} {{.PackageDescriptor.Repository.FullName}}
{{end}}
{{svg "octicon-calendar" 16 "mr-3"}} {{TimeSinceUnix .PackageDescriptor.Version.CreatedUnix $.locale}}
{{svg "octicon-download" 16 "mr-3"}} {{.PackageDescriptor.Version.DownloadCount}}
@@ -91,7 +91,7 @@
{{if .HasRepositoryAccess}} -
{{svg "octicon-issue-opened" 16 "mr-3"}} {{.locale.Tr "repo.issues"}}
+
{{svg "octicon-issue-opened" 16 "mr-3"}} {{.locale.Tr "repo.issues"}}
{{end}} {{if .CanWritePackages}}
{{svg "octicon-tools" 16 "mr-3"}} {{.locale.Tr "repo.settings"}}
-- cgit v1.2.3