Merge branch 'master' into changelist_page
This commit is contained in:
commit
20eda0e89f
|
@ -2,13 +2,38 @@
|
|||
### Major 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
|
||||
* 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
|
||||
* 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 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
|
||||
* Fix pesky Cucumber infinite loop (#1139)
|
||||
* Do not write posts with timezones in Cucumber tests (#1124)
|
||||
|
||||
## 1.0.2 / 2013-05-12
|
||||
|
||||
|
|
|
@ -37,8 +37,10 @@ command :new do |c|
|
|||
c.syntax = 'jekyll new 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|
|
||||
Jekyll::Commands::New.process(args)
|
||||
Jekyll::Commands::New.process(args, options.__hash__)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ Feature: Draft Posts
|
|||
As a hacker who likes to blog
|
||||
I want to be able to preview drafts locally
|
||||
In order to see if they look alright before publishing
|
||||
|
||||
|
||||
Scenario: Preview a draft
|
||||
Given I have a configuration file with "permalink" set to "none"
|
||||
And I have a _drafts directory
|
||||
|
|
|
@ -117,7 +117,7 @@ Feature: Post data
|
|||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
|
||||
Scenario: Use post.categories variable when category is in YAML and is mixed-case
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
|
@ -128,7 +128,7 @@ Feature: Post data
|
|||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
|
||||
|
||||
|
||||
Scenario: Use post.categories variable when category is in YAML
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
|
|
|
@ -47,44 +47,38 @@ Given /^I have an? (.*) directory$/ do |dir|
|
|||
FileUtils.mkdir_p(dir)
|
||||
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|
|
||||
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
||||
|
||||
if direction && direction == "in"
|
||||
before = folder || '.'
|
||||
elsif direction && direction == "under"
|
||||
after = folder || '.'
|
||||
end
|
||||
|
||||
title = slug(post['title'])
|
||||
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
|
||||
path = File.join(before || '.', '_drafts', after || '.', "#{title}.#{ext}")
|
||||
else
|
||||
format = if has_time_component?(post['date'])
|
||||
'%Y-%m-%d %H:%M %z'
|
||||
else
|
||||
'%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}")
|
||||
folder_post = '_drafts'
|
||||
filename = "#{title}.#{ext}"
|
||||
elsif "post" == status
|
||||
folder_post = '_posts'
|
||||
filename = "#{parsed_date.strftime('%Y-%m-%d')}-#{title}.#{ext}"
|
||||
end
|
||||
|
||||
path = File.join(before, folder_post, after, filename)
|
||||
|
||||
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]
|
||||
end
|
||||
if "post" == status
|
||||
matter_hash["date"] = post["date"] if post["date"]
|
||||
end
|
||||
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp
|
||||
|
||||
content = post['content']
|
||||
if post['input'] && post['filter']
|
||||
content = "{{ #{post['input']} | #{post['filter']} }}"
|
||||
content = if post['input'] && post['filter']
|
||||
"{{ #{post['input']} | #{post['filter']} }}"
|
||||
else
|
||||
post['content']
|
||||
end
|
||||
|
||||
File.open(path, 'w') do |f|
|
||||
|
|
|
@ -2,10 +2,6 @@ require 'fileutils'
|
|||
require 'rr'
|
||||
require 'test/unit'
|
||||
|
||||
World do
|
||||
include Test::Unit::Assertions
|
||||
end
|
||||
|
||||
TEST_DIR = File.join('/', 'tmp', 'jekyll')
|
||||
JEKYLL_PATH = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'jekyll')
|
||||
|
||||
|
@ -17,9 +13,29 @@ def run_jekyll(opts = {})
|
|||
system command
|
||||
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)
|
||||
date_string.split(" ").size > 1
|
||||
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)
|
||||
Test::Unit.run = true if RUBY_VERSION < '1.9'
|
||||
|
|
|
@ -37,7 +37,7 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency('rdoc', "~> 3.11")
|
||||
s.add_development_dependency('redgreen', "~> 1.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('RedCloth', "~> 4.2")
|
||||
s.add_development_dependency('rdiscount', "~> 1.6")
|
||||
|
@ -92,13 +92,14 @@ Gem::Specification.new do |s|
|
|||
lib/jekyll/generator.rb
|
||||
lib/jekyll/generators/pagination.rb
|
||||
lib/jekyll/layout.rb
|
||||
lib/jekyll/logger.rb
|
||||
lib/jekyll/mime.types
|
||||
lib/jekyll/page.rb
|
||||
lib/jekyll/plugin.rb
|
||||
lib/jekyll/post.rb
|
||||
lib/jekyll/related_posts.rb
|
||||
lib/jekyll/site.rb
|
||||
lib/jekyll/static_file.rb
|
||||
lib/jekyll/stevenson.rb
|
||||
lib/jekyll/tags/gist.rb
|
||||
lib/jekyll/tags/highlight.rb
|
||||
lib/jekyll/tags/include.rb
|
||||
|
@ -236,6 +237,7 @@ Gem::Specification.new do |s|
|
|||
test/test_rdiscount.rb
|
||||
test/test_redcarpet.rb
|
||||
test/test_redcloth.rb
|
||||
test/test_related_posts.rb
|
||||
test/test_site.rb
|
||||
test/test_tags.rb
|
||||
]
|
||||
|
|
|
@ -28,7 +28,7 @@ require 'colorator'
|
|||
|
||||
# internal requires
|
||||
require 'jekyll/core_ext'
|
||||
require 'jekyll/logger'
|
||||
require 'jekyll/stevenson'
|
||||
require 'jekyll/deprecator'
|
||||
require 'jekyll/configuration'
|
||||
require 'jekyll/site'
|
||||
|
@ -40,6 +40,7 @@ require 'jekyll/draft'
|
|||
require 'jekyll/filters'
|
||||
require 'jekyll/static_file'
|
||||
require 'jekyll/errors'
|
||||
require 'jekyll/related_posts'
|
||||
|
||||
# extensions
|
||||
require 'jekyll/plugin'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,7 +7,7 @@ module Jekyll
|
|||
site.read
|
||||
|
||||
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
|
||||
|
||||
|
@ -15,7 +15,7 @@ module Jekyll
|
|||
contains_deprecated_pages = false
|
||||
site.pages.each do |page|
|
||||
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" +
|
||||
" Jekyll v1.1 and beyond."
|
||||
contains_deprecated_pages = true
|
||||
|
|
|
@ -3,13 +3,13 @@ require 'erb'
|
|||
module Jekyll
|
||||
module Commands
|
||||
class New < Command
|
||||
def self.process(args)
|
||||
def self.process(args, options = {})
|
||||
raise ArgumentError.new('You must specify a path.') if args.empty?
|
||||
|
||||
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."
|
||||
if preserve_source_location?(new_blog_path, options)
|
||||
Jekyll::Stevenson.error "Conflict:", "#{new_blog_path} exists and is not empty."
|
||||
exit(1)
|
||||
end
|
||||
|
||||
|
@ -33,6 +33,11 @@ module Jekyll
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def self.preserve_source_location?(path, options)
|
||||
!options[:force] && !Dir["#{path}/**/*"].empty?
|
||||
end
|
||||
|
||||
def self.create_sample_files(path)
|
||||
FileUtils.cp_r site_template + '/.', path
|
||||
FileUtils.rm File.expand_path(scaffold_path, path)
|
||||
|
|
|
@ -115,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
|
||||
|
||||
|
@ -135,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
|
||||
|
@ -145,6 +145,15 @@ module Jekyll
|
|||
configuration.backwards_compatibilize
|
||||
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
|
||||
# backwards-compatibility with Jekyll pre-1.0
|
||||
#
|
||||
|
@ -153,7 +162,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')
|
||||
|
@ -161,14 +170,14 @@ 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::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" +
|
||||
" file accordingly."
|
||||
# copy but don't overwrite:
|
||||
|
@ -176,6 +185,22 @@ module Jekyll
|
|||
config.delete('server_port')
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ module Jekyll
|
|||
self.data = YAML.safe_load($1)
|
||||
end
|
||||
rescue SyntaxError => e
|
||||
puts "YAML Exception reading #{File.join(base, name)}: #{e.message}"
|
||||
puts "YAML Exception reading #{File.join(base, name)}: #{e.message}"
|
||||
rescue Exception => e
|
||||
puts "Error reading file #{File.join(base, name)}: #{e.message}"
|
||||
end
|
||||
|
@ -76,11 +76,8 @@ 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]}"
|
||||
e.backtrace.each do |backtrace|
|
||||
puts backtrace
|
||||
end
|
||||
abort("Build Failed")
|
||||
Jekyll::Stevenson.error "Liquid Exception:", "#{e.message} in #{payload[:file]}"
|
||||
raise e
|
||||
end
|
||||
|
||||
# Recursively render layouts
|
||||
|
@ -99,7 +96,7 @@ module Jekyll
|
|||
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
||||
|
||||
self.output = self.render_liquid(layout.content,
|
||||
payload.merge({:file => self.data["layout"]}),
|
||||
payload.merge({:file => layout.name}),
|
||||
info)
|
||||
|
||||
if layout = layouts[layout.data["layout"]]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -99,7 +99,17 @@ module Jekyll
|
|||
def cgi_escape(input)
|
||||
CGI::escape(input)
|
||||
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)
|
||||
URI.escape(input)
|
||||
end
|
||||
|
@ -146,7 +156,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
|
||||
|
|
|
@ -92,8 +92,9 @@ module Jekyll
|
|||
# Returns the pagination path as a string
|
||||
def self.paginate_path(site_config, num_page)
|
||||
return nil if num_page.nil? || num_page <= 1
|
||||
format = File.basename(site_config['paginate_path'])
|
||||
format.sub(':num', num_page.to_s)
|
||||
format = site_config['paginate_path']
|
||||
format = format.sub(':num', num_page.to_s)
|
||||
File.basename(format)
|
||||
end
|
||||
|
||||
# Initialize a new Pager.
|
||||
|
|
|
@ -5,6 +5,9 @@ module Jekyll
|
|||
# Gets the Site object.
|
||||
attr_reader :site
|
||||
|
||||
# Gets the name of this layout.
|
||||
attr_reader :name
|
||||
|
||||
# Gets/Sets the extension of this layout.
|
||||
attr_accessor :ext
|
||||
|
||||
|
|
|
@ -244,29 +244,7 @@ module Jekyll
|
|||
#
|
||||
# Returns an Array of related Posts.
|
||||
def related_posts(posts)
|
||||
return [] unless posts.size > 1
|
||||
|
||||
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
|
||||
Jekyll::RelatedPosts.new(self).build
|
||||
end
|
||||
|
||||
# Add any necessary layouts to this post.
|
||||
|
|
|
@ -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
|
|
@ -71,8 +71,6 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing.
|
||||
def setup
|
||||
require 'classifier' if self.lsi
|
||||
|
||||
# Check that the destination dir isn't the source dir or a directory
|
||||
# parent to the source dir.
|
||||
if self.source =~ /^#{self.dest}/
|
||||
|
@ -423,12 +421,12 @@ module Jekyll
|
|||
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" +
|
||||
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::Logger.formatted_topic("") + "..." # for "done."
|
||||
$stderr.print Jekyll::Stevenson.formatted_topic("") + "..." # for "done."
|
||||
@deprecated_relative_permalinks = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'logger'
|
||||
|
||||
module Jekyll
|
||||
class Logger < Logger
|
||||
class Stevenson
|
||||
# Public: Print a jekyll message to stdout
|
||||
#
|
||||
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
|
|
@ -21,7 +21,7 @@
|
|||
<h1 class="title"><a href="/">{{ site.name }}</a></h1>
|
||||
<a class="extra" href="/">home</a>
|
||||
</div>
|
||||
|
||||
|
||||
{{ content }}
|
||||
|
||||
<div class="footer">
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
.highlight .gr { color: #c0c0c0; font-weight: bold; background-color: #c00000 } /* Generic.Error */
|
||||
.highlight .gh { color: #cd5c5c} /* Generic.Heading */
|
||||
.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 .gs { color: #ffffff} /* Generic.Strong */
|
||||
.highlight .gu { color: #cd5c5c} /* Generic.Subheading */
|
||||
|
|
|
@ -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;
|
||||
color: #fff;
|
||||
border-radius: 5px;
|
||||
|
@ -528,10 +528,17 @@ pre, code {
|
|||
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 {
|
||||
padding: 10px 0;
|
||||
width: 100%;
|
||||
overflow: scroll;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* HTML Elements */
|
||||
|
|
|
@ -50,10 +50,8 @@ community can improve the experience for everyone.
|
|||
|
||||
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
|
||||
include syntax highlighting of code snippets using
|
||||
[Pygments](http://pygments.org/), LaTeX support, and the use of alternative
|
||||
content rendering engines. Check out [the extras page](../extras) for more
|
||||
information.
|
||||
include LaTeX support, and the use of alternative content rendering engines.
|
||||
Check out [the extras page](../extras) for more information.
|
||||
|
||||
<div class="note">
|
||||
<h5>ProTip™: Enable Syntax Highlighting</h5>
|
||||
|
|
|
@ -15,12 +15,13 @@ the foreign system.
|
|||
## Preparing for migrations
|
||||
|
||||
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
|
||||
to do is install the gem, and they will become available as part of Jekyll's
|
||||
standard command line interface.
|
||||
available via a separate gem called
|
||||
[`jekyll-import`](https://github.com/jekyll/jekyll-import). To use them, all
|
||||
you need to do is install the gem, and they will become available as part of
|
||||
Jekyll's standard command line interface.
|
||||
|
||||
{% highlight bash %}
|
||||
$ gem install jekyll-import
|
||||
$ gem install jekyll-import --pre
|
||||
{% endhighlight %}
|
||||
|
||||
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:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/wordpressdotcom";
|
||||
Jekyll::WordpressDotCom.process("wordpress.xml")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpressdotcom";
|
||||
JekyllImport::WordpressDotCom.process("wordpress.xml")'
|
||||
{% endhighlight %}
|
||||
|
||||
<div class="note">
|
||||
<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>
|
||||
|
||||
### 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:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/wordpress";
|
||||
Jekyll::WordPress.process("database", "user", "pass")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpress";
|
||||
JekyllImport::WordPress.process("database", "user", "pass")'
|
||||
{% endhighlight %}
|
||||
|
||||
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:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/wordpress";
|
||||
Jekyll::WordPress.process("database", "user", "pass", "127.0.0.1")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/wordpress";
|
||||
JekyllImport::WordPress.process("database", "user", "pass", "127.0.0.1")'
|
||||
{% endhighlight %}
|
||||
|
||||
### Further Wordpress migration alternatives
|
||||
|
@ -104,29 +105,38 @@ might be useful to you:
|
|||
|
||||
## Drupal
|
||||
|
||||
If you’re migrating from [Drupal](http://drupal.org), there is [a
|
||||
migrator](https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/drupal.rb)
|
||||
for you too:
|
||||
If you’re migrating from [Drupal](http://drupal.org), there are two migrators
|
||||
for you, depending upon your Drupal version:
|
||||
- [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 %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/drupal";
|
||||
Jekyll::Drupal.process("database", "user", "pass")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal6";
|
||||
JekyllImport::Drupal6.process("dbname", "user", "pass")'
|
||||
# ... or ...
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/drupal7";
|
||||
JekyllImport::Drupal7.process("dbname", "user", "pass")'
|
||||
{% endhighlight %}
|
||||
|
||||
<div class="note warning">
|
||||
<h5>Warning: Drupal Version Compatibility</h5>
|
||||
<p>This migrator was written for Drupal 6.1 and may not work as expected with
|
||||
newer versions of Drupal. Please update it and send us a pull request if
|
||||
necessary.</p>
|
||||
</div>
|
||||
If you are connecting to a different host or need to specify a table prefix for
|
||||
your database, you may optionally add those two parameters to the end of either
|
||||
Drupal migrator execution:
|
||||
|
||||
{% highlight bash %}
|
||||
$ 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
|
||||
|
||||
To import posts from Movable Type:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/mt";
|
||||
Jekyll::MT.process("database", "user", "pass")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/mt";
|
||||
JekyllImport::MT.process("database", "user", "pass")'
|
||||
{% endhighlight %}
|
||||
|
||||
## Typo
|
||||
|
@ -134,8 +144,8 @@ $ ruby -rubygems -e 'require "jekyll/migrators/mt";
|
|||
To import posts from Typo:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/typo";
|
||||
Jekyll::Typo.process("database", "user", "pass")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/typo";
|
||||
JekyllImport::Typo.process("database", "user", "pass")'
|
||||
{% endhighlight %}
|
||||
|
||||
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:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/textpattern";
|
||||
Jekyll::TextPattern.process("database_name", "username", "password", "hostname")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/textpattern";
|
||||
JekyllImport::TextPattern.process("database_name", "username", "password", "hostname")'
|
||||
{% endhighlight %}
|
||||
|
||||
You will need to run the above from the parent directory of your `_import`
|
||||
|
@ -161,15 +171,15 @@ sticky.
|
|||
To import posts from Mephisto:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/mephisto";
|
||||
Jekyll::Mephisto.process("database", "user", "password")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/mephisto";
|
||||
JekyllImport::Mephisto.process("database", "user", "password")'
|
||||
{% endhighlight %}
|
||||
|
||||
If your data is in Postgres, you should do this instead:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/mephisto";
|
||||
Jekyll::Mephisto.postgres({:database => "database", :username=>"username", :password =>"password"})'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/mephisto";
|
||||
JekyllImport::Mephisto.postgres({:database => "database", :username=>"username", :password =>"password"})'
|
||||
{% endhighlight %}
|
||||
|
||||
## Blogger (Blogspot)
|
||||
|
@ -196,16 +206,16 @@ alternatives:
|
|||
To import posts from your primary Posterous blog:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/posterous";
|
||||
Jekyll::Posterous.process("my_email", "my_pass")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/posterous";
|
||||
JekyllImport::Posterous.process("my_email", "my_pass")'
|
||||
{% endhighlight %}
|
||||
|
||||
For any other Posterous blog on your account, you will need to specify the
|
||||
`blog_id` for the blog:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/posterous";
|
||||
Jekyll::Posterous.process("my_email", "my_pass", "blog_id")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/posterous";
|
||||
JekyllImport::Posterous.process("my_email", "my_pass", "blog_id")'
|
||||
{% endhighlight %}
|
||||
|
||||
There is also an [alternative Posterous
|
||||
|
@ -217,30 +227,19 @@ that maintains permalinks and attempts to import images too.
|
|||
To import posts from Tumblr:
|
||||
|
||||
{% highlight bash %}
|
||||
$ ruby -rubygems -e 'require "jekyll/migrators/tumblr";
|
||||
Jekyll::Tumblr.process("http://www.your_blog_url.com", true)'
|
||||
{% endhighlight %}
|
||||
|
||||
There is also [a modified Tumblr
|
||||
migrator](https://github.com/stephenmcd/jekyll/blob/master/lib/jekyll/migrators/tumblr.rb)
|
||||
that exports posts as Markdown and preserves post tags.
|
||||
|
||||
The migrator above requires the `json` gem and Python's `html2text` to be
|
||||
installed as follows:
|
||||
|
||||
{% 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")'
|
||||
$ ruby -rubygems -e 'require "jekyll/jekyll-import/tumblr";
|
||||
JekyllImport::Tumblr.process(url, format, grab_images, add_highlights, rewrite_urls)'
|
||||
# url - String: your blog's URL
|
||||
# format - String: the output file extension. Use "md" to have your content
|
||||
# converted from HTML to Markdown. Defaults to "html".
|
||||
# grab_images - Boolean: whether to download images as well. Defaults to false.
|
||||
# add_highlights - Boolean: whether to wrap code blocks (indented 4 spaces) in a Liquid
|
||||
"highlight" tag. Defaults to false.
|
||||
# rewrite_urls - Boolean: whether to write pages that redirect from the old Tumblr paths
|
||||
to the new Jekyll paths. Defaults to false.
|
||||
{% endhighlight %}
|
||||
|
||||
## Other Systems
|
||||
|
||||
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).
|
||||
|
|
|
@ -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-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-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.
|
||||
- [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.
|
||||
|
@ -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.
|
||||
- [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.
|
||||
- [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">
|
||||
<h5>Jekyll Plugins Wanted</h5>
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
||||
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
|
||||
use the dedicated Liquid tag as follows:
|
||||
Pygments, and including a code snippet in any post is easy. Just use the
|
||||
dedicated Liquid tag as follows:
|
||||
|
||||
{% highlight text %}
|
||||
{% raw %}{% highlight ruby %}{% endraw %}
|
||||
|
|
|
@ -37,6 +37,20 @@ common tasks easier.
|
|||
</p>
|
||||
</td>
|
||||
</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>
|
||||
<td>
|
||||
<p class='name'><strong>Date to String</strong></p>
|
||||
|
@ -93,6 +107,22 @@ common tasks easier.
|
|||
</p>
|
||||
</td>
|
||||
</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>
|
||||
<td>
|
||||
<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
|
||||
languages](http://pygments.org/languages/) thanks to
|
||||
[Pygments](http://pygments.org/). In order to take advantage of this you’ll need
|
||||
to have Pygments installed, and the `pygmentize` binary must be in your `$PATH`.
|
||||
When you run Jekyll, make sure you run it with [Pygments enabled](../extras).
|
||||
[Pygments](http://pygments.org/). When you run Jekyll, make sure you run it
|
||||
with `pygments` set to `true` in your configuration file.
|
||||
|
||||
To render a code block with syntax highlighting, surround your code as follows:
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
<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
|
||||
changed a bit. Instead of specifying `server: true` in the site's
|
||||
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 `--watch` flag with either `jekyll serve`
|
||||
or `jekyll build`.</p>
|
||||
</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
|
||||
instead of relative permalinks.
|
||||
|
||||
* To use absolute permalinks, set `relative_permalinks: true` in your configuration file.
|
||||
* To continue using relative permalinks, set `relative_permalinks: false` in your configuration file.
|
||||
* To use absolute 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">
|
||||
<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`
|
||||
|
||||
<div class="note info">
|
||||
<h5 markdown="1">The `--config` explicitly specifies your configuration file(s)</h5>
|
||||
<p markdown="1">If you use the `--config` flag, Jekyll will ignore your
|
||||
`config.yml` file. Want to merge a custom configuration with the normal
|
||||
<h5>The config flag explicitly specifies your configuration file(s)</h5>
|
||||
<p markdown="1">If you use the `--config` flag, Jekyll will ignore your
|
||||
`_config.yml` file. Want to merge a custom configuration with the normal
|
||||
configuration? No problem. Jekyll will accept more than one custom config
|
||||
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`,
|
||||
the values in the config files on the right (`config-dev.yml`) overwrite
|
||||
those on the left (`config.yml`) when both contain the same key.</p>
|
||||
that if I run `jekyll serve --config _config.yml,_config-dev.yml`,
|
||||
the values in the config files on the right (`_config-dev.yml`) overwrite
|
||||
those on the left (`_config.yml`) when both contain the same key.</p>
|
||||
</div>
|
||||
|
||||
### Draft posts
|
||||
|
@ -89,14 +89,15 @@ 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
|
||||
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
|
||||
`Jekyll serve` command with the `--drafts` flag.
|
||||
`jekyll serve` command with the `--drafts` flag.
|
||||
|
||||
<div class="note info">
|
||||
<h5 markdown="1">Drafts don't have dates</h5>
|
||||
<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
|
||||
`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>
|
||||
<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
|
||||
`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>
|
||||
</div>
|
||||
|
||||
### Baseurl
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div class="title">
|
||||
Tom Preston-Werner
|
||||
</div>
|
||||
|
||||
|
||||
{{ content }}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -51,9 +51,11 @@ class TestConfiguration < Test::Unit::TestCase
|
|||
context "#backwards_compatibilize" do
|
||||
setup do
|
||||
@config = Configuration[{
|
||||
"auto" => true,
|
||||
"watch" => true,
|
||||
"server" => true
|
||||
"auto" => true,
|
||||
"watch" => true,
|
||||
"server" => true,
|
||||
"exclude" => "READ-ME.md, Gemfile,CONTRIBUTING.hello.markdown",
|
||||
"include" => "STOP_THE_PRESSES.txt,.heloses, .git"
|
||||
}]
|
||||
end
|
||||
should "unset 'auto' and 'watch'" do
|
||||
|
@ -66,6 +68,16 @@ class TestConfiguration < Test::Unit::TestCase
|
|||
assert @config.has_key?("server")
|
||||
assert !@config.backwards_compatibilize.has_key?("server")
|
||||
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
|
||||
context "loading configuration" do
|
||||
setup do
|
||||
|
|
|
@ -102,7 +102,7 @@ class TestPage < Test::Unit::TestCase
|
|||
assert_equal "/about/", @page.dir
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with specified layout of nil" do
|
||||
setup do
|
||||
@page = setup_page('sitemap.xml')
|
||||
|
|
|
@ -11,6 +11,13 @@ class TestPager < Test::Unit::TestCase
|
|||
assert_equal(3, Pager.calculate_pages([1,2,3,4,5], '2'))
|
||||
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
|
||||
setup do
|
||||
stub(Jekyll).configuration do
|
||||
|
|
|
@ -139,7 +139,7 @@ class TestPost < Test::Unit::TestCase
|
|||
assert_equal "/2013/2008/09/09/foo-bar.html", @post.url
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with specified layout of nil" do
|
||||
setup do
|
||||
file = '2013-01-12-nil-layout.textile'
|
||||
|
@ -422,7 +422,7 @@ class TestPost < Test::Unit::TestCase
|
|||
post = setup_post("2009-01-27-empty-categories.textile")
|
||||
assert_equal [], post.categories
|
||||
end
|
||||
|
||||
|
||||
should "recognize number category in yaml" do
|
||||
post = setup_post("2013-05-10-number-category.textile")
|
||||
assert post.categories.include?('2013')
|
||||
|
@ -440,7 +440,7 @@ class TestPost < Test::Unit::TestCase
|
|||
assert post.tags.include?('cooking')
|
||||
assert post.tags.include?('pizza')
|
||||
end
|
||||
|
||||
|
||||
should "recognize empty tag in yaml" do
|
||||
post = setup_post("2009-05-18-empty-tag.textile")
|
||||
assert_equal [], post.tags
|
||||
|
@ -528,46 +528,46 @@ class TestPost < Test::Unit::TestCase
|
|||
assert_equal ['foo'], post.categories
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "converter file extension settings" do
|
||||
setup do
|
||||
stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS }
|
||||
@site = Site.new(Jekyll.configuration)
|
||||
end
|
||||
|
||||
|
||||
should "process .md as markdown under default configuration" do
|
||||
post = setup_post '2011-04-12-md-extension.md'
|
||||
conv = post.converter
|
||||
assert conv.kind_of? Jekyll::Converters::Markdown
|
||||
end
|
||||
|
||||
|
||||
should "process .text as identity under default configuration" do
|
||||
post = setup_post '2011-04-12-text-extension.text'
|
||||
conv = post.converter
|
||||
assert conv.kind_of? Jekyll::Converters::Identity
|
||||
end
|
||||
|
||||
|
||||
should "process .text as markdown under alternate configuration" do
|
||||
@site.config['markdown_ext'] = 'markdown,mdw,mdwn,md,text'
|
||||
post = setup_post '2011-04-12-text-extension.text'
|
||||
conv = post.converter
|
||||
assert conv.kind_of? Jekyll::Converters::Markdown
|
||||
end
|
||||
|
||||
|
||||
should "process .md as markdown under alternate configuration" do
|
||||
@site.config['markdown_ext'] = 'markdown,mkd,mkdn,md,text'
|
||||
post = setup_post '2011-04-12-text-extension.text'
|
||||
conv = post.converter
|
||||
assert conv.kind_of? Jekyll::Converters::Markdown
|
||||
end
|
||||
|
||||
|
||||
should "process .text as textile under alternate configuration" do
|
||||
@site.config['textile_ext'] = 'textile,text'
|
||||
post = setup_post '2011-04-12-text-extension.text'
|
||||
conv = post.converter
|
||||
assert conv.kind_of? Jekyll::Converters::Textile
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class TestRedCloth < Test::Unit::TestCase
|
|||
setup do
|
||||
@textile = Converters::Textile.new
|
||||
end
|
||||
|
||||
|
||||
should "preserve single line breaks in HTML output" do
|
||||
assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ class TestRedCloth < Test::Unit::TestCase
|
|||
}
|
||||
@textile = Converters::Textile.new config
|
||||
end
|
||||
|
||||
|
||||
should "preserve single line breaks in HTML output" do
|
||||
assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ class TestRedCloth < Test::Unit::TestCase
|
|||
}
|
||||
@textile = Converters::Textile.new config
|
||||
end
|
||||
|
||||
|
||||
should "preserve single line breaks in HTML output" do
|
||||
assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
|
||||
end
|
||||
|
|
|
@ -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
|
|
@ -195,7 +195,7 @@ class TestSite < Test::Unit::TestCase
|
|||
@site.exclude = excludes + ["exclude*"]
|
||||
assert_equal files, @site.filter_entries(excludes + files + ["excludeA"])
|
||||
end
|
||||
|
||||
|
||||
should "not filter entries within include" do
|
||||
includes = %w[_index.html .htaccess include*]
|
||||
files = %w[index.html _index.html .htaccess includeA]
|
||||
|
@ -284,7 +284,7 @@ class TestSite < Test::Unit::TestCase
|
|||
File.open(dest_dir('.svn/HEAD'), 'w')
|
||||
File.open(dest_dir('.hg/HEAD'), 'w')
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_f(dest_dir('obsolete.html'))
|
||||
FileUtils.rm_rf(dest_dir('qux'))
|
||||
|
@ -293,7 +293,7 @@ class TestSite < Test::Unit::TestCase
|
|||
FileUtils.rm_rf(dest_dir('.svn'))
|
||||
FileUtils.rm_rf(dest_dir('.hg'))
|
||||
end
|
||||
|
||||
|
||||
should 'remove orphaned files in destination' do
|
||||
@site.process
|
||||
assert !File.exist?(dest_dir('obsolete.html'))
|
||||
|
@ -317,7 +317,7 @@ class TestSite < Test::Unit::TestCase
|
|||
assert File.exist?(dest_dir('.svn/HEAD'))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'with an invalid markdown processor in the configuration' do
|
||||
should 'not throw an error at initialization time' do
|
||||
bad_processor = 'not a processor name'
|
||||
|
@ -325,7 +325,7 @@ class TestSite < Test::Unit::TestCase
|
|||
Site.new(Jekyll.configuration.merge({ 'markdown' => bad_processor }))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
should 'throw FatalException at process time' do
|
||||
bad_processor = 'not a processor name'
|
||||
s = Site.new(Jekyll.configuration.merge({ 'markdown' => bad_processor }))
|
||||
|
@ -334,6 +334,6 @@ class TestSite < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue