All tags
parent
3e167c5cfe
commit
aa2e26356b
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -495,6 +495,10 @@ section.main {
|
|||
color: #2B6E9B;
|
||||
}
|
||||
}
|
||||
a.all-tags {
|
||||
font-weight: bold;
|
||||
margin-left: 22px;
|
||||
}
|
||||
}
|
||||
nav.footer {
|
||||
margin: 0 15px 32px;
|
||||
|
@ -1513,7 +1517,6 @@ body.api {
|
|||
}
|
||||
aside.api-info {
|
||||
float: right;
|
||||
margin-top: 26px;
|
||||
width: 190px;
|
||||
|
||||
div.api-inner {
|
||||
|
@ -1556,6 +1559,7 @@ body.api {
|
|||
}
|
||||
aside.main {
|
||||
nav.footer {
|
||||
float: left;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
@ -1583,3 +1587,22 @@ body.pro {
|
|||
text-align: center;
|
||||
}
|
||||
}
|
||||
body.tags {
|
||||
div.alert {
|
||||
margin: 30px 30px 10px 30px;
|
||||
}
|
||||
div.static-box {
|
||||
margin-top: 10px;
|
||||
|
||||
ul {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
div.pagination {
|
||||
margin-bottom: 8px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
aside.main {
|
||||
padding-top: 30px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<aside class="api-info immediate-help">
|
||||
<div class="api-inner">
|
||||
<h5>Need immediate help?</h5>
|
||||
<p>Join our lead developer “nicksergeant” in <strong>#snipt</strong> on irc.freenode.net.</p>
|
||||
<p>Ping “nicksergeant” in <strong>#snipt</strong> on irc.freenode.net.</p>
|
||||
</div>
|
||||
</aside>
|
||||
{% endif %}
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<a href="/tags/" class="all-tags">View all tags »</a>
|
||||
</section>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "registration/registration_base.html" %}
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block page-title %}Snipt Pro{% endblock %}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load pagination_tags %}
|
||||
|
||||
{% block page-title %}All tags{% endblock %}
|
||||
|
||||
{% block body-class %}{{ block.super }} static tags{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
<li><a href="/tags/">All tags</a></li>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="alert alert-info">We're working on improving this section. Stay tuned!</div>
|
||||
<div class="static-box">
|
||||
<ul>
|
||||
{% autopaginate all_tags 100 %}
|
||||
{% for tag in all_tags %}
|
||||
<li><a href="/public/tag/{{ tag.slug }}/">{{ tag }} ({{ tag.count }})</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% paginate %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block tags %}
|
||||
{% include "snipts/tags-public.html" %}
|
||||
{% endblock %}
|
3
urls.py
3
urls.py
|
@ -2,7 +2,7 @@ from django.conf.urls.defaults import include, patterns, url
|
|||
from django.views.generic.simple import direct_to_template
|
||||
from registration.forms import RegistrationFormUniqueEmail
|
||||
from django.http import HttpResponseRedirect
|
||||
from views import lexers, sitemap
|
||||
from views import lexers, sitemap, tags
|
||||
from django.contrib import admin
|
||||
from snipts.views import search
|
||||
from tastypie.api import Api
|
||||
|
@ -35,6 +35,7 @@ urlpatterns = patterns('',
|
|||
url(r'^humans.txt$', direct_to_template, {'template': 'humans.txt'}),
|
||||
url(r'^sitemap.xml$', sitemap),
|
||||
url(r'^pro/$', direct_to_template, {'template': 'pro.html'}),
|
||||
url(r'^tags/$', tags),
|
||||
|
||||
url(r'^api/public/lexer/$', lexers),
|
||||
|
||||
|
|
39
views.py
39
views.py
|
@ -1,22 +1,11 @@
|
|||
from annoying.decorators import ajax_request, render_to
|
||||
from django.shortcuts import render_to_response
|
||||
from annoying.decorators import ajax_request
|
||||
from django.template import RequestContext
|
||||
from snipts.utils import get_lexers_list
|
||||
from django.db.models import Count
|
||||
from taggit.models import Tag
|
||||
|
||||
|
||||
def sitemap(request):
|
||||
|
||||
tags = Tag.objects.filter(snipt__public=True)
|
||||
tags = tags.annotate(count=Count('taggit_taggeditem_items__id'))
|
||||
tags = tags.order_by('-count')[:1000]
|
||||
|
||||
return render_to_response('sitemap.xml',
|
||||
{'tags': tags},
|
||||
context_instance=RequestContext(request),
|
||||
mimetype='application/xml')
|
||||
|
||||
@ajax_request
|
||||
def lexers(request):
|
||||
lexers = get_lexers_list()
|
||||
|
@ -42,3 +31,29 @@ def lexers(request):
|
|||
})
|
||||
|
||||
return {'objects': objects}
|
||||
def sitemap(request):
|
||||
|
||||
tags = Tag.objects.filter(snipt__public=True)
|
||||
tags = tags.annotate(count=Count('taggit_taggeditem_items__id'))
|
||||
tags = tags.order_by('-count')[:1000]
|
||||
|
||||
return render_to_response('sitemap.xml',
|
||||
{'tags': tags},
|
||||
context_instance=RequestContext(request),
|
||||
mimetype='application/xml')
|
||||
|
||||
@render_to('tags.html')
|
||||
def tags(request):
|
||||
|
||||
all_tags = Tag.objects.filter(snipt__public=True).order_by('name')
|
||||
all_tags = all_tags.annotate(count=Count('taggit_taggeditem_items__id'))
|
||||
|
||||
popular_tags = Tag.objects.filter(snipt__public=True)
|
||||
popular_tags = popular_tags.annotate(count=Count('taggit_taggeditem_items__id'))
|
||||
popular_tags = popular_tags.order_by('-count')[:20]
|
||||
popular_tags = sorted(popular_tags, key=lambda tag: tag.name)
|
||||
|
||||
return {
|
||||
'all_tags': all_tags,
|
||||
'tags': popular_tags
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue