Merge pull request #1081 from mojombo/relative-permalinks
Backwards-compatibilize relative permalinks
This commit is contained in:
commit
28b9e351c4
14
bin/jekyll
14
bin/jekyll
|
@ -86,6 +86,20 @@ command :serve do |c|
|
|||
end
|
||||
alias_command :server, :serve
|
||||
|
||||
command :doctor do |c|
|
||||
c.syntax = 'jekyll doctor'
|
||||
c.description = 'Search site and print specific deprecation warnings'
|
||||
|
||||
c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
|
||||
|
||||
c.action do |args, options|
|
||||
options = normalize_options(options.__hash__)
|
||||
options = Jekyll.configuration(options)
|
||||
Jekyll::Commands::Doctor.process(options)
|
||||
end
|
||||
end
|
||||
alias_command :hyde, :doctor
|
||||
|
||||
command :import do |c|
|
||||
c.syntax = 'jekyll import <platform> [options]'
|
||||
c.description = 'Import your old blog to Jekyll'
|
||||
|
|
|
@ -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."
|
||||
end
|
||||
end
|
||||
|
||||
def deprecated_relative_permalinks(site)
|
||||
contains_deprecated_pages = false
|
||||
site.pages.each do |page|
|
||||
if page.uses_relative_permalinks
|
||||
Jekyll::Logger.warn "Deprecation:", "'#{page.path}' uses relative" +
|
||||
" permalinks which will be deprecated in" +
|
||||
" Jekyll v1.1 and beyond."
|
||||
contains_deprecated_pages = true
|
||||
end
|
||||
end
|
||||
contains_deprecated_pages
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -19,7 +19,10 @@ module Jekyll
|
|||
'limit_posts' => 0,
|
||||
'lsi' => false,
|
||||
'future' => true, # remove and make true just default
|
||||
'pygments' => true, # remove and make true just default
|
||||
'pygments' => true,
|
||||
|
||||
'relative_permalinks' => true, # backwards-compatibility with < 1.0
|
||||
# will be set to false once 1.1 hits
|
||||
|
||||
'markdown' => 'maruku',
|
||||
'permalink' => 'date',
|
||||
|
|
|
@ -64,7 +64,11 @@ module Jekyll
|
|||
return @url if @url
|
||||
|
||||
url = if permalink
|
||||
permalink
|
||||
if site.config['relative_permalinks']
|
||||
File.join(@dir, permalink)
|
||||
else
|
||||
permalink
|
||||
end
|
||||
else
|
||||
{
|
||||
"path" => @dir,
|
||||
|
@ -114,7 +118,14 @@ module Jekyll
|
|||
self.data.deep_merge({
|
||||
"url" => self.url,
|
||||
"content" => self.content,
|
||||
"path" => self.data['path'] || File.join(@dir, @name).sub(/\A\//, '') })
|
||||
"path" => self.data['path'] || path })
|
||||
end
|
||||
|
||||
# The path to the source file
|
||||
#
|
||||
# Returns the path to the source file
|
||||
def path
|
||||
File.join(@dir, @name).sub(/\A\//, '')
|
||||
end
|
||||
|
||||
# Obtain destination path.
|
||||
|
@ -144,5 +155,9 @@ module Jekyll
|
|||
def index?
|
||||
basename == 'index'
|
||||
end
|
||||
|
||||
def uses_relative_permalinks
|
||||
permalink && @dir != "" && site.config['relative_permalinks']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -231,6 +231,7 @@ module Jekyll
|
|||
end
|
||||
|
||||
self.pages.each do |page|
|
||||
relative_permalinks_deprecation_method if page.uses_relative_permalinks
|
||||
page.render(self.layouts, payload)
|
||||
end
|
||||
|
||||
|
@ -418,5 +419,18 @@ module Jekyll
|
|||
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
|
||||
$stderr.puts # Places newline after "Generating..."
|
||||
Jekyll::Logger.warn "Deprecation:", "Starting in 1.1, permalinks for pages" +
|
||||
" in subfolders must be relative to the" +
|
||||
" site source directory, not the parent" +
|
||||
" directory. Check http://jekyllrb.com/docs/upgrading/"+
|
||||
" for more info."
|
||||
$stderr.print Jekyll::Logger.formatted_topic("") + "..." # for "done."
|
||||
@deprecated_relative_permalinks = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue