Class: GitHubPages::Configuration
- Inherits:
-
Object
- Object
- GitHubPages::Configuration
- Defined in:
- lib/github-pages/configuration.rb
Constant Summary collapse
- DEFAULT_PLUGINS =
Plugins which are activated by default
%w( jekyll-coffeescript jekyll-gist jekyll-github-metadata jekyll-paginate ).freeze
- PLUGIN_WHITELIST =
Plugins allowed by GitHub Pages
%w( jekyll-coffeescript jekyll-feed jekyll-gist jekyll-github-metadata jekyll-mentions jekyll-paginate jekyll-redirect-from jekyll-seo-tag jekyll-sitemap jemoji ).freeze
- DEFAULTS =
Default, user overwritable options
{ "jailed" => false, "gems" => DEFAULT_PLUGINS, "kramdown" => { "input" => "GFM", "hard_wrap" => false } }.freeze
- MERGED_DEFAULTS =
Jekyll defaults merged with Pages defaults.
Jekyll::Utils.deep_merge_hashes( Jekyll::Configuration::DEFAULTS, DEFAULTS ).freeze
- OVERRIDES =
Options which GitHub Pages sets, regardless of the user-specified value
The following values are also overridden by GitHub Pages, but are not overridden locally, for practical purposes:
-
source
-
destination
-
jailed
-
verbose
-
incremental
-
GH_ENV
-
{ "lsi" => false, "safe" => true, "plugins" => SecureRandom.hex, "plugins_dir" => SecureRandom.hex, "whitelist" => PLUGIN_WHITELIST, "highlighter" => "rouge", "kramdown" => { "template" => "", "math_engine" => "mathjax", "syntax_highlighter" => "rouge" }, "gist" => { "noscript" => false } }.freeze
- CONFIGS_WITH_METHODS =
These configuration settings have corresponding instance variables on Jekyll::Site and need to be set properly when the config is updated.
%w( safe lsi highlighter baseurl exclude include future unpublished show_drafts limit_posts keep_files gems ).freeze
Class Method Summary collapse
-
.debug_print_versions ⇒ Object
Print the versions for github-pages and jekyll to the debug stream for debugging purposes.
- .disable_whitelist? ⇒ Boolean
-
.effective_config(user_config) ⇒ Object
Given a user’s config, determines the effective configuration by building a user configuration sandwhich with our overrides overriding the user’s specified values which themselves override our defaults.
- .processed(site) ⇒ Object
- .processed?(site) ⇒ Boolean
-
.set(site) ⇒ Object
Set the site’s configuration.
-
.set!(site) ⇒ Object
Set the site’s configuration with all the proper defaults and overrides.
Class Method Details
.debug_print_versions ⇒ Object
Print the versions for github-pages and jekyll to the debug stream for debugging purposes. See by running Jekyll with ‘–verbose’
126 127 128 129 |
# File 'lib/github-pages/configuration.rb', line 126 def debug_print_versions Jekyll.logger.debug "GitHub Pages:", "github-pages v#{GitHubPages::VERSION}" Jekyll.logger.debug "GitHub Pages:", "jekyll v#{Jekyll::VERSION}" end |
.disable_whitelist? ⇒ Boolean
87 88 89 |
# File 'lib/github-pages/configuration.rb', line 87 def disable_whitelist? Jekyll.env == "development" && !ENV["DISABLE_WHITELIST"].to_s.empty? end |
.effective_config(user_config) ⇒ Object
Given a user’s config, determines the effective configuration by building a user configuration sandwhich with our overrides overriding the user’s specified values which themselves override our defaults.
Returns the effective Configuration
Note: this is a highly modified version of Jekyll#configuration
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/github-pages/configuration.rb', line 98 def effective_config(user_config) # Merge user config into defaults config = Jekyll::Utils.deep_merge_hashes(MERGED_DEFAULTS, user_config) .fix_common_issues .add_default_collections # Merge overwrites into user config config = Jekyll::Utils.deep_merge_hashes config, OVERRIDES # Ensure we have those gems we want. config["gems"] = Array(config["gems"]) | DEFAULT_PLUGINS config["whitelist"] = config["whitelist"] | config["gems"] if disable_whitelist? config end |
.processed(site) ⇒ Object
83 84 85 |
# File 'lib/github-pages/configuration.rb', line 83 def processed(site) site.instance_variable_set :@_github_pages_processed, true end |
.processed?(site) ⇒ Boolean
79 80 81 |
# File 'lib/github-pages/configuration.rb', line 79 def processed?(site) site.instance_variable_get(:@_github_pages_processed) == true end |
.set(site) ⇒ Object
Set the site’s configuration. Implemented as an after_reset hook. Equivalent #set! function contains the code of interest. This function guards against double-processing via the value in #processed.
117 118 119 120 121 122 |
# File 'lib/github-pages/configuration.rb', line 117 def set(site) return if processed? site debug_print_versions set!(site) processed(site) end |
.set!(site) ⇒ Object
Set the site’s configuration with all the proper defaults and overrides. Should be called by #set to protect against multiple processings.
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/github-pages/configuration.rb', line 133 def set!(site) config = effective_config(site.config) # Assign everything to the site site.instance_variable_set :@config, config # Ensure all CONFIGS_WITH_METHODS.each do |opt| site.public_send("#{opt}=", site.config[opt]) end end |