Backwards-compatibilize relative permalinks #1081

Merged
merged 12 commits into from May 12, 2013

Projects

None yet

3 participants

@parkr
Member
parkr commented May 11, 2013

Fix for #1077

This is both

  • deprecation message on build/serve
  • jekyll doctor command

// @mojombo @benbalter @zachgersh

@benbalter
Contributor

Maybe I'm misreading the diff, but where does it handle absolute permalinks if relative_permalinks is false?

@parkr
Member
parkr commented May 11, 2013

I haven't modified the write behaviour yet - working on that.

@parkr
Member
parkr commented May 11, 2013

Output for build:

~/code/jekyll/tsite$ be ../bin/jekyll build
Configuration file: /Users/parker/code/jekyll/tsite/_config.yml
            Source: /Users/parker/code/jekyll/tsite
       Destination: /Users/parker/code/jekyll/tsite/_site
      Generating...
       Deprecation: Starting in 1.1, permalinks for pages in subfolders must be absolute permalinks relative to the site source.
                    ...done.

Output for doctor:

~/code/jekyll/tsite$ be ../bin/jekyll doctor
Configuration file: /Users/parker/code/jekyll/tsite/_config.yml
       Deprecation: 'test/foo.md' uses relative permalinks which will be automatically deprecated in Jekyll v1.1.
       Deprecation: 'test/index.md' uses relative permalinks which will be automatically deprecated in Jekyll v1.1.
@benbalter benbalter commented on an outdated diff May 11, 2013
lib/jekyll/site.rb
@@ -418,5 +419,16 @@ def aggregate_post_info(post)
post.categories.each { |c| self.categories[c] << post }
post.tags.each { |c| self.tags[c] << post }
end
+
+ def relative_permalinks_deprecation_method
+ if config['relative_permalinks'] && !@deprecated_relative_permalinks
+ puts # Places newline after "Generating..."
+ Jekyll::Logger.warn "Deprecation:", "Starting in 1.1, permalinks for pages" +
+ " in subfolders must be absolute" +
@benbalter
benbalter May 11, 2013 Contributor

"absolute permalinks relative to..."

  1. Perhaps "relative to the site source directory, not the parent directory" to clarify
  2. Would be awesome if we could link out to upgrade page for more infos.
@benbalter benbalter and 1 other commented on an outdated diff May 11, 2013
lib/jekyll/page.rb
@@ -144,5 +151,9 @@ def html?
def index?
basename == 'index'
end
+
+ def uses_relative_permalinks
+ permalink && !permalink.include?(File.expand_path(@dir, site.source))
@benbalter
benbalter May 11, 2013 Contributor

How does this handle pages in the root? e.g., if permalink is /foo in root, wouldn't site source be ./?

@parkr
parkr May 11, 2013 Member

If I have ./foo.md with permalink: foo, when I run jekyll doctor:

Configuration file: /Users/parker/code/jekyll/tsite/_config.yml
       Deprecation: 'foo.md' uses relative permalinks which will be automatically deprecated in Jekyll v1.1.
       Deprecation: 'test/foo.md' uses relative permalinks which will be automatically deprecated in Jekyll v1.1.
       Deprecation: 'test/index.md' uses relative permalinks which will be automatically deprecated in Jekyll v1.1.
@parkr
parkr May 11, 2013 Member

It still notes it, which i guess doesn't make sense in this case.

@parkr
Member
parkr commented May 11, 2013

Should definitely loop in @mattr-.

@parkr
Member
parkr commented May 11, 2013

Error is a git error on Travis's side. @benbalter Ready for final scrutiny.

@benbalter
Contributor

Mobile, but couldn't tell from above. Does it err out on root pages with
explicit permalinks?
On May 11, 2013 1:54 PM, "Parker Moore" notifications@github.com wrote:

Error is a git error on Travis's side. @benbalterhttps://github.com/benbalterReady for final scrutiny.


