diff --git a/Gemfile b/Gemfile index 1b93ae31..df6d2f27 100644 --- a/Gemfile +++ b/Gemfile @@ -31,6 +31,7 @@ group :test do gem "rubocop-performance" gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__) gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) + gem "test-theme-skinny", :path => File.expand_path("test/fixtures/test-theme-skinny", __dir__) gem "test-theme-symlink", :path => File.expand_path("test/fixtures/test-theme-symlink", __dir__) gem "jruby-openssl" if RUBY_ENGINE == "jruby" diff --git a/features/theme.feature b/features/theme.feature index 650c1675..3941abc8 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -57,6 +57,17 @@ Feature: Writing themes And I should see "From your site." in "_site/assets/application.coffee" And I should see "From your site." in "_site/assets/base.js" + Scenario: A theme with *just* layouts + Given I have a configuration file with "theme" set to "test-theme-skinny" + And I have an "index.html" page with layout "home" that contains "The quick brown fox." + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "Message: The quick brown fox." in "_site/index.html" + But I should not see "_includes" in the build output + And I should not see "_sass" in the build output + And I should not see "assets" in the build output + Scenario: Requiring dependencies of a theme Given I have a configuration file with "theme" set to "test-dependency-theme" When I run jekyll build diff --git a/lib/jekyll/theme.rb b/lib/jekyll/theme.rb index 3eb44157..ac033020 100644 --- a/lib/jekyll/theme.rb +++ b/lib/jekyll/theme.rb @@ -62,11 +62,22 @@ module Jekyll # escape the theme root. # However, symlinks are allowed to point to other directories within the theme. Jekyll.sanitized_path(root, File.realpath(Jekyll.sanitized_path(root, folder.to_s))) - rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP - Jekyll.logger.warn "Invalid theme folder:", folder + rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP => e + log_realpath_exception(e, folder) nil end + def log_realpath_exception(err, folder) + return if err.is_a?(Errno::ENOENT) + + case err + when Errno::EACCES + Jekyll.logger.error "Theme error:", "Directory '#{folder}' is not accessible." + when Errno::ELOOP + Jekyll.logger.error "Theme error:", "Directory '#{folder}' includes a symbolic link loop." + end + end + def gemspec @gemspec ||= Gem::Specification.find_by_name(name) rescue Gem::LoadError diff --git a/test/fixtures/test-theme-skinny/_layouts/default.html b/test/fixtures/test-theme-skinny/_layouts/default.html new file mode 100644 index 00000000..837a4dc7 --- /dev/null +++ b/test/fixtures/test-theme-skinny/_layouts/default.html @@ -0,0 +1,11 @@ + + + + + Skinny + + +

Hello World

+ {{ content }} + + diff --git a/test/fixtures/test-theme-skinny/_layouts/home.html b/test/fixtures/test-theme-skinny/_layouts/home.html new file mode 100644 index 00000000..6d9ce5c7 --- /dev/null +++ b/test/fixtures/test-theme-skinny/_layouts/home.html @@ -0,0 +1,5 @@ +--- +layout: default +--- + +Message: {{ content }} diff --git a/test/fixtures/test-theme-skinny/test-theme-skinny.gemspec b/test/fixtures/test-theme-skinny/test-theme-skinny.gemspec new file mode 100644 index 00000000..84f59b9d --- /dev/null +++ b/test/fixtures/test-theme-skinny/test-theme-skinny.gemspec @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +Gem::Specification.new do |s| + s.name = "test-theme-skinny" + s.version = "0.1.0" + s.licenses = ["MIT"] + s.summary = "This is a theme with just layouts used to test Jekyll" + s.authors = ["Jekyll"] + s.files = ["lib/example.rb"] + s.homepage = "https://github.com/jekyll/jekyll" +end