Skip to content

Commit

Permalink
Merge branch 'master' into percent_r
Browse files Browse the repository at this point in the history
* master: (22 commits)
  Update history to reflect merge of jekyll#4980 [ci skip]
  werdz
  Use jekyll-mentions and restructure
  Add post about GSoC project.
  Update history to reflect merge of jekyll#4976 [ci skip]
  Amend WEBrick default headers documentation
  Update history to reflect merge of jekyll#4966 [ci skip]
  .rubocop.yml - remove lib/jekyll.rb
  lib/jekyll.rb - fix offenses reported by rubocop method set_timezone is ignored using rubocop:disable Style/AccessorMethodName
  Update history to reflect merge of jekyll#4977 [ci skip]
  Update history to reflect merge of jekyll#4962 [ci skip]
  Update history to reflect merge of jekyll#4959 [ci skip]
  Fixed typo
  Changed github-gem to github-pages
  Included installation instructions
  Installation instructions for github-pages gem
  Added link to windows doc page
  Fix inaccurate HTTP response header field name
  Minor tweak to fix missing apostrophne
  Feedback for flubbed regex and prefer File's directory check
  ...
  • Loading branch information
parkr committed Jun 4, 2016
2 parents f5a0db9 + ea0b43f commit 8917fa8
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 101 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ AllCops:
- lib/jekyll/renderer.rb
- lib/jekyll/site.rb
- lib/jekyll/static_file.rb
- lib/jekyll/theme.rb
- lib/jekyll/url.rb
- lib/jekyll/utils.rb
- lib/jekyll.rb
- bin/**/*
- benchmark/**/*
- script/**/*
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ group :site do
gem "jekyll-sitemap"
gem "jekyll-seo-tag", "~> 1.1"
gem "jekyll-avatar"
gem "jekyll-mentions"
end
6 changes: 6 additions & 0 deletions History.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
* Rubocop: Readers (#4932)
* rubocop: jekyll/lib/frontmatter_defaults.rb (#4974)
* rubocop: features/step_definitions.rb (#4956)
* Rubocop theme and url jekyll libs (#4959)
* Rubocop jekyll.rb (#4966)

### Site Enhancements

Expand Down Expand Up @@ -128,6 +130,10 @@
* Corrected pagination docs for hidden: true feature (#4903)
* Remove a Broken Link for Refheap Plugin (#4971)
* Instructions on how to install github-gem on Windows (#4975)
* Minor tweak to fix missing apostrophne (#4962)
* Instructions on how to install github-gem on Windows (v2) (#4977)
* Fix inaccurate HTTP response header field name (#4976)
* Add post about GSoC project (#4980)

## 3.1.6 / 2016-05-19

Expand Down
149 changes: 76 additions & 73 deletions lib/jekyll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,79 +6,79 @@
#
# Returns nothing.
def require_all(path)
glob = File.join(File.dirname(__FILE__), path, '*.rb')
glob = File.join(File.dirname(__FILE__), path, "*.rb")
Dir[glob].sort.each do |f|
require f
end
end

# rubygems
require 'rubygems'
require "rubygems"

# stdlib
require "pathutil"
require 'forwardable'
require 'fileutils'
require 'time'
require 'English'
require 'pathname'
require 'logger'
require 'set'
require "forwardable"
require "fileutils"
require "time"
require "English"
require "pathname"
require "logger"
require "set"

# 3rd party
require 'safe_yaml/load'
require 'liquid'
require 'kramdown'
require 'colorator'
require "safe_yaml/load"
require "liquid"
require "kramdown"
require "colorator"

SafeYAML::OPTIONS[:suppress_warnings] = true

module Jekyll
# internal requires
autoload :Cleaner, 'jekyll/cleaner'
autoload :Collection, 'jekyll/collection'
autoload :Configuration, 'jekyll/configuration'
autoload :Convertible, 'jekyll/convertible'
autoload :Deprecator, 'jekyll/deprecator'
autoload :Document, 'jekyll/document'
autoload :Draft, 'jekyll/draft'
autoload :EntryFilter, 'jekyll/entry_filter'
autoload :Errors, 'jekyll/errors'
autoload :Excerpt, 'jekyll/excerpt'
autoload :External, 'jekyll/external'
autoload :FrontmatterDefaults, 'jekyll/frontmatter_defaults'
autoload :Hooks, 'jekyll/hooks'
autoload :Layout, 'jekyll/layout'
autoload :CollectionReader, 'jekyll/readers/collection_reader'
autoload :DataReader, 'jekyll/readers/data_reader'
autoload :LayoutReader, 'jekyll/readers/layout_reader'
autoload :PostReader, 'jekyll/readers/post_reader'
autoload :PageReader, 'jekyll/readers/page_reader'
autoload :StaticFileReader, 'jekyll/readers/static_file_reader'
autoload :LogAdapter, 'jekyll/log_adapter'
autoload :Page, 'jekyll/page'
autoload :PluginManager, 'jekyll/plugin_manager'
autoload :Publisher, 'jekyll/publisher'
autoload :Reader, 'jekyll/reader'
autoload :Regenerator, 'jekyll/regenerator'
autoload :RelatedPosts, 'jekyll/related_posts'
autoload :Renderer, 'jekyll/renderer'
autoload :LiquidRenderer, 'jekyll/liquid_renderer'
autoload :Site, 'jekyll/site'
autoload :StaticFile, 'jekyll/static_file'
autoload :Stevenson, 'jekyll/stevenson'
autoload :Theme, 'jekyll/theme'
autoload :ThemeBuilder, 'jekyll/theme_builder'
autoload :URL, 'jekyll/url'
autoload :Utils, 'jekyll/utils'
autoload :VERSION, 'jekyll/version'
autoload :Cleaner, "jekyll/cleaner"
autoload :Collection, "jekyll/collection"
autoload :Configuration, "jekyll/configuration"
autoload :Convertible, "jekyll/convertible"
autoload :Deprecator, "jekyll/deprecator"
autoload :Document, "jekyll/document"
autoload :Draft, "jekyll/draft"
autoload :EntryFilter, "jekyll/entry_filter"
autoload :Errors, "jekyll/errors"
autoload :Excerpt, "jekyll/excerpt"
autoload :External, "jekyll/external"
autoload :FrontmatterDefaults, "jekyll/frontmatter_defaults"
autoload :Hooks, "jekyll/hooks"
autoload :Layout, "jekyll/layout"
autoload :CollectionReader, "jekyll/readers/collection_reader"
autoload :DataReader, "jekyll/readers/data_reader"
autoload :LayoutReader, "jekyll/readers/layout_reader"
autoload :PostReader, "jekyll/readers/post_reader"
autoload :PageReader, "jekyll/readers/page_reader"
autoload :StaticFileReader, "jekyll/readers/static_file_reader"
autoload :LogAdapter, "jekyll/log_adapter"
autoload :Page, "jekyll/page"
autoload :PluginManager, "jekyll/plugin_manager"
autoload :Publisher, "jekyll/publisher"
autoload :Reader, "jekyll/reader"
autoload :Regenerator, "jekyll/regenerator"
autoload :RelatedPosts, "jekyll/related_posts"
autoload :Renderer, "jekyll/renderer"
autoload :LiquidRenderer, "jekyll/liquid_renderer"
autoload :Site, "jekyll/site"
autoload :StaticFile, "jekyll/static_file"
autoload :Stevenson, "jekyll/stevenson"
autoload :Theme, "jekyll/theme"
autoload :ThemeBuilder, "jekyll/theme_builder"
autoload :URL, "jekyll/url"
autoload :Utils, "jekyll/utils"
autoload :VERSION, "jekyll/version"

# extensions
require 'jekyll/plugin'
require 'jekyll/converter'
require 'jekyll/generator'
require 'jekyll/command'
require 'jekyll/liquid_extensions'
require "jekyll/plugin"
require "jekyll/converter"
require "jekyll/generator"
require "jekyll/command"
require "jekyll/liquid_extensions"
require "jekyll/filters"

class << self
Expand All @@ -94,19 +94,20 @@ def env
# options with anything in _config.yml, and adding the given options on top.
#
# override - A Hash of config directives that override any options in both
# the defaults and the config file. See Jekyll::Configuration::DEFAULTS for a
# the defaults and the config file.
# See Jekyll::Configuration::DEFAULTS for a
# list of option names and their defaults.
#
# Returns the final configuration Hash.
def configuration(override = Hash.new)
def configuration(override = {})
config = Configuration.new
unless override.delete('skip_config_files')
unless override.delete("skip_config_files")
config = config.read_config_files(config.config_files(override))
end

# Merge DEFAULTS < _config.yml < override
Configuration.from(Utils.deep_merge_hashes(config, override)).tap do |config|
set_timezone(config['timezone']) if config['timezone']
Configuration.from(Utils.deep_merge_hashes(config, override)).tap do |obj|
set_timezone(obj["timezone"]) if obj["timezone"]
end
end

Expand All @@ -115,9 +116,11 @@ def configuration(override = Hash.new)
# timezone - the IANA Time Zone
#
# Returns nothing
# rubocop:disable Style/AccessorMethodName
def set_timezone(timezone)
ENV['TZ'] = timezone
ENV["TZ"] = timezone
end
# rubocop:enable Style/AccessorMethodName

# Public: Fetch the logger instance for this Jekyll process.
#
Expand Down Expand Up @@ -154,29 +157,29 @@ def sites
def sanitized_path(base_directory, questionable_path)
return base_directory if base_directory.eql?(questionable_path)

questionable_path.insert(0, '/') if questionable_path.start_with?('~')
questionable_path.insert(0, "/") if questionable_path.start_with?("~")
clean_path = File.expand_path(questionable_path, "/")
clean_path.sub!(/\A\w\:\//, '/')
clean_path.sub!(%r!\A\w:/!, "/")

if clean_path.start_with?(base_directory.sub(/\A\w\:\//, '/'))
if clean_path.start_with?(base_directory.sub(%r!\A\w:/!, "/"))
clean_path
else
File.join(base_directory, clean_path)
end
end

# Conditional optimizations
Jekyll::External.require_if_present('liquid-c')
Jekyll::External.require_if_present("liquid-c")
end
end

require "jekyll/drops/drop"
require "jekyll/drops/document_drop"
require_all 'jekyll/commands'
require_all 'jekyll/converters'
require_all 'jekyll/converters/markdown'
require_all 'jekyll/drops'
require_all 'jekyll/generators'
require_all 'jekyll/tags'

require 'jekyll-sass-converter'
require_all "jekyll/commands"
require_all "jekyll/converters"
require_all "jekyll/converters/markdown"
require_all "jekyll/drops"
require_all "jekyll/generators"
require_all "jekyll/tags"

require "jekyll-sass-converter"
7 changes: 4 additions & 3 deletions lib/jekyll/theme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def sass_path

def configure_sass
return unless sass_path
require 'sass'
require "sass"
Sass.load_paths << sass_path
end

Expand All @@ -38,7 +38,7 @@ def path_for(folder)
return unless resolved_dir

path = Jekyll.sanitized_path(root, resolved_dir)
path if Dir.exists?(path)
path if File.directory?(path)
end

def realpath_for(folder)
Expand All @@ -50,7 +50,8 @@ def realpath_for(folder)
def gemspec
@gemspec ||= Gem::Specification.find_by_name(name)
rescue Gem::LoadError
raise Jekyll::Errors::MissingDependencyException, "The #{name} theme could not be found."
raise Jekyll::Errors::MissingDependencyException,
"The #{name} theme could not be found."
end
end
end
24 changes: 12 additions & 12 deletions lib/jekyll/url.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'uri'
require "uri"

# Public: Methods that generate a URL for a resource such as a Post or a Page.
#
Expand Down Expand Up @@ -67,32 +67,32 @@ def generate_url(template)

def generate_url_from_hash(template)
@placeholders.inject(template) do |result, token|
break result if result.index(':').nil?
break result if result.index(":").nil?
if token.last.nil?
# Remove leading '/' to avoid generating urls with `//`
result.gsub(/\/:#{token.first}/, '')
# Remove leading "/" to avoid generating urls with `//`
result.gsub(%r!/:#{token.first}!, "")
else
result.gsub(/:#{token.first}/, self.class.escape_path(token.last))
end
end
end

def generate_url_from_drop(template)
template.gsub(/:([a-z_]+)/.freeze) do |match|
replacement = @placeholders.public_send(match.sub(':'.freeze, ''.freeze))
template.gsub(/:([a-z_]+)/) do |match|
replacement = @placeholders.public_send(match.sub(":".freeze, "".freeze))
if replacement.nil?
''.freeze
"".freeze
else
self.class.escape_path(replacement)
end
end.gsub(/\/\//.freeze, '/'.freeze)
end.gsub(%r!//!, "/".freeze)
end

# Returns a sanitized String URL, stripping "../../" and multiples of "/",
# as well as the beginning "/" so we can enforce and ensure it.

def sanitize_url(str)
"/" + str.gsub(/\/{2,}/, "/").gsub(/\.+\/|\A\/+/, "")
"/" + str.gsub(%r!/{2,}!, "/").gsub(%r!\.+/|\A/+!, "")
end

# Escapes a path to be a valid URL path segment
Expand All @@ -106,7 +106,7 @@ def sanitize_url(str)
#
# Returns the escaped path.
def self.escape_path(path)
# Because URI.escape doesn't escape '?', '[' and ']' by default,
# Because URI.escape doesn't escape "?", "[" and "]" by default,
# specify unsafe string (except unreserved, sub-delims, ":", "@" and "/").
#
# URI path segment is defined in RFC 3986 as follows:
Expand All @@ -116,7 +116,7 @@ def self.escape_path(path)
# pct-encoded = "%" HEXDIG HEXDIG
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
# / "*" / "+" / "," / ";" / "="
URI.escape(path, /[^a-zA-Z\d\-._~!$&'()*+,;=:@\/]/).encode('utf-8')
URI.escape(path, %r{[^a-zA-Z\d\-._~!$&'()*+,;=:@\/]}).encode("utf-8")
end

# Unescapes a URL path segment
Expand All @@ -130,7 +130,7 @@ def self.escape_path(path)
#
# Returns the unescaped path.
def self.unescape_path(path)
URI.unescape(path.encode('utf-8'))
URI.unescape(path.encode("utf-8"))
end
end
end
1 change: 1 addition & 0 deletions site/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ gems:
- jekyll-sitemap
- jekyll-seo-tag
- jekyll-avatar
- jekyll-mentions
11 changes: 6 additions & 5 deletions site/_docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ before your site is served.
</p>
</div>

## Custom WEBRick Headers
## Custom WEBrick Headers

You can provide custom headers for your site by adding them to `_config.yml`

Expand All @@ -397,9 +397,10 @@ webrick:

### Defaults

We only provide one default and that's a Content-Type header that disables
caching in development so that you don't have to fight with Chrome's aggressive
caching when you are in development mode.
We provide by default `Content-Type` and `Cache-Control` response headers: one
dynamic in order to specify the nature of the data being served, the other
static in order to disable caching so that you don't have to fight with Chrome's
aggressive caching when you are in development mode.

## Specifying a Jekyll environment at build time

Expand Down Expand Up @@ -462,7 +463,7 @@ defaults:
</p>
</div>

Here, we are scoping the `values` to any file that exists in the scopes path. Since the path is set as an empty string, it will apply to **all files** in your project. You probably don't want to set a layout on every file in your project - like css files, for example - so you can also specify a `type` value under the `scope` key.
Here, we are scoping the `values` to any file that exists in the path `scope`. Since the path is set as an empty string, it will apply to **all files** in your project. You probably don't want to set a layout on every file in your project - like css files, for example - so you can also specify a `type` value under the `scope` key.

{% highlight yaml %}
defaults:
Expand Down
Loading

0 comments on commit 8917fa8

Please sign in to comment.