summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/blog/build.py11
-rw-r--r--app/blog/models.py4
-rw-r--r--app/blog/views.py2
-rw-r--r--app/builder/base.py17
-rw-r--r--app/builder/views.py22
-rw-r--r--app/links/build.py10
-rw-r--r--app/links/views.py3
7 files changed, 56 insertions, 13 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):