From 26b4fb108929b78e2bdf0b8a4cc3d64d91e713d6 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Thu, 19 Sep 2024 16:07:17 +0530 Subject: [PATCH] Load gem `rackup` via monkey-patch --- jekyll-admin.gemspec | 1 + lib/jekyll/commands/serve.rb | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/jekyll-admin.gemspec b/jekyll-admin.gemspec index a33feb873..d5be10dc4 100644 --- a/jekyll-admin.gemspec +++ b/jekyll-admin.gemspec @@ -24,6 +24,7 @@ Gem::Specification.new do |spec| spec.required_rubygems_version = ">= 2.7.0" spec.add_runtime_dependency "jekyll", ">= 3.7", "< 5.0" + spec.add_runtime_dependency "rackup", "~> 2.0" spec.add_runtime_dependency "sinatra", "~> 4.0" spec.add_runtime_dependency "sinatra-contrib", "~> 4.0" end diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 50e6548e8..5abec8ecc 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -20,8 +20,10 @@ def start_up_webrick(opts, destination) end def jekyll_admin_monkey_patch - @server.mount "/admin", Rack::Handler::WEBrick, JekyllAdmin::StaticServer - @server.mount "/_api", Rack::Handler::WEBrick, JekyllAdmin::Server + Jekyll::External.require_with_graceful_fail "rackup" + + @server.mount "/admin", Rackup::Handler::WEBrick, JekyllAdmin::StaticServer + @server.mount "/_api", Rackup::Handler::WEBrick, JekyllAdmin::Server Jekyll.logger.info "JekyllAdmin mode:", ENV["RACK_ENV"] || "production" end end