diff --git a/History.markdown b/History.markdown index 436e50a3..6fae363d 100644 --- a/History.markdown +++ b/History.markdown @@ -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 diff --git a/bin/jekyll b/bin/jekyll index 01f97cf9..fe61508e 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -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' diff --git a/features/post_excerpts.feature b/features/post_excerpts.feature new file mode 100644 index 00000000..09e41338 --- /dev/null +++ b/features/post_excerpts.feature @@ -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 "

content for entry1.

" 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 "

content for entry1.

" in "_site/2007/12/31/entry1.html" + And I should see exactly "

content for entry1.

" 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 "{{ 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 "

content for entry1.

" in "_site/index.html" + And I should see exactly "

content for entry1.

" in "_site/2007/12/31/entry1.html" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 9208c4ec..136f048d 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -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 diff --git a/jekyll.gemspec b/jekyll.gemspec index c99f5161..b29d9667 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -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 diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 77cc7cd5..3f575837 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -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. diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 8757a91b..00b08c20 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -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 diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 16584963..a02272b5 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -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: "" - # - # 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. diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 415a3f66..f157f0c1 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -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. diff --git a/lib/jekyll/stevenson.rb b/lib/jekyll/stevenson.rb index 5be5f04c..898bc09f 100644 --- a/lib/jekyll/stevenson.rb +++ b/lib/jekyll/stevenson.rb @@ -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. diff --git a/site/_includes/docs_contents.html b/site/_includes/docs_contents.html index 909832f4..35904fbf 100644 --- a/site/_includes/docs_contents.html +++ b/site/_includes/docs_contents.html @@ -2,43 +2,43 @@