mirror of https://github.com/gogs/gogs.git
parent
f545faa06d
commit
d3d8284985
2
gogs.go
2
gogs.go
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/gogs/gogs/pkg/setting"
|
"github.com/gogs/gogs/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.11.77.1206"
|
const APP_VER = "0.11.78.1210"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setting.AppVer = APP_VER
|
setting.AppVer = APP_VER
|
||||||
|
|
|
@ -64,7 +64,7 @@ func NewFuncMap() []template.FuncMap {
|
||||||
"AppendAvatarSize": tool.AppendAvatarSize,
|
"AppendAvatarSize": tool.AppendAvatarSize,
|
||||||
"Safe": Safe,
|
"Safe": Safe,
|
||||||
"Sanitize": bluemonday.UGCPolicy().Sanitize,
|
"Sanitize": bluemonday.UGCPolicy().Sanitize,
|
||||||
"Str2html": Str2HTML,
|
"Str2html": Str2HTML, // TODO: Rename to Str2HTML
|
||||||
"NewLine2br": NewLine2br,
|
"NewLine2br": NewLine2br,
|
||||||
"TimeSince": tool.TimeSince,
|
"TimeSince": tool.TimeSince,
|
||||||
"RawTimeSince": tool.RawTimeSince,
|
"RawTimeSince": tool.RawTimeSince,
|
||||||
|
@ -176,12 +176,14 @@ func ToUTF8WithErr(content []byte) (error, string) {
|
||||||
return err, result
|
return err, result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Unused function
|
||||||
func ToUTF8(content string) string {
|
func ToUTF8(content string) string {
|
||||||
_, res := ToUTF8WithErr([]byte(content))
|
_, res := ToUTF8WithErr([]byte(content))
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replaces all prefixes 'old' in 's' with 'new'.
|
// Replaces all prefixes 'old' in 's' with 'new'.
|
||||||
|
// FIXME: Unused function
|
||||||
func ReplaceLeft(s, old, new string) string {
|
func ReplaceLeft(s, old, new string) string {
|
||||||
old_len, new_len, i, n := len(old), len(new), 0, 0
|
old_len, new_len, i, n := len(old), len(new), 0, 0
|
||||||
for ; i < len(s) && strings.HasPrefix(s[i:], old); n += 1 {
|
for ; i < len(s) && strings.HasPrefix(s[i:], old); n += 1 {
|
||||||
|
@ -206,16 +208,16 @@ func ReplaceLeft(s, old, new string) string {
|
||||||
return string(replacement)
|
return string(replacement)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderCommitMessage renders commit message with XSS-safe and special links.
|
// RenderCommitMessage renders commit message with special links.
|
||||||
func RenderCommitMessage(full bool, msg, urlPrefix string, metas map[string]string) template.HTML {
|
func RenderCommitMessage(full bool, msg, urlPrefix string, metas map[string]string) string {
|
||||||
cleanMsg := template.HTMLEscapeString(msg)
|
cleanMsg := template.HTMLEscapeString(msg)
|
||||||
fullMessage := string(markup.RenderIssueIndexPattern([]byte(cleanMsg), urlPrefix, metas))
|
fullMessage := string(markup.RenderIssueIndexPattern([]byte(cleanMsg), urlPrefix, metas))
|
||||||
msgLines := strings.Split(strings.TrimSpace(fullMessage), "\n")
|
msgLines := strings.Split(strings.TrimSpace(fullMessage), "\n")
|
||||||
numLines := len(msgLines)
|
numLines := len(msgLines)
|
||||||
if numLines == 0 {
|
if numLines == 0 {
|
||||||
return template.HTML("")
|
return ""
|
||||||
} else if !full {
|
} else if !full {
|
||||||
return template.HTML(msgLines[0])
|
return msgLines[0]
|
||||||
} else if numLines == 1 || (numLines >= 2 && len(msgLines[1]) == 0) {
|
} else if numLines == 1 || (numLines >= 2 && len(msgLines[1]) == 0) {
|
||||||
// First line is a header, standalone or followed by empty line
|
// First line is a header, standalone or followed by empty line
|
||||||
header := fmt.Sprintf("<h3>%s</h3>", msgLines[0])
|
header := fmt.Sprintf("<h3>%s</h3>", msgLines[0])
|
||||||
|
@ -228,7 +230,7 @@ func RenderCommitMessage(full bool, msg, urlPrefix string, metas map[string]stri
|
||||||
// Non-standard git message, there is no header line
|
// Non-standard git message, there is no header line
|
||||||
fullMessage = fmt.Sprintf("<h4>%s</h4>", strings.Join(msgLines, "<br>"))
|
fullMessage = fmt.Sprintf("<h4>%s</h4>", strings.Join(msgLines, "<br>"))
|
||||||
}
|
}
|
||||||
return template.HTML(fullMessage)
|
return fullMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
type Actioner interface {
|
type Actioner interface {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.11.77.1206
|
0.11.78.1210
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
<a rel="nofollow" class="ui sha label" href="{{AppSubURL}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">{{ShortSHA1 .ID.String}}</a>
|
<a rel="nofollow" class="ui sha label" href="{{AppSubURL}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">{{ShortSHA1 .ID.String}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
<span class="{{if gt .ParentCount 1}}grey text {{end}} has-emoji">{{RenderCommitMessage false .Summary $.RepoLink $.Repository.ComposeMetas}}</span>
|
<span class="{{if gt .ParentCount 1}}grey text {{end}} has-emoji">{{RenderCommitMessage false .Summary $.RepoLink $.Repository.ComposeMetas | Str2html}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
|
<td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<a class="ui floated right blue tiny button" href="{{EscapePound .SourcePath}}">
|
<a class="ui floated right blue tiny button" href="{{EscapePound .SourcePath}}">
|
||||||
{{.i18n.Tr "repo.diff.browse_source"}}
|
{{.i18n.Tr "repo.diff.browse_source"}}
|
||||||
</a>
|
</a>
|
||||||
{{RenderCommitMessage true .Commit.Message $.RepoLink $.Repository.ComposeMetas}}
|
{{RenderCommitMessage true .Commit.Message $.RepoLink $.Repository.ComposeMetas | Str2html}}
|
||||||
</div>
|
</div>
|
||||||
<div class="ui attached info segment">
|
<div class="ui attached info segment">
|
||||||
{{if .Author}}
|
{{if .Author}}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<strong>{{.LatestCommit.Author.Name}}</strong>
|
<strong>{{.LatestCommit.Author.Name}}</strong>
|
||||||
{{end}}
|
{{end}}
|
||||||
<a rel="nofollow" class="ui sha label" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}" rel="nofollow">{{ShortSHA1 .LatestCommit.ID.String}}</a>
|
<a rel="nofollow" class="ui sha label" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}" rel="nofollow">{{ShortSHA1 .LatestCommit.ID.String}}</a>
|
||||||
<span class="grey has-emoji">{{RenderCommitMessage false .LatestCommit.Summary .RepoLink $.Repository.ComposeMetas}}</span>
|
<span class="grey has-emoji">{{RenderCommitMessage false .LatestCommit.Summary .RepoLink $.Repository.ComposeMetas | Str2html}}</span>
|
||||||
</th>
|
</th>
|
||||||
<th class="nine wide">
|
<th class="nine wide">
|
||||||
</th>
|
</th>
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
<td class="message collapsing has-emoji">
|
<td class="message collapsing has-emoji">
|
||||||
<a rel="nofollow" class="ui sha label" href="{{$.RepoLink}}/commit/{{$commit.ID}}">{{ShortSHA1 $commit.ID.String}}</a>
|
<a rel="nofollow" class="ui sha label" href="{{$.RepoLink}}/commit/{{$commit.ID}}">{{ShortSHA1 $commit.ID.String}}</a>
|
||||||
{{RenderCommitMessage false $commit.Summary $.RepoLink $.Repository.ComposeMetas}}
|
{{RenderCommitMessage false $commit.Summary $.RepoLink $.Repository.ComposeMetas | Str2html}}
|
||||||
</td>
|
</td>
|
||||||
<td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td>
|
<td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue