diff --git a/dynastie/generators/post.py b/dynastie/generators/post.py index 761dede..c3ea1d4 100755 --- a/dynastie/generators/post.py +++ b/dynastie/generators/post.py @@ -184,17 +184,26 @@ class Post(Index): impl = xml.dom.getDOMImplementation() for post in posts: - if not post.published: continue - #print 'Generate ' + filename - dom_ = impl.createDocument('', 'xml', None) - dom_.replaceChild(dom.firstChild.cloneNode(True), dom_.firstChild) - nodes = self.parse(src, self.hooks, post, dom_, dom_.firstChild) - filename = output + '/post/' filename = filename + post.creation_date.strftime("%Y") + '/' + post.creation_date.strftime("%m") + '/' if not os.path.exists(filename): os.makedirs(filename) filename = filename + post.title_slug + '.html' + + if not post.published: + if os.path.exists(filename): + from dynastie.search import * + os.unlink(filename) + os.unlink(filename + '.gz') + self.addReport('Remove ' + filename) + s = Search() + s.delete_post(blog, post.id) + continue + #print 'Generate ' + filename + dom_ = impl.createDocument('', 'xml', None) + dom_.replaceChild(dom.firstChild.cloneNode(True), dom_.firstChild) + nodes = self.parse(src, self.hooks, post, dom_, dom_.firstChild) + self.writeIfNotTheSame(filename, nodes) if not self.somethingWrote: