Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2613 — allow enabling pretty URLs with per-post setting #2614

Merged
merged 2 commits into from Jan 4, 2017

Conversation

Kwpolska
Copy link
Member

@Kwpolska Kwpolska commented Jan 1, 2017

This is #2613. This is an example implementation, and it may not be merged if deemed unnecessary.

cc @felixfontein, @ChillarAnand

return False
m = self.meta[lang].get('pretty_url', '')
return ((self.pretty_urls and m != 'False' and
self.meta[lang]['slug'] != 'index') or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't self.meta[lang]['slug'] != 'index' be anded with both sides of or? I.e. something like

    return self.meta[lang]['slug'] != 'index' and ((self.pretty_urls and m != 'False') or (not self.pretty_urls and m == 'True'))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be, but if you are specifying pretty_url as a special case, you probably don’t want it overridden by some magic. In fact, we could go the other way: allow index to create a pretty URL if there is an override, even if self.pretty_urls is True. Which way should I go?

m = self.meta[lang].get('pretty_url', '')
return ((self.pretty_urls and m != 'False' and
self.meta[lang]['slug'] != 'index') or
(not self.pretty_urls and m == 'True'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not replace the whole logic with:

    m = self.meta[lang].get('pretty_url', repr(self.pretty_urls))
    return self.meta[lang]['slug'] != 'index' and m == 'True'

?

@ChillarAnand
Copy link
Contributor

ChillarAnand commented Jan 1, 2017

@Kwpolska mentioned an alternate solution here. With that solution, users have to change posts directory structure whenever pretty urls is necessary.

I prefer this fix as directory structure can remain same. But its up to you to decide.

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Kwpolska Kwpolska merged commit b43e416 into master Jan 4, 2017
@Kwpolska Kwpolska deleted the fix-2613 branch January 4, 2017 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants