From 32dc8e5928092c55522ea4126e751473e97b2de5 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 23 Apr 2013 06:03:21 +0200 Subject: [PATCH 1/4] Use protocol-relative url for jQuery. Fixes #15. HTTP urls are blocked in modern browsers when accessing the page over HTTPS (https://dpaste.de/), so jQuery wasn't being loaded and the rest of the javascript failed on various ReferenceError and TypeError exceptions around "$ is undefined". --- dpaste/templates/dpaste/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpaste/templates/dpaste/base.html b/dpaste/templates/dpaste/base.html index c85fd74..0c328ae 100644 --- a/dpaste/templates/dpaste/base.html +++ b/dpaste/templates/dpaste/base.html @@ -28,7 +28,7 @@ {% block script_footer %} - + - {% endif %} - + diff --git a/dpaste/templates/dpaste/snippet_list.html b/dpaste/templates/dpaste/snippet_list.html index f36c061..21f33c1 100644 --- a/dpaste/templates/dpaste/snippet_list.html +++ b/dpaste/templates/dpaste/snippet_list.html @@ -13,7 +13,7 @@ {% include "dpaste/snippet_pre.html" %} - {% if not forloop.last %}
{% endif %} + {% if not forloop.last %}
{% endif %} {% empty %}

{% trans "No snippets saved. Either all your snippets are expired or your cookie has changed." %}

{% endfor %} From b6ac14cd1a45cb951c6b9ec74abba3a92d243e5a Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 23 Apr 2013 06:28:49 +0200 Subject: [PATCH 3/4] Readme: Promote dpaste.de instead of www.dpaste.de This doesn't fix #16, but I figured I could at least make it consistent within the code. A grep count tells me dpaste.de is used everywhere except here. (www.)dpaste.org is not mentioned anywhere. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfe4115..5ff869b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ dpaste dpaste is a Django based pastebin. It's intended to run separatly or installed 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 From fee4bd1354e814da58b04d7ac79dcb1656cb6781 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 23 Apr 2013 06:57:57 +0200 Subject: [PATCH 4/4] Update and enhance javascript code * Use shorthand notation for `$(document).ready`. This isn't just shorter but also slightly faster as it uses a cached instance or $(document) instead of re-instantiating jQuery. * Use .prop('checked') instead of .attr('checked'). Form fields reflect live state in properties, attributes are only used when parsing the HTML to set the initial values of the DOM properties. In the past (upto jQuery 1.6) jQuery would cover you by secretly calling .prop() for common mistakes but this has been deprecated and removed. * Use .toggleClass instead of `if hasClass/addClass/removeClass`. * Cancel previous AJAX request before starting another one. This fixes the bug where using the "Guess lexer" or "Diff" button twice in a row can sometimes result in the second push being ignored. Since the requests are asynchronous, one can arrive before or after the other and the callback called in a different order. It also saves a bit on the network I guess. * DiffAjax: Moved location.hash assignment to before the request. It is asynchronous anyway, so the assignment happened before the request already. But now it is more obvious that this is the case. * Simplified various selectors to just an ID instead of element with ID. IDs are unique. If you have more than one of them with a different element, there's something wrong. I suppose in a way it also saves potential maintenance in the future if a minor detail changes (e.g. from
to

). * Removed weird variable conflict that was incorrectly copy-pasted in 1f863b345f896353. `var a;` when `a` already exists does nothing. It doesn't clear or reset it. It just weird syntax that should throw an error but is instead silently ignored. And `curLine` is already set and continues to be there. --- dpaste/templates/dpaste/base.html | 32 +++++++----- dpaste/templates/dpaste/snippet_details.html | 53 +++++++++++--------- 2 files changed, 48 insertions(+), 37 deletions(-) diff --git a/dpaste/templates/dpaste/base.html b/dpaste/templates/dpaste/base.html index ec22962..f6b8a62 100644 --- a/dpaste/templates/dpaste/base.html +++ b/dpaste/templates/dpaste/base.html @@ -31,20 +31,26 @@