Skip to content

Commit

Permalink
fix #1168
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jun 13, 2015
1 parent afe5b36 commit 7233a4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
@@ -1,6 +1,11 @@
New in Master
=============

Features
--------

* Add redirection for tags in Wordpress importer (Issue #1168)

Bugfixes
--------

Expand Down
8 changes: 8 additions & 0 deletions nikola/plugins/command/import_wordpress.py
Expand Up @@ -101,6 +101,7 @@ class CommandImportWordpress(Command, ImportMixin):
'help': "The pattern for translation files names",
},
]
all_tags = set([])

def _execute(self, options={}, args=[]):
"""Import a WordPress blog from an export file into a Nikola site."""
Expand Down Expand Up @@ -165,6 +166,12 @@ def show_info_about_mising_module(modulename):
self.extra_languages)
self.context['REDIRECTIONS'] = self.configure_redirections(
self.url_map)

# Add tag redirects
for tag in self.all_tags:
tag = utils.slugify(tag.decode('utf8'))
self.url_map['{}tag/{}'.format(self.context['SITE_URL'], tag)] = self.context['SITE_URL'] + 'categories/' + tag + '.html'

self.write_urlmap_csv(
os.path.join(self.output_folder, 'url_map.csv'), self.url_map)
rendered_template = conf_template.render(**prepare_config(self.context))
Expand Down Expand Up @@ -445,6 +452,7 @@ def import_item(self, item, wordpress_namespace, out_folder=None):
if text == 'Uncategorized':
continue
tags.append(text)
self.all_tags.add(text)

if '$latex' in content:
tags.append('mathjax')
Expand Down

0 comments on commit 7233a4c

Please sign in to comment.