blob: 75dbd0d82c862dcdcaa33d98d71c8b5b82f0ecea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import os
from django.template.loader import render_to_string
from django.template import Context
from django.urls import reverse
from django.conf import settings
from builder.base import BuildNew
class BuildPages(BuildNew):
def build(self):
self.build_detail_view()
print("building pages")
def build_detail_view(self):
'''
Grab all the blog posts, render them to a template
string and write that out to the filesystem
'''
for entry in self.get_model_queryset():
url = entry.get_absolute_url()
path, slug = os.path.split(entry.get_absolute_url())
path = '%s/' % path
# write html
response = self.client.get(url)
if slug == 'homepage':
slug = 'index'
self.write_file(path, response.content, filename=slug)
# write txt
response = self.client.get('%s.txt' % url)
self.write_file(path, response.content, ext='txt', filename=slug)
def get_model_queryset(self):
return self.model.objects.filter(build=True)
def builder():
j = BuildPages("pages", "Page")
j.build()
|