mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-26 09:09:36 -05:00
c8b45ecc27
* render code view server side * remove debug print * fix multiline selection bug * change string concatenation to bytes.Buffer for efficiency * Fix newlines added by previous for hljs * fix selection highlighting * make css changes in .less
56 lines
2.2 KiB
Cheetah
56 lines
2.2 KiB
Cheetah
<div id="file-content">
|
|
<h4 class="ui top attached header" id="{{if .ReadmeExist}}repo-readme{{else}}repo-read-file{{end}}">
|
|
{{if .ReadmeExist}}
|
|
<i class="book icon ui left"></i>
|
|
{{if .ReadmeInList}}
|
|
<strong>{{.FileName}}</strong>
|
|
{{else}}
|
|
<strong>{{.FileName}}</strong> <span class="text grey normal">{{FileSize .FileSize}}</span>
|
|
{{end}}
|
|
{{else}}
|
|
<i class="file text outline icon ui left"></i>
|
|
<strong>{{.FileName}}</strong> <span class="text grey normal">{{FileSize .FileSize}}</span>
|
|
{{end}}
|
|
{{if not .ReadmeInList}}
|
|
<div class="ui right">
|
|
<div class="ui small grey basic buttons">
|
|
{{if not .IsViewCommit}}
|
|
<a class="ui button" href="{{.RepoLink}}/src/{{.CommitID}}/{{EscapePound .TreeName}}">{{.i18n.Tr "repo.file_permalink"}}</a>
|
|
{{end}}
|
|
<a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}/{{EscapePound .TreeName}}">{{.i18n.Tr "repo.file_history"}}</a>
|
|
<a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</h4>
|
|
<div class="ui attached table segment">
|
|
<div class="file-view {{if .ReadmeExist}}markdown{{else if .IsFileText}}code-view{{end}} has-emoji">
|
|
{{if .ReadmeExist}}
|
|
{{if .FileContent}}{{.FileContent | Str2html}}{{end}}
|
|
{{else if not .IsFileText}}
|
|
<div class="view-raw ui center">
|
|
{{if .IsImageFile}}
|
|
<img src="{{EscapePound .FileLink}}">
|
|
{{else if .IsPDFFile}}
|
|
<iframe width="100%" height="600px" src="{{AppSubUrl}}/plugins/pdfjs-1.4.20/web/viewer.html?file={{EscapePound .FileLink}}"></iframe>
|
|
{{else}}
|
|
<a href="{{EscapePound .FileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
|
|
{{end}}
|
|
</div>
|
|
{{else if .FileSize}}
|
|
<table>
|
|
<tbody>
|
|
<tr>
|
|
{{if .IsFileTooLarge}}
|
|
<td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
|
|
{{else}}
|
|
<td class="lines-num">{{.LineNums}}</td>
|
|
<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
|
|
{{end}}
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|