Wrap long lines in diff
This commit is contained in:
@@ -40,22 +40,22 @@ func Diff(text string) string {
|
||||
}
|
||||
|
||||
if len(line) < 1 {
|
||||
html.WriteString("\n");
|
||||
html.WriteString("<br />\n");
|
||||
} else {
|
||||
c := line[0]
|
||||
htmlLine := template.HTMLEscapeString(string(line[1:]))
|
||||
if c == '+' {
|
||||
html.WriteString("<span class=\"plus\">+</span>")
|
||||
html.WriteString("<span class=\"plus-line\">" + htmlLine + "</span>\n")
|
||||
html.WriteString("<span class=\"plus-line\">" + htmlLine + "</span><br />\n")
|
||||
} else if c == '-' {
|
||||
html.WriteString("<span class=\"minus\">-</span>")
|
||||
html.WriteString("<span class=\"minus-line\">" + htmlLine + "</span>\n")
|
||||
html.WriteString("<span class=\"minus-line\">" + htmlLine + "</span><br />\n")
|
||||
} else if c == '@' {
|
||||
html.WriteString("<span class=\"hunk\">@")
|
||||
html.WriteString(htmlLine + "</span>\n")
|
||||
html.WriteString(htmlLine + "</span><br />\n")
|
||||
} else {
|
||||
html.WriteByte(c)
|
||||
html.WriteString(htmlLine + "\n")
|
||||
html.WriteString(htmlLine + "<br />\n")
|
||||
}
|
||||
}
|
||||
index = nextLine
|
||||
|
||||
@@ -24,18 +24,20 @@
|
||||
|
||||
<h1>Revisions - {{.Name}}</h1>
|
||||
|
||||
<ul>
|
||||
{{range .Revisions}}
|
||||
<li>
|
||||
<div><code>
|
||||
{{.Diff | fmtdiff}}
|
||||
</code></div>
|
||||
<form action="/{{.Name | pathescape}}" method="GET">
|
||||
<input type="hidden" name="a" value="rev" />
|
||||
<input type="hidden" name="i" value="{{.ID}}" />
|
||||
<input type="submit" value="View" />
|
||||
</form>
|
||||
<pre>{{.Diff | fmtdiff}}</pre>
|
||||
</li>
|
||||
<hr />
|
||||
{{else}}
|
||||
<li>No revisions found.</li>
|
||||
<div>
|
||||
No revisions found.
|
||||
</div>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user