Skip to content

Commit

Permalink
Rename post._has_pretty_url → post.has_pretty_url
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 29, 2017
1 parent 04cd8e0 commit d774e62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nikola/plugins/task/page_index.py
Expand Up @@ -64,7 +64,7 @@ def is_enabled(self, lang=None):
def classify(self, post, lang):
"""Classify the given post for the given language."""
destpath = post.destination_path(lang, sep='/')
if post._has_pretty_url(lang):
if post.has_pretty_url(lang):
idx = '/index.html'
if destpath.endswith(idx):
destpath = destpath[:-len(idx)]
Expand Down
11 changes: 8 additions & 3 deletions nikola/post.py
Expand Up @@ -279,7 +279,8 @@ def __repr__(self):
m.update(utils.unicode_str(json.dumps(clean_meta, cls=utils.CustomEncoder, sort_keys=True)).encode('utf-8'))
return '<Post: {0!r} {1}>'.format(self.source_path, m.hexdigest())

def _has_pretty_url(self, lang):
def has_pretty_url(self, lang):
"""Check if this page has a pretty URL."""
m = self.meta[lang].get('pretty_url', '')
if m:
# match is a non-empty string, overides anything
Expand All @@ -288,6 +289,10 @@ def _has_pretty_url(self, lang):
# use PRETTY_URLS, unless the slug is 'index'
return self.pretty_urls and self.meta[lang]['slug'] != 'index'

def _has_pretty_url(self, lang):
"""Check if this page has a pretty URL."""
return _has_pretty_url(lang)

@property
def is_mathjax(self):
"""True if this post has the mathjax tag in the current language or is a python notebook."""
Expand Down Expand Up @@ -796,7 +801,7 @@ def destination_path(self, lang=None, extension='.html', sep=os.sep):
if lang is None:
lang = nikola.utils.LocaleBorg().current_lang
folder = self.folders[lang]
if self._has_pretty_url(lang):
if self.has_pretty_url(lang):
path = os.path.join(self.translations[lang],
folder, self.meta[lang]['slug'], 'index' + extension)
else:
Expand Down Expand Up @@ -874,7 +879,7 @@ def permalink(self, lang=None, absolute=False, extension='.html', query=None):

pieces = self.translations[lang].split(os.sep)
pieces += self.folders[lang].split(os.sep)
if self._has_pretty_url(lang):
if self.has_pretty_url(lang):
pieces += [self.meta[lang]['slug'], 'index' + extension]
else:
pieces += [self.meta[lang]['slug'] + extension]
Expand Down

0 comments on commit d774e62

Please sign in to comment.