Browse Source

Changes to be committed:

modified:   routes/repo/view.go
	modified:   templates/repo/view_file.tmpl
pull/4590/head
28111600 8 years ago
parent
commit
e88ed75bdd
  1. 12
      routes/repo/view.go
  2. 10
      templates/repo/view_file.tmpl

12
routes/repo/view.go

@ -186,15 +186,15 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
var output bytes.Buffer var output bytes.Buffer
lines := strings.Split(fileContent, "\n") lines := strings.Split(fileContent, "\n")
for index, line := range lines { for index, line := range lines {
output.WriteString(fmt.Sprintf(`<li class="L%d" rel="L%d">%s</li>`, index+1, index+1, gotemplate.HTMLEscapeString(strings.TrimRight(line, "\r"))) + "\n") output.WriteString(fmt.Sprintf(`<tr><td>%d</td><td id="L%d" rel="L%d">%s</td></tr>`, index+1, index+1, index+1, gotemplate.HTMLEscapeString(strings.TrimRight(line, "\r"))) + "\n")
} }
c.Data["FileContent"] = gotemplate.HTML(output.String()) c.Data["FileContent"] = gotemplate.HTML(output.String())
output.Reset() // output.Reset()
for i := 0; i < len(lines); i++ { // for i := 0; i < len(lines); i++ {
output.WriteString(fmt.Sprintf(`<span id="L%d">%d</span>`, i+1, i+1)) // output.WriteString(fmt.Sprintf(`<span id="L%d">%d</span>`, i+1, i+1))
} // }
c.Data["LineNums"] = gotemplate.HTML(output.String()) // c.Data["LineNums"] = gotemplate.HTML(output.String())
} }
if canEnableEditor { if canEnableEditor {

10
templates/repo/view_file.tmpl

@ -82,14 +82,14 @@
{{else if .FileSize}} {{else if .FileSize}}
<table> <table>
<tbody> <tbody>
<tr>
{{if .IsFileTooLarge}} {{if .IsFileTooLarge}}
<td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td> <tr>
<td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td></tr>
{{else}} {{else}}
<td class="lines-num">{{.LineNums}}</td> {{.FileContent}}
<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
{{end}} {{end}}
</tr>
</tbody> </tbody>
</table> </table>
{{end}} {{end}}

Loading…
Cancel
Save