summaryrefslogtreecommitdiffstats
path: root/templates/repo/view_file.tmpl
blob: 5e519354b7dda5f135384e5cedc96df65359a0f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<div class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content">
	<h4 class="file-header ui top attached header">
		<div class="file-header-left">
			{{if .ReadmeInList}}
				{{if .FileIsSymlink}}
					<i class="icons"><i class="book icon"></i><i class="bottom left corner tiny inverted share icon"></i></i>
				{{else}}
					<i class="book icon"></i>
				{{end}}
				<strong>{{.FileName}}</strong>
			{{else}}
				<div class="file-info text grey normal mono">
					{{if .FileIsSymlink}}
						<div class="file-info-entry">
							{{.i18n.Tr "repo.symbolic_link"}}
						</div>
					{{end}}
					{{if .NumLinesSet}}
						<div class="file-info-entry">
							{{.NumLines}} {{.i18n.Tr (TrN .i18n.Lang .NumLines "repo.line" "repo.lines") }}
						</div>
					{{end}}
					{{if .FileSize}}
						<div class="file-info-entry">
							{{FileSize .FileSize}}{{if .IsLFSFile}} ({{.i18n.Tr "repo.stored_lfs"}}){{end}}
						</div>
					{{end}}
					{{if .LFSLock}}
						<div class="file-info-entry">
							<i class="fa fa-lock poping up disabled" data-content="{{.LFSLockHint}}" data-position="bottom center" data-variation="tiny inverted"></i>
							<a href="{{AppSubUrl}}/{{.LFSLock.Owner.Name}}">{{.LFSLockOwner}}</a>
						</div>
					{{end}}
				</div>
			{{end}}
		</div>
		{{if not .ReadmeInList}}
		<div class="file-header-right">
			<div class="ui right file-actions">
				<div class="ui buttons">
					<a class="ui button" href="{{EscapePound $.RawFileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
					{{if not .IsViewCommit}}
						<a class="ui button" href="{{.RepoLink}}/src/commit/{{.CommitID}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_permalink"}}</a>
					{{end}}
					{{if .IsTextFile}}
						<a class="ui button" href="{{.RepoLink}}/blame/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.blame"}}</a>
					{{end}}
					<a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a>
				</div>
				{{if .Repository.CanEnableEditor}}
					{{if .CanEditFile}}
						<a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><span class="btn-octicon poping up"  data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span></a>
					{{else}}
						<span class="btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span>
					{{end}}
					{{if .CanDeleteFile}}
						<a href="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><span class="btn-octicon btn-octicon-danger poping up"  data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-trashcan" 16}}</span></a>
					{{else}}
						<span class="btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-trashcan" 16}}</span>
					{{end}}
				{{end}}
			</div>
		</div>
		{{end}}
	</h4>
	<div class="ui attached table unstackable segment">
		<div class="file-view {{if .IsMarkup}}{{.MarkupType}} markdown{{else if .IsRenderedHTML}}plain-text{{else if .IsTextFile}}code-view{{end}}">
			{{if .IsMarkup}}
				{{if .FileContent}}{{.FileContent | Safe}}{{end}}
			{{else if .IsRenderedHTML}}
				<pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
			{{else if not .IsTextFile}}
				<div class="view-raw ui center">
					{{if .IsImageFile}}
						<img src="{{EscapePound $.RawFileLink}}">
					{{else if .IsVideoFile}}
						<video controls src="{{EscapePound $.RawFileLink}}">
							<strong>{{.i18n.Tr "repo.video_not_supported_in_browser"}}</strong>
						</video>
					{{else if .IsAudioFile}}
						<audio controls src="{{EscapePound $.RawFileLink}}">
							<strong>{{.i18n.Tr "repo.audio_not_supported_in_browser"}}</strong>
						</audio>
					{{else if .IsPDFFile}}
						<iframe width="100%" height="600px" src="{{StaticUrlPrefix}}/vendor/plugins/pdfjs/web/viewer.html?file={{EscapePound $.RawFileLink}}"></iframe>
					{{else}}
						<a href="{{EscapePound $.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
					{{end}}
				</div>
			{{else if .FileSize}}
				{{if .IsFileTooLarge}}
				<table>
					<tbody>
						<tr>
							<td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
						</tr>
					</tbody>
				</table>
				{{else}}
				<table>
					<tbody>
						{{range $line, $code := .FileContent}}
						<tr>
							<td id="L{{$line}}" class="lines-num">
								<span id="L{{$line}}" data-line-number="{{$line}}"></span>
							</td>
							<td rel="L{{$line}}" class="lines-code chroma">
								<pre><code>{{$code | Safe}}</code></pre>
							</td>
						</tr>
						{{end}}
					</tbody>
				</table>
				{{end}}
			{{end}}
		</div>
	</div>
</div>

<script>
function submitDeleteForm() {
    var message = prompt("{{.i18n.Tr "repo.delete_confirm_message"}}\n\n{{.i18n.Tr "repo.delete_commit_summary"}}", "Delete '{{.TreeName}}'");
    if (message != null) {
        $("#delete-message").val(message);
        $("#delete-file-form").submit()
    }
}
</script>