diff options
-rw-r--r-- | app/src/build.py | 23 | ||||
-rw-r--r-- | app/src/urls.py | 1 | ||||
-rw-r--r-- | app/src/views.py | 9 | ||||
-rw-r--r-- | design/sass/_src.scss | 20 | ||||
-rw-r--r-- | design/templates/archives/src_home.html | 8 |
5 files changed, 47 insertions, 14 deletions
diff --git a/app/src/build.py b/app/src/build.py index 46cfd79..3abd8ff 100644 --- a/app/src/build.py +++ b/app/src/build.py @@ -1,23 +1,19 @@ from builder.base import * -from django.apps import apps +from .models import Topic, Entry class BuildSrc(Build): def build(self): self.build_archive() + self.build_topic_archive() self.build_detail_pages() - def queryset(self): - return self.get_model().objects.filter(status__exact=1).order_by('-pub_date') - - def get_model(self): - return apps.get_model('src', 'Entry') def build_detail_pages(self): ''' Grab all the notes, render them to a template string and write that out to the filesystem ''' - for entry in self.queryset(): + for entry in Entry.objects.filter(status__exact=1): c = Context({'object': entry, 'MEDIA_URL': settings.BAKED_MEDIA_URL, 'IMAGES_URL': settings.BAKED_IMAGES_URL, 'SITE_URL':settings.SITE_URL}) t = render_to_string('details/src_entry.html', c).encode('utf-8') path = 'src/' @@ -28,10 +24,21 @@ class BuildSrc(Build): def build_archive(self): path = 'src/' c = Context({ - 'object_list': self.queryset(), + 'object_list': Entry.objects.filter(status__exact=1), 'MEDIA_URL': settings.BAKED_MEDIA_URL, 'IMAGES_URL': settings.BAKED_IMAGES_URL }) t = render_to_string('archives/src_home.html', c).encode('utf-8') self.write_file(path, t) + def build_topic_archive(self): + for topic in Topic.objects.all(): + path = 'src/%s' % topic.slug + c = Context({ + 'object_list': Entry.objects.filter(topic__slug=topic.slug), + 'topic': topic, + 'MEDIA_URL': settings.BAKED_MEDIA_URL, + 'IMAGES_URL': settings.BAKED_IMAGES_URL + }) + t = render_to_string('archives/src_home.html', c).encode('utf-8') + self.write_file(path, t) diff --git a/app/src/urls.py b/app/src/urls.py index c9e8077..a2368e3 100644 --- a/app/src/urls.py +++ b/app/src/urls.py @@ -4,6 +4,7 @@ from django.views.generic import ListView from .models import Entry, Book urlpatterns = patterns('', + (r'topic/(?P<slug>[-\w]+)/$', 'src.views.topic'), (r'books/$', ListView.as_view( queryset=Book.objects.filter(status__exact=1).order_by('-pub_date'), template_name="archives/src_books.html", diff --git a/app/src/views.py b/app/src/views.py index f3803b9..ceba079 100644 --- a/app/src/views.py +++ b/app/src/views.py @@ -1,6 +1,13 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext -from .models import Entry +from .models import Entry, Topic + + +def topic(request, slug): + obj = get_object_or_404(Topic, slug__exact=slug) + qs = Entry.objects.filter(topics__slug=slug).order_by('-pub_date') + return render_to_response('archives/src_home.html', {'object_list': qs, 'topic':obj}, context_instance=RequestContext(request)) + def detail(request, slug): obj = get_object_or_404(Entry, slug__exact=slug) diff --git a/design/sass/_src.scss b/design/sass/_src.scss index 4d75b9b..003e457 100644 --- a/design/sass/_src.scss +++ b/design/sass/_src.scss @@ -1,10 +1,18 @@ .src-archive { - text-align: left; + .topic-hed { + @include fontsize(20); + @include constrain_narrow; + margin-top: 1.5em; + margin-bottom: 1.5em; + @include breakpoint(beta) { + @include fontsize(28); + margin-top: 1em; + } + } article { margin-bottom: 3em; p { color: lighten($body_font, 15); - font-size: 99%; } } h2 { @@ -15,8 +23,16 @@ margin-bottom: .25em; a { color: $body_font; + color: lighten($body_font, 15); } } + p { + text-align: left; + } + + @include breakpoint(beta) { + text-align: left; + } } .src-topics { @include smcaps; diff --git a/design/templates/archives/src_home.html b/design/templates/archives/src_home.html index 3ef6c15..9f373a3 100644 --- a/design/templates/archives/src_home.html +++ b/design/templates/archives/src_home.html @@ -6,11 +6,13 @@ {% block metadescription %}luxagraf:src - thoughts on code, the web, servers, tools and things that might be useful to a couple of people somewhere in the future.{% endblock %} {% block primary %}<ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> - <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li> - <li><code>src</code></li> + <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li>{% if topic %} + <li><a href="/src/" title="luxagraf:src homepage" itemprop="url"><span itemprop="title"><code>src</code></span></a> → </li> + <li>{{topic}}</li>{%else%} + <li><code>src</code></li>{%endif%} </ul> <main role="main" id="src-archive" class="src-archive"> - <h1 class="hide">Luxagraf:src</h1>{% for object in object_list %}{% if object.slug != 'about' %} + <h1 class="topic-hed"><code>src:</code> {% if topic %}Articles about {{topic.pluralized_name}}{%else%}Archive{%endif%}</h1>{% for object in object_list %}{% if object.slug != 'about' %} <article class="h-entry hentry {% cycle 'odd' 'even' %} {% cycle 'first' 'second' 'third' %}" itemscope itemType="http://schema.org/Article"> <h2><a href="{{object.get_absolute_url}}">{{object.title|safe|smartypants|widont}}</a></h2> <p>{{object.meta_description|safe|smartypants|widont}} <a href="{{object.get_absolute_url}}">Read ⇢</a></p> |