snippet_details.html
6.82 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
{% extends "dpaste/base.html" %}
{% load mptt_tags %}
{% load i18n %}
{% load dpaste_tags %}
{% block page %}
{# Snippet options #}
<div id="snippet-diff" class="row">
<div class="col-md-10">
<div id="diff" style="display:none;"></div>
</div>
<div id="snippet-diff-form" class="col-md-2">
<form method="get" id="diffform" action="{% url "snippet_diff" %}">
{% csrf_token %}
<div class="form-group tree">
{% for tree_item,structure in tree|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
<div>
<span class="pull-right">
<input type="radio" name="a" value="{{ tree_item.id }}" {% ifequal tree_item.id snippet.parent_id %}checked="checked"{% endifequal %}>
<input type="radio" name="b" value="{{ tree_item.id }}" {% ifequal snippet tree_item %}checked="checked"{% endifequal %}>
</span>
{% ifequal snippet tree_item %}
<strong>#{{ tree_item.id }}</strong>
{% else %}
<a href="{{ tree_item.get_absolute_url }}">#{{ tree_item.id }}</a>
{% endifequal %}
</div>
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
{% endfor %}
</div>
<div class="form-group pull-right">
<button type="submit" class="btn btn-default">{% trans "Compare" %}</button>
</div>
</form>
</div>
</div>
<div class="btn-group btn-group-sm snippet-options">
<a href="#" class="btn btn-default disabled">
{% if snippet.expire_type == 1 %}
{% blocktrans with date=snippet.expires|timeuntil %}Expires in: {{ date }}{% endblocktrans %}
{% elif snippet.expire_type == 2 %}
{% trans "Snippet never expires" %}
{% elif snippet.expire_type == 3 %}
{% trans "One-time snippet" %}
{% endif %}
</a>
{% if snippet.pk|in_list:request.session.snippet_list %}
<a href="{% url "snippet_delete" snippet.secret_id %}" class="btn btn-default" onclick="return confirm('{% trans "Really delete this snippet?" %}');">
<span class="glyphicon glyphicon-trash"></span>
{% trans "Delete Now" %}
</a>
{% endif %}
{% if not snippet.is_single %}
<a href="#snippet-diff" class="btn btn-default snippet-diff-trigger" title="{% trans "Compare Snippets" %}">
<span class="glyphicon glyphicon-search"></span>
{% trans "Compare Snippets" %}
</a>
{% endif %}
<a href="{% url "snippet_details_raw" snippet.secret_id %}" class="btn btn-default" title="{% trans "View Raw" %}">
<span class="glyphicon glyphicon-align-left"></span>
{% trans "View Raw" %}
</a>
<a href="{% url "snippet_gist" snippet.secret_id %}" class="btn btn-default" rel="nofollow" title="Create a secret Gist">
<span class="glyphicon glyphicon-share"></span>
</i> {% trans "Gist" %}
</a>
<a href="/pastebin" class="btn btn-primary">
New snippet
<span class="glyphicon glyphicon-arrow-right"></span>
</a>
</div>
{% if snippet.expire_type == 3 %}
<div class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{% trans "This is a one-time snippet." %}
{% if snippet.remaining_views > 1 %}
{% trans "It will automatically get deleted after {{ remaining }} further views." %}
{% elif snippet.remaining_views == 1 %}
{% trans "It will automatically get deleted after the next view." %}
{% else %}
{% trans "It cannot be viewed again." %}
{% endif %}
</div>
{% endif %}
{% if snippet.lexer == 'text' %}
<div class="snippet-rendered">
{{ snippet.content|linebreaksbr }}
</div>
{% else %}
{% include "dpaste/snippet_pre.html" %}
{% endif %}
{% if not snippet.expire_type == 3 %}
<div class="snippet-reply snippet-reply-hidden">
<h3>{% trans "Reply to this snippet" %} →</h3>
{% include "dpaste/snippet_form.html" %}
</div>
{% endif %}
{% block footer_js %}
<script>
$(document).ready(function() {
$('.snippet-reply-hidden').click(function(e) {
$(this).removeClass('snippet-reply-hidden');
});
var diffReq;
$('.snippet-diff-trigger').click(function(event) {
$('#snippet-diff form').submit();
$('#snippet-diff').show();
event.preventDefault();
});
$('#diffform').submit(function() {
var a = $('input[name="a"]:checked').val(),
b = $('input[name="b"]:checked').val();
window.location.hash = 'D' + a + ',' + b;
// Cancel previous request if it is still pending
if (diffReq) {
diffReq.abort();
}
diffReq = $.get("{% url "snippet_diff" %}", {
a: a,
b: b
}).done(function(data) {
$('#diff').html(data).slideDown('fast');
}).complete(function() {
diffReq = null;
});
return false;
});
var curLine = document.location.hash,
hashlist;
if (curLine.substring(0, 2) === '#D') {
hashlist = curLine.substring(2).split(',');
if (hashlist.length === 2) {
console.log(hashlist);
$('#diffform input[name="a"][value="' + hashlist[0] + '"]').prop('checked', true);
$('#diffform input[name="b"][value="' + hashlist[1] + '"]').prop('checked', true);
$('#snippet-diff form').submit();
$('#snippet-diff').show();
}
}
/* ------------------------------------------------------------------------
Line Highlighting
------------------------------------------------------------------------ */
if (curLine.substring(0, 2) === '#L') {
hashlist = curLine.substring(2).split(',');
if (hashlist.length > 0 && hashlist[0] !== '') {
$.each(hashlist, function(index, elem){
$('.code li#' + elem).addClass('marked');
});
}
}
$('.code li').click(function(event) {
var hash = 'L';
$(this).toggleClass("marked");
$('.code li.marked').each(function (index, elem) {
if (hash !== 'L') hash += ',';
hash += $(elem).attr('id');
});
window.location.hash = hash;
e.preventDefault();
});
/* ------------------------------------------------------------------------
Line Highlighting
------------------------------------------------------------------------ */
$('#toggleWordwrap').click(function(e){
e.preventDefault();
$('.code').toggleClass('wordwrap');
});
});
</script>
{% endblock %}
{% endblock %}