Link for blog posts. Closes #44
parent
ed48e50d6b
commit
f5ccc64cd9
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -544,7 +544,7 @@ section.main {
|
|||
border-bottom: 1px solid #5AB6F4;
|
||||
}
|
||||
}
|
||||
a.favorited-snipts {
|
||||
a.alt-link {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
margin: 0 0 10px 22px;
|
||||
|
@ -552,6 +552,9 @@ section.main {
|
|||
&.active {
|
||||
color: #2B6E9B;
|
||||
}
|
||||
&.favorites {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
nav.footer {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
{% include "snipts/snipt-list.html" %}
|
||||
{% empty %}
|
||||
<div class="empty-snipts">
|
||||
{{ user.username }} has no public snipts.
|
||||
No snipts to show here. Sorry!
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% paginate %}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<section class="tags">
|
||||
{% if request.user == user %}
|
||||
<a href="/{{ user }}/favorites/" class="favorited-snipts {% if 'favorites' in request.path %}active{% endif %}"><span>View favorited snipts »</span></a>
|
||||
<a href="/{{ user }}/favorites/" class="alt-link favorites {% if 'favorites' in request.path %}active{% endif %}"><span>View favorited snipts »</span></a>
|
||||
{% endif %}
|
||||
<a href="/{{ user }}/blog-posts/" class="alt-link {% if 'blog-posts' in request.path %}active{% endif %}"><span>View blog posts »</span></a>
|
||||
{% if tags %}
|
||||
<h1>{{ user.username }}'s tags</h1>
|
||||
<ul>
|
||||
|
|
|
@ -12,5 +12,6 @@ urlpatterns = patterns('',
|
|||
url(r'^(?P<username_or_custom_slug>[^/]+)/$', views.list_user, name='list-user'),
|
||||
url(r'^(?P<username_or_custom_slug>[^/]+)/tag/(?P<tag_slug>[^/]+)/$', views.list_user, name='list-user-tag'),
|
||||
url(r'^(?P<username>[^/]+)/favorites/$', views.favorites, name='favorites'),
|
||||
url(r'^(?P<username>[^/]+)/blog-posts/$', views.blog_posts, name='blog-posts'),
|
||||
url(r'^(?P<username>[^/]+)/(?P<snipt_slug>[^/]+)/$', views.detail, name='detail'),
|
||||
)
|
||||
|
|
|
@ -79,6 +79,43 @@ def embed(request, snipt_key):
|
|||
context_instance=RequestContext(request),
|
||||
mimetype='application/javascript')
|
||||
|
||||
@render_to('snipts/list-user.html')
|
||||
def blog_posts(request, username):
|
||||
|
||||
if request.blog_user:
|
||||
raise Http404
|
||||
|
||||
if request.user.username == username:
|
||||
public = False
|
||||
public_user = False
|
||||
user = request.user
|
||||
snipts = Snipt.objects.filter(user=request.user, blog_post=True)
|
||||
tags = Tag.objects.filter(snipt__user=request.user).distinct()
|
||||
else:
|
||||
public = True
|
||||
public_user = True
|
||||
user = User.objects.get(username=username)
|
||||
snipts = Snipt.objects.filter(blog_post=True, user=user, public=True)
|
||||
tags = Tag.objects.filter(snipt__user=user, snipt__public=True).distinct()
|
||||
|
||||
tags = tags.order_by('name')
|
||||
snipts = snipts.order_by('-created')
|
||||
|
||||
context = {
|
||||
'has_snipts': True,
|
||||
'public': public,
|
||||
'public_user': public_user,
|
||||
'snipts': snipts,
|
||||
'tags': tags,
|
||||
'user': user,
|
||||
}
|
||||
|
||||
if 'rss' in request.GET:
|
||||
context['snipts'] = context['snipts'][:20]
|
||||
return rss(request, context)
|
||||
|
||||
return context
|
||||
|
||||
@render_to('snipts/list-user.html')
|
||||
def favorites(request, username):
|
||||
|
||||
|
|
Loading…
Reference in New Issue