diff options
author | luxagraf <sng@luxagraf.net> | 2015-03-09 12:08:30 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-03-09 12:08:30 -0400 |
commit | e8a3b0c7898eec7791ef97e550f950b1f0b75ba0 (patch) | |
tree | f565f363c9dd642f4234ff9b7f04e6510358fb17 /app/builder | |
parent | b8b640ae95b5feda4a2c6d873ae1ce9fda2b36ac (diff) |
added build function to backup posts as text files with yaml metadata
Diffstat (limited to 'app/builder')
-rw-r--r-- | app/builder/base.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/builder/base.py b/app/builder/base.py index a706261..6701cf1 100644 --- a/app/builder/base.py +++ b/app/builder/base.py @@ -302,3 +302,24 @@ class BuildMap(Build): }) t = render_to_string('archives/map.html', c).encode('utf-8') self.write_file('', t, "html",'map') + + +# Back up entries to markdown text files which are then stored in dropbox and git +class EntryBak(Build): + def get_model_querset(self): + model = get_model('blog', 'entry') + qs = model.objects.filter(status__exact=1) + return qs + + def write_file(self, path, text_object): + file = open(path, 'wb') + file.write(text_object) + file.close() + + def build_writing_bak(self): + qs = self.get_model_querset() + for obj in qs: + c = Context({'object': obj, 'MEDIA_URL': settings.BAKED_MEDIA_URL, 'IMAGES_URL': settings.BAKED_IMAGES_URL}) + path = "%szbak/posts/%s_%s.txt" %(settings.PROJ_ROOT, (obj.pub_date.strftime("%Y-%m-%d").lower()), obj.slug) + t = render_to_string('details/entry-bak.txt', c).encode('utf-8') + self.write_file(path, t) |