Update post/_createPost to not simply append post content, but replace dyn:post node

This commit is contained in:
Gregory Soutade 2020-04-06 10:31:28 +02:00
parent 10347ec588
commit 1805967833
2 changed files with 6 additions and 8 deletions

View File

@ -261,12 +261,11 @@ class DynastieGenerator:
return root return root
blockname = block.getAttribute('name') blockname = block.getAttribute('name')
for target_block in target_blocks: for target_block in target_blocks:
if blockname != target_block.getAttribute('name'): if blockname != target_block.getAttribute('name'):
continue continue
for child in target_block.childNodes: for child in target_block.childNodes:
block.parentNode.insertBefore(child.cloneNode(True),block) block.parentNode.insertBefore(child.cloneNode(True), block)
block_found = True block_found = True
break break
block.parentNode.removeChild(block) block.parentNode.removeChild(block)

View File

@ -146,15 +146,14 @@ class Post(Index):
self.replaceByText(dom, root, node, value) self.replaceByText(dom, root, node, value)
return None return None
def _createPost(self, post, dom, post_elem, root): def _createPost(self, post, dom, root, node):
self.cur_post_obj = post self.cur_post_obj = post
posts = [post] posts = [post]
self.createPost(posts, dom, post_elem, root) post_elem = self.createElement(dom, 'post')
post_elem = self.createPost(posts, dom, post_elem, node)
# Post are appended by index. Remove template # Post are appended by index. Remove template
post_nodes = dom.getElementsByTagNameNS(self.URI, 'post') root.replaceChild(post_elem, node)
post_elem = post_nodes[0]
post_elem.parentNode.removeChild(post_elem)
title_nodes = dom.getElementsByTagName('title') title_nodes = dom.getElementsByTagName('title')
@ -164,7 +163,7 @@ class Post(Index):
node.removeChild(node.childNodes[0]) node.removeChild(node.childNodes[0])
node.appendChild(dom.createTextNode(post.title)) node.appendChild(dom.createTextNode(post.title))
return node return post_elem
def _generate(self, blog, src, output, posts): def _generate(self, blog, src, output, posts):
from dynastie.search import Search from dynastie.search import Search