Skip to content

Commit

Permalink
Merge pull request #781 from github/revert-to-gem-based-themes
Browse files Browse the repository at this point in the history
Roll back remote themes for gem-based themes
  • Loading branch information
parkr committed Jul 29, 2021
2 parents 17e1f80 + 0a269c2 commit d966ac6
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 27 deletions.
7 changes: 1 addition & 6 deletions lib/github-pages/configuration.rb
Expand Up @@ -159,12 +159,7 @@ def restrict_and_config_markdown_processor(config)

# If the user has set a 'theme', then see if we can automatically use remote theme instead.
def migrate_theme_to_remote_theme(config)
return unless config["theme"]
return unless GitHubPages::Plugins::THEMES_TO_CONVERT_TO_REMOTE_THEMES.key?(config["theme"])

theme_name = config.delete("theme")
config["remote_theme"] ||= GitHubPages::Plugins::THEMES_TO_CONVERT_TO_REMOTE_THEMES[theme_name]
config["plugins"] = Array(config["plugins"]).concat(["jekyll-remote-theme"]).uniq
# This functionality has been rolled back due to complications with jekyll-remote-theme.
end

# If the user's 'exclude' config is the default, also exclude the CNAME
Expand Down
14 changes: 14 additions & 0 deletions lib/github-pages/plugins.rb
Expand Up @@ -49,6 +49,20 @@ class Plugins
# Themes
THEMES = {
"minima" => "2.5.1",
"jekyll-swiss" => "1.0.0",
"jekyll-theme-primer" => "0.6.0",
"jekyll-theme-architect" => "0.2.0",
"jekyll-theme-cayman" => "0.2.0",
"jekyll-theme-dinky" => "0.2.0",
"jekyll-theme-hacker" => "0.2.0",
"jekyll-theme-leap-day" => "0.2.0",
"jekyll-theme-merlot" => "0.2.0",
"jekyll-theme-midnight" => "0.2.0",
"jekyll-theme-minimal" => "0.2.0",
"jekyll-theme-modernist" => "0.2.0",
"jekyll-theme-slate" => "0.2.0",
"jekyll-theme-tactile" => "0.2.0",
"jekyll-theme-time-machine" => "0.2.0",
}.freeze

# Themes to convert to remote themes
Expand Down
17 changes: 6 additions & 11 deletions spec/github-pages/configuration_spec.rb
Expand Up @@ -20,7 +20,6 @@
ENV.delete("DISABLE_WHITELIST")
ENV["JEKYLL_ENV"] = "test"
ENV["PAGES_REPO_NWO"] = "github/pages-gem"
stub_request_for_remote_theme(:repo => "pages-themes/primer", :revision => "v0.6.0", :filename => "primer-0.6.0.zip")
end

context "#effective_config" do
Expand Down Expand Up @@ -104,10 +103,9 @@
context "themes" do
context "with no theme set" do
it "sets the theme" do
expect(effective_config["plugins"]).to include("jekyll-remote-theme")
expect(site.theme).to_not be_nil
expect(site.theme).to be_a(Jekyll::Theme)
expect(site.theme.name).to eql("primer")
expect(site.theme.name).to eql("jekyll-theme-primer")
end
end

Expand All @@ -120,16 +118,10 @@
)
end

before(:each) do
stub_request_for_remote_theme(:repo => "pages-themes/merlot", :revision => "v0.2.0", :filename => "merlot-0.2.0.zip")
end

it "respects the theme" do
expect(configuration["theme"]).to be_nil
expect(configuration["remote_theme"]).to eq(GitHubPages::Plugins::THEMES_TO_CONVERT_TO_REMOTE_THEMES["jekyll-theme-merlot"])
expect(site.theme).to_not be_nil
expect(site.theme).to be_a(Jekyll::Theme)
expect(site.theme.name).to eql("merlot")
expect(site.theme.name).to eql("jekyll-theme-merlot")
end
end

Expand All @@ -144,6 +136,10 @@
end
end

it "plugins don't include jekyll remote theme" do
expect(effective_config["plugins"]).to_not include("jekyll-remote-theme")
end

context "with a remote theme" do
let(:test_config) do
{
Expand All @@ -156,7 +152,6 @@
end

it "plugins include jekyll remote theme" do
stub_request_for_remote_theme(:repo => "foo/bar", :revision => "HEAD", :filename => "primer-0.6.0.zip")
expect(effective_config["plugins"]).to include("jekyll-remote-theme")
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/github-pages/integration_spec.rb
Expand Up @@ -258,7 +258,7 @@ def rm_destination

context "jekyll-theme-primer" do
it "sets the theme" do
expect(contents).to match("Theme: primer")
expect(contents).to match("Theme: jekyll-theme-primer")
end

it "uses the theme" do
Expand Down
9 changes: 0 additions & 9 deletions spec/spec_helper.rb
Expand Up @@ -29,15 +29,6 @@ def tmp_dir
File.expand_path "../tmp", __dir__
end

def support_dir
File.expand_path "support", __dir__
end

def stub_request_for_remote_theme(repo:, revision:, filename:)
stub_request(:get, "https://codeload.github.com/#{repo}/zip/#{revision}").
to_return(:status => 200, :body => File.binread(File.join(support_dir, filename)), :headers => {"Content-Type" => "archive/zip"})
end

RSpec::Matchers.define :be_an_existing_file do
match { |path| File.exist?(path) }
end
Binary file removed spec/support/merlot-0.2.0.zip
Binary file not shown.
Binary file removed spec/support/primer-0.6.0.zip
Binary file not shown.

0 comments on commit d966ac6

Please sign in to comment.