summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/template/template.go22
-rwxr-xr-xpublic/css/gogs.css17
-rw-r--r--public/less/_base.less18
-rw-r--r--templates/repo/commits_table.tmpl2
-rw-r--r--templates/repo/diff.tmpl14
-rw-r--r--templates/repo/view_list.tmpl4
6 files changed, 52 insertions, 25 deletions
diff --git a/modules/template/template.go b/modules/template/template.go
index d0d77b017b..9d63452dd3 100644
--- a/modules/template/template.go
+++ b/modules/template/template.go
@@ -183,15 +183,27 @@ func ReplaceLeft(s, old, new string) string {
}
// RenderCommitMessage renders commit message with XSS-safe and special links.
-func RenderCommitMessage(msg, urlPrefix string, metas map[string]string) template.HTML {
+func RenderCommitMessage(full bool, msg, urlPrefix string, metas map[string]string) template.HTML {
cleanMsg := template.HTMLEscapeString(msg)
fullMessage := string(base.RenderIssueIndexPattern([]byte(cleanMsg), urlPrefix, metas))
msgLines := strings.Split(strings.TrimSpace(fullMessage), "\n")
- for i := range msgLines {
- msgLines[i] = ReplaceLeft(msgLines[i], " ", " ")
+ numLines := len(msgLines)
+ if numLines == 0 {
+ return template.HTML("")
+ } else if !full {
+ return template.HTML(msgLines[0])
+ } else if numLines == 1 || (numLines >= 2 && len(msgLines[1]) == 0) {
+ // First line is a header, standalone or followed by empty line
+ header := fmt.Sprintf("<h3>%s</h3>", msgLines[0])
+ if numLines >= 2 {
+ fullMessage = header + fmt.Sprintf("\n<pre>%s</pre>", strings.Join(msgLines[2:], "\n"))
+ } else {
+ fullMessage = header
+ }
+ } else {
+ // Non-standard git message, there is no header line
+ fullMessage = fmt.Sprintf("<h4>%s</h4>", strings.Join(msgLines, "<br>"))
}
-
- fullMessage = strings.Join(msgLines, "<br>")
return template.HTML(fullMessage)
}
diff --git a/public/css/gogs.css b/public/css/gogs.css
index 583297afef..56a64cfd8e 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -895,13 +895,22 @@ pre.raw {
.ui .warning.segment {
border-color: #F0C36D;
}
-.ui .info.header {
- background-color: #d9edf7 !important;
- border-color: #85c5e5;
-}
.ui .info.segment {
border-color: #85c5e5;
}
+.ui .info.segment.top {
+ background-color: #d9edf7 !important;
+}
+.ui .info.segment.top h3,
+.ui .info.segment.top h4 {
+ margin-top: 0;
+}
+.ui .info.segment.top h3:last-child {
+ margin-top: 4px;
+}
+.ui .info.segment.top > :last-child {
+ margin-bottom: 0;
+}
.ui .normal.header {
font-weight: normal;
}
diff --git a/public/less/_base.less b/public/less/_base.less
index bd51f2303f..e359363423 100644
--- a/public/less/_base.less
+++ b/public/less/_base.less
@@ -196,12 +196,20 @@ pre {
}
}
.info {
- &.header {
- background-color: #d9edf7 !important;
- border-color: #85c5e5;
- }
&.segment {
- border-color: #85c5e5;
+ border-color: #85c5e5;
+ &.top {
+ background-color: #d9edf7 !important;
+ h3, h4 {
+ margin-top: 0;
+ }
+ h3:last-child {
+ margin-top: 4px;
+ }
+ > :last-child {
+ margin-bottom: 0;
+ }
+ }
}
}
diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl
index 2adc1770f9..8bab2be00f 100644
--- a/templates/repo/commits_table.tmpl
+++ b/templates/repo/commits_table.tmpl
@@ -37,7 +37,7 @@
</td>
<td class="message collapsing">
<a rel="nofollow" class="ui sha label" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">{{ShortSha .ID.String}}</a>
- {{RenderCommitMessage .Summary $.RepoLink $.Repository.ComposeMetas}}
+ {{RenderCommitMessage false .Summary $.RepoLink $.Repository.ComposeMetas}}
</td>
<td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
</tr>
diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl
index ba1322e437..18de976ebc 100644
--- a/templates/repo/diff.tmpl
+++ b/templates/repo/diff.tmpl
@@ -5,14 +5,12 @@
{{if .IsDiffCompare }}
{{template "repo/commits_table" .}}
{{else}}
- <h4 class="ui top attached info header">
- <div class="ui right">
- <a class="ui blue tiny button" href="{{EscapePound .SourcePath}}">
- {{.i18n.Tr "repo.diff.browse_source"}}
- </a>
- </div>
- {{RenderCommitMessage .Commit.Message $.RepoLink $.Repository.ComposeMetas}}
- </h4>
+ <div class="ui top attached info clearing segment">
+ <a class="ui floated right blue tiny button" href="{{EscapePound .SourcePath}}">
+ {{.i18n.Tr "repo.diff.browse_source"}}
+ </a>
+ {{RenderCommitMessage true .Commit.Message $.RepoLink $.Repository.ComposeMetas}}
+ </div>
<div class="ui attached info segment">
{{if .Author}}
<img class="ui avatar image" src="{{.Author.AvatarLink}}" />
diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl
index 9fb71908aa..887ce8e251 100644
--- a/templates/repo/view_list.tmpl
+++ b/templates/repo/view_list.tmpl
@@ -10,7 +10,7 @@
<strong>{{.LastCommit.Author.Name}}</strong>
{{end}}
<a rel="nofollow" class="ui sha label" href="{{.RepoLink}}/commit/{{.LastCommit.ID}}" rel="nofollow">{{ShortSha .LastCommit.ID.String}}</a>
- <span class="grey">{{RenderCommitMessage .LastCommit.Summary .RepoLink $.Repository.ComposeMetas}}</span>
+ <span class="grey">{{RenderCommitMessage false .LastCommit.Summary .RepoLink $.Repository.ComposeMetas}}</span>
</th>
<th class="nine wide">
</th>
@@ -44,7 +44,7 @@
{{end}}
<td class="message collapsing">
<a rel="nofollow" class="ui sha label" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.ID}}">{{ShortSha $commit.ID.String}}</a>
- {{RenderCommitMessage $commit.Summary $.RepoLink $.Repository.ComposeMetas}}
+ {{RenderCommitMessage false $commit.Summary $.RepoLink $.Repository.ComposeMetas}}
</td>
<td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td>
</tr>