Archive geenration was broken for tags

Change ALl rights reserved in Tous droits réservés
This commit is contained in:
Grégory Soutadé 2013-02-17 08:38:58 +01:00
parent e277e1cc24
commit cce2361b75
7 changed files with 14 additions and 24 deletions

View File

@ -62,20 +62,18 @@ class Archive(Index):
if i < nb_post-1:
if posts[i].creation_date.year != posts[i+1].creation_date.year:
dom = parse(src + '/_archive.html')
my_post.reverse()
self.nb_pages = 0
self.cur_page = 0
self.cur_post = 0
self.dirname = '/archive/' + str(self.cur_year)
self.generatePages(dom, my_post, src, output, 'archive', 'archive')
self.generatePages(dom, my_post, src, output, 'archive')
self.cur_year = int(posts[i+1].creation_date.year)
#print 'New year ' + str(self.cur_year)
my_post = []
if self.cur_year == int(now.year):
break
else:
my_post.append(posts[i])
else:

View File

@ -60,7 +60,7 @@ class Category(Index):
self.dirname = '/category/' + category.name_slug
self.generatePages(dom, posts, src, output, 'category', 'category')
self.generatePages(dom, posts, src, output, 'category')
if not self.somethingWrote:
self.addReport('Nothing changed')

View File

@ -294,7 +294,7 @@ class Index(DynastieGenerator):
from dynastie.models import Post
tags_elem = self.createElement(dom, 'tags')
create_link = (node.getAttribute('link') == '1')
if type(posts) == models.query.QuerySet:
if type(posts) == models.query.QuerySet or type(posts) == list:
if len(posts) > self.cur_post:
cur_post = posts[self.cur_post]
else:
@ -386,7 +386,7 @@ class Index(DynastieGenerator):
return code
def parseTemplate(self, blog, src, output, name, directory=None):
def parseTemplate(self, blog, src, output, name, directory=None, parsePostsTag=True):
self.blog = blog
if not os.path.exists(src + '/_%s.html' % name):
@ -402,6 +402,8 @@ class Index(DynastieGenerator):
if not directory is None and not os.path.exists(output + '/' + directory):
os.mkdir(output + '/' + directory)
if not parsePostsTag: return dom
post_nodes = dom.getElementsByTagNameNS(self.URI, "posts")
if not post_nodes is None:
@ -414,11 +416,11 @@ class Index(DynastieGenerator):
return dom
def generatePages(self, dom, posts, src, output, name, directory=None):
def generatePages(self, dom, posts, src, output, name):
if len(posts) > self.posts_per_page:
self.nb_pages = self.computeNbPages(len(posts), self.posts_per_page)
if not directory is None and not os.path.exists(output + self.dirname):
if not os.path.exists(output + self.dirname):
os.mkdir(output + self.dirname)
filename = self.dirname + '/' + self.filename + '.html'

View File

@ -179,18 +179,8 @@ class Post(Index):
del self.hooks['recents']
del self.hooks['posts']
self.blog = blog
name = 'post'
if not os.path.exists(src + '/_%s.html' % name):
self.addError('No _%s.html found, exiting' % name)
return self.report
try:
dom = parse(src + '/_%s.html' % name)
except xml.dom.DOMException as e:
self.addError('Error parsing _%s.html : ' + e)
return self.report
dom = self.parseTemplate(blog, src, output, 'post', None, False)
if dom is None: return self.report
impl = xml.dom.getDOMImplementation()
for post in posts:

View File

@ -60,7 +60,7 @@ class Tag(Index):
self.dirname = '/tag/' + tag.name_slug
self.generatePages(dom, posts, src, output, 'tag', 'tag')
self.generatePages(dom, posts, src, output, 'tag')
if not self.somethingWrote:
self.addReport('Nothing changed')

View File

@ -83,7 +83,7 @@
<footer>
<div class="footer">
Copyright © 2010-2013 Grégory Soutadé.<br/>
All Rights Reserved.
Tous droits réservés.
</div>
</footer>
</div>

View File

@ -85,7 +85,7 @@
<footer>
<div class="footer">
Copyright © 2010-2013 Grégory Soutadé.<br/>
All Rights Reserved.
Tous droits réservés.
</div>
</footer>
</div>