summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/pages/models.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/pages/models.py b/app/pages/models.py
index 0256508..278ec80 100644
--- a/app/pages/models.py
+++ b/app/pages/models.py
@@ -33,3 +33,35 @@ class PageSitemap(Sitemap):
def items(self):
return Page.objects.all()
+
+
+
+'''
+ function to parse through text files, read them into the database and then based on yaml either add them to site map or skip them. Then I make a button to call that function via the admin and shell script to just run it locally if I don't want to bother with that.
+ basically:
+
+metayaml, body_markdown = open(filename).read().split('\n---')
+metadata = yaml.loads(metayaml)
+metadata.title
+metadata.slug
+metadata.meta_description
+metadata.include_in_sitemap
+metadata.template
+'''
+
+from os import walk
+import yaml
+
+class PageFile():
+
+ def get_files(self, path):
+ for (dirpath, dirnames, filenames) in walk(path):
+ for f in filenames:
+ self.read(f)
+
+ def read(self, filename):
+ with open(filename, "r", encoding="utf-8") as f:
+ contents = f.read()
+ metayaml, body_markdown = contents.split('\n---')
+ metadata = yaml.loads(metayaml)
+ print(metadata)