From 0693fbfc00ed71bfba56239e2de6f190884bc5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Fri, 17 Mar 2017 06:57:43 +0100 Subject: [PATCH] Refactor repo/issue/view_content.tmpl (#1276) --- templates/repo/issue/view_content.tmpl | 313 +----------------- .../repo/issue/view_content/comments.tmpl | 144 ++++++++ templates/repo/issue/view_content/pull.tmpl | 63 ++++ .../repo/issue/view_content/sidebar.tmpl | 102 ++++++ 4 files changed, 312 insertions(+), 310 deletions(-) create mode 100644 templates/repo/issue/view_content/comments.tmpl create mode 100644 templates/repo/issue/view_content/pull.tmpl create mode 100644 templates/repo/issue/view_content/sidebar.tmpl diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 4e35614dbb..7de9502242 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -55,216 +55,10 @@ - {{range .Issue.Comments}} - {{ $createdStr:= TimeSince .Created $.Lang }} - - - {{if eq .Type 0}} -
- - - -
-
- {{.Poster.Name}} {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}} -
- {{if gt .ShowTag 0}} -
- {{if eq .ShowTag 1}} - {{$.i18n.Tr "repo.issues.poster"}} - {{else if eq .ShowTag 2}} - {{$.i18n.Tr "repo.issues.collaborator"}} - {{else if eq .ShowTag 3}} - {{$.i18n.Tr "repo.issues.owner"}} - {{end}} -
- {{end}} - {{if or $.IsRepositoryAdmin (eq .Poster.ID $.SignedUserID)}} -
- - -
- {{end}} -
-
-
-
- {{if .RenderedContent}} - {{.RenderedContent|Str2html}} - {{else}} - {{$.i18n.Tr "repo.issues.no_content"}} - {{end}} -
-
{{.Content}}
-
-
- {{if .Attachments}} -
- -
- {{end}} -
-
- {{else if eq .Type 1}} -
- - - - - {{.Poster.Name}} {{$.i18n.Tr "repo.issues.reopened_at" .EventTag $createdStr | Safe}} -
- {{else if eq .Type 2}} -
- - - - - {{.Poster.Name}} {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}} -
- {{else if eq .Type 4}} -
- - - - - {{.Poster.Name}} {{$.i18n.Tr "repo.issues.commit_ref_at" .EventTag $createdStr | Safe}} - -
- - {{.Content | Str2html}} -
-
- {{else if eq .Type 7}} - {{if .Label}} -
- - - - - {{.Poster.Name}} - {{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{end}} -
- {{end}} - {{else if eq .Type 8}} -
- - - - - {{.Poster.Name}} - {{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.change_milestone_at" .OldMilestone.Name .Milestone.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_milestone_at" .OldMilestone.Name $createdStr | Safe}}{{end}}{{else if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.add_milestone_at" .Milestone.Name $createdStr | Safe}}{{end}} -
- {{else if eq .Type 9}} -
- - {{if gt .AssigneeID 0}}{{if eq .Poster.ID .AssigneeID}} - - {{.Poster.Name}} {{$.i18n.Tr "repo.issues.self_assign_at" $createdStr | Safe}} - {{else}} - - {{.Assignee.Name}} {{$.i18n.Tr "repo.issues.add_assignee_at" .Poster.Name $createdStr | Safe}} {{end}}{{else if gt .OldAssigneeID 0}} - - - {{.Poster.Name}} {{$.i18n.Tr "repo.issues.remove_assignee_at" $createdStr | Safe}} {{end}} -
- {{else if eq .Type 10}} -
- -
- - - - {{.Poster.Name}} - {{$.i18n.Tr "repo.issues.change_title_at" .OldTitle .NewTitle $createdStr | Safe}} - - {{else if eq .Type 11}} -
- -
- - - - {{.Poster.Name}} - {{$.i18n.Tr "repo.issues.delete_branch_at" .CommitSHA $createdStr | Safe}} - - {{end}} - - {{end}} + {{ template "repo/issue/view_content/comments" . }} {{if .Issue.IsPull}} -
- -
-
- {{if .Issue.PullRequest.HasMerged}} -
- {{$.i18n.Tr "repo.pulls.has_merged"}} -
- {{if .IsPullBranchDeletable}} -
-
- {{$.i18n.Tr "repo.branch.delete" .HeadTarget}} -
- {{end}} - {{else if .Issue.IsClosed}} -
- {{$.i18n.Tr "repo.pulls.reopen_to_merge"}} -
- {{else if .IsPullReuqestBroken}} -
- - {{$.i18n.Tr "repo.pulls.data_broken"}} -
- {{else if .Issue.PullRequest.IsChecking}} -
- - {{$.i18n.Tr "repo.pulls.is_checking"}} -
- {{else if .Issue.PullRequest.CanAutoMerge}} -
- - {{$.i18n.Tr "repo.pulls.can_auto_merge_desc"}} -
- {{if .IsRepositoryWriter}} -
-
-
- {{.CsrfTokenHtml}} - -
-
- {{end}} - {{else}} -
- - {{$.i18n.Tr "repo.pulls.cannot_auto_merge_desc"}} -
-
- - {{$.i18n.Tr "repo.pulls.cannot_auto_merge_helper"}} -
- {{end}} -
-
-
+ {{ template "repo/issue/view_content/pull". }} {{end}} {{if .IsSigned}} @@ -304,108 +98,7 @@ -
-
- -
- {{.i18n.Tr "repo.issues.new.no_label"}} - {{range .Labels}} - - - {{end}} -
- -
- - -
- {{.i18n.Tr "repo.issues.new.no_milestone"}} -
- {{if .Issue.Milestone}} - {{.Issue.Milestone.Name | Sanitize}} - {{end}} -
-
- -
- - - -
- {{.i18n.Tr "repo.issues.new.no_assignee"}} -
- {{if .Issue.Assignee}} - {{.Issue.Assignee.Name}} - {{end}} -
-
- -
- -
- {{.i18n.Tr "repo.issues.num_participants" .NumParticipants}} -
- {{range .Participants}} - - - - {{end}} -
-
-
-
+ {{ template "repo/issue/view_content/sidebar" . }}
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl new file mode 100644 index 0000000000..c1b4e7f599 --- /dev/null +++ b/templates/repo/issue/view_content/comments.tmpl @@ -0,0 +1,144 @@ +{{range .Issue.Comments}} + {{ $createdStr:= TimeSince .Created $.Lang }} + + + {{if eq .Type 0}} +
+ + + +
+
+ {{.Poster.Name}} {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}} +
+ {{if gt .ShowTag 0}} +
+ {{if eq .ShowTag 1}} + {{$.i18n.Tr "repo.issues.poster"}} + {{else if eq .ShowTag 2}} + {{$.i18n.Tr "repo.issues.collaborator"}} + {{else if eq .ShowTag 3}} + {{$.i18n.Tr "repo.issues.owner"}} + {{end}} +
+ {{end}} + {{if or $.IsRepositoryAdmin (eq .Poster.ID $.SignedUserID)}} +
+ + +
+ {{end}} +
+
+
+
+ {{if .RenderedContent}} + {{.RenderedContent|Str2html}} + {{else}} + {{$.i18n.Tr "repo.issues.no_content"}} + {{end}} +
+
{{.Content}}
+
+
+ {{if .Attachments}} +
+ +
+ {{end}} +
+
+ {{else if eq .Type 1}} +
+ + + + + {{.Poster.Name}} {{$.i18n.Tr "repo.issues.reopened_at" .EventTag $createdStr | Safe}} +
+ {{else if eq .Type 2}} +
+ + + + + {{.Poster.Name}} {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}} +
+ {{else if eq .Type 4}} +
+ + + + + {{.Poster.Name}} {{$.i18n.Tr "repo.issues.commit_ref_at" .EventTag $createdStr | Safe}} + +
+ + {{.Content | Str2html}} +
+
+ {{else if eq .Type 7}} + {{if .Label}} +
+ + + + + {{.Poster.Name}} + {{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{end}} +
+ {{end}} + {{else if eq .Type 8}} +
+ + + + + {{.Poster.Name}} + {{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.change_milestone_at" .OldMilestone.Name .Milestone.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_milestone_at" .OldMilestone.Name $createdStr | Safe}}{{end}}{{else if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.add_milestone_at" .Milestone.Name $createdStr | Safe}}{{end}} +
+ {{else if eq .Type 9}} +
+ + {{if gt .AssigneeID 0}}{{if eq .Poster.ID .AssigneeID}} + + {{.Poster.Name}} {{$.i18n.Tr "repo.issues.self_assign_at" $createdStr | Safe}} + {{else}} + + {{.Assignee.Name}} {{$.i18n.Tr "repo.issues.add_assignee_at" .Poster.Name $createdStr | Safe}} {{end}}{{else if gt .OldAssigneeID 0}} + + + {{.Poster.Name}} {{$.i18n.Tr "repo.issues.remove_assignee_at" $createdStr | Safe}} {{end}} +
+ {{else if eq .Type 10}} +
+ +
+ + + + {{.Poster.Name}} + {{$.i18n.Tr "repo.issues.change_title_at" .OldTitle .NewTitle $createdStr | Safe}} + + {{else if eq .Type 11}} +
+ +
+ + + + {{.Poster.Name}} + {{$.i18n.Tr "repo.issues.delete_branch_at" .CommitSHA $createdStr | Safe}} + + {{end}} +{{end}} diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl new file mode 100644 index 0000000000..87de9c508b --- /dev/null +++ b/templates/repo/issue/view_content/pull.tmpl @@ -0,0 +1,63 @@ +
+ +
+
+ {{if .Issue.PullRequest.HasMerged}} +
+ {{$.i18n.Tr "repo.pulls.has_merged"}} +
+ {{if .IsPullBranchDeletable}} +
+ + {{end}} + {{else if .Issue.IsClosed}} +
+ {{$.i18n.Tr "repo.pulls.reopen_to_merge"}} +
+ {{else if .IsPullReuqestBroken}} +
+ + {{$.i18n.Tr "repo.pulls.data_broken"}} +
+ {{else if .Issue.PullRequest.IsChecking}} +
+ + {{$.i18n.Tr "repo.pulls.is_checking"}} +
+ {{else if .Issue.PullRequest.CanAutoMerge}} +
+ + {{$.i18n.Tr "repo.pulls.can_auto_merge_desc"}} +
+ {{if .IsRepositoryWriter}} +
+
+
+ {{.CsrfTokenHtml}} + +
+
+ {{end}} + {{else}} +
+ + {{$.i18n.Tr "repo.pulls.cannot_auto_merge_desc"}} +
+
+ + {{$.i18n.Tr "repo.pulls.cannot_auto_merge_helper"}} +
+ {{end}} +
+
+
diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl new file mode 100644 index 0000000000..ea46e5f94d --- /dev/null +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -0,0 +1,102 @@ +
+
+ +
+ {{.i18n.Tr "repo.issues.new.no_label"}} + {{range .Labels}} + + + {{end}} +
+ +
+ + +
+ {{.i18n.Tr "repo.issues.new.no_milestone"}} +
+ {{if .Issue.Milestone}} + {{.Issue.Milestone.Name | Sanitize}} + {{end}} +
+
+ +
+ + + +
+ {{.i18n.Tr "repo.issues.new.no_assignee"}} +
+ {{if .Issue.Assignee}} + {{.Issue.Assignee.Name}} + {{end}} +
+
+ +
+ +
+ {{.i18n.Tr "repo.issues.num_participants" .NumParticipants}} +
+ {{range .Participants}} + + + + {{end}} +
+
+
+