aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-05-01 22:32:46 -0400
committerbnewbold <bnewbold@robocracy.org>2016-05-01 22:32:46 -0400
commitca7d2d294c095a72de8111bc162cb561d123ca43 (patch)
tree08dbbf9f8128e3180dc88db68b12728be479fe02
parentbfff944dfaa0692b5f69e3312964842b50e30f67 (diff)
downloadbnewnet-ca7d2d294c095a72de8111bc162cb561d123ca43.tar.gz
bnewnet-ca7d2d294c095a72de8111bc162cb561d123ca43.zip
add django-to-file dump script
-rw-r--r--bn_django/dump_to_pelican.py41
1 files changed, 41 insertions, 0 deletions
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("<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()
+