Merge pull request #17 from Krinkle/cleanup

Merge Krinkle's cleanup branch
This commit is contained in:
Martin Mahner 2013-04-27 23:47:46 -07:00
commit 9df90ad73c
7 changed files with 73 additions and 59 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*.pyc
dpaste/settings_local.py dpaste/settings_local.py
dpaste.egg-info dpaste.egg-info

View file

@ -5,7 +5,7 @@ dpaste
dpaste is a Django based pastebin. It's intended to run separatly or installed dpaste is a Django based pastebin. It's intended to run separatly or installed
into an existing Django project. into an existing Django project.
You can find a live example on http://www.dpaste.de/ You can find a live example on http://dpaste.de/
Testing Testing
@ -16,5 +16,5 @@ Testing
``` ```
$ pip install -r requirements.txt $ pip install -r requirements.txt
$ pip install -e . $ pip install -e .
$ manage.py test dpaste $ manage.py test dpaste
``` ```

View file

@ -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>

View file

@ -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>
@ -28,21 +28,29 @@
{% block script_footer %} {% block script_footer %}
<script src="http://code.jquery.com/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(function($) {
$('#guess_lexer_btn').click(function(){ var lexerReq;
$.getJSON('{% url "snippet_guess_lexer" %}', $('#guess_lexer_btn').click(function() {
{'codestring': $('#id_content').val()}, // Cancel previous request if it is still pending
function(data){ if (lexerReq) {
if(data.lexer == "unknown"){ lexerReq.abort();
$('#guess_lexer_btn').css('color', 'red'); }
}else{
$('#id_lexer').val(data.lexer); lexerReq = $.getJSON('{% url "snippet_guess_lexer" %}', {
$('#guess_lexer_btn').css('color', 'inherit'); codestring: $('#id_content').val()
} }).done(function(data) {
}); if (data.lexer === 'unknown') {
$('#guess_lexer_btn').css('color', 'red');
} else {
$('#id_lexer').val(data.lexer);
$('#guess_lexer_btn').css('color', 'inherit');
}
}).complete(function() {
lexerReq = null;
});
}); });
$('.autofocus input:text, .autofocus textarea').first().focus(); $('.autofocus input:text, .autofocus textarea').first().focus();

View file

@ -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" %} &rarr;</h3> <h3>{% trans "Reply to this snippet" %} &rarr;</h3>
@ -77,77 +77,82 @@
{% block script_footer %} {% block script_footer %}
{{ block.super }} {{ block.super }}
<script type="text/javascript"> <script>
$(document).ready(function(){ jQuery(function($) {
$('.snippet-reply-hidden').click(function(e){ var diffReq;
$('.snippet-reply-hidden').click(function(e) {
$(this).removeClass('snippet-reply-hidden'); $(this).removeClass('snippet-reply-hidden');
}); });
/** /**
* Diff Ajax Call * Diff Ajax Call
*/ */
$('.snippet-diff-trigger').click(function(e){ $('.snippet-diff-trigger').click(function(e) {
e.preventDefault(); e.preventDefault();
$('#snippet-diff').slideDown('fast'); $('#snippet-diff').slideDown('fast');
$('#snippet-diff form').submit(); $('#snippet-diff form').submit();
}); });
$("form#diffform").submit(function() { $('#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;
$.get("{% url "snippet_diff" %}", { 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, a: a,
b: b b: b
}, function(data){ }).done(function(data) {
$('#diff').html(data).slideDown('fast'); $('#diff').html(data).slideDown('fast');
}).complete(function() {
diffReq = null;
}); });
window.location.hash = hash;
return false; return false;
}); });
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); $('#diffform input[name="a"][value="' + hashlist[0] + '"]').prop('checked', true);
$('form#diffform input[name=b][value='+hashlist[1]+']').attr('checked', true); $('#diffform input[name="b"][value="' + hashlist[1] + '"]').prop('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,
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');
}); });
} }
} }
$('.linenums li').click(function(e){ $('.linenums li').click(function(e) {
var line = $(this), var line = $(this),
hash = 'L'; hash = 'L';
if (line.hasClass('marked')) { line.toggleClass('marked');
line.removeClass('marked');
} else {
line.addClass('marked');
}
$('.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');
}); });

View file

@ -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>

View file

@ -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 %}