commit
d800cdcc31
|
@ -3,11 +3,14 @@
|
||||||
### Major Enhancements
|
### Major Enhancements
|
||||||
|
|
||||||
### Minor Enhancements
|
### Minor Enhancements
|
||||||
|
* Decrease the specificity in the site template CSS (#1574)
|
||||||
|
* Add `encoding` configuration option (#1449)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
* Fix up matching against source and destination when the two
|
* Fix up matching against source and destination when the two
|
||||||
locations are similar (#1556)
|
locations are similar (#1556)
|
||||||
* Fix the missing `pathname` require in certain cases (#1255)
|
* Fix the missing `pathname` require in certain cases (#1255)
|
||||||
|
* Use `+` instead of `Array#concat` when building `Post` attribute list (#1571)
|
||||||
|
|
||||||
### Development Fixes
|
### Development Fixes
|
||||||
* Add coverage reporting with Coveralls (#1539)
|
* Add coverage reporting with Coveralls (#1539)
|
||||||
|
|
|
@ -14,6 +14,8 @@ module Jekyll
|
||||||
|
|
||||||
'timezone' => nil, # use the local timezone
|
'timezone' => nil, # use the local timezone
|
||||||
|
|
||||||
|
'encoding' => nil, # use the system encoding
|
||||||
|
|
||||||
'safe' => false,
|
'safe' => false,
|
||||||
'detach' => false, # default to not detaching the server
|
'detach' => false, # default to not detaching the server
|
||||||
'show_drafts' => nil,
|
'show_drafts' => nil,
|
||||||
|
|
|
@ -20,16 +20,23 @@ module Jekyll
|
||||||
self.content || ''
|
self.content || ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns merged optin hash for File.read of self.site (if exists)
|
||||||
|
# and a given param
|
||||||
|
def merged_file_read_opts(opts)
|
||||||
|
(self.site ? self.site.file_read_opts : {}).merge(opts)
|
||||||
|
end
|
||||||
|
|
||||||
# Read the YAML frontmatter.
|
# Read the YAML frontmatter.
|
||||||
#
|
#
|
||||||
# base - The String path to the dir containing the file.
|
# base - The String path to the dir containing the file.
|
||||||
# name - The String filename of the file.
|
# name - The String filename of the file.
|
||||||
|
# opts - optional parameter to File.read, default at site configs
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def read_yaml(base, name)
|
def read_yaml(base, name, opts = {})
|
||||||
begin
|
begin
|
||||||
self.content = File.read(File.join(base, name))
|
self.content = File.read_with_options(File.join(base, name),
|
||||||
|
merged_file_read_opts(opts))
|
||||||
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
||||||
self.content = $POSTMATCH
|
self.content = $POSTMATCH
|
||||||
self.data = YAML.safe_load($1)
|
self.data = YAML.safe_load($1)
|
||||||
|
|
|
@ -69,3 +69,18 @@ module Enumerable
|
||||||
any? { |exp| File.fnmatch?(exp, e) }
|
any? { |exp| File.fnmatch?(exp, e) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Ruby 1.8's File.read don't support option.
|
||||||
|
# read_with_options ignore optional parameter for 1.8,
|
||||||
|
# and act as alias for 1.9 or later.
|
||||||
|
class File
|
||||||
|
if RUBY_VERSION < '1.9'
|
||||||
|
def self.read_with_options(path, opts = {})
|
||||||
|
self.read(path)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
def self.read_with_options(path, opts = {})
|
||||||
|
self.read(path, opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -19,10 +19,10 @@ module Jekyll
|
||||||
]
|
]
|
||||||
|
|
||||||
# Attributes for Liquid templates
|
# Attributes for Liquid templates
|
||||||
ATTRIBUTES_FOR_LIQUID = EXCERPT_ATTRIBUTES_FOR_LIQUID.concat(%w[
|
ATTRIBUTES_FOR_LIQUID = EXCERPT_ATTRIBUTES_FOR_LIQUID + %w[
|
||||||
content
|
content
|
||||||
excerpt
|
excerpt
|
||||||
])
|
]
|
||||||
|
|
||||||
# Post name validator. Post filenames must be like:
|
# Post name validator. Post filenames must be like:
|
||||||
# 2008-11-05-my-awesome-post.textile
|
# 2008-11-05-my-awesome-post.textile
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Jekyll
|
||||||
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
||||||
:categories, :exclude, :include, :source, :dest, :lsi, :pygments,
|
:categories, :exclude, :include, :source, :dest, :lsi, :pygments,
|
||||||
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
|
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
|
||||||
:show_drafts, :keep_files, :baseurl
|
:show_drafts, :keep_files, :baseurl, :file_read_opts
|
||||||
|
|
||||||
attr_accessor :converters, :generators
|
attr_accessor :converters, :generators
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ module Jekyll
|
||||||
self.plugins = plugins_path
|
self.plugins = plugins_path
|
||||||
self.permalink_style = config['permalink'].to_sym
|
self.permalink_style = config['permalink'].to_sym
|
||||||
|
|
||||||
|
self.file_read_opts = {}
|
||||||
|
self.file_read_opts[:encoding] = config['encoding'] if config['encoding']
|
||||||
|
|
||||||
self.reset
|
self.reset
|
||||||
self.setup
|
self.setup
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,6 +70,11 @@ eos
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Grab file read opts in the context
|
||||||
|
def file_read_opts(context)
|
||||||
|
context.registers[:site].file_read_opts
|
||||||
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
dir = File.join(context.registers[:site].source, INCLUDES_DIR)
|
dir = File.join(context.registers[:site].source, INCLUDES_DIR)
|
||||||
if error = validate_dir(dir, context.registers[:site].safe)
|
if error = validate_dir(dir, context.registers[:site].safe)
|
||||||
|
@ -81,7 +86,7 @@ eos
|
||||||
return error
|
return error
|
||||||
end
|
end
|
||||||
|
|
||||||
partial = Liquid::Template.parse(source(file))
|
partial = Liquid::Template.parse(source(file, context))
|
||||||
|
|
||||||
context.stack do
|
context.stack do
|
||||||
context['include'] = parse_params(context) if @params
|
context['include'] = parse_params(context) if @params
|
||||||
|
@ -108,8 +113,8 @@ eos
|
||||||
end
|
end
|
||||||
|
|
||||||
# This method allows to modify the file content by inheriting from the class.
|
# This method allows to modify the file content by inheriting from the class.
|
||||||
def source(file)
|
def source(file, context)
|
||||||
File.read(file)
|
File.read_with_options(file, file_read_opts(context))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,16 +34,16 @@ a:visited { color: #a0a; }
|
||||||
/* Home
|
/* Home
|
||||||
/*
|
/*
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
ul.posts {
|
.posts {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.posts li {
|
.posts li {
|
||||||
line-height: 1.75em;
|
line-height: 1.75em;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.posts span {
|
.posts span {
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
font-family: Monaco, "Courier New", monospace;
|
font-family: Monaco, "Courier New", monospace;
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
|
@ -63,38 +63,38 @@ ul.posts span {
|
||||||
line-height: 1.5em;
|
line-height: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .header a {
|
.header a {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .header h1.title {
|
.title {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .header h1.title a {
|
.title a {
|
||||||
color: #a00;
|
color: #a00;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .header h1.title a:hover {
|
.title a:hover {
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .header a.extra {
|
.header a.extra {
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .header a.extra:hover {
|
.header a.extra:hover {
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .meta {
|
.meta {
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .footer {
|
.footer {
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
color: #666;
|
color: #666;
|
||||||
border-top: 4px solid #eee;
|
border-top: 4px solid #eee;
|
||||||
|
@ -102,22 +102,22 @@ ul.posts span {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .footer .contact {
|
.footer .contact {
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 3em;
|
margin-right: 3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .footer .contact a {
|
.footer .contact a {
|
||||||
color: #8085C1;
|
color: #8085C1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .footer .rss {
|
.footer .rss {
|
||||||
margin-top: 1.1em;
|
margin-top: 1.1em;
|
||||||
margin-right: -.2em;
|
margin-right: -.2em;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site .footer .rss img {
|
.footer .rss img {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,22 @@ class="flag">flags</code> (specified on the command-line) that control them.
|
||||||
<p><code class="option">timezone: TIMEZONE</code></p>
|
<p><code class="option">timezone: TIMEZONE</code></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class='setting'>
|
||||||
|
<td>
|
||||||
|
<p class='name'><strong>Encoding</strong></p>
|
||||||
|
<p class="description">
|
||||||
|
Set the encoding of files by name. Only available for Ruby
|
||||||
|
1.9 or later).
|
||||||
|
The default value is nil, which use Ruby default,
|
||||||
|
<code>ASCII-8BIT</code>.
|
||||||
|
Available encoding for the ruby in use, can be shown by
|
||||||
|
command <code>ruby -e 'puts Encoding::list.join("\n")'</code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td class='align-center'>
|
||||||
|
<p><code class="option">encoding: ENCODING</code></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -266,6 +282,7 @@ include: ['.htaccess']
|
||||||
exclude: []
|
exclude: []
|
||||||
keep_files: ['.git','.svn']
|
keep_files: ['.git','.svn']
|
||||||
timezone: nil
|
timezone: nil
|
||||||
|
encoding: nil
|
||||||
|
|
||||||
future: true
|
future: true
|
||||||
show_drafts: nil
|
show_drafts: nil
|
||||||
|
|
|
@ -40,7 +40,7 @@ class TestConvertible < Test::Unit::TestCase
|
||||||
should "not parse if there is encoding error in file" do
|
should "not parse if there is encoding error in file" do
|
||||||
name = 'broken_front_matter3.erb'
|
name = 'broken_front_matter3.erb'
|
||||||
out = capture_stdout do
|
out = capture_stdout do
|
||||||
ret = @convertible.read_yaml(@base, name)
|
ret = @convertible.read_yaml(@base, name, :encoding => 'utf-8')
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
end
|
end
|
||||||
assert_match(/invalid byte sequence in UTF-8/, out)
|
assert_match(/invalid byte sequence in UTF-8/, out)
|
||||||
|
|
Loading…
Reference in New Issue