mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-06 03:01:43 -04:00
Merge branch 'master' into refactor-related-posts
This commit is contained in:
@@ -57,7 +57,7 @@ require_all 'jekyll/tags'
|
||||
SafeYAML::OPTIONS[:suppress_warnings] = true
|
||||
|
||||
module Jekyll
|
||||
VERSION = '1.0.1'
|
||||
VERSION = '1.0.2'
|
||||
|
||||
# Public: Generate a Jekyll configuration Hash by merging the default
|
||||
# options with anything in _config.yml, and adding the given options on top.
|
||||
|
||||
@@ -18,9 +18,9 @@ module Jekyll
|
||||
site.process
|
||||
rescue Jekyll::FatalException => e
|
||||
puts
|
||||
Jekyll::Logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
|
||||
Jekyll::Logger.error "", "------------------------------------"
|
||||
Jekyll::Logger.error "", e.message
|
||||
Jekyll::Stevenson.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
|
||||
Jekyll::Stevenson.error "", "------------------------------------"
|
||||
Jekyll::Stevenson.error "", e.message
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,9 +17,9 @@ module Jekyll
|
||||
def self.build(site, options)
|
||||
source = options['source']
|
||||
destination = options['destination']
|
||||
Jekyll::Logger.info "Source:", source
|
||||
Jekyll::Logger.info "Destination:", destination
|
||||
print Jekyll::Logger.formatted_topic "Generating..."
|
||||
Jekyll::Stevenson.info "Source:", source
|
||||
Jekyll::Stevenson.info "Destination:", destination
|
||||
print Jekyll::Stevenson.formatted_topic "Generating..."
|
||||
self.process_site(site)
|
||||
puts "done."
|
||||
end
|
||||
@@ -36,14 +36,14 @@ module Jekyll
|
||||
source = options['source']
|
||||
destination = options['destination']
|
||||
|
||||
Jekyll::Logger.info "Auto-regeneration:", "enabled"
|
||||
Jekyll::Stevenson.info "Auto-regeneration:", "enabled"
|
||||
|
||||
dw = DirectoryWatcher.new(source, :glob => self.globs(source, destination), :pre_load => true)
|
||||
dw.interval = 1
|
||||
|
||||
dw.add_observer do |*args|
|
||||
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
print Jekyll::Logger.formatted_topic("Regenerating:") + "#{args.size} files at #{t} "
|
||||
print Jekyll::Stevenson.formatted_topic("Regenerating:") + "#{args.size} files at #{t} "
|
||||
self.process_site(site)
|
||||
puts "...done."
|
||||
end
|
||||
|
||||
29
lib/jekyll/commands/doctor.rb
Normal file
29
lib/jekyll/commands/doctor.rb
Normal file
@@ -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::Stevenson.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::Stevenson.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
|
||||
@@ -9,7 +9,7 @@ module Jekyll
|
||||
new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
|
||||
FileUtils.mkdir_p new_blog_path
|
||||
unless Dir["#{new_blog_path}/**/*"].empty?
|
||||
Jekyll::Logger.error "Conflict:", "#{new_blog_path} exists and is not empty."
|
||||
Jekyll::Stevenson.error "Conflict:", "#{new_blog_path} exists and is not empty."
|
||||
exit(1)
|
||||
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',
|
||||
@@ -112,7 +115,7 @@ module Jekyll
|
||||
def read_config_file(file)
|
||||
next_config = YAML.safe_load_file(file)
|
||||
raise "Configuration file: (INVALID) #{file}".yellow if !next_config.is_a?(Hash)
|
||||
Jekyll::Logger.info "Configuration file:", file
|
||||
Jekyll::Stevenson.info "Configuration file:", file
|
||||
next_config
|
||||
end
|
||||
|
||||
@@ -132,9 +135,9 @@ module Jekyll
|
||||
end
|
||||
rescue SystemCallError
|
||||
# Errno:ENOENT = file not found
|
||||
Jekyll::Logger.warn "Configuration file:", "none"
|
||||
Jekyll::Stevenson.warn "Configuration file:", "none"
|
||||
rescue => err
|
||||
Jekyll::Logger.warn "WARNING:", "Error reading configuration. " +
|
||||
Jekyll::Stevenson.warn "WARNING:", "Error reading configuration. " +
|
||||
"Using defaults (and options)."
|
||||
$stderr.puts "#{err}"
|
||||
end
|
||||
@@ -150,7 +153,7 @@ module Jekyll
|
||||
config = clone
|
||||
# Provide backwards-compatibility
|
||||
if config.has_key?('auto') || config.has_key?('watch')
|
||||
Jekyll::Logger.warn "Deprecation:", "Auto-regeneration can no longer" +
|
||||
Jekyll::Stevenson.warn "Deprecation:", "Auto-regeneration can no longer" +
|
||||
" be set from your configuration file(s). Use the"+
|
||||
" --watch/-w command-line option instead."
|
||||
config.delete('auto')
|
||||
@@ -158,12 +161,21 @@ module Jekyll
|
||||
end
|
||||
|
||||
if config.has_key? 'server'
|
||||
Jekyll::Logger.warn "Deprecation:", "The 'server' configuration option" +
|
||||
Jekyll::Stevenson.warn "Deprecation:", "The 'server' configuration option" +
|
||||
" is no longer accepted. Use the 'jekyll serve'" +
|
||||
" subcommand to serve your site with WEBrick."
|
||||
config.delete('server')
|
||||
end
|
||||
|
||||
if config.has_key? 'server_port'
|
||||
Jekyll::Stevenson.warn "Deprecation:", "The 'server_port' configuration option" +
|
||||
" has been renamed to 'port'. Please update your config" +
|
||||
" file accordingly."
|
||||
# copy but don't overwrite:
|
||||
config['port'] = config['server_port'] unless config.has_key?('port')
|
||||
config.delete('server_port')
|
||||
end
|
||||
|
||||
config
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ module Jekyll
|
||||
|
||||
module CommonMethods
|
||||
def add_code_tags(code, lang)
|
||||
code = code.sub(/<pre>/, "<pre><code class=\"#{lang} language-#{lang}\">")
|
||||
code = code.sub(/<pre>/, "<pre><code class=\"#{lang} language-#{lang}\" data-lang=\"#{lang}\">")
|
||||
code = code.sub(/<\/pre>/,"</code></pre>")
|
||||
end
|
||||
end
|
||||
@@ -52,7 +52,7 @@ module Jekyll
|
||||
include WithoutPygments
|
||||
end
|
||||
end
|
||||
rescue LoadErro
|
||||
rescue LoadError
|
||||
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
||||
STDERR.puts ' $ [sudo] gem install redcarpet'
|
||||
raise FatalException.new("Missing dependency: redcarpet")
|
||||
|
||||
@@ -76,7 +76,7 @@ module Jekyll
|
||||
def render_liquid(content, payload, info)
|
||||
Liquid::Template.parse(content).render!(payload, info)
|
||||
rescue Exception => e
|
||||
Jekyll::Logger.error "Liquid Exception:", "#{e.message} in #{payload[:file]}"
|
||||
Jekyll::Stevenson.error "Liquid Exception:", "#{e.message} in #{payload[:file]}"
|
||||
e.backtrace.each do |backtrace|
|
||||
puts backtrace
|
||||
end
|
||||
|
||||
@@ -18,14 +18,14 @@ module Jekyll
|
||||
|
||||
def self.no_subcommand(args)
|
||||
if args.size > 0 && args.first =~ /^--/ && !%w[--help --version].include?(args.first)
|
||||
Jekyll::Logger.error "Deprecation:", "Jekyll now uses subcommands instead of just \
|
||||
Jekyll::Stevenson.error "Deprecation:", "Jekyll now uses subcommands instead of just \
|
||||
switches. Run `jekyll help' to find out more."
|
||||
end
|
||||
end
|
||||
|
||||
def self.deprecation_message(args, deprecated_argument, message)
|
||||
if args.include?(deprecated_argument)
|
||||
Jekyll::Logger.error "Deprecation:", message
|
||||
Jekyll::Stevenson.error "Deprecation:", message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -146,7 +146,7 @@ module Jekyll
|
||||
when String
|
||||
Time.parse(input)
|
||||
else
|
||||
Jekyll::Logger.error "Invalid Date:", "'#{input}' is not a valid datetime."
|
||||
Jekyll::Stevenson.error "Invalid Date:", "'#{input}' is not a valid datetime."
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'logger'
|
||||
|
||||
module Jekyll
|
||||
class Logger < Logger
|
||||
class Stevenson < Logger
|
||||
# Public: Print a jekyll message to stdout
|
||||
#
|
||||
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -76,7 +76,7 @@ module Jekyll
|
||||
|
||||
def populate_categories
|
||||
if self.categories.empty?
|
||||
self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.downcase}
|
||||
self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.to_s.downcase}
|
||||
end
|
||||
self.categories.flatten!
|
||||
end
|
||||
|
||||
@@ -229,6 +229,7 @@ module Jekyll
|
||||
end
|
||||
|
||||
self.pages.each do |page|
|
||||
relative_permalinks_deprecation_method if page.uses_relative_permalinks
|
||||
page.render(self.layouts, payload)
|
||||
end
|
||||
|
||||
@@ -416,5 +417,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::Stevenson.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::Stevenson.formatted_topic("") + "..." # for "done."
|
||||
@deprecated_relative_permalinks = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user