mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 08:02:54 +11:00
Clean up: Drop redundant attributes, minor JS clean up, gitignore
* Dropped redundant `type` attribute from script elements (some had them removed already). * Dropped redundant `media` attribute from link elements. * <div> is not a valid self-closing tag. * Dropped redundant / in self-closing tags in <hr/>, <br/>, <input/>. Just like was done for <img> and <link> already). * Aliasing $ to jQuery (local reference is cheaper and using jQuery as global seems more stable, bootstrap.js does this too). * Unminified it a bit (nothing extreme, just more consistent other code here already). * Consistently used single quotes in the js code (most code used singled quotes already). * Quoting attribute selectors $('input[name="foo"]'). Unquoted selectors have been deprecated. * Ignore .pyc files (so they don't show up in `git status`, and aren't accidentally committed with `git add`).
This commit is contained in:
parent
32dc8e5928
commit
b2265b1af8
7 changed files with 38 additions and 35 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
|
*.pyc
|
||||||
dpaste/settings_local.py
|
dpaste/settings_local.py
|
||||||
dpaste.egg-info
|
dpaste.egg-info
|
||||||
|
|
|
@ -47,16 +47,16 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="clearfix"/>
|
<div class="clearfix"></div>
|
||||||
<hr class="clearfix"/>
|
<hr class="clearfix">
|
||||||
|
|
||||||
<h3>Imprint</h3>
|
<h3>Imprint</h3>
|
||||||
|
|
||||||
<p><strong>Address:</strong></p>
|
<p><strong>Address:</strong></p>
|
||||||
<p>
|
<p>
|
||||||
Martin Mahner<br/>
|
Martin Mahner<br>
|
||||||
Lauterbacher Str. 4<br/>
|
Lauterbacher Str. 4<br>
|
||||||
DE-18581 Putbus<br/>
|
DE-18581 Putbus<br>
|
||||||
Germany
|
Germany
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>dpaste.de: {% block title %}{% trans "New snippet" %}{% endblock %}</title>
|
<title>dpaste.de: {% block title %}{% trans "New snippet" %}{% endblock %}</title>
|
||||||
<link href="{% static "dpaste/bootstrap/css/bootstrap.min.css" %}" rel="stylesheet" media="screen">
|
<link rel="stylesheet" href="{% static "dpaste/bootstrap/css/bootstrap.min.css" %}">
|
||||||
<link href="{% static "dpaste/theme.css" %}" rel="stylesheet" media="screen">
|
<link rel="stylesheet" href="{% static "dpaste/theme.css" %}">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
{% block extrahead %}{% endblock %}
|
{% block extrahead %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
@ -30,15 +30,17 @@
|
||||||
{% block script_footer %}
|
{% block script_footer %}
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
|
||||||
<script src="{% static "dpaste/bootstrap/js/bootstrap.min.js" %}"></script>
|
<script src="{% static "dpaste/bootstrap/js/bootstrap.min.js" %}"></script>
|
||||||
<script type="text/javascript">
|
<script>
|
||||||
$(document).ready(function(){
|
jQuery(document).ready(function($) {
|
||||||
$('#guess_lexer_btn').click(function(){
|
$('#guess_lexer_btn').click(function() {
|
||||||
$.getJSON('{% url "snippet_guess_lexer" %}',
|
$.getJSON('{% url "snippet_guess_lexer" %}',
|
||||||
{'codestring': $('#id_content').val()},
|
{
|
||||||
function(data){
|
codestring: $('#id_content').val()
|
||||||
if(data.lexer == "unknown"){
|
},
|
||||||
|
function(data) {
|
||||||
|
if (data.lexer === 'unknown') {
|
||||||
$('#guess_lexer_btn').css('color', 'red');
|
$('#guess_lexer_btn').css('color', 'red');
|
||||||
}else{
|
} else {
|
||||||
$('#id_lexer').val(data.lexer);
|
$('#id_lexer').val(data.lexer);
|
||||||
$('#guess_lexer_btn').css('color', 'inherit');
|
$('#guess_lexer_btn').css('color', 'inherit');
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
|
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
|
||||||
<div>
|
<div>
|
||||||
<span class="diff">
|
<span class="diff">
|
||||||
<input type="radio" name="a" value="{{ tree_item.id }}" {% ifequal tree_item.id snippet.parent_id %}checked="checked"{% endifequal %}/>
|
<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 %}/>
|
<input type="radio" name="b" value="{{ tree_item.id }}" {% ifequal snippet tree_item %}checked="checked"{% endifequal %}>
|
||||||
</span>
|
</span>
|
||||||
{% ifequal snippet tree_item %}
|
{% ifequal snippet tree_item %}
|
||||||
<strong>#{{ tree_item.id }}</strong>
|
<strong>#{{ tree_item.id }}</strong>
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
|
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="submit">
|
<div class="submit">
|
||||||
<input type="submit" value="{% trans "Compare" %}"/>
|
<input type="submit" value="{% trans "Compare" %}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<!-- ======================================================================
|
<!-- ======================================================================
|
||||||
Snippet Reply
|
Snippet Reply
|
||||||
======================================================================= -->
|
======================================================================= -->
|
||||||
<hr/>
|
<hr>
|
||||||
|
|
||||||
<div class="snippet-reply snippet-reply-hidden">
|
<div class="snippet-reply snippet-reply-hidden">
|
||||||
<h3>{% trans "Reply to this snippet" %} →</h3>
|
<h3>{% trans "Reply to this snippet" %} →</h3>
|
||||||
|
@ -77,8 +77,8 @@
|
||||||
|
|
||||||
{% block script_footer %}
|
{% block script_footer %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script type="text/javascript">
|
<script>
|
||||||
$(document).ready(function(){
|
jQuery(document).ready(function($){
|
||||||
$('.snippet-reply-hidden').click(function(e){
|
$('.snippet-reply-hidden').click(function(e){
|
||||||
$(this).removeClass('snippet-reply-hidden');
|
$(this).removeClass('snippet-reply-hidden');
|
||||||
});
|
});
|
||||||
|
@ -93,10 +93,10 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$("form#diffform").submit(function() {
|
$('form#diffform').submit(function() {
|
||||||
var a = $("input[name=a]:checked").val(),
|
var a = $('input[name="a"]:checked').val(),
|
||||||
b = $("input[name=b]:checked").val(),
|
b = $('input[name="b"]:checked').val(),
|
||||||
hash = 'D'+a+','+b;
|
hash = 'D' + a + ',' + b;
|
||||||
$.get("{% url "snippet_diff" %}", {
|
$.get("{% url "snippet_diff" %}", {
|
||||||
a: a,
|
a: a,
|
||||||
b: b
|
b: b
|
||||||
|
@ -110,26 +110,26 @@ $(document).ready(function(){
|
||||||
var curLine = document.location.hash,
|
var curLine = document.location.hash,
|
||||||
hashlist;
|
hashlist;
|
||||||
|
|
||||||
if(curLine.substring(0,2) == '#D'){
|
if (curLine.substring(0, 2) === '#D'){
|
||||||
hashlist = curLine.substring(2).split(',');
|
hashlist = curLine.substring(2).split(',');
|
||||||
if (hashlist.length == 2) {
|
if (hashlist.length == 2) {
|
||||||
console.log(hashlist);
|
console.log(hashlist);
|
||||||
$('form#diffform input[name=a][value='+hashlist[0]+']').attr('checked', true);
|
$('form#diffform input[name="a"][value="'+hashlist[0]+'"]').attr('checked', true);
|
||||||
$('form#diffform input[name=b][value='+hashlist[1]+']').attr('checked', true);
|
$('form#diffform input[name="b"][value="'+hashlist[1]+'"]').attr('checked', true);
|
||||||
$('#snippet-diff').slideDown('fast');
|
$('#snippet-diff').slideDown('fast');
|
||||||
$('#snippet-diff form').submit();
|
$('#snippet-diff form').submit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Line Highlighting
|
* Line Highlighting
|
||||||
*/
|
*/
|
||||||
var curLine = document.location.hash,
|
var curLine = document.location.hash,
|
||||||
hashlist;
|
hashlist;
|
||||||
|
|
||||||
if(curLine.substring(0,2) == '#L'){
|
if (curLine.substring(0, 2) == '#L'){
|
||||||
hashlist = curLine.substring(2).split(',');
|
hashlist = curLine.substring(2).split(',');
|
||||||
if (hashlist.length > 0 && hashlist[0] !== "") {
|
if (hashlist.length > 0 && hashlist[0] !== '') {
|
||||||
$.each(hashlist, function(index, elem){
|
$.each(hashlist, function(index, elem){
|
||||||
$('.linenums li#' + elem).addClass('marked');
|
$('.linenums li#' + elem).addClass('marked');
|
||||||
});
|
});
|
||||||
|
@ -147,7 +147,7 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.linenums li.marked').each(function (index, elem) {
|
$('.linenums li.marked').each(function (index, elem) {
|
||||||
if (hash !== "L") hash += ',';
|
if (hash !== 'L') hash += ',';
|
||||||
hash += $(elem).attr('id');
|
hash += $(elem).attr('id');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,6 @@
|
||||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}"/>
|
<input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
{% include "dpaste/snippet_pre.html" %}
|
{% include "dpaste/snippet_pre.html" %}
|
||||||
{% if not forloop.last %}<hr/>{% endif %}
|
{% if not forloop.last %}<hr>{% endif %}
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<p>{% trans "No snippets saved. Either all your snippets are expired or your cookie has changed." %}</p>
|
<p>{% trans "No snippets saved. Either all your snippets are expired or your cookie has changed." %}</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue