From ca7d2d294c095a72de8111bc162cb561d123ca43 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 1 May 2016 22:32:46 -0400 Subject: add django-to-file dump script --- bn_django/dump_to_pelican.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 bn_django/dump_to_pelican.py diff --git a/bn_django/dump_to_pelican.py b/bn_django/dump_to_pelican.py new file mode 100644 index 0000000..bc2be28 --- /dev/null +++ b/bn_django/dump_to_pelican.py @@ -0,0 +1,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("\n") + f.close() + +def save_micro(): + f = open("micro_dump.html", 'w') + f.write("\n") + f.close() + -- cgit v1.2.3