Merge branch 'master' into changelist_page

This commit is contained in:
zachgersh 2013-05-28 21:54:49 -07:00
commit 20eda0e89f
39 changed files with 443 additions and 209 deletions

View File

@ -2,13 +2,38 @@
### Major Enhancements ### Major Enhancements
### Minor Enhancements ### Minor Enhancements
* Move the building of related posts into their own class (#1057)
* Removed trailing spaces in several places throughout the code (#1116)
* Add a `--force` option to `jekyll new` (#1115)
### Bug Fixes ### Bug Fixes
* Rename Jekyll::Logger to Jekyll::Stevenson to fix inheritance issue (#1106)
* Exit with a non-zero exit code when dealing with a Liquid error (#1121)
* Make the `exclude` and `include` options backwards compatible with
versions of Jekyll prior to 1.0 (#1114)
* Fix pagination on Windows (#1063)
* Fix the application of Pygments' Generic Output style to Go code
(#1156)
### Site Enhancements ### Site Enhancements
* Documentation for `date_to_rfc822` and `uri_escape` (#1142)
* Documentation highlight boxes shouldn't show scrollbars if not necessary (#1123)
* Add link to jekyll-minibundle in the doc's plugins list (#1035)
* Quick patch for importers documentation
* Fix prefix for WordpressDotCom importer in docs (#1107)
* Add jekyll-contentblocks plugin to docs (#1068)
* Make code bits in notes look more natural, more readable (#1089)
* Fix logic for `relative_permalinks` instructions on Upgrading page (#1101)
* Add docs for post excerpt (#1072)
* Add docs for gist tag (#1072) * Add docs for gist tag (#1072)
* Add docs indicating that Pygments does not need to be installed
separately (#1099, #1119)
* Update the migrator docs to be current (#1136)
* Add the Jekyll Gallery Plugin to the plugin list (#1143)
### Development Fixes ### Development Fixes
* Fix pesky Cucumber infinite loop (#1139)
* Do not write posts with timezones in Cucumber tests (#1124)
## 1.0.2 / 2013-05-12 ## 1.0.2 / 2013-05-12

View File

@ -37,8 +37,10 @@ command :new do |c|
c.syntax = 'jekyll new PATH' c.syntax = 'jekyll new PATH'
c.description = 'Creates a new Jekyll site scaffold in PATH' c.description = 'Creates a new Jekyll site scaffold in PATH'
c.option '--force', 'Force creation even if PATH already exists'
c.action do |args, options| c.action do |args, options|
Jekyll::Commands::New.process(args) Jekyll::Commands::New.process(args, options.__hash__)
end end
end end

View File

@ -47,44 +47,38 @@ Given /^I have an? (.*) directory$/ do |dir|
FileUtils.mkdir_p(dir) FileUtils.mkdir_p(dir)
end end
Given /^I have the following (draft|post)s?(?: (.*) "(.*)")?:$/ do |status, direction, folder, table| Given /^I have the following (draft|post)s?(?: (in|under) "([^"]+)")?:$/ do |status, direction, folder, table|
table.hashes.each do |post| table.hashes.each do |post|
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-') title = slug(post['title'])
if direction && direction == "in"
before = folder || '.'
elsif direction && direction == "under"
after = folder || '.'
end
ext = post['type'] || 'textile' ext = post['type'] || 'textile'
before, after = location(folder, direction)
if post['date']
in_format, out_format = time_format(post['date'])
parsed_date = DateTime.strptime(post['date'], in_format)
post['date'] = parsed_date.strftime(out_format)
end
if "draft" == status if "draft" == status
path = File.join(before || '.', '_drafts', after || '.', "#{title}.#{ext}") folder_post = '_drafts'
else filename = "#{title}.#{ext}"
format = if has_time_component?(post['date']) elsif "post" == status
'%Y-%m-%d %H:%M %z' folder_post = '_posts'
else filename = "#{parsed_date.strftime('%Y-%m-%d')}-#{title}.#{ext}"
'%m/%d/%Y' # why even
end
parsed_date = DateTime.strptime(post['date'], format)
post['date'] = parsed_date.to_s
date = parsed_date.strftime('%Y-%m-%d')
path = File.join(before || '.', '_posts', after || '.', "#{date}-#{title}.#{ext}")
end end
path = File.join(before, folder_post, after, filename)
matter_hash = {} matter_hash = {}
%w(title layout tag tags category categories published author path).each do |key| %w(title layout tag tags category categories published author path date).each do |key|
matter_hash[key] = post[key] if post[key] matter_hash[key] = post[key] if post[key]
end end
if "post" == status
matter_hash["date"] = post["date"] if post["date"]
end
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp
content = post['content'] content = if post['input'] && post['filter']
if post['input'] && post['filter'] "{{ #{post['input']} | #{post['filter']} }}"
content = "{{ #{post['input']} | #{post['filter']} }}" else
post['content']
end end
File.open(path, 'w') do |f| File.open(path, 'w') do |f|

View File

@ -2,10 +2,6 @@ require 'fileutils'
require 'rr' require 'rr'
require 'test/unit' require 'test/unit'
World do
include Test::Unit::Assertions
end
TEST_DIR = File.join('/', 'tmp', 'jekyll') TEST_DIR = File.join('/', 'tmp', 'jekyll')
JEKYLL_PATH = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'jekyll') JEKYLL_PATH = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'jekyll')
@ -17,9 +13,29 @@ def run_jekyll(opts = {})
system command system command
end end
def time_format(date)
if has_time_component?(date)
['%Y-%m-%d %H:%M %z'] * 2
else
['%m/%d/%Y', '%Y-%m-%d %H:%M']
end
end
def has_time_component?(date_string) def has_time_component?(date_string)
date_string.split(" ").size > 1 date_string.split(" ").size > 1
end end
def slug(title)
title.downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
end
def location(folder, direction)
if folder
before = folder if direction == "in"
after = folder if direction == "under"
end
[before || '.', after || '.']
end
# work around "invalid option: --format" cucumber bug (see #296) # work around "invalid option: --format" cucumber bug (see #296)
Test::Unit.run = true if RUBY_VERSION < '1.9' Test::Unit.run = true if RUBY_VERSION < '1.9'

View File

@ -37,7 +37,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('rdoc', "~> 3.11") s.add_development_dependency('rdoc', "~> 3.11")
s.add_development_dependency('redgreen', "~> 1.2") s.add_development_dependency('redgreen', "~> 1.2")
s.add_development_dependency('shoulda', "~> 3.3.2") s.add_development_dependency('shoulda', "~> 3.3.2")
s.add_development_dependency('rr', "~> 1.0") s.add_development_dependency('rr', "~> 1.0.0")
s.add_development_dependency('cucumber', "~> 1.2.1", '!= 1.2.4') s.add_development_dependency('cucumber', "~> 1.2.1", '!= 1.2.4')
s.add_development_dependency('RedCloth', "~> 4.2") s.add_development_dependency('RedCloth', "~> 4.2")
s.add_development_dependency('rdiscount', "~> 1.6") s.add_development_dependency('rdiscount', "~> 1.6")
@ -92,13 +92,14 @@ Gem::Specification.new do |s|
lib/jekyll/generator.rb lib/jekyll/generator.rb
lib/jekyll/generators/pagination.rb lib/jekyll/generators/pagination.rb
lib/jekyll/layout.rb lib/jekyll/layout.rb
lib/jekyll/logger.rb
lib/jekyll/mime.types lib/jekyll/mime.types
lib/jekyll/page.rb lib/jekyll/page.rb
lib/jekyll/plugin.rb lib/jekyll/plugin.rb
lib/jekyll/post.rb lib/jekyll/post.rb
lib/jekyll/related_posts.rb
lib/jekyll/site.rb lib/jekyll/site.rb
lib/jekyll/static_file.rb lib/jekyll/static_file.rb
lib/jekyll/stevenson.rb
lib/jekyll/tags/gist.rb lib/jekyll/tags/gist.rb
lib/jekyll/tags/highlight.rb lib/jekyll/tags/highlight.rb
lib/jekyll/tags/include.rb lib/jekyll/tags/include.rb
@ -236,6 +237,7 @@ Gem::Specification.new do |s|
test/test_rdiscount.rb test/test_rdiscount.rb
test/test_redcarpet.rb test/test_redcarpet.rb
test/test_redcloth.rb test/test_redcloth.rb
test/test_related_posts.rb
test/test_site.rb test/test_site.rb
test/test_tags.rb test/test_tags.rb
] ]

View File

@ -28,7 +28,7 @@ require 'colorator'
# internal requires # internal requires
require 'jekyll/core_ext' require 'jekyll/core_ext'
require 'jekyll/logger' require 'jekyll/stevenson'
require 'jekyll/deprecator' require 'jekyll/deprecator'
require 'jekyll/configuration' require 'jekyll/configuration'
require 'jekyll/site' require 'jekyll/site'
@ -40,6 +40,7 @@ require 'jekyll/draft'
require 'jekyll/filters' require 'jekyll/filters'
require 'jekyll/static_file' require 'jekyll/static_file'
require 'jekyll/errors' require 'jekyll/errors'
require 'jekyll/related_posts'
# extensions # extensions
require 'jekyll/plugin' require 'jekyll/plugin'

View File

@ -18,9 +18,9 @@ module Jekyll
site.process site.process
rescue Jekyll::FatalException => e rescue Jekyll::FatalException => e
puts puts
Jekyll::Logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:" Jekyll::Stevenson.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
Jekyll::Logger.error "", "------------------------------------" Jekyll::Stevenson.error "", "------------------------------------"
Jekyll::Logger.error "", e.message Jekyll::Stevenson.error "", e.message
exit(1) exit(1)
end end
end end

View File

@ -17,9 +17,9 @@ module Jekyll
def self.build(site, options) def self.build(site, options)
source = options['source'] source = options['source']
destination = options['destination'] destination = options['destination']
Jekyll::Logger.info "Source:", source Jekyll::Stevenson.info "Source:", source
Jekyll::Logger.info "Destination:", destination Jekyll::Stevenson.info "Destination:", destination
print Jekyll::Logger.formatted_topic "Generating..." print Jekyll::Stevenson.formatted_topic "Generating..."
self.process_site(site) self.process_site(site)
puts "done." puts "done."
end end
@ -36,14 +36,14 @@ module Jekyll
source = options['source'] source = options['source']
destination = options['destination'] 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 = DirectoryWatcher.new(source, :glob => self.globs(source, destination), :pre_load => true)
dw.interval = 1 dw.interval = 1
dw.add_observer do |*args| dw.add_observer do |*args|
t = Time.now.strftime("%Y-%m-%d %H:%M:%S") 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) self.process_site(site)
puts "...done." puts "...done."
end end

View File

@ -7,7 +7,7 @@ module Jekyll
site.read site.read
unless deprecated_relative_permalinks(site) unless deprecated_relative_permalinks(site)
Jekyll::Logger.info "Your test results", "are in. Everything looks fine." Jekyll::Stevenson.info "Your test results", "are in. Everything looks fine."
end end
end end
@ -15,7 +15,7 @@ module Jekyll
contains_deprecated_pages = false contains_deprecated_pages = false
site.pages.each do |page| site.pages.each do |page|
if page.uses_relative_permalinks if page.uses_relative_permalinks
Jekyll::Logger.warn "Deprecation:", "'#{page.path}' uses relative" + Jekyll::Stevenson.warn "Deprecation:", "'#{page.path}' uses relative" +
" permalinks which will be deprecated in" + " permalinks which will be deprecated in" +
" Jekyll v1.1 and beyond." " Jekyll v1.1 and beyond."
contains_deprecated_pages = true contains_deprecated_pages = true

View File

@ -3,13 +3,13 @@ require 'erb'
module Jekyll module Jekyll
module Commands module Commands
class New < Command class New < Command
def self.process(args) def self.process(args, options = {})
raise ArgumentError.new('You must specify a path.') if args.empty? raise ArgumentError.new('You must specify a path.') if args.empty?
new_blog_path = File.expand_path(args.join(" "), Dir.pwd) new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
FileUtils.mkdir_p new_blog_path FileUtils.mkdir_p new_blog_path
unless Dir["#{new_blog_path}/**/*"].empty? if preserve_source_location?(new_blog_path, options)
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) exit(1)
end end
@ -33,6 +33,11 @@ module Jekyll
end end
private private
def self.preserve_source_location?(path, options)
!options[:force] && !Dir["#{path}/**/*"].empty?
end
def self.create_sample_files(path) def self.create_sample_files(path)
FileUtils.cp_r site_template + '/.', path FileUtils.cp_r site_template + '/.', path
FileUtils.rm File.expand_path(scaffold_path, path) FileUtils.rm File.expand_path(scaffold_path, path)

View File

@ -115,7 +115,7 @@ module Jekyll
def read_config_file(file) def read_config_file(file)
next_config = YAML.safe_load_file(file) next_config = YAML.safe_load_file(file)
raise "Configuration file: (INVALID) #{file}".yellow if !next_config.is_a?(Hash) 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 next_config
end end
@ -135,9 +135,9 @@ module Jekyll
end end
rescue SystemCallError rescue SystemCallError
# Errno:ENOENT = file not found # Errno:ENOENT = file not found
Jekyll::Logger.warn "Configuration file:", "none" Jekyll::Stevenson.warn "Configuration file:", "none"
rescue => err rescue => err
Jekyll::Logger.warn "WARNING:", "Error reading configuration. " + Jekyll::Stevenson.warn "WARNING:", "Error reading configuration. " +
"Using defaults (and options)." "Using defaults (and options)."
$stderr.puts "#{err}" $stderr.puts "#{err}"
end end
@ -145,6 +145,15 @@ module Jekyll
configuration.backwards_compatibilize configuration.backwards_compatibilize
end end
# Public: Split a CSV string into an array containing its values
#
# csv - the string of comma-separated values
#
# Returns an array of the values contained in the CSV
def csv_to_array(csv)
csv.split(",").map(&:strip)
end
# Public: Ensure the proper options are set in the configuration to allow for # Public: Ensure the proper options are set in the configuration to allow for
# backwards-compatibility with Jekyll pre-1.0 # backwards-compatibility with Jekyll pre-1.0
# #
@ -153,7 +162,7 @@ module Jekyll
config = clone config = clone
# Provide backwards-compatibility # Provide backwards-compatibility
if config.has_key?('auto') || config.has_key?('watch') 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"+ " be set from your configuration file(s). Use the"+
" --watch/-w command-line option instead." " --watch/-w command-line option instead."
config.delete('auto') config.delete('auto')
@ -161,14 +170,14 @@ module Jekyll
end end
if config.has_key? 'server' 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'" + " is no longer accepted. Use the 'jekyll serve'" +
" subcommand to serve your site with WEBrick." " subcommand to serve your site with WEBrick."
config.delete('server') config.delete('server')
end end
if config.has_key? 'server_port' if config.has_key? 'server_port'
Jekyll::Logger.warn "Deprecation:", "The 'server_port' configuration option" + Jekyll::Stevenson.warn "Deprecation:", "The 'server_port' configuration option" +
" has been renamed to 'port'. Please update your config" + " has been renamed to 'port'. Please update your config" +
" file accordingly." " file accordingly."
# copy but don't overwrite: # copy but don't overwrite:
@ -176,6 +185,22 @@ module Jekyll
config.delete('server_port') config.delete('server_port')
end end
if config.has_key?('exclude') && config['exclude'].is_a?(String)
Jekyll::Stevenson.warn "Deprecation:", "The 'exclude' configuration option" +
" must now be specified as an array, but you specified" +
" a string. For now, we've treated the string you provided" +
" as a list of comma-separated values."
config['exclude'] = csv_to_array(config['exclude'])
end
if config.has_key?('include') && config['include'].is_a?(String)
Jekyll::Stevenson.warn "Deprecation:", "The 'include' configuration option" +
" must now be specified as an array, but you specified" +
" a string. For now, we've treated the string you provided" +
" as a list of comma-separated values."
config['include'] = csv_to_array(config['include'])
end
config config
end end

View File

@ -76,11 +76,8 @@ module Jekyll
def render_liquid(content, payload, info) def render_liquid(content, payload, info)
Liquid::Template.parse(content).render!(payload, info) Liquid::Template.parse(content).render!(payload, info)
rescue Exception => e 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| raise e
puts backtrace
end
abort("Build Failed")
end end
# Recursively render layouts # Recursively render layouts
@ -99,7 +96,7 @@ module Jekyll
payload = payload.deep_merge({"content" => self.output, "page" => layout.data}) payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
self.output = self.render_liquid(layout.content, self.output = self.render_liquid(layout.content,
payload.merge({:file => self.data["layout"]}), payload.merge({:file => layout.name}),
info) info)
if layout = layouts[layout.data["layout"]] if layout = layouts[layout.data["layout"]]

View File

@ -18,14 +18,14 @@ module Jekyll
def self.no_subcommand(args) def self.no_subcommand(args)
if args.size > 0 && args.first =~ /^--/ && !%w[--help --version].include?(args.first) 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." switches. Run `jekyll help' to find out more."
end end
end end
def self.deprecation_message(args, deprecated_argument, message) def self.deprecation_message(args, deprecated_argument, message)
if args.include?(deprecated_argument) if args.include?(deprecated_argument)
Jekyll::Logger.error "Deprecation:", message Jekyll::Stevenson.error "Deprecation:", message
end end
end end
end end

View File

@ -100,6 +100,16 @@ module Jekyll
CGI::escape(input) CGI::escape(input)
end end
# URI escape a string.
#
# input - The String to escape.
#
# Examples
#
# uri_escape('foo, bar \\baz?')
# # => "foo,%20bar%20%5Cbaz?"
#
# Returns the escaped String.
def uri_escape(input) def uri_escape(input)
URI.escape(input) URI.escape(input)
end end
@ -146,7 +156,7 @@ module Jekyll
when String when String
Time.parse(input) Time.parse(input)
else 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) exit(1)
end end
end end

View File

@ -92,8 +92,9 @@ module Jekyll
# Returns the pagination path as a string # Returns the pagination path as a string
def self.paginate_path(site_config, num_page) def self.paginate_path(site_config, num_page)
return nil if num_page.nil? || num_page <= 1 return nil if num_page.nil? || num_page <= 1
format = File.basename(site_config['paginate_path']) format = site_config['paginate_path']
format.sub(':num', num_page.to_s) format = format.sub(':num', num_page.to_s)
File.basename(format)
end end
# Initialize a new Pager. # Initialize a new Pager.

View File

@ -5,6 +5,9 @@ module Jekyll
# Gets the Site object. # Gets the Site object.
attr_reader :site attr_reader :site
# Gets the name of this layout.
attr_reader :name
# Gets/Sets the extension of this layout. # Gets/Sets the extension of this layout.
attr_accessor :ext attr_accessor :ext

View File

@ -244,29 +244,7 @@ module Jekyll
# #
# Returns an Array of related Posts. # Returns an Array of related Posts.
def related_posts(posts) def related_posts(posts)
return [] unless posts.size > 1 Jekyll::RelatedPosts.new(self).build
if self.site.lsi
build_index
related = self.class.lsi.find_related(self.content, 11)
related - [self]
else
(posts - [self])[0..9]
end
end
def build_index
self.class.lsi ||= begin
puts "Starting the classifier..."
lsi = Classifier::LSI.new(:auto_rebuild => false)
$stdout.print(" Populating LSI... "); $stdout.flush
self.site.posts.each { |x| $stdout.print("."); $stdout.flush; lsi.add_item(x) }
$stdout.print("\n Rebuilding LSI index... ")
lsi.build_index
puts ""
lsi
end
end end
# Add any necessary layouts to this post. # Add any necessary layouts to this post.

View File

@ -0,0 +1,58 @@
module Jekyll
class RelatedPosts
class << self
attr_accessor :lsi
end
attr_reader :post, :site
def initialize(post)
@post = post
@site = post.site
require 'classifier' if site.lsi
end
def build
return [] unless self.site.posts.size > 1
if self.site.lsi
build_index
lsi_related_posts
else
most_recent_posts
end
end
def build_index
self.class.lsi ||= begin
lsi = Classifier::LSI.new(:auto_rebuild => false)
display("Populating LSI...")
self.site.posts.each do |x|
lsi.add_item(x)
end
display("Rebuilding index...")
lsi.build_index
display("")
lsi
end
end
def lsi_related_posts
self.class.lsi.find_related(post.content, 11) - [self.post]
end
def most_recent_posts
(self.site.posts - [self.post])[0..9]
end
def display(output)
$stdout.print("\n")
$stdout.print(Jekyll::Stevenson.formatted_topic(output))
$stdout.flush
end
end
end

View File

@ -71,8 +71,6 @@ module Jekyll
# #
# Returns nothing. # Returns nothing.
def setup def setup
require 'classifier' if self.lsi
# Check that the destination dir isn't the source dir or a directory # Check that the destination dir isn't the source dir or a directory
# parent to the source dir. # parent to the source dir.
if self.source =~ /^#{self.dest}/ if self.source =~ /^#{self.dest}/
@ -423,12 +421,12 @@ module Jekyll
def relative_permalinks_deprecation_method def relative_permalinks_deprecation_method
if config['relative_permalinks'] && !@deprecated_relative_permalinks if config['relative_permalinks'] && !@deprecated_relative_permalinks
$stderr.puts # Places newline after "Generating..." $stderr.puts # Places newline after "Generating..."
Jekyll::Logger.warn "Deprecation:", "Starting in 1.1, permalinks for pages" + Jekyll::Stevenson.warn "Deprecation:", "Starting in 1.1, permalinks for pages" +
" in subfolders must be relative to the" + " in subfolders must be relative to the" +
" site source directory, not the parent" + " site source directory, not the parent" +
" directory. Check http://jekyllrb.com/docs/upgrading/"+ " directory. Check http://jekyllrb.com/docs/upgrading/"+
" for more info." " for more info."
$stderr.print Jekyll::Logger.formatted_topic("") + "..." # for "done." $stderr.print Jekyll::Stevenson.formatted_topic("") + "..." # for "done."
@deprecated_relative_permalinks = true @deprecated_relative_permalinks = true
end end
end end

View File

@ -1,7 +1,7 @@
require 'logger' require 'logger'
module Jekyll module Jekyll
class Logger < Logger class Stevenson
# Public: Print a jekyll message to stdout # Public: Print a jekyll message to stdout
# #
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.

View File

@ -18,7 +18,7 @@
.highlight .gr { color: #c0c0c0; font-weight: bold; background-color: #c00000 } /* Generic.Error */ .highlight .gr { color: #c0c0c0; font-weight: bold; background-color: #c00000 } /* Generic.Error */
.highlight .gh { color: #cd5c5c} /* Generic.Heading */ .highlight .gh { color: #cd5c5c} /* Generic.Heading */
.highlight .gi { color: #ffffff; background-color: #0000c0 } /* Generic.Inserted */ .highlight .gi { color: #ffffff; background-color: #0000c0 } /* Generic.Inserted */
.highlight .go { color: #add8e6; font-weight: bold; background-color: #4d4d4d } /* Generic.Output */ .highlight span.go { color: #add8e6; font-weight: bold; background-color: #4d4d4d } /* Generic.Output, qualified with span to prevent applying this style to the Go language, see #1153. */
.highlight .gp { color: #ffffff} /* Generic.Prompt */ .highlight .gp { color: #ffffff} /* Generic.Prompt */
.highlight .gs { color: #ffffff} /* Generic.Strong */ .highlight .gs { color: #ffffff} /* Generic.Strong */
.highlight .gu { color: #cd5c5c} /* Generic.Subheading */ .highlight .gu { color: #cd5c5c} /* Generic.Subheading */

View File

@ -519,7 +519,7 @@ pre, code {
} }
} }
.highlight, p > pre, p > code, p > nobr > code, li > code { .highlight, p > pre, p > code, p > nobr > code, li > code, h5 > code, .note > code {
background: #333; background: #333;
color: #fff; color: #fff;
border-radius: 5px; border-radius: 5px;
@ -528,10 +528,17 @@ pre, code {
0 -1px 0 rgba(0,0,0,.5); 0 -1px 0 rgba(0,0,0,.5);
} }
.note code {
background-color: rgba(0,0,0,0.2);
margin-left: 2.5px;
margin-right: 2.5px;
font-size: 0.8em;
}
.highlight { .highlight {
padding: 10px 0; padding: 10px 0;
width: 100%; width: 100%;
overflow: scroll; overflow: auto;
} }
/* HTML Elements */ /* HTML Elements */

View File

@ -50,10 +50,8 @@ community can improve the experience for everyone.
There are a number of (optional) extra features that Jekyll supports that you There are a number of (optional) extra features that Jekyll supports that you
may want to install, depending on how you plan to use Jekyll. These extras may want to install, depending on how you plan to use Jekyll. These extras
include syntax highlighting of code snippets using include LaTeX support, and the use of alternative content rendering engines.
[Pygments](http://pygments.org/), LaTeX support, and the use of alternative Check out [the extras page](../extras) for more information.
content rendering engines. Check out [the extras page](../extras) for more
information.
<div class="note"> <div class="note">
<h5>ProTip™: Enable Syntax Highlighting</h5> <h5>ProTip™: Enable Syntax Highlighting</h5>

View File

@ -15,12 +15,13 @@ the foreign system.
## Preparing for migrations ## Preparing for migrations
Because the importers have many of their own dependencies, they are made Because the importers have many of their own dependencies, they are made
available via a separate gem called `jekyll-import`. To use them, all you need available via a separate gem called
to do is install the gem, and they will become available as part of Jekyll's [`jekyll-import`](https://github.com/jekyll/jekyll-import). To use them, all
standard command line interface. you need to do is install the gem, and they will become available as part of
Jekyll's standard command line interface.
{% highlight bash %} {% highlight bash %}
$ gem install jekyll-import $ gem install jekyll-import --pre
{% endhighlight %} {% endhighlight %}
You should now be all set to run the importers below. If you ever get stuck, you You should now be all set to run the importers below. If you ever get stuck, you
@ -55,13 +56,13 @@ Next, export your blog using the Wordpress export utility. Assuming that the
exported file is saved as `wordpress.xml`, here is the command you need to run: exported file is saved as `wordpress.xml`, here is the command you need to run:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/wordpressdotcom"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpressdotcom";
Jekyll::WordpressDotCom.process("wordpress.xml")' JekyllImport::WordpressDotCom.process("wordpress.xml")'
{% endhighlight %} {% endhighlight %}
<div class="note"> <div class="note">
<h5>ProTip™: Wordpress.com Export Tool</h5> <h5>ProTip™: Wordpress.com Export Tool</h5>
<p>If you are migrating from a Wordpress.com account, you can access the export tool at the following URL: `https://YOUR-USER-NAME.wordpress.com/wp-admin/export.php`.</p> <p markdown="1">If you are migrating from a Wordpress.com account, you can access the export tool at the following URL: `https://YOUR-USER-NAME.wordpress.com/wp-admin/export.php`.</p>
</div> </div>
### Using Wordpress MySQL server connection ### Using Wordpress MySQL server connection
@ -69,8 +70,8 @@ $ ruby -rubygems -e 'require "jekyll/migrators/wordpressdotcom";
If you want to import using a direct connection to the Wordpress MySQL server, here's how: If you want to import using a direct connection to the Wordpress MySQL server, here's how:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/wordpress"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpress";
Jekyll::WordPress.process("database", "user", "pass")' JekyllImport::WordPress.process("database", "user", "pass")'
{% endhighlight %} {% endhighlight %}
If you are using Webfaction and have to set up an [SSH If you are using Webfaction and have to set up an [SSH
@ -80,8 +81,8 @@ your access based on `localhost` and `127.0.0.1` not being equivalent in its
authentication system: authentication system:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/wordpress"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpress";
Jekyll::WordPress.process("database", "user", "pass", "127.0.0.1")' JekyllImport::WordPress.process("database", "user", "pass", "127.0.0.1")'
{% endhighlight %} {% endhighlight %}
### Further Wordpress migration alternatives ### Further Wordpress migration alternatives
@ -104,29 +105,38 @@ might be useful to you:
## Drupal ## Drupal
If youre migrating from [Drupal](http://drupal.org), there is [a If youre migrating from [Drupal](http://drupal.org), there are two migrators
migrator](https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/drupal.rb) for you, depending upon your Drupal version:
for you too: - [Drupal 6](https://github.com/jekyll/jekyll-import/blob/v0.1.0.beta1/lib/jekyll/jekyll-import/drupal6.rb)
- [Drupal 7](https://github.com/jekyll/jekyll-import/blob/v0.1.0.beta1/lib/jekyll/jekyll-import/drupal7.rb)
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/drupal"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal6";
Jekyll::Drupal.process("database", "user", "pass")' JekyllImport::Drupal6.process("dbname", "user", "pass")'
# ... or ...
$ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal7";
JekyllImport::Drupal7.process("dbname", "user", "pass")'
{% endhighlight %} {% endhighlight %}
<div class="note warning"> If you are connecting to a different host or need to specify a table prefix for
<h5>Warning: Drupal Version Compatibility</h5> your database, you may optionally add those two parameters to the end of either
<p>This migrator was written for Drupal 6.1 and may not work as expected with Drupal migrator execution:
newer versions of Drupal. Please update it and send us a pull request if
necessary.</p> {% highlight bash %}
</div> $ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal6";
JekyllImport::Drupal6.process("dbname", "user", "pass", "host", "table_prefix")'
# ... or ...
$ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal7";
JekyllImport::Drupal7.process("dbname", "user", "pass", "host", "table_prefix")'
{% endhighlight %}
## Movable Type ## Movable Type
To import posts from Movable Type: To import posts from Movable Type:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/mt"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/mt";
Jekyll::MT.process("database", "user", "pass")' JekyllImport::MT.process("database", "user", "pass")'
{% endhighlight %} {% endhighlight %}
## Typo ## Typo
@ -134,8 +144,8 @@ $ ruby -rubygems -e 'require "jekyll/migrators/mt";
To import posts from Typo: To import posts from Typo:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/typo"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/typo";
Jekyll::Typo.process("database", "user", "pass")' JekyllImport::Typo.process("database", "user", "pass")'
{% endhighlight %} {% endhighlight %}
This code has only been tested with Typo version 4+. This code has only been tested with Typo version 4+.
@ -145,8 +155,8 @@ This code has only been tested with Typo version 4+.
To import posts from TextPattern: To import posts from TextPattern:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/textpattern"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/textpattern";
Jekyll::TextPattern.process("database_name", "username", "password", "hostname")' JekyllImport::TextPattern.process("database_name", "username", "password", "hostname")'
{% endhighlight %} {% endhighlight %}
You will need to run the above from the parent directory of your `_import` You will need to run the above from the parent directory of your `_import`
@ -161,15 +171,15 @@ sticky.
To import posts from Mephisto: To import posts from Mephisto:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/mephisto"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/mephisto";
Jekyll::Mephisto.process("database", "user", "password")' JekyllImport::Mephisto.process("database", "user", "password")'
{% endhighlight %} {% endhighlight %}
If your data is in Postgres, you should do this instead: If your data is in Postgres, you should do this instead:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/mephisto"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/mephisto";
Jekyll::Mephisto.postgres({:database => "database", :username=>"username", :password =>"password"})' JekyllImport::Mephisto.postgres({:database => "database", :username=>"username", :password =>"password"})'
{% endhighlight %} {% endhighlight %}
## Blogger (Blogspot) ## Blogger (Blogspot)
@ -196,16 +206,16 @@ alternatives:
To import posts from your primary Posterous blog: To import posts from your primary Posterous blog:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/posterous"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/posterous";
Jekyll::Posterous.process("my_email", "my_pass")' JekyllImport::Posterous.process("my_email", "my_pass")'
{% endhighlight %} {% endhighlight %}
For any other Posterous blog on your account, you will need to specify the For any other Posterous blog on your account, you will need to specify the
`blog_id` for the blog: `blog_id` for the blog:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/posterous"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/posterous";
Jekyll::Posterous.process("my_email", "my_pass", "blog_id")' JekyllImport::Posterous.process("my_email", "my_pass", "blog_id")'
{% endhighlight %} {% endhighlight %}
There is also an [alternative Posterous There is also an [alternative Posterous
@ -217,30 +227,19 @@ that maintains permalinks and attempts to import images too.
To import posts from Tumblr: To import posts from Tumblr:
{% highlight bash %} {% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/tumblr"; $ ruby -rubygems -e 'require "jekyll/jekyll-import/tumblr";
Jekyll::Tumblr.process("http://www.your_blog_url.com", true)' JekyllImport::Tumblr.process(url, format, grab_images, add_highlights, rewrite_urls)'
{% endhighlight %} # url - String: your blog's URL
# format - String: the output file extension. Use "md" to have your content
There is also [a modified Tumblr # converted from HTML to Markdown. Defaults to "html".
migrator](https://github.com/stephenmcd/jekyll/blob/master/lib/jekyll/migrators/tumblr.rb) # grab_images - Boolean: whether to download images as well. Defaults to false.
that exports posts as Markdown and preserves post tags. # add_highlights - Boolean: whether to wrap code blocks (indented 4 spaces) in a Liquid
"highlight" tag. Defaults to false.
The migrator above requires the `json` gem and Python's `html2text` to be # rewrite_urls - Boolean: whether to write pages that redirect from the old Tumblr paths
installed as follows: to the new Jekyll paths. Defaults to false.
{% highlight bash %}
$ gem install json
$ pip install html2text
{% endhighlight %}
Once installed, simply use the format argument:
{% highlight bash %}
$ ruby -rubygems -e 'require "jekyll/migrators/tumblr";
Jekyll::Tumblr.process("http://www.your_blog_url.com", format="md")'
{% endhighlight %} {% endhighlight %}
## Other Systems ## Other Systems
If you have a system for which there is currently no migrator, consider writing If you have a system for which there is currently no migrator, consider writing
one and sending us a pull request. one and sending us [a pull request](https://github.com/jekyll/jekyll-import).

View File

@ -404,6 +404,7 @@ There are a few useful, prebuilt plugins at the following locations:
- [jekyll-rendering](https://github.com/blackwinter/jekyll-rendering): Jekyll plugin to provide alternative rendering engines. - [jekyll-rendering](https://github.com/blackwinter/jekyll-rendering): Jekyll plugin to provide alternative rendering engines.
- [jekyll-pagination](https://github.com/blackwinter/jekyll-pagination): Jekyll plugin to extend the pagination generator. - [jekyll-pagination](https://github.com/blackwinter/jekyll-pagination): Jekyll plugin to extend the pagination generator.
- [jekyll-tagging](https://github.com/pattex/jekyll-tagging): Jekyll plugin to automatically generate a tag cloud and tag pages. - [jekyll-tagging](https://github.com/pattex/jekyll-tagging): Jekyll plugin to automatically generate a tag cloud and tag pages.
- [jekyll-contentblocks](https://github.com/rustygeldmacher/jekyll-contentblocks): Lets you use Rails-like content_for tags in your templates, for passing content from your posts up to your layouts.
- [Generate YouTube Embed (tag)](https://gist.github.com/1805814) by [joelverhagen](https://github.com/joelverhagen): Jekyll plugin which allows you to embed a YouTube video in your page with the YouTube ID. Optionally specify width and height dimensions. Like “oEmbed Tag” but just for YouTube. - [Generate YouTube Embed (tag)](https://gist.github.com/1805814) by [joelverhagen](https://github.com/joelverhagen): Jekyll plugin which allows you to embed a YouTube video in your page with the YouTube ID. Optionally specify width and height dimensions. Like “oEmbed Tag” but just for YouTube.
- [JSON Filter](https://gist.github.com/1850654) by [joelverhagen](https://github.com/joelverhagen): filter that takes input text and outputs it as JSON. Great for rendering JavaScript. - [JSON Filter](https://gist.github.com/1850654) by [joelverhagen](https://github.com/joelverhagen): filter that takes input text and outputs it as JSON. Great for rendering JavaScript.
- [jekyll-beastiepress](https://github.com/okeeblow/jekyll-beastiepress): FreeBSD utility tags for Jekyll sites. - [jekyll-beastiepress](https://github.com/okeeblow/jekyll-beastiepress): FreeBSD utility tags for Jekyll sites.
@ -426,6 +427,8 @@ There are a few useful, prebuilt plugins at the following locations:
- [File compressor](https://gist.github.com/2758691) by [mytharcher](https://github.com/mytharcher): Compress HTML (\*.html) and JavaScript(\*.js) files when output. - [File compressor](https://gist.github.com/2758691) by [mytharcher](https://github.com/mytharcher): Compress HTML (\*.html) and JavaScript(\*.js) files when output.
- [smilify](https://github.com/SaswatPadhi/jekyll_smilify) by [SaswatPadhi](https://github.com/SaswatPadhi): Convert text emoticons in your content to themeable smiley pics. [Demo](http://saswatpadhi.github.com/) - [smilify](https://github.com/SaswatPadhi/jekyll_smilify) by [SaswatPadhi](https://github.com/SaswatPadhi): Convert text emoticons in your content to themeable smiley pics. [Demo](http://saswatpadhi.github.com/)
- [excerpts](http://blog.darkrefraction.com/2012/jekyll-excerpt-plugin.html) by [drawoc](https://github.com/drawoc): provides a nice way to implement page excerpts. - [excerpts](http://blog.darkrefraction.com/2012/jekyll-excerpt-plugin.html) by [drawoc](https://github.com/drawoc): provides a nice way to implement page excerpts.
- [jekyll-minibundle](https://github.com/tkareine/jekyll-minibundle): Asset bundling and cache busting using external minification tool of your choice, no gem dependencies.
- [JekyllGalleryTag](https://github.com/redwallhp/JekyllGalleryTag) by [redwallhp](https://github.com/redwallhp): Generates thumbnails from a directory of images and displays them in a grid with a Liquid tag.
<div class="note info"> <div class="note info">
<h5>Jekyll Plugins Wanted</h5> <h5>Jekyll Plugins Wanted</h5>

View File

@ -113,11 +113,33 @@ Of course, you have full control over how (and where) you display your posts,
and how you structure your site. You should read more about [how templates and how you structure your site. You should read more about [how templates
work](../templates) with Jekyll if you want to know more. work](../templates) with Jekyll if you want to know more.
## Post excerpts
Each post automatically takes the first block of text, from the beginning of the content
to the first occurrence of `excerpt_separator`, and sets it as the `post.excerpt`.
Take the above example of an index of posts. Perhaps you want to include
a little hint about the post's content by adding the first paragraph of each of your
posts:
{% highlight html %}
<ul>
{% raw %}{% for post in site.posts %}{% endraw %}
<li>
<a href="{% raw %}{{ post.url }}{% endraw %}">{% raw %}{{ post.title }}{% endraw %}</a>
<p>{% raw %}{{ post.excerpt }}{% endraw %}</p>
</li>
{% raw %}{% endfor %}{% endraw %}
</ul>
{% endhighlight %}
If you don't like the automatically-generated post excerpt, it can be overridden by adding
`excerpt` to your post's YAML front-matter.
## Highlighting code snippets ## Highlighting code snippets
Jekyll also has built-in support for syntax highlighting of code snippets using Jekyll also has built-in support for syntax highlighting of code snippets using
[Pygments](../extras), and including a code snippet in any post is easy. Just Pygments, and including a code snippet in any post is easy. Just use the
use the dedicated Liquid tag as follows: dedicated Liquid tag as follows:
{% highlight text %} {% highlight text %}
{% raw %}{% highlight ruby %}{% endraw %} {% raw %}{% highlight ruby %}{% endraw %}

View File

@ -37,6 +37,20 @@ common tasks easier.
</p> </p>
</td> </td>
</tr> </tr>
<tr>
<td>
<p class='name'><strong>Date to RFC-822 Format</strong></p>
<p>Convert a Date into the RFC-822 format used for RSS feeds.</p>
</td>
<td class='align-center'>
<p>
<code class='filter'>{% raw %}{{ site.time | date_to_rfc822 }}{% endraw %}</code>
</p>
<p>
<code class='output'>Mon, 17 Nov 2008 13:07:54 -0800</code>
</p>
</td>
</tr>
<tr> <tr>
<td> <td>
<p class='name'><strong>Date to String</strong></p> <p class='name'><strong>Date to String</strong></p>
@ -93,6 +107,22 @@ common tasks easier.
</p> </p>
</td> </td>
</tr> </tr>
<tr>
<td>
<p class='name'><strong>URI Escape</strong></p>
<p>
URI escape a string.
</p>
</td>
<td class='align-center'>
<p>
<code class='filter'>{% raw %}{{ “'foo, bar \\baz?'” | uri_escape }}{% endraw %}</code>
</p>
<p>
<code class='output'>foo,%20bar%20%5Cbaz?</code>
</p>
</td>
</tr>
<tr> <tr>
<td> <td>
<p class='name'><strong>Number of Words</strong></p> <p class='name'><strong>Number of Words</strong></p>
@ -166,9 +196,8 @@ root of your source directory. This will embed the contents of
Jekyll has built in support for syntax highlighting of [over 100 Jekyll has built in support for syntax highlighting of [over 100
languages](http://pygments.org/languages/) thanks to languages](http://pygments.org/languages/) thanks to
[Pygments](http://pygments.org/). In order to take advantage of this youll need [Pygments](http://pygments.org/). When you run Jekyll, make sure you run it
to have Pygments installed, and the `pygmentize` binary must be in your `$PATH`. with `pygments` set to `true` in your configuration file.
When you run Jekyll, make sure you run it with [Pygments enabled](../extras).
To render a code block with syntax highlighting, surround your code as follows: To render a code block with syntax highlighting, surround your code as follows:

View File

@ -25,11 +25,11 @@ and `jekyll serve` to do the same. And if you want Jekyll to automatically
rebuild each time a file changes, just add the `--watch` flag at the end. rebuild each time a file changes, just add the `--watch` flag at the end.
<div class="note info"> <div class="note info">
<h5 markdown="1">Watching and Serving</h5> <h5>Watching and Serving</h5>
<p markdown="1">With the new subcommands, the way sites are previewed locally <p markdown="1">With the new subcommands, the way sites are previewed locally
changed a bit. Instead of specifying `server: true` in the site's changed a bit. Instead of specifying `server: true` in the site's
configuration file, use `jekyll serve`. The same hold's true for configuration file, use `jekyll serve`. The same hold's true for
`watch: true`. Instead, use the `--watch` flag with either `jekyll serve` `watch: true`. Instead, use the `&#45;&#45;watch` flag with either `jekyll serve`
or `jekyll build`.</p> or `jekyll build`.</p>
</div> </div>
@ -40,8 +40,8 @@ Until v1.1, it is **opt-in**. Starting with v1.1, however, absolute permalinks
will become **opt-out**, meaning Jekyll will default to using absolute permalinks will become **opt-out**, meaning Jekyll will default to using absolute permalinks
instead of relative permalinks. instead of relative permalinks.
* To use absolute permalinks, set `relative_permalinks: true` in your configuration file. * To use absolute permalinks, set `relative_permalinks: false` in your configuration file.
* To continue using relative permalinks, set `relative_permalinks: false` in your configuration file. * To continue using relative permalinks, set `relative_permalinks: true` in your configuration file.
<div class="note warning" id="absolute-permalinks-warning"> <div class="note warning" id="absolute-permalinks-warning">
<h5 markdown="1">Absolute permalinks will be default in v1.1 and on</h5> <h5 markdown="1">Absolute permalinks will be default in v1.1 and on</h5>
@ -73,14 +73,14 @@ to one or more config files (comma-delimited, no spaces).
* `--paginate` * `--paginate`
<div class="note info"> <div class="note info">
<h5 markdown="1">The `--config` explicitly specifies your configuration file(s)</h5> <h5>The config flag explicitly specifies your configuration file(s)</h5>
<p markdown="1">If you use the `--config` flag, Jekyll will ignore your <p markdown="1">If you use the `&#45;&#45;config` flag, Jekyll will ignore your
`config.yml` file. Want to merge a custom configuration with the normal `&#95;config.yml` file. Want to merge a custom configuration with the normal
configuration? No problem. Jekyll will accept more than one custom config configuration? No problem. Jekyll will accept more than one custom config
file via the command line. Config files cascade from right to left, such file via the command line. Config files cascade from right to left, such
that if I run `jekyll serve --config config.yml,config-dev.yml`, that if I run `jekyll serve &#45;&#45;config &#95;config.yml,&#95;config-dev.yml`,
the values in the config files on the right (`config-dev.yml`) overwrite the values in the config files on the right (`&#95;config-dev.yml`) overwrite
those on the left (`config.yml`) when both contain the same key.</p> those on the left (`&#95;config.yml`) when both contain the same key.</p>
</div> </div>
### Draft posts ### Draft posts
@ -89,11 +89,12 @@ Jekyll now lets you write draft posts, and allows you to easily preview how
they will look prior to publishing. To start a draft, simply create a folder they will look prior to publishing. To start a draft, simply create a folder
called `_drafts` in your site's source directory (e.g., alongside `_posts`), called `_drafts` in your site's source directory (e.g., alongside `_posts`),
and add a new markdown file to it. To preview your new post, simply run the and add a new markdown file to it. To preview your new post, simply run the
`Jekyll serve` command with the `--drafts` flag. `jekyll serve` command with the `--drafts` flag.
<div class="note info"> <div class="note info">
<h5 markdown="1">Drafts don't have dates</h5> <h5 markdown="1">Drafts don't have dates</h5>
<p markdown="1">Unlike posts, drafts don't have a date, since they haven't <p markdown="1">
Unlike posts, drafts don't have a date, since they haven't
been published yet. Rather than naming your draft something like been published yet. Rather than naming your draft something like
`2013-07-01-my-draft-post.md`, simply name the file what you'd like your `2013-07-01-my-draft-post.md`, simply name the file what you'd like your
post to eventually be titled, here `my-draft-post.md`.</p> post to eventually be titled, here `my-draft-post.md`.</p>

View File

@ -53,7 +53,9 @@ class TestConfiguration < Test::Unit::TestCase
@config = Configuration[{ @config = Configuration[{
"auto" => true, "auto" => true,
"watch" => true, "watch" => true,
"server" => true "server" => true,
"exclude" => "READ-ME.md, Gemfile,CONTRIBUTING.hello.markdown",
"include" => "STOP_THE_PRESSES.txt,.heloses, .git"
}] }]
end end
should "unset 'auto' and 'watch'" do should "unset 'auto' and 'watch'" do
@ -66,6 +68,16 @@ class TestConfiguration < Test::Unit::TestCase
assert @config.has_key?("server") assert @config.has_key?("server")
assert !@config.backwards_compatibilize.has_key?("server") assert !@config.backwards_compatibilize.has_key?("server")
end end
should "transform string exclude into an array" do
assert @config.has_key?("exclude")
assert @config.backwards_compatibilize.has_key?("exclude")
assert_equal @config.backwards_compatibilize["exclude"], %w[READ-ME.md Gemfile CONTRIBUTING.hello.markdown]
end
should "transform string include into an array" do
assert @config.has_key?("include")
assert @config.backwards_compatibilize.has_key?("include")
assert_equal @config.backwards_compatibilize["include"], %w[STOP_THE_PRESSES.txt .heloses .git]
end
end end
context "loading configuration" do context "loading configuration" do
setup do setup do

View File

@ -11,6 +11,13 @@ class TestPager < Test::Unit::TestCase
assert_equal(3, Pager.calculate_pages([1,2,3,4,5], '2')) assert_equal(3, Pager.calculate_pages([1,2,3,4,5], '2'))
end end
should "determine the pagination path" do
assert_nil(Pager.paginate_path(Jekyll::Configuration::DEFAULTS, 1))
assert_equal("page2", Pager.paginate_path(Jekyll::Configuration::DEFAULTS, 2))
assert_nil(Pager.paginate_path(Jekyll::Configuration::DEFAULTS.merge('paginate_path' => '/blog/page-:num'), 1))
assert_equal("page-2", Pager.paginate_path(Jekyll::Configuration::DEFAULTS.merge('paginate_path' => '/blog/page-:num'), 2))
end
context "pagination disabled" do context "pagination disabled" do
setup do setup do
stub(Jekyll).configuration do stub(Jekyll).configuration do

View File

@ -0,0 +1,41 @@
require 'helper'
class TestRelatedPosts < Test::Unit::TestCase
context "building related posts without lsi" do
setup do
stub(Jekyll).configuration do
Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir,
'destination' => dest_dir})
end
@site = Site.new(Jekyll.configuration)
end
should "use the most recent posts for related posts" do
@site.reset
@site.read
assert_equal @site.posts[0..9], Jekyll::RelatedPosts.new(@site.posts.last).build
end
end
context "building related posts with lsi" do
setup do
stub(Jekyll).configuration do
Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir,
'destination' => dest_dir,
'lsi' => true})
end
@site = Site.new(Jekyll.configuration)
end
should "use lsi for the related posts" do
@site.reset
@site.read
require 'classifier'
any_instance_of(::Classifier::LSI) do |c|
stub(c).find_related { @site.posts[-1..-9] }
stub(c).build_index
end
assert_equal @site.posts[-1..-9], Jekyll::RelatedPosts.new(@site.posts.last).build
end
end
end