Browse files

Merge pull request #196 from geekman/fixes

Various fixes
  • Loading branch information...
2 parents 2c0fbbd + 7df61fd commit bb9186aa17011462293c9744f7056b4c424188fb @posativ committed Jan 4, 2014
Showing with 15 additions and 5 deletions.
  1. +4 −0 acrylamid/tasks/imprt.py
  2. +4 −0 acrylamid/views/__init__.py
  3. +3 −2 acrylamid/views/sitemap.py
  4. +4 −3 acrylamid/views/tag.py
View
4 acrylamid/tasks/imprt.py
@@ -245,6 +245,7 @@ def generate(item):
'link': item.find('link').text,
'content': (item.find('%sencoded' % cons).text or '').replace('\n', '<br />\n'),
+ 'description': item.find('%sencoded' % excerptns).text or '',
'date': datetime.strptime(item.find('%spost_date' % wpns).text,
"%Y-%m-%d %H:%M:%S"),
@@ -279,6 +280,7 @@ def generate(item):
for version in range(1, 10):
wpns = '{http://wordpress.org/export/1.%i/}' % version
+ excerptns = '{http://wordpress.org/export/1.%i/excerpt/}' % version
if tree.find('channel/%swxr_version' % wpns) is None:
continue
entries = list(map(generate, tree.findall('channel/item')))
@@ -347,6 +349,8 @@ def create(defaults, item):
f.write(u'draft: %s\n' % item['draft'])
if 'tags' in item:
f.write(u'tags: [%s]\n' % ', '.join(item['tags']))
+ if item.get('description'):
+ f.write(u'description: %s\n' % item['description'])
if 'permalink' in item:
f.write(u'permalink: %s\n' % item['permalink'])
if item.get('type', 'entry') != 'entry':
View
4 acrylamid/views/__init__.py
@@ -268,6 +268,8 @@ def init(self, *args, **kwargs):
if 'pagination' not in kwargs:
self.pagination = self.path + ':num/'
+ self.export.append('curr_page')
+
def generate(self, conf, env, data, **kwargs):
if self.pagination is None:
@@ -283,6 +285,8 @@ def generate(self, conf, env, data, **kwargs):
for (next, curr, prev), entrylist, modified in paginator:
+ curr_page = curr
+
next = None if next is None \
else link(u'Next', expand(self.path, kwargs)) if next == 1 \
else link(u'Next', expand(self.pagination, union({'num': next}, kwargs)))
View
5 acrylamid/views/sitemap.py
@@ -107,12 +107,13 @@ def generate(self, conf, env, data):
continue
permalink = '/' + fname.replace(conf['output_dir'], '')
+ permalink = rchop(permalink, 'index.html')
url = conf['www_root'] + permalink
priority, changefreq = self.scores.get(ns, (0.5, 'weekly'))
if self.imgext:
images = [x for x in self.mapping.get(permalink, []) if splitext(x)[1].lower() in self.imgext]
- sm.add(rchop(url, 'index.html'), getmtime(fname), changefreq, priority, images)
+ sm.add(url, getmtime(fname), changefreq, priority, images)
else:
- sm.add(rchop(url, 'index.html'), getmtime(fname), changefreq, priority)
+ sm.add(url, getmtime(fname), changefreq, priority)
sm.finish()
yield sm, path
View
7 acrylamid/views/tag.py
@@ -86,7 +86,7 @@ class Tag(Index):
def populate_tags(self, request):
tags = fetch(request['entrylist'])
- self.tags = dict([(safeslug(k), v) for k, v in iteritems(tags)])
+ self.tags = tags
return tags
def context(self, conf, env, request):
@@ -99,7 +99,8 @@ def __init__(self, title, href):
def tagify(tags):
href = lambda t: expand(self.path, {'name': safeslug(t)})
- return [Link(t, href(t)) for t in tags]
+ return [Link(t, href(t)) for t in tags] if isinstance(tags, (list, tuple)) \
+ else Link(tags, href(tags))
tags = self.populate_tags(request)
env.engine.register('tagify', tagify)
@@ -116,5 +117,5 @@ def generate(self, conf, env, data):
for tag in self.tags:
data['entrylist'] = [entry for entry in self.tags[tag]]
- for res in Paginator.generate(self, conf, env, data, tag=tag, name=tag):
+ for res in Paginator.generate(self, conf, env, data, tag=tag, name=safeslug(tag)):
yield res

0 comments on commit bb9186a

Please sign in to comment.