Created
May 7, 2013 04:27
-
-
Save koron/5530261 to your computer and use it in GitHub Desktop.
手元のJekyll 1.0への修正 * DNSの逆引き禁止 * encoding指定の追加 * バイナリモードでの出力 * 生成所要時間の出力
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb | |
index a352028b280eb6bf510d21c7cb0f2d76760b5302..53b767f0a45a2512b87f0f326dd563be4cd2cf9a 100644 | |
--- a/lib/jekyll/command.rb | |
+++ b/lib/jekyll/command.rb | |
@@ -15,7 +15,9 @@ module Jekyll | |
# | |
# Returns nothing | |
def self.process_site(site) | |
- site.process | |
+ t = Time.now | |
+ num = site.process | |
+ puts "Built #{num} pages in #{Time.now - t} secs" | |
rescue Jekyll::FatalException => e | |
puts | |
Jekyll::Logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:" | |
diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb | |
index ae28665b3b81398c57f63f8ba6b73299e129f0b3..cd5b974aa2acd10bbab7aae326e379887e2b7b29 100644 | |
--- a/lib/jekyll/commands/serve.rb | |
+++ b/lib/jekyll/commands/serve.rb | |
@@ -20,7 +20,8 @@ module Jekyll | |
s = HTTPServer.new( | |
:Port => options['port'], | |
:BindAddress => options['host'], | |
- :MimeTypes => mime_types | |
+ :MimeTypes => mime_types, | |
+ :DoNotReverseLookup => true | |
) | |
s.mount(options['baseurl'], HTTPServlet::FileHandler, destination, fh_option) | |
diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb | |
index acdb0be0313c3e002dd981be0ef8171e1fa4054a..811ed03bbc5a1181c0d2f038b308ce9588b9704c 100644 | |
--- a/lib/jekyll/convertible.rb | |
+++ b/lib/jekyll/convertible.rb | |
@@ -28,7 +28,7 @@ module Jekyll | |
# Returns nothing. | |
def read_yaml(base, name) | |
begin | |
- self.content = File.read(File.join(base, name)) | |
+ self.content = File.read(File.join(base, name), self.site.file_read_opts) | |
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m | |
self.content = $POSTMATCH | |
@@ -144,7 +144,7 @@ module Jekyll | |
def write(dest) | |
path = destination(dest) | |
FileUtils.mkdir_p(File.dirname(path)) | |
- File.open(path, 'w') do |f| | |
+ File.open(path, 'wb') do |f| | |
f.write(self.output) | |
end | |
end | |
diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb | |
index d8a36e1becdf6e48ea65e12b03d9bfae7fd76040..a035f100272493790b48c2d88dc19d59ddd77c06 100644 | |
--- a/lib/jekyll/site.rb | |
+++ b/lib/jekyll/site.rb | |
@@ -5,7 +5,7 @@ module Jekyll | |
attr_accessor :config, :layouts, :posts, :pages, :static_files, | |
:categories, :exclude, :include, :source, :dest, :lsi, :pygments, | |
: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 | |
@@ -30,6 +30,11 @@ module Jekyll | |
self.limit_posts = config['limit_posts'] | |
self.keep_files = config['keep_files'] | |
+ self.file_read_opts = {} | |
+ if config['encoding'] | |
+ self.file_read_opts[:encoding] = Encoding.find(config['encoding']) | |
+ end | |
+ | |
self.reset | |
self.setup | |
end | |
@@ -44,6 +49,7 @@ module Jekyll | |
self.render | |
self.cleanup | |
self.write | |
+ return self.posts.length + self.pages.length | |
end | |
# Reset Site details. | |
diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb | |
index 3c2fa984d90318ef9575f44b6240ad126c93b071..215ea601468cfb9f5f05275f7ddefb2086b9b899 100644 | |
--- a/lib/jekyll/tags/include.rb | |
+++ b/lib/jekyll/tags/include.rb | |
@@ -20,7 +20,7 @@ module Jekyll | |
Dir.chdir(includes_dir) do | |
choices = Dir['**/*'].reject { |x| File.symlink?(x) } | |
if choices.include?(@file) | |
- source = File.read(@file) | |
+ source = File.read(@file, context.registers[:site].file_read_opts) | |
partial = Liquid::Template.parse(source) | |
context.stack do | |
partial.render(context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment