changeset 314:1ddd18ad5e76

import: Wordpress importer puts drafts in a `draft` folder. Ignore other statuses.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 27 Mar 2015 20:46:36 -0700
parents 9188b362069e
children d1490028e211
files piecrust/importing/wordpress.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/importing/wordpress.py	Fri Mar 27 20:05:13 2015 -0700
+++ b/piecrust/importing/wordpress.py	Fri Mar 27 20:46:36 2015 -0700
@@ -127,8 +127,16 @@
         if excerpt is not None and excerpt.strip() != '':
             text = "%s\n\n---excerpt---\n\n%s" % (content, excerpt)
 
-        path = source.resolveRef(rel_path)
-        create_page(self.app, path, metadata, text)
+        status = metadata.get('status')
+        if status == 'publish':
+            path = source.resolveRef(rel_path)
+            create_page(self.app, path, metadata, text)
+        elif status == 'draft':
+            filename = '-'.join(metadata['title'].split(' ')) + '.html'
+            path = os.path.join(self.app.root_dir, 'drafts', filename)
+            create_page(self.app, path, metadata, text)
+        else:
+            logger.warning("Ignoring post with status: %s" % status)
 
 
 class _XmlImporter(_ImporterBase):