Merge branch 'master' into minor-refactors

This commit is contained in:
maul.esel 2013-07-28 21:21:50 +02:00
commit b5d25427e5
20 changed files with 331 additions and 81 deletions

View File

@ -3,11 +3,30 @@
### Major Enhancements
### Minor Enhancements
* Remove superfluous `table` selector from main.css in `jekyll new` template (#1328)
### Bug Fixes
### Development Fixes
* Remove redundant argument to
Jekyll::Commands::New#scaffold_post_content (#1356)
### Site Enhancements
* Add info about new releases (#1353)
* Update plugin list with jekyll-rss plugin (#1354)
## v1.1.2 / 2013-07-25
### Bug Fixes
* Require Liquid 2.5.1 (#1349)
## v1.1.1 / 2013-07-24
### Minor Enhancements
* Remove superfluous `table` selector from main.css in `jekyll new` template (#1328)
* Abort with non-zero exit codes (#1338)
### Bug Fixes
* Fix up the rendering of excerpts (#1339)
### Site Enhancements
* Add Jekyll Image Tag to the plugins list (#1306)
@ -21,6 +40,7 @@
* Update Quick-Start page to include reminder that all requirements must be installed (#1327)
* Change filename in `include` example to an HTML file so as not to indicate that Jekyll
will automatically convert them. (#1303)
* Add an RSS feed for commits to Jekyll (#1343)
## 1.1.0 / 2013-07-14

View File

@ -12,7 +12,7 @@ program :name, 'jekyll'
program :version, Jekyll::VERSION
program :description, 'Jekyll is a blog-aware, static site generator in Ruby'
default_command :help
default_command :default
global_option '-s', '--source [DIR]', 'Source directory (defaults to ./)'
global_option '-d', '--destination [DIR]', 'Destination directory (defaults to ./_site)'
@ -33,6 +33,16 @@ def normalize_options(options)
options
end
command :default do |c|
c.action do |args, options|
if args.empty?
command(:help).run
else
Jekyll.logger.abort_with "Invalid command. Use --help for more information"
end
end
end
command :new do |c|
c.syntax = 'jekyll new PATH'
c.description = 'Creates a new Jekyll site scaffold in PATH'

View File

@ -0,0 +1,50 @@
Feature: Post excerpts
As a hacker who likes to blog
I want to be able to make a static site
In order to share my awesome ideas with the interwebs
But some people can only focus for a few moments
So just give them a taste
Scenario: An excerpt without a layout
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
And I have a _posts directory
And I have the following posts:
| title | date | layout | content |
| entry1 | 2007-12-31 | post | content for entry1. |
When I run jekyll
Then the _site directory should exist
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"
Scenario: An excerpt from a post with a layout
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
And I have a _posts directory
And I have a _layouts directory
And I have a post layout that contains "{{ page.excerpt }}"
And I have the following posts:
| title | date | layout | content |
| entry1 | 2007-12-31 | post | content for entry1. |
When I run jekyll
Then the _site directory should exist
And the _site/2007 directory should exist
And the _site/2007/12 directory should exist
And the _site/2007/12/31 directory should exist
And the "_site/2007/12/31/entry1.html" file should exist
And I should see exactly "<p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"
Scenario: An excerpt from a post with a layout which has context
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
And I have a _posts directory
And I have a _layouts directory
And I have a post layout that contains "<html><head></head><body>{{ page.excerpt }}</body></html>"
And I have the following posts:
| title | date | layout | content |
| entry1 | 2007-12-31 | post | content for entry1. |
When I run jekyll
Then the _site directory should exist
And the _site/2007 directory should exist
And the _site/2007/12 directory should exist
And the _site/2007/12/31 directory should exist
And the "_site/2007/12/31/entry1.html" file should exist
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"
And I should see exactly "<html><head></head><body><p>content for entry1.</p></body></html>" in "_site/2007/12/31/entry1.html"

View File

@ -4,6 +4,8 @@ Before do
Dir.chdir(TEST_DIR)
end
World(Test::Unit::Assertions)
Given /^I have a blank site in "(.*)"$/ do |path|
FileUtils.mkdir(path)
end
@ -143,6 +145,10 @@ Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
assert Regexp.new(text).match(File.open(file).readlines.join)
end
Then /^I should see exactly "(.*)" in "(.*)"$/ do |text, file|
assert_equal text, File.open(file).readlines.join.strip
end
Then /^I should not see "(.*)" in "(.*)"$/ do |text, file|
assert_no_match Regexp.new(text), File.read(file)
end

View File

@ -4,9 +4,9 @@ Gem::Specification.new do |s|
s.rubygems_version = '1.3.5'
s.name = 'jekyll'
s.version = '1.1.0'
s.version = '1.1.2'
s.license = 'MIT'
s.date = '2013-07-14'
s.date = '2013-07-25'
s.rubyforge_project = 'jekyll'
s.summary = "A simple, blog aware, static site generator."
@ -23,7 +23,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--charset=UTF-8"]
s.extra_rdoc_files = %w[README.markdown LICENSE]
s.add_runtime_dependency('liquid', "~> 2.3")
s.add_runtime_dependency('liquid', "~> 2.5.1")
s.add_runtime_dependency('classifier', "~> 1.3")
s.add_runtime_dependency('directory_watcher', "~> 1.4.1")
s.add_runtime_dependency('maruku', "~> 0.5")
@ -65,6 +65,7 @@ Gem::Specification.new do |s|
features/pagination.feature
features/permalinks.feature
features/post_data.feature
features/post_excerpts.feature
features/site_configuration.feature
features/site_data.feature
features/step_definitions/jekyll_steps.rb
@ -140,6 +141,9 @@ Gem::Specification.new do |s|
site/_posts/2013-05-12-jekyll-1-0-2-released.markdown
site/_posts/2013-06-07-jekyll-1-0-3-released.markdown
site/_posts/2013-07-14-jekyll-1-1-0-released.markdown
site/_posts/2013-07-24-jekyll-1-1-1-released.markdown
site/_posts/2013-07-25-jekyll-1-0-4-released.markdown
site/_posts/2013-07-25-jekyll-1-1-2-released.markdown
site/css/gridism.css
site/css/normalize.css
site/css/pygments.css
@ -228,6 +232,7 @@ Gem::Specification.new do |s|
test/source/_posts/2013-03-19-not-a-post.markdown/.gitkeep
test/source/_posts/2013-04-11-custom-excerpt.markdown
test/source/_posts/2013-05-10-number-category.textile
test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown
test/source/_posts/es/2008-11-21-nested.textile
test/source/about.html
test/source/category/_posts/2008-9-23-categories.textile
@ -248,6 +253,7 @@ Gem::Specification.new do |s|
test/test_configuration.rb
test/test_convertible.rb
test/test_core_ext.rb
test/test_excerpt.rb
test/test_filters.rb
test/test_generated_site.rb
test/test_kramdown.rb

View File

@ -58,7 +58,7 @@ require_all 'jekyll/tags'
SafeYAML::OPTIONS[:suppress_warnings] = true
module Jekyll
VERSION = '1.1.0'
VERSION = '1.1.2'
# Public: Generate a Jekyll configuration Hash by merging the default
# options with anything in _config.yml, and adding the given options on top.

View File

@ -19,7 +19,7 @@ module Jekyll
create_sample_files new_blog_path
File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f|
f.write(self.scaffold_post_content(site_template))
f.write(self.scaffold_post_content)
end
end
@ -33,7 +33,7 @@ module Jekyll
end
end
def self.scaffold_post_content(template_site)
def self.scaffold_post_content
ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result
end

View File

@ -1,41 +1,5 @@
module Jekyll
class Excerpt
# Internal: Extract excerpt from the content
#
# By default excerpt is your first paragraph of a post: everything before
# the first two new lines:
#
# ---
# title: Example
# ---
#
# First paragraph with [link][1].
#
# Second paragraph.
#
# [1]: http://example.com/
#
# This is fairly good option for Markdown and Textile files. But might cause
# problems for HTML posts (which is quite unusual for Jekyll). If default
# excerpt delimiter is not good for you, you might want to set your own via
# configuration option `excerpt_separator`. For example, following is a good
# alternative for HTML posts:
#
# # file: _config.yml
# excerpt_separator: "<!-- more -->"
#
# Notice that all markdown-style link references will be appended to the
# excerpt. So the example post above will have this excerpt source:
#
# First paragraph with [link][1].
#
# [1]: http://example.com/
#
# Excerpts are rendered same time as content is rendered.
#
# Returns excerpt String
include Convertible
attr_accessor :post
@ -49,22 +13,41 @@ module Jekyll
#
# Returns the new Post.
def initialize(post)
@post = post
@content = extract_excerpt(post.content)
self.post = post
self.content = extract_excerpt(post.content)
end
%w[site name data ext].each do |meth|
%w[site name ext].each do |meth|
define_method(meth) do
post.send(meth)
end
end
def to_liquid
post.to_liquid(Post::EXCERPT_ATTRIBUTES_FOR_LIQUID)
end
# Fetch YAML front-matter data from related post, without layout key
#
# Returns Hash of post data
def data
@data ||= post.data.dup
@data.delete("layout")
@data
end
# 'Path' of the excerpt.
#
# Returns the path for the post this excerpt belongs to with #excerpt appended
def path
File.join(post.path, "#excerpt")
end
# Check if excerpt includes a string
#
# Returns true if the string passed in
def include?(something)
(output && output.include?(something)) || content.include?(something)
(self.output && self.output.include?(something)) || self.content.include?(something)
end
# The UID for this post (useful in feeds).
@ -75,15 +58,8 @@ module Jekyll
File.join(post.dir, post.slug, "#excerpt")
end
# Convert this post into a Hash for use in Liquid templates.
#
# Returns the representative Hash.
def to_liquid
post.to_liquid
end
def to_s
output || content
self.output || self.content
end
# Returns the shorthand String identifier of this Post.

View File

@ -6,8 +6,7 @@ module Jekyll
# Valid post name regex.
MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$/
# Attributes for Liquid templates
ATTRIBUTES_FOR_LIQUID = %w[
EXCERPT_ATTRIBUTES_FOR_LIQUID = %w[
title
url
date
@ -16,11 +15,15 @@ module Jekyll
next
previous
tags
content
excerpt
path
]
# Attributes for Liquid templates
ATTRIBUTES_FOR_LIQUID = EXCERPT_ATTRIBUTES_FOR_LIQUID.concat(%w[
content
excerpt
])
# Post name validator. Post filenames must be like:
# 2008-11-05-my-awesome-post.textile
#
@ -251,12 +254,12 @@ module Jekyll
# construct payload
payload = {
"site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) },
"page" => self.to_liquid
"page" => self.to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID)
}.deep_merge(site_payload)
self.extracted_excerpt.do_layout(payload, layouts)
self.extracted_excerpt.do_layout(payload, {})
do_layout(payload, layouts)
do_layout(payload.merge({"page" => self.to_liquid}), layouts)
end
# Obtain destination path.

View File

@ -5,7 +5,7 @@ module Jekyll
DEBUG = 0
INFO = 1
WARN = 2
ERROR = 3
ERROR = 3
# Public: Create a new instance of Stevenson, Jekyll's logger
#
@ -15,6 +15,16 @@ module Jekyll
def initialize(level = INFO)
@log_level = level
end
# Public: Print a jekyll debug message to stdout
#
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
# message - the message detail
#
# Returns nothing
def debug(topic, message = nil)
$stdout.puts(message(topic, message)) if log_level <= DEBUG
end
# Public: Print a jekyll message to stdout
#
@ -22,7 +32,7 @@ module Jekyll
# message - the message detail
#
# Returns nothing
def info(topic, message)
def info(topic, message = nil)
$stdout.puts(message(topic, message)) if log_level <= INFO
end
@ -32,7 +42,7 @@ module Jekyll
# message - the message detail
#
# Returns nothing
def warn(topic, message)
def warn(topic, message = nil)
$stderr.puts(message(topic, message).yellow) if log_level <= WARN
end
@ -42,10 +52,21 @@ module Jekyll
# message - the message detail
#
# Returns nothing
def error(topic, message)
def error(topic, message = nil)
$stderr.puts(message(topic, message).red) if log_level <= ERROR
end
# Public: Print a Jekyll error message to stderr and immediately abort the process
#
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
# message - the message detail (can be omitted)
#
# Returns nothing
def abort_with(topic, message = nil)
error(topic, message)
abort
end
# Public: Build a Jekyll topic method
#
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.

View File

@ -2,43 +2,43 @@
<aside>
<h4>Getting Started</h4>
<ul>
<li class="{% if page.title == "Welcome" %}current{% endif %}">
<li class="{% if page.title == 'Welcome' %}current{% endif %}">
<a href="{{ site.url }}/docs/home">Welcome</a>
</li>
<li class="{% if page.title == "Quick-start guide" %}current{% endif %}">
<li class="{% if page.title == 'Quick-start guide' %}current{% endif %}">
<a href="{{ site.url }}/docs/quickstart">Quick-start guide</a>
</li>
<li class="{% if page.title == "Installation" %}current{% endif %}">
<li class="{% if page.title == 'Installation' %}current{% endif %}">
<a href="{{ site.url }}/docs/installation">Installation</a>
</li>
<li class="{% if page.title == "Basic Usage" %}current{% endif %}">
<li class="{% if page.title == 'Basic Usage' %}current{% endif %}">
<a href="{{ site.url }}/docs/usage">Basic Usage</a>
</li>
<li class="{% if page.title == "Directory structure" %}current{% endif %}">
<li class="{% if page.title == 'Directory structure' %}current{% endif %}">
<a href="{{ site.url }}/docs/structure">Directory structure</a>
</li>
<li class="{% if page.title == "Configuration" %}current{% endif %}">
<li class="{% if page.title == 'Configuration' %}current{% endif %}">
<a href="{{ site.url }}/docs/configuration">Configuration</a>
</li>
</ul>
<h4>Your Content</h4>
<ul>
<li class="{% if page.title == "Front-matter" %}current{% endif %}">
<li class="{% if page.title == 'Front-matter' %}current{% endif %}">
<a href="{{ site.url }}/docs/frontmatter">Front-matter</a>
</li>
<li class="{% if page.title == "Writing posts" %}current{% endif %}">
<li class="{% if page.title == 'Writing posts' %}current{% endif %}">
<a href="{{ site.url }}/docs/posts">Writing posts</a>
</li>
<li class="{% if page.title == "Working with drafts" %}current{% endif %}">
<li class="{% if page.title == 'Working with drafts' %}current{% endif %}">
<a href="{{ site.url }}/docs/drafts">Working with drafts</a>
</li>
<li class="{% if page.title == "Creating pages" %}current{% endif %}">
<li class="{% if page.title == 'Creating pages' %}current{% endif %}">
<a href="{{ site.url }}/docs/pages">Creating pages</a>
</li>
<li class="{% if page.title == "Variables" %}current{% endif %}">
<li class="{% if page.title == 'Variables' %}current{% endif %}">
<a href="{{ site.url }}/docs/variables">Variables</a>
</li>
<li class="{% if page.title == "Blog migrations" %}current{% endif %}">
<li class="{% if page.title == 'Blog migrations' %}current{% endif %}">
<a href="{{ site.url }}/docs/migrations">Blog migrations</a>
</li>
</ul>

View File

@ -5,6 +5,7 @@
<title>{{ page.title }}</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="alternate" type="application/rss+xml" title="Jekyll • Simple, blog-aware, static sites - Feed" href="/feed.xml" />
<link rel="alternate" type="application/atom+xml" title="Recent commits to Jekylls master branch" href="https://github.com/mojombo/jekyll/commits/master.atom" />
<link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Arizonia' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="{{ site.url }}/css/normalize.css" />

View File

@ -0,0 +1,31 @@
---
layout: news_item
title: "Jekyll 1.1.1 Released"
date: "2013-07-24 22:24:14 +0200"
author: parkr
version: 1.1.1
categories: [release]
---
Coming just 10 days after the release of v1.1.0, v1.1.1 is out with a patch for the nasty
excerpt inception bug ([#1339][]) and non-zero exit codes for invalid commands
([#1338][]).
To all those affected by the [strange excerpt bug in v1.1.0][#1321], I'm sorry. I think we
have it all patched up and it should be deployed to [GitHub Pages][gh_pages] in the next
couple weeks. Thank you for your patience!
If you're checking out v1.1.x for the first time, definitely check out [what shipped with
v1.1.0!][v1_1_0]
See the [GitHub Release][] page for more a more detailed changelog for this release.
{% assign issue_numbers = "1339|1338|1321" | split: "|" %}
{% for issue in issue_numbers %}
[{{ issue }}]: https://github.com/mojombo/jekyll/issues/{{ issue }}
{% endfor %}
[GitHub Release]: https://github.com/mojombo/jekyll/releases/tag/v1.1.1
[gh-pages]: http://pages.github.com
[v1_1_0]: https://github.com/mojombo/jekyll/releases/tag/v1.1.0

View File

@ -0,0 +1,20 @@
---
layout: news_item
title: "Jekyll 1.0.4 Released"
date: "2013-07-25 09:08:38 +0200"
author: mattr-
version: 1.0.4
categories: [release]
---
Version 1.0.4 fixes a minor, but nonetheless important security vulnerability affecting several third-party Jekyll plugins. If your Jekyll site does not use plugins, you may, but are not required to upgrade at this time.
Community and custom plugins extending the `Liquid::Drop` class may inadvertently disclose some system information such as directory structure or software configuration to users with access to the Liquid templating system.
We recommend you upgrade to Jekyll v1.0.4 immediately if you use `Liquid::Drop` plugins on your Jekyll site.
Many thanks for [Ben Balter](http://github.com/benbalter) for alerting us to the problem
and [submitting a patch][1349] so quickly.
[230]: https://github.com/Shopify/liquid/pull/230
[1349]: https://github.com/mojombo/jekyll/issues/1349

View File

@ -0,0 +1,20 @@
---
layout: news_item
title: "Jekyll 1.1.2 Released"
date: "2013-07-25 09:08:38 +0200"
author: parkr
version: 1.1.2
categories: [release]
---
Version 1.1.2 fixes a minor, but nonetheless important security vulnerability affecting several third-party Jekyll plugins. If your Jekyll site does not use plugins, you may, but are not required to upgrade at this time.
Community and custom plugins extending the `Liquid::Drop` class may inadvertently disclose some system information such as directory structure or software configuration to users with access to the Liquid templating system.
We recommend you upgrade to Jekyll v1.1.2 immediately if you use `Liquid::Drop` plugins on your Jekyll site.
Many thanks for [Ben Balter](http://github.com/benbalter) for alerting us to the problem
and [submitting a patch][1349] so quickly.
[230]: https://github.com/Shopify/liquid/pull/230
[1349]: https://github.com/mojombo/jekyll/issues/1349

View File

@ -361,6 +361,7 @@ You can find a few useful plugins at the following locations:
- [Full-text search by Pascal Widdershoven](https://github.com/PascalW/jekyll_indextank): Adds full-text search to your Jekyll site with a plugin and a bit of JavaScript.
- [AliasGenerator by Thomas Mango](https://github.com/tsmango/jekyll_alias_generator): Generates redirect pages for posts when an alias is specified in the YAML Front Matter.
- [Projectlist by Frederic Hemberger](https://github.com/fhemberger/jekyll-projectlist): Renders files in a directory as a single page instead of separate posts.
- [RssGenerator by Assaf Gelber](https://github.com/agelber/jekyll-rss): Automatically creates an RSS 2.0 feed from your posts.
#### Converters

View File

@ -169,7 +169,7 @@ following is a reference of the available data.
<td><p><code>page.title</code></p></td>
<td><p>
The title of the Post.
The title of the Page.
</p></td>
</tr>

View File

@ -0,0 +1,23 @@
---
layout: post
title: Post Excerpt with Layout
categories:
- bar
- baz
- z_category
tags:
- first
- second
- third
- jekyllrb.com
---
First paragraph with [link ref][link].
Second paragraph
---
Third paragraph
[link]: http://www.jekyllrb.com/

62
test/test_excerpt.rb Normal file
View File

@ -0,0 +1,62 @@
require 'helper'
class TestExcerpt < Test::Unit::TestCase
def setup_post(file)
Post.new(@site, source_dir, '', file)
end
def do_render(post)
layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")}
post.render(layouts, {"site" => {"posts" => []}})
end
context "An extracted excerpt" do
setup do
clear_dest
stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS }
@site = Site.new(Jekyll.configuration)
@post = setup_post("2013-07-22-post-excerpt-with-layout.markdown")
@excerpt = @post.send :extract_excerpt
end
context "#to_liquid" do
should "contain the proper page data to mimick the post liquid" do
assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"]
assert_equal "/bar/baz/z_category/2013/07/22/post-excerpt-with-layout.html", @excerpt.to_liquid["url"]
assert_equal Time.parse("2013-07-22"), @excerpt.to_liquid["date"]
assert_equal %w[bar baz z_category], @excerpt.to_liquid["categories"]
assert_equal %w[first second third jekyllrb.com], @excerpt.to_liquid["tags"]
assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown", @excerpt.to_liquid["path"]
end
end
context "#content" do
context "before render" do
should "be the first paragraph of the page" do
assert_equal "First paragraph with [link ref][link].\n\n[link]: http://www.jekyllrb.com/", @excerpt.content
end
should "contain any refs at the bottom of the page" do
assert @excerpt.content.include?("[link]: http://www.jekyllrb.com/")
end
end
context "after render" do
setup do
@rendered_post = @post.dup
do_render(@rendered_post)
@extracted_excerpt = @rendered_post.send :extracted_excerpt
end
should "be the first paragraph of the page" do
assert_equal "<p>First paragraph with <a href='http://www.jekyllrb.com/'>link ref</a>.</p>", @extracted_excerpt.content
end
should "link properly" do
assert @extracted_excerpt.content.include?("http://www.jekyllrb.com/")
end
end
end
end
end

View File

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