Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Accept custom configs #725

Closed
wants to merge 22 commits into from

4 participants

@parkr
Owner

Fixes & tests for #393. Also adds ability to pass in multiple config files which cascade from right to left (later files override earlier files' configs).

@tobi put a great use-case very nicely:

Same here, we run www.shopify.com from a fork that has this merged. We keep _config.yml with the project but also have _config.live.yml which enables things like asset compression and performs some other tasks that are not needed in development environment.

@sl4mmy

I mentioned another use case in #561:

Some sites hosted on GitHub Pages run Jekyll locally in unsafe mode in order to use plugins, and push static HTML up to GitHub Pages where Jekyll is run in safe mode. This feature would simplify setting up such workflows, especially on documentation projects with many contributors.

@parkr parkr was assigned
@mattr-

missing a > here at the end of the line.

@parkr
Owner

Going to re-submit under a different PR.

@parkr parkr closed this
@parkr parkr deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 2, 2013
  1. @StefanLiebenberg @parkr

    added custom config file

    StefanLiebenberg authored parkr committed
    Signed-off-by: Parker Moore <parkrmoore@gmail.com>
  2. @parkr
  3. @parkr
  4. @parkr

    Tests for --config

    parkr authored
  5. @parkr
Commits on Jan 16, 2013
  1. @parkr

    Added the missing '>'

    parkr authored
  2. @parkr

    Fixed merge conflict

    parkr authored
  3. @parkr

    Tests for --config

    parkr authored
  4. @parkr
  5. @parkr

    Added the missing '>'

    parkr authored
  6. @parkr

    Merged bin/jekyll

    parkr authored
Commits on Mar 13, 2013
  1. @parkr

    Merge pull request #855 from danielgrieve/remove-ruby-version

    parkr authored
    ignore .ruby-version
Commits on Mar 14, 2013
  1. @parkr

    Bump version to 1.0.0.pre.

    parkr authored
  2. @parkr

    Release 1.0.0.pre

    parkr authored
  3. @parkr
  4. @parkr

    Release 1.0.0.beta1

    parkr authored
Commits on Mar 16, 2013
  1. @parkr

    Renamed test under wrong name.

    parkr authored
  2. @parkr

    Rebase on master

    parkr authored
  3. @parkr

    Tests for --config

    parkr authored
  4. @parkr
  5. @parkr

    Added the missing '>'

    parkr authored
  6. @parkr

    Merge branch 'accept-custom-config' of github.com:mojombo/jekyll into…

    parkr authored
    … accept-custom-config
    
    * 'accept-custom-config' of github.com:mojombo/jekyll:
      Added the missing '>'
      Using default config if config passed is either empty or null
      Tests for --config
      Fixed merge conflict
      Added the missing '>'
      Using default config if config passed is either empty or null
      Tests for --config
      Raise error if no config file is passed to --config
      Moved --config block to below importer switches
      added custom config file
