diff options
-rw-r--r-- | app/blog/build.py | 11 | ||||
-rw-r--r-- | app/blog/models.py | 4 | ||||
-rw-r--r-- | app/blog/views.py | 2 | ||||
-rw-r--r-- | app/builder/base.py | 17 | ||||
-rw-r--r-- | app/builder/views.py | 22 | ||||
-rw-r--r-- | app/links/build.py | 10 | ||||
-rw-r--r-- | app/links/views.py | 3 | ||||
-rw-r--r-- | config/base_urls.py | 11 | ||||
-rw-r--r-- | design/templates/admin/buttons.html | 6 | ||||
-rw-r--r-- | design/templates/base.html | 2 | ||||
-rw-r--r-- | design/templates/blog/entry_detail.txt | 8 | ||||
-rw-r--r-- | design/templates/feed.xml | 26 |
12 files changed, 104 insertions, 18 deletions
diff --git a/app/blog/build.py b/app/blog/build.py index 392e991..10553a6 100644 --- a/app/blog/build.py +++ b/app/blog/build.py @@ -16,7 +16,16 @@ class BuildEssays(BuildNew): response = self.client.get('/essays/') self.write_file('essays/', response.content) + def build_homepage(self): + response = self.client.get('/') + self.write_file('', response.content) + def essaybuilder(): - j = BuildEssays("essays", "essay") + j = BuildEssays("blog", "Entry") j.build() + + +def homebuilder(): + j = BuildEssays("blog", "Entry") + j.build_homepage() diff --git a/app/blog/models.py b/app/blog/models.py index 61ac407..ee4aca0 100644 --- a/app/blog/models.py +++ b/app/blog/models.py @@ -57,13 +57,13 @@ class Entry(models.Model): super(Entry, self).save() -class GuideSitemap(Sitemap): +class BlogSitemap(Sitemap): changefreq = "never" priority = 1.0 protocol = "https" def items(self): - return Essay.objects.filter(status=1) + return Entry.objects.filter(status=1) def lastmod(self, obj): return obj.pub_date diff --git a/app/blog/views.py b/app/blog/views.py index cf0fdf6..224decb 100644 --- a/app/blog/views.py +++ b/app/blog/views.py @@ -23,7 +23,7 @@ class EntryDetailView(DetailView): class EntryDetailViewTXT(EntryDetailView): - template_name = "entry_detail.txt" + template_name = "blog/entry_detail.txt" class EntryYearArchiveView(YearArchiveView): diff --git a/app/builder/base.py b/app/builder/base.py index 0d2cb0f..839c522 100644 --- a/app/builder/base.py +++ b/app/builder/base.py @@ -1,4 +1,6 @@ import os +from operator import attrgetter +from itertools import chain from math import ceil from decimal import Decimal from django.test.client import Client @@ -150,3 +152,18 @@ class BuildPages(BuildNew): fpath = '%s' %(page.slug) self.write_file('', t, 'html', page.slug) self.write_file('', t, 'txt', page.slug) + + +class BuildRSS(BuildNew): + def build(self): + entry_list = apps.get_model('blog', 'entry').objects.filter(status=1) + link_list = apps.get_model('links', 'link').objects.filter(status=1) + result_list = sorted( + chain(entry_list, link_list), + key=attrgetter('pub_date') + ) + qs = reversed(result_list) + c = {'object_list': qs, 'SITE_URL': settings.SITE_URL} + t = render_to_string('feed.xml', c).encode('utf-8') + fpath = '%s' % ('rss/',) + self.write_file(fpath, t, 'xml') diff --git a/app/builder/views.py b/app/builder/views.py index 9d12aaa..3c63b00 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -1,13 +1,31 @@ from django.shortcuts import render_to_response -from django.template import RequestContext -#from src.build import builder as src_builder from pages.build import builder as page_builder +from builder.base import BuildSitemap, BuildRSS +from blog.build import essaybuilder, homebuilder +from links.build import linkbuilder def do_build(request): section = request.GET.get('id', '') context = {} + if section == 'essays': + context = {'message': 'Writing Essays to Disk'} + essaybuilder() + if section == 'links': + context = {'message': 'Writing Links to Disk'} + linkbuilder() if section == 'pages': context = {'message': 'Writing Pages to Disk'} page_builder() + if section == 'home': + context = {'message': 'Writing Homepage to Disk'} + homebuilder() + if section == 'sitemap': + context = {'message': 'Writing Sitemap to Disk'} + j = BuildSitemap("blog", "Entry") + j.build() + if section == 'rss': + context = {'message': 'Writing RSS feed to Disk'} + j = BuildRSS("blog", "Entry") + j.build() return render_to_response('admin/message.html', context) diff --git a/app/links/build.py b/app/links/build.py index 392e991..cc57884 100644 --- a/app/links/build.py +++ b/app/links/build.py @@ -4,7 +4,7 @@ from django.urls import reverse from . import models -class BuildEssays(BuildNew): +class BuildLinks(BuildNew): def build(self): self.build_list_view() @@ -13,10 +13,10 @@ class BuildEssays(BuildNew): #self.build_feed("src:feed") def build_list_view(self): - response = self.client.get('/essays/') - self.write_file('essays/', response.content) + response = self.client.get('/linked/') + self.write_file('linked/', response.content) -def essaybuilder(): - j = BuildEssays("essays", "essay") +def linkbuilder(): + j = BuildLinks("links", "link") j.build() diff --git a/app/links/views.py b/app/links/views.py index 64cc5f7..6d03d19 100644 --- a/app/links/views.py +++ b/app/links/views.py @@ -20,8 +20,7 @@ class EntryDetailView(DetailView): class EntryDetailViewTXT(EntryDetailView): - template_name = "entry_detail.txt" - + template_name = "blog/entry_detail.txt" class EntryYearArchiveView(YearArchiveView): diff --git a/config/base_urls.py b/config/base_urls.py index cbc9517..e55cd33 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -5,11 +5,20 @@ from django.conf import settings from django.contrib.sitemaps.views import sitemap from pages.views import PageDetailView +from pages.models import PageSitemap from blog.views import HomePageView +from blog.models import BlogSitemap +from links.models import LinkedSitemap #import builder.views import utils.views import builder.views +sitemaps = { + 'blog': BlogSitemap, + 'links': LinkedSitemap, + 'pages': PageSitemap, +} + admin.autodiscover() @@ -18,7 +27,7 @@ urlpatterns = [ path(r'admin/data/', include('utils.urls')), path(r'admin/', admin.site.urls), #path(r'luximages/insert/', utils.views.insert_image), - #path(r'sitemap.xml', sitemap, {'sitemaps': sitemaps}), + path(r'sitemap.xml', sitemap, {'sitemaps': sitemaps}), path(r'essays/', include('blog.urls')), path(r'linked/', include('links.urls')), path(r'<slug>', PageDetailView.as_view()), diff --git a/design/templates/admin/buttons.html b/design/templates/admin/buttons.html index d9d3171..7c6a115 100644 --- a/design/templates/admin/buttons.html +++ b/design/templates/admin/buttons.html @@ -39,9 +39,9 @@ {%endif%} <div class="grp-module"> <ul class="grp-listing-small cust"> - <li class="item"><a href="/admin/build/build?id=builddetails">Build Writing Details</a></li> - <li class="item"><a href="/admin/build/build?id=writingarchives">Build Writing Archives</a></li> - <li class="item"><a href="/admin/build/build?id=homepage">Build Homepage</a></li> + <li class="item"><a href="/admin/build/build?id=essays">Build Essays</a></li> + <li class="item"><a href="/admin/build/build?id=links">Build links</a></li> + <li class="item"><a href="/admin/build/build?id=home">Build Homepage</a></li> <li class="item"><a href="/admin/build/build?id=sitemap">Build Sitemap</a></li> <li class="item"><a href="/admin/build/build?id=buildrss">Build RSS</a></li> <li class="item"><a href="/admin/build/build?id=pages">Build All Pages</a></li> diff --git a/design/templates/base.html b/design/templates/base.html index 9be4f51..7e48bc5 100644 --- a/design/templates/base.html +++ b/design/templates/base.html @@ -42,7 +42,7 @@ <footer> <ul class="nav-menu footer-nav-menu"> <li><a href="/contact" title="How to get in touch regarding Libregraf">Contact</a></li> - <li><a href="/rss" title="RSS feed">RSS</a></li> + <li><a href="/rss/index.xml" title="RSS feed">RSS</a></li> <li><a href="" title="Libregraf on twitter">Twitter</a></li> </ul> <p class="hed-tertiary"> diff --git a/design/templates/blog/entry_detail.txt b/design/templates/blog/entry_detail.txt new file mode 100644 index 0000000..547ce79 --- /dev/null +++ b/design/templates/blog/entry_detail.txt @@ -0,0 +1,8 @@ +{{object.title|safe}} +{% for letter in object.title %}={%endfor%} + + by Scott Gilbertson + <{{SITE_URL}}{{object.get_absolute_url}}> + {{object.pub_date|date:"l, d F Y"}} + +{{object.body_markdown|safe}} diff --git a/design/templates/feed.xml b/design/templates/feed.xml new file mode 100644 index 0000000..7745976 --- /dev/null +++ b/design/templates/feed.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- RSS generated by luxpub v2.0 on {% now "D, d M Y H:i:00" %} GMT --> +<rss version="2.0"> + <channel> + <title>Libregraf</title> + <link>https://libregraf.net/</link> + <description>Latest posts on libregraf.net</description> + <language>en-us</language> + <copyright>Copyright 2011-{% now "Y" %} Libregraf</copyright> + <pubDate>{% now "D, d M Y H:i:00" %} GMT</pubDate> + <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>comments@libregraf.net</managingEditor> + <webMaster>comments@libregraf.net</webMaster>{% for object in object_list %} + <item> + <title>{{object.title|escape}}</title> + <link>{{SITE_URL}}{{object.get_absolute_url}}</link> + <guid>{{SITE_URL}}{{object.get_absolute_url}}</guid> + <description> + {{object.body_html|escape}} + </description> + <pubDate>{{object.pub_date|date:'D, d M Y H:i:00'}} EST</pubDate> + </item>{% endfor %} + </channel> +</rss> |