Compare commits

..

35 Commits

Author SHA1 Message Date
Parker Moore
ed2d30dc88 URL#generate_url_from_drop: optimizations to reduce object creation & speed things up 2017-08-02 20:18:11 -04:00
Parker Moore
3088032128 Hash#reduce vs Hash#each_with_object :thinking_face: 2017-08-02 17:58:34 -04:00
Parker Moore
56436f46fe Update History.markdown to unify Bug Fixes and fix 2017-07-30 19:20:21 -04:00
jekyllbot
34967978c2 Update history to reflect merge of #6253 [ci skip] 2017-07-30 15:12:43 -04:00
Ben Balter
b35c0d8607 Call to_s on site.url before attempting to concatenate strings (#6253)
Merge pull request 6253
2017-07-30 15:12:42 -04:00
jekyllbot
a6efa48883 Update history to reflect merge of #6255 [ci skip] 2017-07-30 14:32:26 -04:00
Frank Taillandier
12832af98e docs: add missing backticks in History (#6255)
Merge pull request 6255
2017-07-30 14:32:25 -04:00
jekyllbot
f8d06f20aa Update history to reflect merge of #6247 [ci skip] 2017-07-28 12:05:45 -04:00
Parker Moore
143367c5ca kramdown: symbolize keys in-place (#6247)
Merge pull request 6247
2017-07-28 12:05:43 -04:00
jekyllbot
592daf4ce2 Update history to reflect merge of #6239 [ci skip] 2017-07-26 20:09:35 -04:00
ashmaroli
82c219a2e7 exit site.process sooner (#6239)
Merge pull request 6239
2017-07-26 20:09:33 -04:00
jekyllbot
590dd6cf80 Update history to reflect merge of #6087 [ci skip] 2017-07-25 19:20:21 -04:00
Bogdan
8f1959bbc4 Define path with __dir__ (#6087)
Merge pull request 6087
2017-07-25 19:20:20 -04:00
jekyllbot
8a017b5a2a Update history to reflect merge of #6220 [ci skip] 2017-07-25 18:45:45 -04:00
ashmaroli
96724af03e Bump supported Ruby version to >= 2.1.0 (#6220)
Merge pull request 6220
2017-07-25 18:45:44 -04:00
jekyllbot
4493f2a58b Update history to reflect merge of #6225 [ci skip] 2017-07-25 18:23:39 -04:00
Joshua Byrd
93169f60c3 Adding DevKit helpers (#6225)
Merge pull request 6225
2017-07-25 18:23:38 -04:00
jekyllbot
7b255baac2 Update history to reflect merge of #6226 [ci skip] 2017-07-25 18:23:04 -04:00
Parker Moore
188bc71713 Reader#read_directories: guard against an entry not being a directory (#6226)
Merge pull request 6226
2017-07-25 18:23:02 -04:00
jekyllbot
897cdbb427 Update history to reflect merge of #6231 [ci skip] 2017-07-25 18:22:41 -04:00
Matt Sturgeon
ec84bec6d6 Fix serving files that clash with directories (#6231)
Merge pull request 6231
2017-07-25 18:22:40 -04:00
jekyllbot
819491b99c Update history to reflect merge of #6240 [ci skip] 2017-07-25 06:28:18 -04:00
ashmaroli
00a1d70e8f fix tests (#6240)
Merge pull request 6240
2017-07-25 06:28:17 -04:00
jekyllbot
66c39d3bf9 Update history to reflect merge of #6198 [ci skip] 2017-07-24 06:02:25 -04:00
Jordon Bedwell
e25c4af590 Users should be installing patch versions. (#6198)
Merge pull request 6198
2017-07-24 06:02:24 -04:00
jekyllbot
1a592c5757 Update history to reflect merge of #6218 [ci skip] 2017-07-24 05:55:07 -04:00
Maciej Bembenista
a54906c78a Update custom-404-page.md - fix a typo (#6218)
Merge pull request 6218
2017-07-24 05:55:06 -04:00
jekyllbot
56546a28fd Update history to reflect merge of #6229 [ci skip] 2017-07-18 08:11:25 -04:00
ashmaroli
c0c1185c56 deprecator.rb: fix typo for --serve command (#6229)
Merge pull request 6229
2017-07-18 08:11:23 -04:00
jekyllbot
c2b240e9b5 Update history to reflect merge of #5760 [ci skip] 2017-07-18 08:06:07 -04:00
Pat Hawks
da65e94728 Add URL checks to Doctor (#5760)
Merge pull request 5760
2017-07-18 08:06:05 -04:00
jekyllbot
2b28f9fd57 Update history to reflect merge of #6054 [ci skip] 2017-07-18 03:29:34 -04:00
ashmaroli
026f8280e0 Ignore final newline in folded YAML string (#6054)
Merge pull request 6054
2017-07-18 03:29:33 -04:00
jekyllbot
33cb629079 Update history to reflect merge of #6228 [ci skip] 2017-07-18 02:55:56 -04:00
ashmaroli
f904a7201e strip unnecessary leading whitespace (#6228)
Merge pull request 6228
2017-07-18 02:55:54 -04:00
33 changed files with 186 additions and 79 deletions

View File

@@ -27,8 +27,8 @@ group :test do
gem "rspec"
gem "rspec-mocks"
gem "rubocop", "~> 0.49.1"
gem "test-dependency-theme", :path => File.expand_path("./test/fixtures/test-dependency-theme", File.dirname(__FILE__))
gem "test-theme", :path => File.expand_path("./test/fixtures/test-theme", File.dirname(__FILE__))
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)
gem "jruby-openssl" if RUBY_ENGINE == "jruby"
end
@@ -53,6 +53,7 @@ end
group :benchmark do
if ENV["BENCHMARK"]
gem "benchmark-ips"
gem "benchmark-memory"
gem "rbtrace"
gem "ruby-prof"
gem "stackprof"

View File

@@ -1,13 +1,35 @@
## 3.5.2 / 2017-08-12
## HEAD
### Development Fixes
* Strip unnecessary leading whitespace in template (#6228)
* Users should be installing patch versions. (#6198)
* fix tests (#6240)
* Define path with __dir__ (#6087)
* exit site.process sooner (#6239)
### Minor Enhancements
* Ignore final newline in folded YAML string (#6054)
* Add URL checks to Doctor (#5760)
* Fix serving files that clash with directories (#6222) (#6231)
* Bump supported Ruby version to `>= 2.1.0` (#6220)
### Bug Fixes
* Backport #6281 for v3.5.x: Fix `Drop#key?` so it can handle a nil argument (#6288)
* Backport #6280 for v3.5.x: Guard against type error in `absolute_url` (#6287)
* Backport #6266 for v3.5.x: Memoize the return value of `Document#url` (#6301)
* Backport #6273 for v3.5.x: delegate `StaticFile#to_json` to `StaticFile#to_liquid` (#6302)
* Backport #6226 for v3.5.x: `Reader#read_directories`: guard against an entry not being a directory (#6304)
* Backport #6247 for v3.5.x: kramdown: symbolize keys in-place (#6303)
* `Deprecator`: fix typo for `--serve` command (#6229)
* `Reader#read_directories`: guard against an entry not being a directory (#6226)
* kramdown: symbolize keys in-place (#6247)
* Call to_s on site.url before attempting to concatenate strings (#6253)
### Documentation
* Fix a typo in `custom-404-page.md` (#6218)
* Docs: fix links to issues in History.markdown (#6255)
### Site Enhancements
* Adding DevKit helpers (#6225)
## 3.5.1 / 2017-07-17
@@ -29,7 +51,7 @@
* add plugins for multiple page pagination (#6055)
* Update minimum Ruby version in installation.md (#6164)
* [docs] Add information about finding a collection in `site.collections` (#6165)
* Add {%raw%} to Liquid example on site (#6179)
* Add `{% raw %}` to Liquid example on site (#6179)
* Added improved Pug plugin - removed 404 Jade plugin (#6174)
* Linking the link (#6210)
* Small correction in documentation for includes (#6193)

View File

@@ -4,7 +4,7 @@ require "rdoc"
require "date"
require "yaml"
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
$LOAD_PATH.unshift File.expand_path("lib", __dir__)
require "jekyll/version"
Dir.glob("rake/**.rake").each { |f| import f }

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "benchmark/ips"
require "benchmark/memory"
GC.disable
PERIOD = "."
PROPERTY_AS_HASH = ["hello", "there_oh", "friends"]
property = "hello.there_oh.friends"
item = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
def candidate(property, item)
property.to_s.split(".".freeze).each_with_object(item) do |attribute, memo|
memo = memo[attribute]
end
end
def control(property, item)
property.to_s.split(".").reduce(item) do |subvalue, attribute|
subvalue[attribute]
end
end
Benchmark.ips do |x|
x.report("candidate") { candidate(property, item) }
x.report("control") { control(property, item) }
x.compare!
end
Benchmark.memory do |x|
x.report("candidate") { candidate(property, item) }
x.report("control") { control(property, item) }
x.compare!
end

View File

@@ -212,5 +212,7 @@ As of v1.3.0, Jekyll uses the `listen` gem to watch for changes when the `--watc
Add the following to the Gemfile for your site if you have issues with auto-regeneration on Windows alone:
```ruby
gem 'wdm', '~> 0.1.0' if Gem.win_platform?
gem 'wdm', '~> 0.1.1' if Gem.win_platform?
```
You may first have to download and install the [Ruby DevKit](https://rubyinstaller.org/downloads/) by following [the instructions here](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit).

View File

@@ -53,7 +53,7 @@ More info on configuring Apache Error Pages can found in [official documentation
The procedure is just as simple as configuring Apache servers, but slightly different.
Add the following to the ngnix configuration file, `nginx.conf`, which is usually located inside `/etc/nginx/` or `/etc/nginx/conf/`:
Add the following to the nginx configuration file, `nginx.conf`, which is usually located inside `/etc/nginx/` or `/etc/nginx/conf/`:
```
server {

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
STDOUT.sync = true
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "jekyll"
require "mercenary"

View File

@@ -1,6 +1,6 @@
# coding: utf-8
lib = File.expand_path("../lib", __FILE__)
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "jekyll/version"
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.specification_version = 2 if s.respond_to? :specification_version=
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.rubygems_version = "2.2.2"
s.required_ruby_version = ">= 2.0.0"
s.required_ruby_version = ">= 2.1.0"
s.name = "jekyll"
s.version = Jekyll::VERSION

View File

@@ -1,4 +1,4 @@
$LOAD_PATH.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
$LOAD_PATH.unshift __dir__ # For use/testing when no gem is installed
# Require all of the Ruby files in the given directory.
#
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__) # For use/testing when no gem is insta
#
# Returns nothing.
def require_all(path)
glob = File.join(File.dirname(__FILE__), path, "*.rb")
glob = File.join(__dir__, path, "*.rb")
Dir[glob].sort.each do |f|
require f
end

View File

@@ -1,3 +1,5 @@
require "addressable/uri"
module Jekyll
module Commands
class Doctor < Command
@@ -36,6 +38,7 @@ module Jekyll
!deprecated_relative_permalinks(site),
!conflicting_urls(site),
!urls_only_differ_by_case(site),
proper_site_url?(site),
].all?
end
@@ -91,6 +94,15 @@ module Jekyll
urls_only_differ_by_case
end
def proper_site_url?(site)
url = site.config["url"]
[
url_exists?(url),
url_valid?(url),
url_absolute(url),
].all?
end
private
def collect_urls(urls, things, destination)
things.each do |thing|
@@ -110,6 +122,29 @@ module Jekyll
(memo[dest.downcase] ||= []) << dest
end
end
def url_exists?(url)
return true unless url.nil? || url.empty?
Jekyll.logger.warn "Warning:", "You didn't set an URL in the config file, "\
"you may encounter problems with some plugins."
false
end
def url_valid?(url)
Addressable::URI.parse(url)
true
rescue
Jekyll.logger.warn "Warning:", "The site URL does not seem to be valid, "\
"check the value of `url` in your config file."
false
end
def url_absolute(url)
return true if Addressable::URI.parse(url).absolute?
Jekyll.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
"check the value of `url` in your config file."
false
end
end
end
end

View File

@@ -70,7 +70,7 @@ source "https://rubygems.org"
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "#{Jekyll::VERSION}"
gem "jekyll", "~> #{Jekyll::VERSION}"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.0"
@@ -81,7 +81,7 @@ gem "minima", "~> 2.0"
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
gem "jekyll-feed", "~> 0.6"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
@@ -113,7 +113,7 @@ RUBY
end
def site_template
File.expand_path("../../site_template", File.dirname(__FILE__))
File.expand_path("../../site_template", __dir__)
end
def scaffold_path

View File

@@ -234,7 +234,7 @@ module Jekyll
private
def mime_types
file = File.expand_path("../mime.types", File.dirname(__FILE__))
file = File.expand_path("../mime.types", __dir__)
WEBrick::HTTPUtils.load_mime_types(file)
end
end

View File

@@ -22,7 +22,7 @@ module Jekyll
def search_file(req, res, basename)
# /file.* > /file/index.html > /file.html
super || super(req, res, "#{basename}.html")
super || super(req, res, ".html") || super(req, res, "#{basename}.html")
end
# rubocop:disable Style/MethodName

View File

@@ -5,7 +5,7 @@ module Jekyll
def process(args)
arg_is_present? args, "--server", "The --server command has been replaced by the \
'serve' subcommand."
arg_is_present? args, "--serve", "The --server command has been replaced by the \
arg_is_present? args, "--serve", "The --serve command has been replaced by the \
'serve' subcommand."
arg_is_present? args, "--no-server", "To build Jekyll without launching a server, \
use the 'build' subcommand."
@@ -46,6 +46,5 @@ module Jekyll
Jekyll.logger.warn "Defaults:", "Please update your front-matter defaults to use \
'type: #{current}'."
end
end
end

View File

@@ -203,7 +203,7 @@ module Jekyll
#
# Returns the computed URL for the document.
def url
@url ||= URL.new({
@url = URL.new({
:template => url_template,
:placeholders => url_placeholders,
:permalink => permalink,

View File

@@ -71,7 +71,7 @@ module Jekyll
def []=(key, val)
if respond_to?("#{key}=")
public_send("#{key}=", val)
elsif respond_to?(key.to_s)
elsif respond_to? key
if self.class.mutable?
@mutations[key] = val
else
@@ -105,7 +105,7 @@ module Jekyll
if self.class.mutable
@mutations.key?(key)
else
!key.nil? && (respond_to?(key) || fallback_data.key?(key))
respond_to?(key) || fallback_data.key?(key)
end
end

View File

@@ -10,7 +10,7 @@ module Jekyll
# Returns the absolute URL as a String.
def absolute_url(input)
return if input.nil?
return input if Addressable::URI.parse(input.to_s).absolute?
return input if Addressable::URI.parse(input).absolute?
site = @context.registers[:site]
return relative_url(input).to_s if site.config["url"].nil?
Addressable::URI.parse(

View File

@@ -73,13 +73,11 @@ module Jekyll
render
cleanup
write
print_stats
print_stats if config["profile"]
end
def print_stats
if @config["profile"]
puts @liquid_renderer.stats_table
end
puts @liquid_renderer.stats_table
end
# Reset Site details.

View File

@@ -1,11 +1,7 @@
module Jekyll
class StaticFile
extend Forwardable
attr_reader :relative_path, :extname, :name, :data
def_delegator :to_liquid, :to_json, :to_json
class << self
# The cache of last modification times [path] -> mtime.
def mtimes

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "addressable/uri"
# Public: Methods that generate a URL for a resource such as a Post or a Page.
@@ -83,30 +85,18 @@ module Jekyll
# That should be :month and :day, but our key extraction regexp isn't
# smart enough to know that so we have to make it an explicit
# possibility.
def possible_keys(key)
if key.end_with?("_")
[key, key.chomp("_")]
else
[key]
end
end
def generate_url_from_drop(template)
template.gsub(%r!:([a-z_]+)!) do |match|
pool = possible_keys(match.sub(":".freeze, "".freeze))
key = match[1..-1]
key = match[1..-2] if !@placeholders.key?(key) && key.end_with?("_")
winner = pool.find { |key| @placeholders.key?(key) }
if winner.nil?
unless @placeholders.key?(key)
raise NoMethodError,
"The URL template doesn't have #{pool.join(" or ")} keys. "\
"The URL template doesn't have #{key} key. "\
"Check your permalink template!"
end
value = @placeholders[winner]
value = "" if value.nil?
replacement = self.class.escape_path(value)
match.sub(":#{winner}", replacement)
match.sub(":" + key, self.class.escape_path(@placeholders[key].to_s))
end.gsub(%r!//!, "/".freeze)
end

View File

@@ -1,3 +1,3 @@
module Jekyll
VERSION = "3.5.2".freeze
VERSION = "3.5.1".freeze
end

View File

@@ -15,7 +15,7 @@
# in the templates via {{ site.myvariable }}.
title: Your awesome title
email: your-email@example.com
description: > # this means to ignore newlines until "baseurl:"
description: >- # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
line in _config.yml. It will appear in your document head meta (for
Google search results) and in your feed.xml site description.

View File

@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
require 'pry'
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require 'jekyll'
TEST_DIR = File.expand_path(File.join(File.dirname(__FILE__), *%w{ .. test }))
TEST_DIR = File.expand_path("../test", __dir__)
def fixture_site(overrides = {})
Jekyll::Site.new(site_configuration(overrides))

View File

@@ -3,10 +3,10 @@
require "bundler/setup"
require "json"
require "stackprof"
require File.expand_path("../../lib/jekyll", __FILE__)
require File.expand_path("../lib/jekyll", __dir__)
MODE = ARGV.first || "cpu"
PROF_OUTPUT_FILE = File.expand_path("../../tmp/stackprof-#{MODE}-#{Time.now.strftime("%Y%m%d%H%M")}.dump", __FILE__)
PROF_OUTPUT_FILE = File.expand_path("../tmp/stackprof-#{MODE}-#{Time.now.strftime("%Y%m%d%H%M")}.dump", __dir__)
puts "Stackprof Mode: #{MODE}"

View File

@@ -5,7 +5,7 @@
require 'json'
require 'open-uri'
config = File.expand_path "../lib/jekyll/mime.types", File.dirname(__FILE__)
config = File.expand_path "../lib/jekyll/mime.types", __dir__
# Create an array of vendored mimetype => [extensions]
mimes = {}

View File

@@ -13,7 +13,7 @@ if ENV["CI"]
require "simplecov"
SimpleCov.start
else
require File.expand_path("../simplecov_custom_profile", __FILE__)
require File.expand_path("simplecov_custom_profile", __dir__)
SimpleCov.start "gem" do
add_filter "/vendor/gem"
add_filter "/vendor/bundle"
@@ -63,7 +63,7 @@ end
module DirectoryHelpers
def root_dir(*subdirs)
File.join(File.dirname(File.dirname(__FILE__)), *subdirs)
File.expand_path(File.join("..", *subdirs), __dir__)
end
def dest_dir(*subdirs)

View File

@@ -0,0 +1,8 @@
folded_string: >
This string of text will ignore
newlines till the next key.
foo: bar
clean_folded_string: >-
This string of text will ignore
newlines till the next key.
baz: foo

View File

@@ -494,4 +494,36 @@ class TestConfiguration < JekyllUnitTest
})
end
end
context "folded YAML string" do
setup do
@tester = Configuration.new
end
should "ignore newlines in that string entirely from a sample file" do
config = Jekyll.configuration(
@tester.read_config_file(
source_dir("_config_folded.yml")
)
)
assert_equal(
config["folded_string"],
"This string of text will ignore newlines till the next key.\n"
)
assert_equal(
config["clean_folded_string"],
"This string of text will ignore newlines till the next key."
)
end
should "ignore newlines in that string entirely from the template file" do
config = Jekyll.configuration(
@tester.read_config_file(
File.expand_path("../lib/site_template/_config.yml", File.dirname(__FILE__))
)
)
assert_includes config["description"], "an awesome description"
refute_includes config["description"], "\n"
end
end
end

View File

@@ -6,11 +6,11 @@ class TestConvertible < JekyllUnitTest
setup do
@convertible = OpenStruct.new(
"site" => Site.new(Jekyll.configuration(
"source" => File.expand_path("../fixtures", __FILE__)
"source" => File.expand_path("fixtures", __dir__)
))
)
@convertible.extend Jekyll::Convertible
@base = File.expand_path("../fixtures", __FILE__)
@base = File.expand_path("fixtures", __dir__)
end
should "parse the front matter correctly" do

View File

@@ -13,10 +13,6 @@ class TestDrop < JekyllUnitTest
@drop = @document.to_liquid
end
should "reject 'nil' key" do
refute @drop.key?(nil)
end
should "raise KeyError if key is not found and no default provided" do
assert_raises KeyError do
@drop.fetch("not_existing_key")

View File

@@ -439,10 +439,6 @@ class TestFilters < JekyllUnitTest
filter = make_filter_mock({ "url" => Value.new(proc { "http://example.org" }) })
assert_equal "http://example.org#{page_url}", filter.absolute_url(page_url)
end
should "not raise a TypeError when passed a hash" do
assert @filter.absolute_url({ "foo" => "bar" })
end
end
context "relative_url filter" do

View File

@@ -9,7 +9,7 @@ class TestNewCommand < JekyllUnitTest
end
def site_template
File.expand_path("../lib/site_template", File.dirname(__FILE__))
File.expand_path("../lib/site_template", __dir__)
end
context "when args contains a path" do
@@ -34,7 +34,7 @@ class TestNewCommand < JekyllUnitTest
refute_exist @full_path
capture_output { Jekyll::Commands::New.process(@args) }
assert_exist gemfile
assert_match(%r!gem "jekyll", "#{Jekyll::VERSION}"!, File.read(gemfile))
assert_match(%r!gem "jekyll", "~> #{Jekyll::VERSION}"!, File.read(gemfile))
assert_match(%r!gem "github-pages"!, File.read(gemfile))
end

View File

@@ -174,9 +174,5 @@ class TestStaticFile < JekyllUnitTest
}
assert_equal expected, @static_file.to_liquid.to_h
end
should "jsonify its liquid drop instead of itself" do
assert_equal @static_file.to_liquid.to_json, @static_file.to_json
end
end
end