Skip to content

Commit ce2fbb2

Browse files
authored
Merge pull request #772 from github/remove-gem-themes
Remove gem-based themes, replace with remote themes
2 parents dc62d72 + b08711a commit ce2fbb2

File tree

7 files changed

+56
-24
lines changed

7 files changed

+56
-24
lines changed

lib/github-pages/configuration.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def effective_config(user_config)
107107
# Allow theme to be explicitly disabled via "theme: null"
108108
config["theme"] = user_config["theme"] if user_config.key?("theme")
109109

110+
migrate_theme_to_remote_theme(config)
110111
exclude_cname(config)
111112

112113
# Merge overwrites into user config
@@ -156,6 +157,16 @@ def restrict_and_config_markdown_processor(config)
156157
}
157158
end
158159

160+
# If the user has set a 'theme', then see if we can automatically use remote theme instead.
161+
def migrate_theme_to_remote_theme(config)
162+
return unless config["theme"]
163+
return unless GitHubPages::Plugins::THEMES_TO_CONVERT_TO_REMOTE_THEMES.key?(config["theme"])
164+
165+
theme_name = config.delete("theme")
166+
config["remote_theme"] ||= GitHubPages::Plugins::THEMES_TO_CONVERT_TO_REMOTE_THEMES[theme_name]
167+
config["plugins"] = Array(config["plugins"]).concat(["jekyll-remote-theme"]).uniq
168+
end
169+
159170
# If the user's 'exclude' config is the default, also exclude the CNAME
160171
def exclude_cname(config)
161172
return unless config["exclude"].eql? Jekyll::Configuration::DEFAULTS["exclude"]

lib/github-pages/plugins.rb

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,25 @@ class Plugins
4848

4949
# Themes
5050
THEMES = {
51-
"jekyll-swiss" => "1.0.0",
5251
"minima" => "2.5.1",
53-
"jekyll-theme-primer" => "0.5.4",
54-
"jekyll-theme-architect" => "0.1.1",
55-
"jekyll-theme-cayman" => "0.1.1",
56-
"jekyll-theme-dinky" => "0.1.1",
57-
"jekyll-theme-hacker" => "0.1.2",
58-
"jekyll-theme-leap-day" => "0.1.1",
59-
"jekyll-theme-merlot" => "0.1.1",
60-
"jekyll-theme-midnight" => "0.1.1",
61-
"jekyll-theme-minimal" => "0.1.1",
62-
"jekyll-theme-modernist" => "0.1.1",
63-
"jekyll-theme-slate" => "0.1.1",
64-
"jekyll-theme-tactile" => "0.1.1",
65-
"jekyll-theme-time-machine" => "0.1.1",
6652
}.freeze
53+
54+
# Themes to convert to remote themes
55+
THEMES_TO_CONVERT_TO_REMOTE_THEMES = {
56+
"jekyll-swiss" => "broccolini/swiss",
57+
"jekyll-theme-primer" => "pages-themes/[email protected]",
58+
"jekyll-theme-architect" => "pages-themes/[email protected]",
59+
"jekyll-theme-cayman" => "pages-themes/[email protected]",
60+
"jekyll-theme-dinky" => "pages-themes/[email protected]",
61+
"jekyll-theme-hacker" => "pages-themes/[email protected]",
62+
"jekyll-theme-leap-day" => "pages-themes/[email protected]",
63+
"jekyll-theme-merlot" => "pages-themes/[email protected]",
64+
"jekyll-theme-midnight" => "pages-themes/[email protected]",
65+
"jekyll-theme-minimal" => "pages-themes/[email protected]",
66+
"jekyll-theme-modernist" => "pages-themes/[email protected]",
67+
"jekyll-theme-slate" => "pages-themes/[email protected]",
68+
"jekyll-theme-tactile" => "pages-themes/[email protected]",
69+
"jekyll-theme-time-machine" => "pages-themes/[email protected]",
70+
}
6771
end
6872
end

