aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/view_file.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'templates/repo/view_file.tmpl')
-rw-r--r--templates/repo/view_file.tmpl34
1 files changed, 29 insertions, 5 deletions
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl
index 76175334d2..0321dbd09b 100644
--- a/templates/repo/view_file.tmpl
+++ b/templates/repo/view_file.tmpl
@@ -12,20 +12,34 @@
<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">
+ <div class="ui right file-actions">
+ <div class="ui 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>
+ {{if .FileEditLink}}
+ <a href="{{EscapePound $.FileEditLink}}"><i class="poping up octicon octicon-pencil btn-octicon" data-content="{{.FileEditLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
+ {{else}}
+ <i class="octicon btn-octicon octicon-pencil poping up disabled" data-content="{{.FileEditLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
+ {{end}}
+ {{if .FileDeleteLink}}
+ <form id="delete-file-form" class="ui form inline-form" action="{{EscapePound $.FileDeleteLink}}" method="post">
+ {{.CsrfTokenHtml}}
+ <button onclick="submitDeleteForm()" class="octicon octicon-trashcan btn-octicon btn-octicon-danger poping up" type="button" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></button>
+ <input type="hidden" id="delete-message" name="commit_message" value="">
+ </form>
+ {{else}}
+ <i class="octicon btn-octicon octicon-trashcan poping up disabled" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
+ {{end}}
</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}}
+ <div class="file-view {{if .IsMarkdown}}markdown{{else if .IsFileText}}code-view{{end}} has-emoji">
+ {{if .IsMarkdown}}
{{if .FileContent}}{{.FileContent | Str2html}}{{end}}
{{else if not .IsFileText}}
<div class="view-raw ui center">
@@ -34,7 +48,7 @@
{{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>
+ <a href="{{EscapePound $.FileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
{{end}}
</div>
{{else if .FileSize}}
@@ -54,3 +68,13 @@
</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>