Skip to content

Commit f898c92

Browse files
committedJan 22, 2016
Fix #2224 -- don’t redirect WP ?p links in subdirs
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 66d1970 commit f898c92

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed
 

‎CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Features
1414
Bugfixes
1515
--------
1616

17+
* Don’t attempt to create redirects for URLs with query strings in
18+
WordPress imports if the site is in a subdirectory (Issue #2224)
1719
* Avoid some random file rebuilds (Issue #2220)
1820
* Honor ``MATHJAX_CONFIG``
1921
* Display tags and archives in a unified format, with the date on the

‎nikola/plugins/basic_import.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ def get_channel_from_file(cls, filename):
7676
return channel
7777

7878
@staticmethod
79-
def configure_redirections(url_map):
79+
def configure_redirections(url_map, base_dir=''):
8080
"""Configure redirections from an url_map."""
81+
index = base_dir + 'index.html'
82+
if index.startswith('/'):
83+
index = index[1:]
8184
redirections = []
8285
for k, v in url_map.items():
8386
if not k[-1] == '/':
@@ -86,11 +89,10 @@ def configure_redirections(url_map):
8689
# remove the initial "/" because src is a relative file path
8790
src = (urlparse(k).path + 'index.html')[1:]
8891
dst = (urlparse(v).path)
89-
if src == 'index.html':
92+
if src == index:
9093
utils.LOGGER.warn("Can't do a redirect for: {0!r}".format(k))
9194
else:
9295
redirections.append((src, dst))
93-
9496
return redirections
9597

9698
def generate_base_site(self):

‎nikola/plugins/command/import_wordpress.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def show_info_about_mising_module(modulename):
334334
self.context['TRANSLATIONS'] = format_default_translations_config(
335335
self.extra_languages)
336336
self.context['REDIRECTIONS'] = self.configure_redirections(
337-
self.url_map)
337+
self.url_map, self.base_dir)
338338
if self.timezone:
339339
self.context['TIMEZONE'] = self.timezone
340340
if self.export_categories_as_categories:

0 commit comments

Comments
 (0)
Please sign in to comment.