diff --git a/dynastie/generators/index.py b/dynastie/generators/index.py index 07bcecd..211897c 100755 --- a/dynastie/generators/index.py +++ b/dynastie/generators/index.py @@ -46,7 +46,9 @@ class Index(DynastieGenerator): 'navigation' : self.createNavigation, 'recents' : self.createRecents, 'tags' : self.createTags, - 'replace' : self.createReplace} + 'first_page_only' : self.createFirstPageOnly, + 'ljdc_last' : self.createLJDCLast, + } self.first_try = True @@ -133,6 +135,23 @@ class Index(DynastieGenerator): root.replaceChild(node, title_elem) + def createFirstPageOnly(self, posts, dom, root, node): + if self.cur_page == 0: + for n in node.childNodes: + root.insertBefore(n.cloneNode(True), node) + root.removeChild(node) + + def createLJDCLast(self, posts, dom, root, node): + from dynastie.generators.ljdc import LJDC + + l = LJDC() + img = l.getLast(dom, self.blog.src_path) + + if not img is None: + root.replaceChild(img, node) + else: + root.removeChild(node) + def createDate(self, posts, dom, root, date_elem): date_format = date_elem.getAttribute('format') if date_format == '': @@ -457,6 +476,8 @@ class Index(DynastieGenerator): def generate(self, blog, src, output): from dynastie.models import Post, Blog + self.blog = blog + dom = self.parseTemplate(blog, src, output, 'index') if dom is None: return self.report diff --git a/dynastie/generators/ljdc.py b/dynastie/generators/ljdc.py index 74bdaaa..db72c9f 100755 --- a/dynastie/generators/ljdc.py +++ b/dynastie/generators/ljdc.py @@ -42,7 +42,8 @@ class LJDC(Index): a.setAttribute('href', address.childNodes[0].nodeValue) title_value = self.cur_post_obj.getElementsByTagName('title')[0] - title = self.createElement(dom, 'title', title_value.childNodes[0].nodeValue) + title_value = title_value.childNodes[0].nodeValue + title = self.createElement(dom, 'title', title_value) a.appendChild(title) img_src = self.cur_post_obj.getElementsByTagName('img')[0] @@ -57,9 +58,7 @@ class LJDC(Index): return new_elem - def generate(self, blog, src, output): - from dynastie.models import Post, Blog, Category - + def _load_references(self, src): name = '_ljdc.xml' if not os.path.exists(src + '/%s' % name): self.addWarning('No %s found, exiting' % name) @@ -71,6 +70,13 @@ class LJDC(Index): self.addError('Error parsing %s : ' + e) return None + return srcdom + + def generate(self, blog, src, output): + srcdom = self._load_references(src) + + if srcdom is None: return None + posts = srcdom.getElementsByTagName("entry") dom = self.parseTemplate(blog, src, output, 'ljdc', 'ljdc') @@ -83,3 +89,18 @@ class LJDC(Index): return self.report + def getLast(self, dom, src): + srcdom = self._load_references(src) + if srcdom is None: return None + + images = srcdom.getElementsByTagName("img") + if len(images) == 0: return None + + img = dom.createElement('img') + img.setAttribute('src', images[0].childNodes[0].nodeValue) + + title = srcdom.getElementsByTagName("title")[0] + title = title.childNodes[0].nodeValue + img.setAttribute('alt', title.replace("\"", "'")) + + return img diff --git a/dynastie/sites/blog.soutade.fr/_generators b/dynastie/sites/blog.soutade.fr/_generators index 16985e9..e17ba29 100755 --- a/dynastie/sites/blog.soutade.fr/_generators +++ b/dynastie/sites/blog.soutade.fr/_generators @@ -1,5 +1,5 @@ -post index +post category tag archive diff --git a/dynastie/sites/blog.soutade.fr/_index.html b/dynastie/sites/blog.soutade.fr/_index.html index 3c8ad3e..1d2f4e7 100755 --- a/dynastie/sites/blog.soutade.fr/_index.html +++ b/dynastie/sites/blog.soutade.fr/_index.html @@ -17,6 +17,12 @@ + +
+ Dernier gif les joies du code + +
+