Skip to content

Commit 2019983

Browse files
oscarlofwenhamntechknowlogick
authored andcommitted
Make "Ghost" not link to 404 page (#6410)
* Make Ghost not link to 404 page * 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 * Make Ghost avatar not link to 404 page * Make Ghost on milestone_issues not link to 404 page
1 parent ee0d3ee commit 2019983

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

models/issue.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,17 @@ func (issue *Issue) GetLastEventLabel() string {
990990
return "repo.issues.opened_by"
991991
}
992992

993+
// GetLastEventLabelFake returns the localization label for the current issue without providing a link in the username.
994+
func (issue *Issue) GetLastEventLabelFake() string {
995+
if issue.IsClosed {
996+
if issue.IsPull && issue.PullRequest.HasMerged {
997+
return "repo.pulls.merged_by_fake"
998+
}
999+
return "repo.issues.closed_by_fake"
1000+
}
1001+
return "repo.issues.opened_by_fake"
1002+
}
1003+
9931004
// NewIssueOptions represents the options of a new issue.
9941005
type NewIssueOptions struct {
9951006
Repo *Repository

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,10 @@ issues.action_assignee = Assignee
770770
issues.action_assignee_no_select = No assignee
771771
issues.opened_by = opened %[1]s by <a href="%[2]s">%[3]s</a>
772772
pulls.merged_by = merged %[1]s by <a href="%[2]s">%[3]s</a>
773+
pulls.merged_by_fake = merged %[1]s by %[2]s
773774
issues.closed_by = closed %[1]s by <a href="%[2]s">%[3]s</a>
774775
issues.opened_by_fake = opened %[1]s by %[2]s
776+
issues.closed_by_fake = closed %[1]s by %[2]s
775777
issues.previous = Previous
776778
issues.next = Next
777779
issues.open_title = Open

templates/repo/issue/list.tmpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,12 @@
220220

221221
<p class="desc">
222222
{{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }}
223-
{{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}}
223+
224+
{{if gt .Poster.ID 0}}
225+
{{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}}
226+
{{else}}
227+
{{$.i18n.Tr .GetLastEventLabelFake $timeStr .Poster.Name | Safe}}
228+
{{end}}
224229

225230
{{$tasks := .GetTasks}}
226231
{{if gt $tasks 0}}

templates/repo/issue/milestone_issues.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@
203203
{{end}}
204204

205205
<p class="desc">
206-
{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}}
206+
{{if gt .Poster.ID 0}}
207+
{{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}}
208+
{{else}}
209+
{{$.i18n.Tr .GetLastEventLabelFake $timeStr .Poster.Name | Safe}}
210+
{{end}}
207211
{{$tasks := .GetTasks}}
208212
{{if gt $tasks 0}}
209213
{{$tasksDone := .GetTasksDone}}

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<span class="text"><strong>{{.i18n.Tr "repo.issues.num_participants" .NumParticipants}}</strong></span>
113113
<div>
114114
{{range .Participants}}
115-
<a href="{{.HomeLink}}">
115+
<a {{if gt .ID 0}}href="{{.HomeLink}}"{{end}}>
116116
<img class="ui avatar image poping up" src="{{.RelAvatarLink}}" data-content="{{.DisplayName}}" data-position="top center" data-variation="small inverted">
117117
</a>
118118
{{end}}

templates/user/dashboard/feeds.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
<div class="ui fourteen wide column">
88
<div class="{{if or (eq .GetOpType 5) (eq .GetOpType 18)}}push news{{end}}">
99
<p>
10-
<a href="{{AppSubUrl}}/{{.GetActUserName}}" title="{{.GetActFullName}}">{{.ShortActUserName}}</a>
10+
{{if gt .ActUser.ID 0}}
11+
<a href="{{AppSubUrl}}/{{.GetActUserName}}" title="{{.GetActFullName}}">{{.ShortActUserName}}</a>
12+
{{else}}
13+
{{.ShortActUserName}}
14+
{{end}}
1115
{{if eq .GetOpType 1}}
1216
{{$.i18n.Tr "action.create_repo" .GetRepoLink .ShortRepoPath | Str2html}}
1317
{{else if eq .GetOpType 2}}

templates/user/dashboard/issues.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@
8686
{{end}}
8787

8888
<p class="desc">
89-
{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}}
89+
{{if gt .Poster.ID 0}}
90+
{{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}}
91+
{{else}}
92+
{{$.i18n.Tr .GetLastEventLabelFake $timeStr .Poster.Name | Safe}}
93+
{{end}}
9094
{{if .Assignee}}
9195
<a class="ui right assignee poping up" href="{{.Assignee.HomeLink}}" data-content="{{.Assignee.Name}}" data-variation="inverted" data-position="left center">
9296
<img class="ui avatar image" src="{{.Assignee.RelAvatarLink}}">

0 commit comments

Comments
 (0)