Add dyn:first_page_only
Add dyn:ljdc_last
This commit is contained in:
parent
a747417ad2
commit
0741709259
|
@ -46,7 +46,9 @@ class Index(DynastieGenerator):
|
||||||
'navigation' : self.createNavigation,
|
'navigation' : self.createNavigation,
|
||||||
'recents' : self.createRecents,
|
'recents' : self.createRecents,
|
||||||
'tags' : self.createTags,
|
'tags' : self.createTags,
|
||||||
'replace' : self.createReplace}
|
'first_page_only' : self.createFirstPageOnly,
|
||||||
|
'ljdc_last' : self.createLJDCLast,
|
||||||
|
}
|
||||||
|
|
||||||
self.first_try = True
|
self.first_try = True
|
||||||
|
|
||||||
|
@ -133,6 +135,23 @@ class Index(DynastieGenerator):
|
||||||
|
|
||||||
root.replaceChild(node, title_elem)
|
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):
|
def createDate(self, posts, dom, root, date_elem):
|
||||||
date_format = date_elem.getAttribute('format')
|
date_format = date_elem.getAttribute('format')
|
||||||
if date_format == '':
|
if date_format == '':
|
||||||
|
@ -457,6 +476,8 @@ class Index(DynastieGenerator):
|
||||||
def generate(self, blog, src, output):
|
def generate(self, blog, src, output):
|
||||||
from dynastie.models import Post, Blog
|
from dynastie.models import Post, Blog
|
||||||
|
|
||||||
|
self.blog = blog
|
||||||
|
|
||||||
dom = self.parseTemplate(blog, src, output, 'index')
|
dom = self.parseTemplate(blog, src, output, 'index')
|
||||||
if dom is None: return self.report
|
if dom is None: return self.report
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,8 @@ class LJDC(Index):
|
||||||
a.setAttribute('href', address.childNodes[0].nodeValue)
|
a.setAttribute('href', address.childNodes[0].nodeValue)
|
||||||
|
|
||||||
title_value = self.cur_post_obj.getElementsByTagName('title')[0]
|
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)
|
a.appendChild(title)
|
||||||
|
|
||||||
img_src = self.cur_post_obj.getElementsByTagName('img')[0]
|
img_src = self.cur_post_obj.getElementsByTagName('img')[0]
|
||||||
|
@ -57,9 +58,7 @@ class LJDC(Index):
|
||||||
|
|
||||||
return new_elem
|
return new_elem
|
||||||
|
|
||||||
def generate(self, blog, src, output):
|
def _load_references(self, src):
|
||||||
from dynastie.models import Post, Blog, Category
|
|
||||||
|
|
||||||
name = '_ljdc.xml'
|
name = '_ljdc.xml'
|
||||||
if not os.path.exists(src + '/%s' % name):
|
if not os.path.exists(src + '/%s' % name):
|
||||||
self.addWarning('No %s found, exiting' % name)
|
self.addWarning('No %s found, exiting' % name)
|
||||||
|
@ -71,6 +70,13 @@ class LJDC(Index):
|
||||||
self.addError('Error parsing %s : ' + e)
|
self.addError('Error parsing %s : ' + e)
|
||||||
return None
|
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")
|
posts = srcdom.getElementsByTagName("entry")
|
||||||
|
|
||||||
dom = self.parseTemplate(blog, src, output, 'ljdc', 'ljdc')
|
dom = self.parseTemplate(blog, src, output, 'ljdc', 'ljdc')
|
||||||
|
@ -83,3 +89,18 @@ class LJDC(Index):
|
||||||
|
|
||||||
return self.report
|
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
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
post
|
|
||||||
index
|
index
|
||||||
|
post
|
||||||
category
|
category
|
||||||
tag
|
tag
|
||||||
archive
|
archive
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
</dyn:posts>
|
</dyn:posts>
|
||||||
|
<dyn:first_page_only>
|
||||||
|
<div id="last_ljdc">
|
||||||
|
<b>Dernier gif</b> <a href="/ljdc">les joies du code</a>
|
||||||
|
<a href="/ljdc"><dyn:ljdc_last/></a>
|
||||||
|
</div>
|
||||||
|
</dyn:first_page_only>
|
||||||
<nav>
|
<nav>
|
||||||
<dyn:recents>
|
<dyn:recents>
|
||||||
<span id="recents_title">More posts...</span>
|
<span id="recents_title">More posts...</span>
|
||||||
|
|
|
@ -595,4 +595,9 @@ div.all_posts div.post
|
||||||
.feed > a
|
.feed > a
|
||||||
{
|
{
|
||||||
margin-right:10px;
|
margin-right:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#last_ljdc
|
||||||
|
{
|
||||||
|
padding-bottom:40px;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user