From f8e5ee7727496ea80b2c8da008dddbfbdb04cd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20L=C3=B6fwenhamn?= Date: Fri, 22 Mar 2019 10:35:11 +0100 Subject: [PATCH 1/4] Make Ghost not link to 404 page --- templates/repo/issue/list.tmpl | 7 ++++++- templates/user/dashboard/feeds.tmpl | 6 +++++- templates/user/dashboard/issues.tmpl | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index deed251cda5f3..90f7738243c3d 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -220,7 +220,12 @@

{{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }} - {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}} + + {{if gt .Poster.ID 0}} + {{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.opened_by_fake" $timeStr .Poster.Name | Safe}} + {{end}} {{$tasks := .GetTasks}} {{if gt $tasks 0}} diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 849ad7fb2f28f..ffc0db3317b96 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -7,7 +7,11 @@

- {{.ShortActUserName}} + {{if gt .ActUser.ID 0}} + {{.ShortActUserName}} + {{else}} + {{.ShortActUserName}} + {{end}} {{if eq .GetOpType 1}} {{$.i18n.Tr "action.create_repo" .GetRepoLink .ShortRepoPath | Str2html}} {{else if eq .GetOpType 2}} diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index b5990e61e041f..57e67db967f50 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -86,7 +86,11 @@ {{end}}

- {{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} + {{if gt .Poster.ID 0}} + {{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.opened_by_fake" $timeStr .Poster.Name | Safe}} + {{end}} {{if .Assignee}} From 3edd91e5cda5a45ff9f15a2ee48a4a4c0a87939c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20L=C3=B6fwenhamn?= Date: Fri, 22 Mar 2019 13:46:10 +0100 Subject: [PATCH 2/4] Make correct localization label show * Create and use GetLastEventLabelFake for when a Ghost user has made the action, thus not linking to a user profile * Add corresponding _fake entries to locale_en-US --- models/issue.go | 11 +++++++++++ options/locale/locale_en-US.ini | 2 ++ templates/repo/issue/list.tmpl | 4 ++-- templates/user/dashboard/issues.tmpl | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/models/issue.go b/models/issue.go index 0429ac4c8c6fd..8a6b20727aba1 100644 --- a/models/issue.go +++ b/models/issue.go @@ -990,6 +990,17 @@ func (issue *Issue) GetLastEventLabel() string { return "repo.issues.opened_by" } +// GetLastEventLabelFake returns the localization label for the current issue without providing a link in the username. +func (issue *Issue) GetLastEventLabelFake() string { + if issue.IsClosed { + if issue.IsPull && issue.PullRequest.HasMerged { + return "repo.pulls.merged_by_fake" + } + return "repo.issues.closed_by_fake" + } + return "repo.issues.opened_by_fake" +} + // NewIssueOptions represents the options of a new issue. type NewIssueOptions struct { Repo *Repository diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 331b94db3c6ca..2d739dd23f655 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -770,8 +770,10 @@ issues.action_assignee = Assignee issues.action_assignee_no_select = No assignee issues.opened_by = opened %[1]s by %[3]s pulls.merged_by = merged %[1]s by %[3]s +pulls.merged_by_fake = merged %[1]s by %[2]s issues.closed_by = closed %[1]s by %[3]s issues.opened_by_fake = opened %[1]s by %[2]s +issues.closed_by_fake = closed %[1]s by %[2]s issues.previous = Previous issues.next = Next issues.open_title = Open diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 90f7738243c3d..78352acb50b0f 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -222,9 +222,9 @@ {{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }} {{if gt .Poster.ID 0}} - {{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} + {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}} {{else}} - {{$.i18n.Tr "repo.issues.opened_by_fake" $timeStr .Poster.Name | Safe}} + {{$.i18n.Tr .GetLastEventLabelFake $timeStr .Poster.Name | Safe}} {{end}} {{$tasks := .GetTasks}} diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index 57e67db967f50..93286df578f83 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -87,9 +87,9 @@

{{if gt .Poster.ID 0}} - {{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} + {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}} {{else}} - {{$.i18n.Tr "repo.issues.opened_by_fake" $timeStr .Poster.Name | Safe}} + {{$.i18n.Tr .GetLastEventLabelFake $timeStr .Poster.Name | Safe}} {{end}} {{if .Assignee}} From 06f00b1c59ef4af007b8fa413fe72a91e03e448e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20L=C3=B6fwenhamn?= Date: Fri, 22 Mar 2019 15:51:04 +0100 Subject: [PATCH 3/4] Make Ghost avatar not link to 404 page --- templates/repo/issue/view_content/sidebar.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 47bf67f903ec4..1f5481530a7bf 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -112,7 +112,7 @@ {{.i18n.Tr "repo.issues.num_participants" .NumParticipants}}

{{range .Participants}} - + {{end}} From 8c67cab06fc2d9120fcc09bbe9bce59a553dccae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20L=C3=B6fwenhamn?= Date: Mon, 25 Mar 2019 08:29:24 +0100 Subject: [PATCH 4/4] Make Ghost on milestone_issues not link to 404 page --- templates/repo/issue/milestone_issues.tmpl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index f2298dfdabc47..c81f6adf8b283 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -203,7 +203,11 @@ {{end}}

- {{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} + {{if gt .Poster.ID 0}} + {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}} + {{else}} + {{$.i18n.Tr .GetLastEventLabelFake $timeStr .Poster.Name | Safe}} + {{end}} {{$tasks := .GetTasks}} {{if gt $tasks 0}} {{$tasksDone := .GetTasksDone}}