Skip to content

Commit

Permalink
Merge pull request #109 from shreve/support-config-baseurl
Browse files Browse the repository at this point in the history
Find destination path from _config.yml
  • Loading branch information
benbalter authored Mar 8, 2018
2 parents c1279d9 + 68e4f46 commit cf84a79
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions lib/jekyll_auth/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ def self.config_file
File.join(Dir.pwd, "_config.yml")
end

def self.jekyll_config
@config ||= YAML.safe_load_file(config_file)
rescue StandardError
{}
end

def self.config
@config ||= begin
config = YAML.safe_load_file(config_file)
config["jekyll_auth"] || {}
rescue StandardError
{}
end
jekyll_config.fetch("jekyll_auth", {})
end

def self.destination
jekyll_config.fetch("destination", File.expand_path("_site", Dir.pwd))
end

def self.whitelist
whitelist = JekyllAuth.config["whitelist"]
whitelist = config["whitelist"]
Regexp.new(whitelist.join("|")) unless whitelist.nil?
end

def self.ssl?
!!JekyllAuth.config["ssl"]
!!config["ssl"]
end
end
4 changes: 2 additions & 2 deletions lib/jekyll_auth/jekyll_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
class JekyllAuth
class JekyllSite < Sinatra::Base
register Sinatra::Index
set :public_folder, File.expand_path("_site", Dir.pwd)
set :public_folder, File.expand_path(JekyllAuth.destination, Dir.pwd)
use_static_index "index.html"

not_found do
status 404
four_oh_four = File.expand_path("_site/404.html", Dir.pwd)
four_oh_four = File.expand_path(settings.public_folder + "/404.html", Dir.pwd)
File.read(four_oh_four) if File.exist?(four_oh_four)
end
end
Expand Down

0 comments on commit cf84a79

Please sign in to comment.