Reply to this email directly or view it on GitHubhttps://github.com/mojombo/jekyll/pull/1081#issuecomment-17764316
.

@parkr
Member
parkr commented May 11, 2013

@benbalter It detects pages in the root with explicit permalinks, yeah. Once you're back, my comment above shows the output of jekyll doctor, which captures this case.

@benbalter
Contributor

But those pages are not affected, correct?
On May 11, 2013 2:15 PM, "Parker Moore" notifications@github.com wrote:

@benbalter https://github.com/benbalter It detects pages in the root
with explicit permalinks, yeah. Once you're back, my comment above shows
the output of jekyll doctor, which captures this case.


Reply to this email directly or view it on GitHubhttps://github.com/mojombo/jekyll/pull/1081#issuecomment-17764650
.

@parkr
Member
parkr commented May 11, 2013

Those pages are effected insofar as they use "/" as their base.

@parkr
Member
parkr commented May 11, 2013

So they are considered as pages which use relative links, but the relative link is just "/" so it's fine :)

@benbalter
Contributor

Re: Above, if my link isn't going to break, you shouldn't tell me it's going to break. Doesn't the leading / explicitly make it absolute?

After testing, a few things:

  • Need success message for doctor if no errors, otherwise I think it failed or something
  • "Automatically" deprecated? How about just deprectated. A bit redundant
  • Root pages are not going to be deprecated... no need to warn. See above
  • Any permalink in any subfolder when relative_permalinks: true should warn.*
  • Doctor should be cool with permalinks in subfolders if config says relative_permalinks: false

* If I have a folder called foo and the permalink of page bar.md is foo/bar, I should still yell at me. My explicit intent (pre 1.0) is foo/foo/bar, which will break with absolute permalinks. No need to look at the parent folder name, ever AFAIK.

Logic should be:

  1. Did they explicitly tell Jekyll to use absolute permalinks? Great. They're good to go. They know their 💩
  2. Loop through pages... for any page:
    1. Is it in a sub folder?
    2. Did they specify a permalink?

If both sub points of 2. are true, yell at me. If only one is true, they're fine. We're not going to deprecate them.

Will double check the page creation, but otherwise, I'd say 👍 with some of the above feedback refinements.

@benbalter
Contributor

👍

@parkr
Member
parkr commented May 11, 2013

Just want @mattr- to look this over and we'll be in business :)

@benbalter benbalter referenced this pull request May 11, 2013
Closed

Document new features #1072

4 of 4 tasks complete
@mattr- mattr- commented on the diff May 12, 2013
lib/jekyll/commands/doctor.rb
@@ -0,0 +1,29 @@
+module Jekyll
+ module Commands
+ class Doctor < Command
+ class << self
+ def process(options)
+ site = Jekyll::Site.new(options)
+ site.read
+
+ unless deprecated_relative_permalinks(site)
+ Jekyll::Logger.info "Your test results", "are in. Everything looks fine."
@mattr-
mattr- May 12, 2013 Member

I'm not intimately familiar with Jekyll::Logger. Why is there a comma here? What am I not aware of that keeps it from being just one string?

@parkr
parkr May 12, 2013 Member

Jekyll::Logger's methods take a topic and a message. The topic is rjust(20)'d then the message is printed. This splits up the message so that it's not [20 spaces]Your test results are in....

@mattr-
Member
mattr- commented May 12, 2013

👍 from me. I don't think my question is a giant blocker.

@parkr parkr merged commit 28b9e35 into master May 12, 2013

1 check passed

default The Travis CI build passed
Details
@parkr parkr deleted the relative-permalinks branch May 12, 2013
@parkr parkr added a commit that referenced this pull request May 12, 2013
@parkr parkr Update history to reflect merge of #1081. 427bb6a
@parkr parkr referenced this pull request in jekyll/jekyll-help Apr 28, 2014
Closed

Is the option relative_permalinks deprecated? #26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment