diff --git a/History.markdown b/History.markdown index b8e72d26..98cb701d 100644 --- a/History.markdown +++ b/History.markdown @@ -1,8 +1,51 @@ ## HEAD ### Major Enhancements - * Add 'docs' subcommand to read Jekyll's docs when offline. (#1046) - * Support passing parameters to templates in 'include' tag (#1204) + +### Minor Enhancements + +### Bug Fixes + +### Development Fixes + +### 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) + * Remove erroneous statement that `site.pages` are sorted alphabetically. + * Add info about the `_drafts` directory to the directory structure + docs (#1320) + * Improve the layout of the plugin listing by organizing it into + categories (#1310) + * Add generator-jekyllrb and grunt-jekyll to plugins page (#1330) + * Mention Kramdown as option for markdown parser on Extras page (#1318) + * 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 + +### Major Enhancements + * Add `docs` subcommand to read Jekyll's docs when offline. (#1046) + * Support passing parameters to templates in `include` tag (#1204) + * Add support for Liquid tags to post excerpts (#1302) ### Minor Enhancements * Search the hierarchy of pagination path up to site root to determine template page for @@ -14,6 +57,8 @@ sites. (#1247) * In the generated site, remove files that will be replaced by a directory (#1118) + * Fail loudly if a user-specified configuration file doesn't exist (#1098) + * Allow for all options for Kramdown HTML Converter (#1201) ### Bug Fixes * Fix pagination in subdirectories. (#1198) @@ -27,6 +72,7 @@ * Restrict activesupport dependency to pre-4.0.0 to maintain compatibility with `<= 1.9.2` * Include/exclude deprecation handling simplification (#1284) * Convert README to Markdown. (#1267) + * Refactor Jekyll::Site (#1144) ### Site Enhancements * Add "News" section for release notes, along with an RSS feed (#1093, #1285, #1286) @@ -63,8 +109,8 @@ * Update the S3 deployment documentation (#1294) * Add suggestion for Xcode CLT install to troubleshooting page in docs (#1296) * Add 'Working with drafts' page to docs (#1289) - -### Development Fixes + * Add information about time zones to the documentation for a page's + date (#1304) ## 1.0.3 / 2013-06-07 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 2f2db1dd..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.0.3' + s.version = '1.1.2' s.license = 'MIT' - s.date = '2013-06-07' + 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") @@ -60,10 +60,12 @@ Gem::Specification.new do |s| features/create_sites.feature features/drafts.feature features/embed_filters.feature + features/include_tag.feature features/markdown.feature 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 @@ -89,6 +91,7 @@ Gem::Specification.new do |s| lib/jekyll/deprecator.rb lib/jekyll/draft.rb lib/jekyll/errors.rb + lib/jekyll/excerpt.rb lib/jekyll/filters.rb lib/jekyll/generator.rb lib/jekyll/generators/pagination.rb @@ -123,11 +126,24 @@ Gem::Specification.new do |s| site/_includes/docs_contents_mobile.html site/_includes/footer.html site/_includes/header.html + site/_includes/news_contents.html + site/_includes/news_contents_mobile.html + site/_includes/news_item.html site/_includes/primary-nav-items.html site/_includes/section_nav.html site/_includes/top.html site/_layouts/default.html site/_layouts/docs.html + site/_layouts/news.html + site/_layouts/news_item.html + site/_posts/2013-05-06-jekyll-1-0-0-released.markdown + site/_posts/2013-05-08-jekyll-1-0-1-released.markdown + 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 @@ -135,6 +151,7 @@ Gem::Specification.new do |s| site/docs/configuration.md site/docs/contributing.md site/docs/deployment-methods.md + site/docs/drafts.md site/docs/extras.md site/docs/frontmatter.md site/docs/github-pages.md @@ -148,6 +165,7 @@ Gem::Specification.new do |s| site/docs/permalinks.md site/docs/plugins.md site/docs/posts.md + site/docs/quickstart.md site/docs/resources.md site/docs/sites.md site/docs/structure.md @@ -157,6 +175,8 @@ Gem::Specification.new do |s| site/docs/usage.md site/docs/variables.md site/favicon.png + site/feed.xml + site/freenode.txt site/img/article-footer.png site/img/footer-arrow.png site/img/footer-logo.png @@ -166,13 +186,17 @@ Gem::Specification.new do |s| site/img/tube1x.png site/index.html site/js/modernizr-2.5.3.min.js + site/news/index.md + site/news/releases/index.md test/fixtures/broken_front_matter1.erb test/fixtures/broken_front_matter2.erb test/fixtures/broken_front_matter3.erb test/fixtures/exploit_front_matter.erb test/fixtures/front_matter.erb test/helper.rb + test/source/+/foo.md test/source/.htaccess + test/source/_includes/params.html test/source/_includes/sig.markdown test/source/_layouts/default.html test/source/_layouts/simple.html @@ -208,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 @@ -228,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 6867d1e5..7b543ec1 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -37,6 +37,7 @@ require 'jekyll/url' require 'jekyll/layout' require 'jekyll/page' require 'jekyll/post' +require 'jekyll/excerpt' require 'jekyll/draft' require 'jekyll/filters' require 'jekyll/static_file' @@ -58,7 +59,7 @@ require_all 'jekyll/tags' SafeYAML::OPTIONS[:suppress_warnings] = true module Jekyll - VERSION = '1.0.3' + 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/configuration.rb b/lib/jekyll/configuration.rb index c428c1a6..5b5dda4b 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -102,7 +102,10 @@ module Jekyll def config_files(override) # Get configuration from /_config.yml or / config_files = override.delete('config') - config_files = File.join(source(override), "_config.yml") if config_files.to_s.empty? + if config_files.to_s.empty? + config_files = File.join(source(override), "_config.yml") + @default_config_file = true + end config_files = [config_files] unless config_files.is_a? Array config_files end @@ -114,9 +117,17 @@ module Jekyll # Returns this configuration, overridden by the values in the file def read_config_file(file) next_config = YAML.safe_load_file(file) - raise "Configuration file: (INVALID) #{file}".yellow if !next_config.is_a?(Hash) + raise ArgumentError.new("Configuration file: (INVALID) #{file}".yellow) if !next_config.is_a?(Hash) Jekyll.logger.info "Configuration file:", file next_config + rescue SystemCallError + if @default_config_file + Jekyll.logger.warn "Configuration file:", "none" + {} + else + Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found." + raise LoadError + end end # Public: Read in a list of configuration files and merge with this hash @@ -133,10 +144,7 @@ module Jekyll new_config = read_config_file(config_file) configuration = configuration.deep_merge(new_config) end - rescue SystemCallError - # Errno:ENOENT = file not found - Jekyll.logger.warn "Configuration file:", "none" - rescue => err + rescue ArgumentError => err Jekyll.logger.warn "WARNING:", "Error reading configuration. " + "Using defaults (and options)." $stderr.puts "#{err}" diff --git a/lib/jekyll/converters/markdown/kramdown_parser.rb b/lib/jekyll/converters/markdown/kramdown_parser.rb index 58857276..b4237881 100644 --- a/lib/jekyll/converters/markdown/kramdown_parser.rb +++ b/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -13,8 +13,8 @@ module Jekyll def convert(content) # Check for use of coderay - kramdown_configs = if @config['kramdown']['use_coderay'] - base_kramdown_configs.merge({ + if @config['kramdown']['use_coderay'] + @config['kramdown'].merge!({ :coderay_wrap => @config['kramdown']['coderay']['coderay_wrap'], :coderay_line_numbers => @config['kramdown']['coderay']['coderay_line_numbers'], :coderay_line_number_start => @config['kramdown']['coderay']['coderay_line_number_start'], @@ -22,22 +22,11 @@ module Jekyll :coderay_bold_every => @config['kramdown']['coderay']['coderay_bold_every'], :coderay_css => @config['kramdown']['coderay']['coderay_css'] }) - else - # not using coderay - base_kramdown_configs end - Kramdown::Document.new(content, kramdown_configs).to_html + + Kramdown::Document.new(content, @config["kramdown"].symbolize_keys).to_html end - def base_kramdown_configs - { - :auto_ids => @config['kramdown']['auto_ids'], - :footnote_nr => @config['kramdown']['footnote_nr'], - :entity_output => @config['kramdown']['entity_output'], - :toc_levels => @config['kramdown']['toc_levels'], - :smart_quotes => @config['kramdown']['smart_quotes'] - } - end end end end diff --git a/lib/jekyll/core_ext.rb b/lib/jekyll/core_ext.rb index b1192cf4..00f64fcf 100644 --- a/lib/jekyll/core_ext.rb +++ b/lib/jekyll/core_ext.rb @@ -41,6 +41,17 @@ class Hash end array || [] end + + def symbolize_keys! + keys.each do |key| + self[(key.to_sym rescue key) || key] = delete(key) + end + self + end + + def symbolize_keys + dup.symbolize_keys! + end end # Thanks, ActiveSupport! diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb new file mode 100644 index 00000000..a02272b5 --- /dev/null +++ b/lib/jekyll/excerpt.rb @@ -0,0 +1,113 @@ +module Jekyll + class Excerpt + include Convertible + + attr_accessor :post + attr_accessor :content, :output, :ext + + # Initialize this Post instance. + # + # site - The Site. + # base - The String path to the dir containing the post file. + # name - The String filename of the post file. + # + # Returns the new Post. + def initialize(post) + self.post = post + self.content = extract_excerpt(post.content) + end + + %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) + (self.output && self.output.include?(something)) || self.content.include?(something) + end + + # The UID for this post (useful in feeds). + # e.g. /2008/11/05/my-awesome-post + # + # Returns the String UID. + def id + File.join(post.dir, post.slug, "#excerpt") + end + + def to_s + self.output || self.content + end + + # Returns the shorthand String identifier of this Post. + def inspect + "" + end + + protected + + # 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 + def extract_excerpt(post_content) + separator = site.config['excerpt_separator'] + head, _, tail = post_content.partition(separator) + + "" << head << "\n\n" << tail.scan(/^\[[^\]]+\]:.+$/).join("\n") + end + end +end diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index acf4a62b..79e751fe 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -11,8 +11,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 @@ -21,11 +20,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 # @@ -110,7 +113,7 @@ module Jekyll if self.data.has_key? 'excerpt' self.data['excerpt'] else - self.extracted_excerpt + self.extracted_excerpt.to_s end end @@ -159,14 +162,6 @@ module Jekyll raise FatalException.new("Post #{name} does not have a valid date.") end - # Transform the contents and excerpt based on the content type. - # - # Returns nothing. - def transform - super - self.extracted_excerpt = converter.convert(self.extracted_excerpt) - end - # The generated directory into which the post will be placed # upon generation. This is derived from the permalink or, if # permalink is absent, set to the default date @@ -241,10 +236,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) - do_layout(payload, layouts) + self.extracted_excerpt.do_layout(payload, {}) + + do_layout(payload.merge({"page" => self.to_liquid}), layouts) end # Obtain destination path. @@ -262,8 +259,8 @@ module Jekyll # Convert this post into a Hash for use in Liquid templates. # # Returns the representative Hash. - def to_liquid - further_data = Hash[ATTRIBUTES_FOR_LIQUID.map { |attribute| + def to_liquid(attrs = ATTRIBUTES_FOR_LIQUID) + further_data = Hash[attrs.map { |attribute| [attribute, send(attribute)] }] data.deep_merge(further_data) @@ -295,45 +292,8 @@ module Jekyll protected - # 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 def extract_excerpt - separator = self.site.config['excerpt_separator'] - head, _, tail = self.content.partition(separator) - - "" << head << "\n\n" << tail.scan(/^\[[^\]]+\]:.+$/).join("\n") + Jekyll::Excerpt.new(self) end end end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index e8990b85..f7a8c379 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -138,34 +138,19 @@ module Jekyll entries = Dir.chdir(base) { filter_entries(Dir.entries('.')) } self.read_posts(dir) - - if self.show_drafts - self.read_drafts(dir) - end - + self.read_drafts(dir) if self.show_drafts self.posts.sort! - - # limit the posts if :limit_posts option is set - if limit_posts > 0 - limit = self.posts.length < limit_posts ? self.posts.length : limit_posts - self.posts = self.posts[-limit, limit] - end + limit_posts! if limit_posts > 0 # limit the posts if :limit_posts option is set entries.each do |f| f_abs = File.join(base, f) - f_rel = File.join(dir, f) if File.directory?(f_abs) - next if self.dest.sub(/\/$/, '') == f_abs - read_directories(f_rel) + f_rel = File.join(dir, f) + read_directories(f_rel) unless self.dest.sub(/\/$/, '') == f_abs + elsif has_yaml_header?(f_abs) + pages << Page.new(self, self.source, dir, f) else - first3 = File.open(f_abs) { |fd| fd.read(3) } - if first3 == "---" - # file appears to have a YAML header so process it as a page - pages << Page.new(self, self.source, dir, f) - else - # otherwise treat it as a static file - static_files << StaticFile.new(self, self.source, dir, f) - end + static_files << StaticFile.new(self, self.source, dir, f) end end end @@ -255,15 +240,7 @@ module Jekyll # files to be written files = Set.new - self.posts.each do |post| - files << post.destination(self.dest) - end - self.pages.each do |page| - files << page.destination(self.dest) - end - self.static_files.each do |sf| - files << sf.destination(self.dest) - end + each_site_file { |item| files << item.destination(self.dest) } # adding files' parent directories dirs = Set.new @@ -294,15 +271,7 @@ module Jekyll # # Returns nothing. def write - self.posts.each do |post| - post.write(self.dest) - end - self.pages.each do |page| - page.write(self.dest) - end - self.static_files.each do |sf| - sf.write(self.dest) - end + each_site_file { |item| item.write(self.dest) } end # Construct a Hash of Posts indexed by the specified Post attribute. @@ -434,5 +403,24 @@ module Jekyll @deprecated_relative_permalinks = true end end + + def each_site_file + %w(posts pages static_files).each do |type| + self.send(type).each do |item| + yield item + end + end + end + + private + + def has_yaml_header?(file) + "---" == File.open(file) { |fd| fd.read(3) } + end + + def limit_posts! + limit = self.posts.length < limit_posts ? self.posts.length : limit_posts + self.posts = self.posts[-limit, limit] + end end end 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/lib/site_template/css/main.css b/lib/site_template/css/main.css index 0e86700b..50a81804 100755 --- a/lib/site_template/css/main.css +++ b/lib/site_template/css/main.css @@ -29,11 +29,6 @@ a { color: #00a; } a:hover { color: #000; } a:visited { color: #a0a; } -table { - font-size: inherit; - font: 100%; -} - /*****************************************************************************/ /* /* Home 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 @@