Compare commits

..

3 Commits

Author SHA1 Message Date
Parker Moore
1c5399b947 Benchmark cached includes.
Calculating -------------------------------------
              cached       634 i/100ms
            uncached       543 i/100ms
-------------------------------------------------
              cached     6570.6 (±3.0%) i/s -      32968 in   5.022063s
            uncached     5613.0 (±2.1%) i/s -      28236 in   5.032667s
2015-01-08 11:30:24 -08:00
Parker Moore
0d6064b1a1 add benchmark-ips to BENCHMARK gemfile 2015-01-08 11:22:35 -08:00
Parker Moore
32ff033f9f Add a cache for the includes.
https://github.com/jekyll/jekyll/issues/3202
2015-01-08 11:13:18 -08:00
24 changed files with 103 additions and 141 deletions

2
.gitignore vendored
View File

@@ -13,5 +13,5 @@ site/_site/
coverage
.ruby-version
.sass-cache
tmp/*
tmp/stackprof-*
.jekyll-metadata

View File

@@ -23,6 +23,7 @@ gem 'minitest' if RUBY_PLATFORM =~ /cygwin/
gem 'test-unit' if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2")
if ENV['BENCHMARK']
gem 'benchmark-ips'
gem 'rbtrace'
gem 'stackprof'
end

View File

@@ -24,7 +24,6 @@
* Kramdown: Use `enable_coderay` key instead of `use_coderay` (#3237)
* Unescape `Document` output path (#2924)
* Fix nav items alignment when on multiple rows (#3264)
* Highlight: Only Strip Newlines/Carriage Returns, not Spaces (#3278)
### Development Fixes
@@ -33,8 +32,6 @@
* Update rake task `site:publish` to fix minor bugs. (#3254)
* Switch to shields.io for the README badges. (#3255)
* Use `FileList` instead of `Dir.glob` in `site:publish` rake task (#3261)
* Fix test script to be platform-independent (#3279)
* Instead of symlinking `/tmp`, create and symlink a local `tmp` in the tests (#3258)
### Site Enhancements
@@ -43,9 +40,6 @@
* Add link to 'Adding Ajax pagination to Jekyll' to Resources page (#3186)
* Add a Resources link to tutorial on building dynamic navbars (#3185)
* Semantic structure improvements to the post and page layouts (#3251)
* Add new AsciiDoc plugin to list of third-party plugins. (#3277)
* Specify that all transformable collection documents must contain YAML front matter (#3271)
* Assorted accessibility fixes (#3256)
## 2.5.3 / 2014-12-22

View File

@@ -0,0 +1,32 @@
require 'benchmark/ips'
require 'jekyll'
site = Jekyll::Site.new(Jekyll.configuration({
'source' => File.expand_path('../site', __dir__),
'destination' => File.expand_path('../site/_site', __dir__)
}))
payload = Jekyll::Utils.deep_merge_hashes(
site.site_payload,
{ 'site' => {'page' => site.pages.first.to_liquid } }
)
info = {
filters: [Jekyll::Filters],
registers: { :site => site, :page => payload['page'] }
}
class WithoutCacheInclude < Jekyll::Tags::IncludeTag
def source(file, context)
File.read(file, file_read_opts(context))
end
end
Liquid::Template.register_tag('include_woc', WithoutCacheInclude)
def parse(tag, payload, info)
Liquid::Template.parse("{% #{tag} footer.html %}").render!(payload, info)
end
Benchmark.ips do |x|
x.report('cached') { parse 'include', payload, info }
x.report('uncached') { parse 'include_woc', payload, info }
end

View File

@@ -45,7 +45,7 @@ module Jekyll
begin
self.content = File.read(site.in_source_dir(base, name),
merged_file_read_opts(opts))
if content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
self.content = $POSTMATCH
self.data = SafeYAML.load($1)
end

View File

@@ -42,7 +42,7 @@ eos
def render(context)
prefix = context["highlighter_prefix"] || ""
suffix = context["highlighter_suffix"] || ""
code = super.to_s.gsub(/^(\n|\r)+|(\n|\r)+$/, '')
code = super.to_s.strip
is_safe = !!context.registers[:site].safe

View File

@@ -18,6 +18,12 @@ module Jekyll
VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/
VARIABLE_SYNTAX = /(?<variable>[^{]*\{\{\s*(?<name>[\w\-\.]+)\s*(\|.*)?\}\}[^\s}]*)(?<params>.*)/
class << self
def source_cache
@@source_cache ||= {}
end
end
def initialize(tag_name, markup, tokens)
super
@includes_dir = tag_includes_dir
@@ -156,7 +162,7 @@ eos
# This method allows to modify the file content by inheriting from the class.
def source(file, context)
File.read(file, file_read_opts(context))
self.class.source_cache[file] ||= File.read(file, file_read_opts(context))
end
end

View File

@@ -4,16 +4,25 @@
# script/test
# script/test <test_file>
if [ ! -d tmp ]; then
mkdir tmp
fi
if [ -z "$1" ]; then
TEST_FILES=$(ruby -e "puts Dir.glob('test/test_*.rb')")
TEST_FILES="./test/test_*.rb"
else
TEST_FILES="$@"
fi
# bundle exec gem env
GEM_DIR=$(bundle exec gem env | grep -C 1 "GEM PATHS" | tail -1 | cut -d '-' -f2 | cut -d' ' -f2)
RAKE_LIB_WITH_VERSION=$(bundle exec ruby -e "puts Gem::Specification.find_by_name('rake').gem_dir.split('/').last + '/lib'")
RAKE_LIB_DIR="${GEM_DIR}/gems/${RAKE_LIB_WITH_VERSION}"
test -d "${RAKE_LIB_DIR}" || {
echo "No ${RAKE_LIB_DIR}. Installing Rake."
bundle show rake | cut -d'/' -f12 | cut -d'-' -f 2 | xargs bundle exec gem install rake -v
}
set -x
time bundle exec ruby -I"lib:test" -rloader $TEST_FILES
time bundle exec ruby -I"lib:test" \
-I"${RAKE_LIB_DIR}" \
"${RAKE_LIB_DIR}/rake/rake_test_loader.rb" \
$TEST_FILES

View File

@@ -37,7 +37,7 @@ collections:
### Step 2: Add your content
Create a corresponding folder (e.g. `<source>/_my_collection`) and add documents.
YAML Front Matter is read in as data if it exists, and everything after it is stuck in the Document's `content` attribute. If no YAML Front Matter is provided, Jekyll will not generate the file in your collection.
YAML Front Matter is read in as data if it exists, if not, then everything is just stuck in the Document's `content` attribute.
Note: the folder must be named identically to the collection you defined in your `_config.yml` file, with the addition of the preceding `_` character.
@@ -211,7 +211,8 @@ In addition to any YAML Front Matter provided in the document's corresponding fi
</td>
<td>
<p>
The (unrendered) content of the document. If no YAML Front Matter is provided, Jekyll will not generate the file in your collection. If YAML Front Matter
The (unrendered) content of the document. If no YAML Front Matter is provided,
this is the entirety of the file contents. If YAML Front Matter
is used, then this is all the contents of the file after the terminating
`---` of the front matter.
</p>

View File

@@ -514,7 +514,6 @@ You can find a few useful plugins at the following locations:
- [Org-mode Converter](https://gist.github.com/abhiyerra/7377603): Org-mode converter for Jekyll.
- [Customized Kramdown Converter](https://github.com/mvdbos/kramdown-with-pygments): Enable Pygments syntax highlighting for Kramdown-parsed fenced code blocks.
- [Bigfootnotes Plugin](https://github.com/TheFox/jekyll-bigfootnotes): Enables big footnotes for Kramdown.
- [AsciiDoc Plugin](https://github.com/asciidoctor/jekyll-asciidoc): AsciiDoc convertor for Jekyll using [Asciidoctor](http://asciidoctor.org/).
#### Filters

View File

@@ -3,8 +3,7 @@
var anchor = document.createElement("a");
anchor.className = "header-link";
anchor.href = "#" + id;
anchor.innerHTML = "<span class=\"sr-only\">Permalink</span><i class=\"fa fa-link\"></i>";
anchor.title = "Permalink";
anchor.innerHTML = "<i class=\"fa fa-link\"></i>";
return anchor;
};

View File

@@ -1,4 +1,4 @@
<footer role="contentinfo">
<footer>
<div class="grid">
<div class="unit one-third center-on-mobiles">
<p>The contents of this website are &copy;&nbsp;{{ site.time | date: '%Y' }} <a href="http://tom.preston-werner.com/">Tom Preston-Werner</a> under the terms of the <a href="{{ site.repository }}/blob/master/LICENSE">MIT&nbsp;License</a>.</p>

View File

@@ -1,4 +1,4 @@
<header role="banner">
<header>
<nav class="mobile-nav show-on-mobiles">
{% include primary-nav-items.html %}
</nav>
@@ -6,8 +6,8 @@
<div class="unit one-third center-on-mobiles">
<h1>
<a href="/">
<span class="sr-only">Jekyll</span>
<img src="/img/logo-2x.png" width="249" height="115" alt="Jekyll Logo">
<span>Jekyll</span>
<img src="/img/logo-2x.png" width="249" height="115" alt="Logo">
</a>
</h1>
</div>

View File

@@ -14,7 +14,7 @@
{{ post.date | date_to_string }}
</span>
<a href="https://github.com/{{ post.author }}" class="post-author">
<img src="https://github.com/{{ post.author }}.png" class="avatar" alt="{{ post.author }} avatar" width="24" height="24">
<img src="https://github.com/{{ post.author }}.png" class="avatar" alt="{{ post.author }}" width="24" height="24">
{{ post.author }}
</a>
</div>

View File

@@ -17,7 +17,7 @@ layout: news
{{ page.date | date_to_string }}
</span>
<a href="https://github.com/{{ page.author }}" class="post-author">
<img src="https://github.com/{{ page.author }}.png" class="avatar" alt="{{ page.author }} avatar" width="24" height="24">
<img src="https://github.com/{{ page.author }}.png" class="avatar" alt="{{ page.author }}" width="24" height="24">
{{ page.author }}
</a>
</div>

View File

@@ -44,6 +44,9 @@ header {
h1,
nav { display: inline-block; }
h1 {
span { display: none; }
}
}
nav {
@@ -162,10 +165,10 @@ h6:hover .header-link {
/* Footer */
footer {
background-color: #212121;
background-color: #222;
font-size: 16px;
padding-bottom: 5px;
color: #c0c0c0;
color: #888;
margin-top: 40px;
a {
@@ -227,7 +230,7 @@ footer {
.content { padding: 0; }
h3 {
h4 {
font-size: 24px;
line-height: 24px;
margin-top: 20px;
@@ -250,7 +253,7 @@ footer {
float: right;
}
h3 {
h4 {
margin: 50px 0 0;
text-align: center;
}
@@ -292,7 +295,7 @@ footer {
padding: 20px;
text-shadow: none;
margin: 0 20px;
background-color: #171717;
background-color: #3d3d3d;
@include border-radius(0 0 5px 5px);
@include box-shadow(0 5px 30px rgba(0,0,0,.3));
}
@@ -330,7 +333,7 @@ footer {
.free-hosting {
.pane {
background-color: #3e3e3e;
background-color: #444;
@include border-radius(10px);
text-shadow: none;
position: relative;
@@ -480,7 +483,7 @@ aside {
@include border-radius(5px);
/*border: 1px solid #333;*/
@include box-shadow(0 1px 3px rgba(0,0,0,.3), inset 0 1px 1px rgba(255,255,255,.5));
background-color: #767676;
background-color: #777;
}
a:hover {
@@ -594,7 +597,7 @@ article h2:first-child { margin-top: 0; }
.post-meta {
padding: 5px 0;
color: #c0c0c0;
color: #aaa;
font-weight: 600;
text-shadow: 0 -1px 0 #000;
}
@@ -632,7 +635,7 @@ p > nobr > code,
li > code,
h5 > code,
.note > code {
background-color: #2b2b2b;
background-color: #333;
color: #fff;
@include border-radius(5px);
@include box-shadow(inset 0 1px 10px rgba(0,0,0,.3),
@@ -968,18 +971,3 @@ code.output {
display: inline !important;
}
}
/* Helper class taken from Bootstrap.
Hides an element to all devices except screen readers.
*/
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}

View File

@@ -38,7 +38,7 @@ overview: true
<section class="quickstart">
<div class="grid">
<div class="unit golden-small center-on-mobiles">
<h3>Get up and running <em>in&nbsp;seconds</em>.</h3>
<h4>Get up and running <em>in&nbsp;seconds</em>.</h4>
</div>
<div class="unit golden-large code">
<p class="title">Quick-start Instructions</p>

View File

@@ -1,44 +0,0 @@
# Yoinked lovingly from Rake's source code.
#
# Copyright (c) Jim Weirich
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require 'rake'
# Load the test files from the command line.
argv = ARGV.select do |argument|
case argument
when /^-/ then
argument
when /\*/ then
FileList[argument].to_a.each do |file|
require File.expand_path file
end
false
else
require File.expand_path argument
false
end
end
ARGV.replace argv

View File

@@ -1 +1 @@
../../../tmp/
/tmp

View File

@@ -0,0 +1,5 @@
---
title: Test Post Where YAML Ends in Dots
...
# Test

View File

@@ -26,4 +26,4 @@ Partial variable test
Relative to self test:
- 9 {% include_relative 2010-01-08-triple-dash.markdown %}
- 9 {% include_relative 2014-03-03-yaml-with-dots.md %}

View File

@@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
end
should "ensure post count is as expected" do
assert_equal 43, @site.posts.size
assert_equal 44, @site.posts.size
end
should "insert site.posts into the index" do

View File

@@ -165,6 +165,18 @@ class TestPost < Test::Unit::TestCase
end
end
context "with three dots ending YAML header" do
setup do
@real_file = "2014-03-03-yaml-with-dots.md"
end
should "should read the YAML header" do
@post.read_yaml(@source, @real_file)
assert_equal({"title" => "Test Post Where YAML Ends in Dots"},
@post.data)
end
end
context "with embedded triple dash" do
setup do
@real_file = "2010-01-08-triple-dash.markdown"

View File

@@ -174,46 +174,6 @@ CONTENT
end
end
context "post content has highlight tag with preceding spaces & lines" do
setup do
fill_post <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
end
should "only strip the preceding newlines" do
assert_match %{<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]}, @result
end
end
context "post content has highlight tag with preceding spaces & Windows-style newlines" do
setup do
fill_post "\r\n\r\n\r\n [,1] [,2]"
end
should "only strip the preceding newlines" do
assert_match %{<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]}, @result
end
end
context "post content has highlight tag with only preceding spaces" do
setup do
fill_post <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
end
should "only strip the preceding newlines" do
assert_match %{<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]}, @result
end
end
context "simple post with markdown and pre tags" do
setup do
@content = <<CONTENT
@@ -359,7 +319,7 @@ CONTENT
context "with symlink'd include" do
should "not allow symlink includes" do
File.open("tmp/pages-test", 'w') { |file| file.write("SYMLINK TEST") }
File.open("/tmp/pages-test", 'w') { |file| file.write("SYMLINK TEST") }
assert_raise IOError do
content = <<CONTENT
---
@@ -650,7 +610,7 @@ CONTENT
context "with symlink'd include" do
should "not allow symlink includes" do
File.open("tmp/pages-test", 'w') { |file| file.write("SYMLINK TEST") }
File.open("/tmp/pages-test", 'w') { |file| file.write("SYMLINK TEST") }
assert_raise IOError do
content = <<CONTENT
---