spec/github-pages/configuration_spec.rb

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
ENV.delete("DISABLE_WHITELIST")
2121
ENV["JEKYLL_ENV"] = "test"
2222
ENV["PAGES_REPO_NWO"] = "github/pages-gem"
23+
stub_request_for_remote_theme(:repo => "pages-themes/primer", :revision => "v0.5.4", :filename => "primer-0.5.4.zip")
2324
end
2425

2526
context "#effective_config" do
@@ -103,22 +104,32 @@
103104
context "themes" do
104105
context "with no theme set" do
105106
it "sets the theme" do
107+
expect(effective_config["plugins"]).to include("jekyll-remote-theme")
106108
expect(site.theme).to_not be_nil
107109
expect(site.theme).to be_a(Jekyll::Theme)
108-
expect(site.theme.name).to eql("jekyll-theme-primer")
110+
expect(site.theme.name).to eql("primer")
109111
end
110112
end
111113

112114
context "with a user-specified theme" do
113-
let(:site) do
114-
config = configuration.merge("theme" => "jekyll-theme-merlot")
115-
Jekyll::Site.new(config)
115+
let(:configuration) do
116+
described_class.effective_config(
117+
Jekyll.configuration(
118+
test_config.merge("theme" => "jekyll-theme-merlot")
119+
)
120+
)
121+
end
122+
123+
before(:each) do
124+
stub_request_for_remote_theme(:repo => "pages-themes/merlot", :revision => "v0.1.1", :filename => "merlot-0.1.1.zip")
116125
end
117126

118127
it "respects the theme" do
128+
expect(configuration["theme"]).to be_nil
129+
expect(configuration["remote_theme"]).to eq(GitHubPages::Plugins::THEMES_TO_CONVERT_TO_REMOTE_THEMES["jekyll-theme-merlot"])
119130
expect(site.theme).to_not be_nil
120131
expect(site.theme).to be_a(Jekyll::Theme)
121-
expect(site.theme.name).to eql("jekyll-theme-merlot")
132+
expect(site.theme.name).to eql("merlot")
122133
end
123134
end
124135

@@ -133,10 +144,6 @@
133144
end
134145
end
135146

136-
it "plugins don't include jekyll remote theme" do
137-
expect(effective_config["plugins"]).to_not include("jekyll-remote-theme")
138-
end
139-
140147
context "with a remote theme" do
141148
let(:test_config) do
142149
{
@@ -149,6 +156,7 @@
149156
end
150157

151158
it "plugins include jekyll remote theme" do
159+
stub_request_for_remote_theme(:repo => "foo/bar", :revision => "HEAD", :filename => "primer-0.5.4.zip")
152160
expect(effective_config["plugins"]).to include("jekyll-remote-theme")
153161
end
154162
end

spec/github-pages/integration_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def rm_destination
258258

259259
context "jekyll-theme-primer" do
260260
it "sets the theme" do
261-
expect(contents).to match("Theme: jekyll-theme-primer")
261+
expect(contents).to match("Theme: primer")
262262
end
263263

264264
it "uses the theme" do

spec/spec_helper.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ def tmp_dir
2929
File.expand_path "../tmp", __dir__
3030
end
3131

32+
def support_dir
33+
File.expand_path "support", __dir__
34+
end
35+
36+
def stub_request_for_remote_theme(repo:, revision:, filename:)
37+
stub_request(:get, "https://codeload.github.com/#{repo}/zip/#{revision}").
38+
to_return(:status => 200, :body => File.binread(File.join(support_dir, filename)), :headers => {"Content-Type" => "archive/zip"})
39+
end
40+
3241
RSpec::Matchers.define :be_an_existing_file do
3342
match { |path| File.exist?(path) }
3443
end

spec/support/merlot-0.1.1.zip

458 KB
Binary file not shown.

spec/support/primer-0.5.4.zip

66.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)