diff options
author | luxagraf <sng@luxagraf.net> | 2015-10-31 21:25:03 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-10-31 21:25:03 -0400 |
commit | c6a87562e6bd9b745dceb09b8c0b076137f46ba6 (patch) | |
tree | 9275dd80c4f34569a9a8d4619519eba88ad58a22 | |
parent | 0d26984b8f8ba1d51e58367e1b2ce42a062c1e85 (diff) |
added rss feed for src
-rw-r--r-- | app/src/TODO | 2 | ||||
-rw-r--r-- | app/src/build.py | 9 | ||||
-rw-r--r-- | app/src/models.py | 13 | ||||
-rw-r--r-- | design/templates/feed.xml | 4 | ||||
-rw-r--r-- | design/templates/src_base.html | 4 |
5 files changed, 25 insertions, 7 deletions
diff --git a/app/src/TODO b/app/src/TODO index c6c7591..6fa16fa 100644 --- a/app/src/TODO +++ b/app/src/TODO @@ -1,5 +1,3 @@ add book detail page. redirect home book and rss -create separate rss for src -fix list formatting diff --git a/app/src/build.py b/app/src/build.py index ac77d0b..a60f80c 100644 --- a/app/src/build.py +++ b/app/src/build.py @@ -7,7 +7,7 @@ class BuildSrc(Build): self.build_archive() self.build_topic_archive() self.build_detail_pages() - + self.build_feed() def build_detail_pages(self): ''' @@ -42,3 +42,10 @@ class BuildSrc(Build): }) t = render_to_string('archives/src_home.html', c).encode('utf-8') self.write_file(path, t, 'html', topic.slug) + + def build_feed(self): + qs = Entry.objects.filter(status__exact=1) + c = Context({'object_list': qs, 'SITE_URL': settings.SITE_URL}) + t = render_to_string('feed.xml', c).encode('utf-8') + fpath = '%s' % ('/src/rss/',) + self.write_file(fpath, t, 'xml') diff --git a/app/src/models.py b/app/src/models.py index 6b5f476..ea70d86 100644 --- a/app/src/models.py +++ b/app/src/models.py @@ -1,5 +1,6 @@ from django.db import models from django.contrib.sitemaps import Sitemap +from django.contrib.syndication.views import Feed from blog.models import image_url_replace, extract_images import markdown import datetime @@ -103,6 +104,18 @@ class Book(models.Model): def get_absolute_url(self): return "/src/books/%s" % (self.slug) + +class LatestFull(Feed): + title = "luxagraf:src Code and Technology" + link = "/src/" + description = "Latest postings to luxagraf.net/src" + description_template = 'feeds/blog_description.html' + + def items(self): + return Entry.objects.filter(status__exact=1).order_by('-pub_date')[:10] + + + from itertools import chain class SrcSitemap(Sitemap): diff --git a/design/templates/feed.xml b/design/templates/feed.xml index d170cd3..44bf670 100644 --- a/design/templates/feed.xml +++ b/design/templates/feed.xml @@ -11,8 +11,8 @@ <lastBuildDate>{% now "D, d M Y H:i:00" %} GMT</lastBuildDate> <docs>http://cyber.law.harvard.edu/rss/rss.html</docs> <generator>IPpub v2.0</generator> - <managingEditor>contact@luxagraf.net</managingEditor> - <webMaster>contact@luxagraf.net</webMaster>{% for object in object_list %} + <managingEditor>sng@luxagraf.net</managingEditor> + <webMaster>sng@luxagraf.net</webMaster>{% for object in object_list %} <item> <title>{{object.title|escape}}</title> <link>{{SITE_URL}}{{object.get_absolute_url}}</link> diff --git a/design/templates/src_base.html b/design/templates/src_base.html index e7ee096..83ea7c2 100644 --- a/design/templates/src_base.html +++ b/design/templates/src_base.html @@ -13,8 +13,8 @@ <![endif]--> <link rel="alternate" type="application/rss+xml" - title="Luxagraf RSS feed" - href="https://luxagraf.net/rss/"> + title="Luxagraf:src RSS feed" + href="https://luxagraf.net/src/rss/"> {%block stylesheet%}<link rel="stylesheet" href="/media/screenv8.css" media="screen">{%endblock%} |