This page is out of date. Refresh to see the latest.
View
2  features/site_configuration.feature
@@ -3,7 +3,7 @@ Feature: Site configuration
I want to be able to configure jekyll
In order to make setting up a site easier
- Scenario: Change destination directory
+ Scenario: Change source directory
Given I have a blank site in "_sourcedir"
And I have an "_sourcedir/index.html" file that contains "Changing source directory"
And I have a configuration file with "source" set to "_sourcedir"
View
64 jekyll.gemspec
@@ -4,9 +4,9 @@ Gem::Specification.new do |s|
s.rubygems_version = '1.3.5'
s.name = 'jekyll'
- s.version = '0.12.0'
+ s.version = '1.0.0.beta1'
s.license = 'MIT'
- s.date = '2012-12-22'
+ s.date = '2013-03-14'
s.rubyforge_project = 'jekyll'
s.summary = "A simple, blog aware, static site generator."
@@ -47,7 +47,6 @@ Gem::Specification.new do |s|
# = MANIFEST =
s.files = %w[
- .travis.yml
CONTRIBUTING.md
Gemfile
History.txt
@@ -57,6 +56,7 @@ Gem::Specification.new do |s|
bin/jekyll
cucumber.yml
features/create_sites.feature
+ features/drafts.feature
features/embed_filters.feature
features/markdown.feature
features/pagination.feature
@@ -77,22 +77,76 @@ Gem::Specification.new do |s|
lib/jekyll/converters/textile.rb
lib/jekyll/convertible.rb
lib/jekyll/core_ext.rb
+ lib/jekyll/draft.rb
lib/jekyll/errors.rb
lib/jekyll/filters.rb
lib/jekyll/generator.rb
lib/jekyll/generators/pagination.rb
lib/jekyll/layout.rb
+ lib/jekyll/mime.types
lib/jekyll/page.rb
lib/jekyll/plugin.rb
lib/jekyll/post.rb
lib/jekyll/site.rb
lib/jekyll/static_file.rb
+ lib/jekyll/tags/gist.rb
lib/jekyll/tags/highlight.rb
lib/jekyll/tags/include.rb
lib/jekyll/tags/post_url.rb
+ script/bootstrap
+ site/.gitignore
+ site/CNAME
+ site/README
+ site/_config.yml
+ site/_includes/analytics.html
+ site/_includes/docs_contents.html
+ site/_includes/footer.html
+ site/_includes/header.html
+ site/_includes/section_nav.html
+ site/_includes/top.html
+ site/_layouts/default.html
+ site/_layouts/docs.html
+ site/_posts/2012-07-01-configuration.md
+ site/_posts/2012-07-01-contributing.md
+ site/_posts/2012-07-01-deployment-methods.md
+ site/_posts/2012-07-01-extras.md
+ site/_posts/2012-07-01-frontmatter.md
+ site/_posts/2012-07-01-github-pages.md
+ site/_posts/2012-07-01-heroku.md
+ site/_posts/2012-07-01-home.md
+ site/_posts/2012-07-01-installation.md
+ site/_posts/2012-07-01-migrations.md
+ site/_posts/2012-07-01-pages.md
+ site/_posts/2012-07-01-pagination.md
+ site/_posts/2012-07-01-permalinks.md
+ site/_posts/2012-07-01-plugins.md
+ site/_posts/2012-07-01-posts.md
+ site/_posts/2012-07-01-resources.md
+ site/_posts/2012-07-01-sites.md
+ site/_posts/2012-07-01-structure.md
+ site/_posts/2012-07-01-templates.md
+ site/_posts/2012-07-01-troubleshooting.md
+ site/_posts/2012-07-01-usage.md
+ site/_posts/2012-07-01-variables.md
+ site/css/grid.css
+ site/css/normalize.css
+ site/css/pygments.css
+ site/css/style.css
+ site/docs/index.html
+ site/favicon.png
+ site/img/article-footer.png
+ site/img/footer-arrow.png
+ site/img/footer-logo.png
+ site/img/logo-2x.png
+ site/img/octojekyll.png
+ site/img/tube.png
+ site/img/tube1x.png
+ site/index.html
+ site/js/modernizr-2.5.3.min.js
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/.htaccess
@@ -124,9 +178,13 @@ Gem::Specification.new do |s|
test/source/_posts/2010-01-16-override-data.textile
test/source/_posts/2011-04-12-md-extension.md
test/source/_posts/2011-04-12-text-extension.text
+ test/source/_posts/2013-01-12-nil-layout.textile
+ test/source/_posts/2013-01-12-no-layout.textile
test/source/about.html
test/source/category/_posts/2008-9-23-categories.textile
test/source/contacts.html
+ test/source/contacts/bar.html
+ test/source/contacts/index.html
test/source/css/screen.css
test/source/deal.with.dots.html
test/source/foo/_posts/bar/2008-12-12-topical-post.textile
View
8 lib/jekyll.rb
@@ -52,7 +52,7 @@ def require_all(path)
SafeYAML::OPTIONS[:suppress_warnings] = true
module Jekyll
- VERSION = '0.12.0'
+ VERSION = '1.0.0.beta1'
# Default options. Overriden by values in _config.yml.
# Strings rather than symbols are used for compatability with YAML.
@@ -129,8 +129,10 @@ def self.configuration(override)
# then, we need to know where to look for _config.yml
source = override['source'] || Jekyll::DEFAULTS['source']
- # Get configuration from <source>/_config.yml
- config_file = File.join(source, '_config.yml')
+ # Get configuration from <source>/_config.yml or <source>/<config_file>
+ config_file = override.delete('config')
+ config_file = File.join(source, "_config.yml") if config_file.to_s.empty?
+
begin
config = YAML.safe_load_file(config_file)
raise "Configuration file: (INVALID) #{config_file}" if !config.is_a?(Hash)
View
27 test/test_configuration.rb
@@ -25,4 +25,31 @@ class TestConfiguration < Test::Unit::TestCase
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
end
end
+ context "loading config from external file" do
+ setup do
+ @paths = {
+ :default => File.join(Dir.pwd, '_config.yml'),
+ :other => File.join(Dir.pwd, '_config.live.yml'),
+ :empty => ""
+ }
+ end
+
+ should "load default config if no config_file is set" do
+ mock(YAML).load_file(@paths[:default]) { Hash.new }
+ mock($stdout).puts("Configuration from #{@paths[:default]}")
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
+ end
+
+ should "load different config if specified" do
+ mock(YAML).load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} }
+ mock($stdout).puts("Configuration from #{@paths[:other]}")
+ assert_equal Jekyll::DEFAULTS.deep_merge({ "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] })
+ end
+
+ should "load default config if path passed is empty" do
+ mock(YAML).load_file(@paths[:default]) { Hash.new }
+ mock($stdout).puts("Configuration from #{@paths[:default]}")
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({ "config" => @paths[:empty] })
+ end
+ end
end
Something went wrong with that request. Please try again.