aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django/dump_to_pelican.py
blob: bc2be289e751a7eeb144e3aa9feb05246cfde6db (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
40
41

import os
from journal.models import *
from django.contrib.flatpages.models import *

def save_page(p):
    if p.id == 15: return
    url = p.url.decode('utf-8')
    f = open("flat_page_dump/" + url.strip("/").replace("/", "_") + ".html", 'w')
    f.write("Title: " + p.title + "\n")
    f.write("Url: " + url + "\n")
    f.write("SaveAs: " +  url + "index.html\n")
    f.write("Date: " + str(p.date))
    f.write("\n")
    f.write("\n")
    f.write(p.content.decode('utf-8'))
    f.close()

os.system("mkdir flat_page_dump")

for page in FlatPage.objects.all():
    save_page(page)

def save_links():
    f = open("link_dump.html", 'w')
    f.write("<ul>\n")
    for l in LinkArtifact.objects.all():
        f.write("<li><b><a href=\"%s\">%s</a></b> (%s): %s</li>\n" % (
            l.url, l.title, str(l.date), l.html_caption))
    f.write("</ul>\n")
    f.close()

def save_micro():
    f = open("micro_dump.html", 'w')
    f.write("<ul>\n")
    for m in MicroEntry.objects.all():
        f.write("<li><b>%s</b>: %s\n" % (
            str(m.date), m.html_content))
    f.write("</ul>\n")
    f.close()