diff --git a/blogs/templates/blogs/list.html b/blogs/templates/blogs/list.html index f87c81e..90ebd30 100644 --- a/blogs/templates/blogs/list.html +++ b/blogs/templates/blogs/list.html @@ -1,4 +1,48 @@ -{% for snipt in snipts %} - {{ snipt.title }}
- {{ snipt.code }}

-{% endfor %} +{% extends "blogs/base.html" %} + +{% load compress pagination_tags %} + +{% block js %} + {{ block.super }} + window.detail = false; +{% endblock %} + +{% block content %} +
+ {% autopaginate snipts 10 %} + {% for snipt in snipts %} + {% include "blogs/snipt-list.html" %} + {% empty %} +
+ {{ user.username }} has no public snipts. +
+ {% endfor %} + {% paginate %} +
+ + +{% endblock %} diff --git a/blogs/views.py b/blogs/views.py index 60f00ef..84e63b7 100644 --- a/blogs/views.py +++ b/blogs/views.py @@ -1 +1,33 @@ -# Create your views here. +from django.shortcuts import get_object_or_404, render_to_response +from django.contrib.auth.models import User +from django.template import RequestContext +from annoying.decorators import render_to + +from snipts.models import Snipt + + +@render_to('blogs/list.html') +def list_blog(request, subdomain): + + subdomain = subdomain.replace('-', '_') + user = get_object_or_404(User, username__iexact=subdomain) + snipts = Snipt.objects.filter(user=user, blog_post=True, public=True).order_by('-created') + + context = { + 'snipts': snipts, + 'user': user, + } + + if 'rss' in request.GET: + context['snipts'] = context['snipts'][:20] + return rss(request, context) + + return context + +def rss(request, context): + return render_to_response( + 'rss.xml', + context, + context_instance=RequestContext(request), + mimetype="application/rss+xml" + ) diff --git a/media/css/style.css b/media/css/style.css index de62ca6..e41e281 100644 --- a/media/css/style.css +++ b/media/css/style.css @@ -1262,3 +1262,21 @@ body.api div#disqus_thread { body.blog article.snipt section.code { height: auto; } + +body.blog-site header.blog div.inner { + border-left: 1px solid rgba(229, 229, 229, 0.25); + margin: 30px auto 0 auto; + width: 939px; +} +body.blog-site header.blog div.inner h1 { + color: #0094AF; + font: normal 34px "Helvetica Neue", Helvetica, Arial, "Liberation Sans", FreeSans, sans-serif; + margin-left: 15px; +} +body.blog-site header.blog div.inner h1 a { + color: #0094AF; +} +body.blog-site header.blog div.inner h1 a:hover { + color: #292929; + text-decoration: none; +} diff --git a/media/css/style.scss b/media/css/style.scss index ad542dd..fd42f03 100644 --- a/media/css/style.scss +++ b/media/css/style.scss @@ -1429,3 +1429,29 @@ body.blog { } } } + +// Blogs +body.blog-site { + header.blog { + div.inner { + border-left: 1px solid rgba(229, 229, 229, .25); + margin: 30px auto 0 auto; + width: 939px; + + h1 { + color: #0094AF; + font: normal 34px $Helvetica; + margin-left: 15px; + + a { + color: #0094AF; + + &:hover { + color: #292929; + text-decoration: none; + } + } + } + } + } +} diff --git a/snipts/templates/snipts/snipt-list.html b/snipts/templates/snipts/snipt-list.html index d1e133f..959204f 100644 --- a/snipts/templates/snipts/snipt-list.html +++ b/snipts/templates/snipts/snipt-list.html @@ -73,10 +73,12 @@