Now that there is no admin anymore I need a quick way to check the total snippet count, to see if something goes wrong or I'm DOSed.

This commit is contained in:
Martin Mahner 2013-03-22 19:33:11 +01:00
parent cad4589b0a
commit 368c8101ce
3 changed files with 52 additions and 21 deletions

View file

@ -1,10 +1,13 @@
{% extends "dpaste/base.html" %}
{% load i18n %}
{% block title %}About dpaste.de{% endblock %}
{% block headline %}About dpaste.de{% endblock %}
{% block dpaste_nav_about %}active{% endblock %}
{% block page %}
<h3>API</h3>
{# Just put the script in dpaste and copy the source node #}
@ -16,30 +19,43 @@
<p>Or you could use <code>curl</code>:
<code>alias dpaste="curl -F 'content=&lt;-' http://dpaste.de/api/"</code></p>
<hr>
<h3>Applications using the API:</h3>
<div class="row-fluid">
<div class="span5">
<h3>Applications using the API:</h3>
<ul>
<ul>
<li><a href="https://github.com/bartTC/dpasteGUI/wiki">dpasteGUI</a>, a OS X interface</li>
<li><a href="https://github.com/bartTC/SubDpaste">a dpaste Sublime 2 plugin</a></li>
<li><a href="http://marmalade-repo.org/packages/dpaste_de">Marmalade</a>, a Emacs plugin</li>
</ul>
</ul>
</div>
<div class="span4">
<p>{% blocktrans %}There are {{ total }} snippets in the database. The most popular languages are:{% endblocktrans %}</p>
<table class="table">
{% for s in stats %}
<tr>
<th>{{ s.lexer|upper }}</th>
<td>{{ s.count }}</th>
</tr>
{% endfor %}
</table>
</div>
<div class="span3">
<h3>Imprint</h3>
<hr/>
<h3>Imprint</h3>
<p><strong>Address:</strong></p>
<p>
<p><strong>Address:</strong></p>
<p>
Martin Mahner<br/>
Lauterbacher Str. 4<br/>
DE-18581 Putbus<br/>
Germany
</p>
</p>
<p><strong>Jabber/E-Mail:</strong></p>
<p><a href="mailto:martin@mahner.org">martin@mahner.org</a></p>
<p><strong>Jabber/E-Mail:</strong></p>
<p><a href="mailto:martin@mahner.org">martin@mahner.org</a></p>
</div>
</div>
{% endblock %}

View file

@ -3,7 +3,7 @@ from django.views.generic import TemplateView
urlpatterns = patterns(
'',
url(r'^about/$', TemplateView.as_view(template_name='dpaste/about.html'), name='about'),
url(r'^about/$', 'dpaste.views.about', name='about'),
url(r'^', include('dpaste.urls.dpaste_api')),
url(r'^', include('dpaste.urls.dpaste')),
)

View file

@ -7,6 +7,7 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.utils import simplejson
from django.db.models import Count
from django.views.defaults import page_not_found as django_page_not_found, \
server_error as django_server_error
@ -17,6 +18,19 @@ from dpaste.highlight import guess_code_lexer, \
import difflib
def about(request, template_name='dpaste/about.html'):
template_context = {
'total': Snippet.objects.count(),
'stats': Snippet.objects.values('lexer').annotate(
count=Count('lexer')).order_by('-count')[:5],
}
return render_to_response(
template_name,
template_context,
RequestContext(request)
)
def snippet_new(request, template_name='dpaste/snippet_new.html'):
if request.method == "POST":
@ -169,6 +183,7 @@ def guess_lexer(request):
return HttpResponse(response)
def page_not_found(request, template_name='dpaste/404.html'):
return django_page_not_found(request, template_name)