Class: Jekyll::GitHubMetadata::Pages

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-github-metadata/pages.rb

Constant Summary collapse

DEFAULTS =
{
  "PAGES_ENV"              => "development".freeze,
  "PAGES_API_URL"          => "https://api.github.com".freeze,
  "PAGES_HELP_URL"         => "https://help.github.com".freeze,
  "PAGES_GITHUB_HOSTNAME"  => "github.com".freeze,
  "PAGES_PAGES_HOSTNAME"   => "github.io".freeze,
  "SSL"                    => "false".freeze,
  "SUBDOMAIN_ISOLATION"    => "false".freeze,
  "PAGES_PREVIEW_HTML_URL" => nil,
  "PAGE_BUILD_ID"          => nil,
}.freeze

Class Method Summary collapse

Class Method Details

.api_urlObject



61
62
63
# File 'lib/jekyll-github-metadata/pages.rb', line 61

def api_url
  trim_last_slash env_var("PAGES_API_URL", ENV["API_URL"])
end

.configurationObject



83
84
85
86
87
# File 'lib/jekyll-github-metadata/pages.rb', line 83

def configuration
  (methods - Object.methods - [:configuration]).sort.each_with_object({}) do |meth, memo|
    memo[meth.to_s] = public_send(meth)
  end
end

.custom_domains_enabled?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/jekyll-github-metadata/pages.rb', line 41

def custom_domains_enabled?
  dotcom? || test?
end

.development?Boolean

Returns:

  • (Boolean)


39
# File 'lib/jekyll-github-metadata/pages.rb', line 39

def development?; env == "development" end

.dotcom?Boolean

Returns:

  • (Boolean)


35
# File 'lib/jekyll-github-metadata/pages.rb', line 35

def dotcom?;      env == "dotcom" end

.enterprise?Boolean

Returns:

  • (Boolean)


37
# File 'lib/jekyll-github-metadata/pages.rb', line 37

def enterprise?;  env == "enterprise" end

.envObject



45
46
47
# File 'lib/jekyll-github-metadata/pages.rb', line 45

def env
  env_var "PAGES_ENV", ENV["JEKYLL_ENV"]
end

.github_hostnameObject



69
70
71
# File 'lib/jekyll-github-metadata/pages.rb', line 69

def github_hostname
  trim_last_slash env_var("PAGES_GITHUB_HOSTNAME", ENV["GITHUB_HOSTNAME"])
end

.github_urlObject



53
54
55
56
57
58
59
# File 'lib/jekyll-github-metadata/pages.rb', line 53

def github_url
  if dotcom?
    "https://github.com".freeze
  else
    "#{scheme}://#{github_hostname}"
  end
end

.help_urlObject



65
66
67
# File 'lib/jekyll-github-metadata/pages.rb', line 65

def help_url
  trim_last_slash env_var("PAGES_HELP_URL", ENV["HELP_URL"])
end

.page_build?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/jekyll-github-metadata/pages.rb', line 79

def page_build?
  !env_var("PAGE_BUILD_ID").to_s.empty?
end

.pages_hostnameObject



73
74
75
76
77
# File 'lib/jekyll-github-metadata/pages.rb', line 73

def pages_hostname
  intermediate_default = ENV["PAGES_HOSTNAME"]
  intermediate_default ||= "localhost:4000" if development?
  trim_last_slash env_var("PAGES_PAGES_HOSTNAME", intermediate_default)
end

.repo_pages_html_url_preview?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/jekyll-github-metadata/pages.rb', line 49

def repo_pages_html_url_preview?
  env_var "PAGES_PREVIEW_HTML_URL"
end

.schemeObject



25
26
27
# File 'lib/jekyll-github-metadata/pages.rb', line 25

def scheme
  ssl? ? "https" : "http"
end

.ssl?Boolean

Whether the GitHub instance supports HTTPS Note: this will be the same as how sites are served in Enterprise, but may be different from how sites are served on GitHub.com. See Repository#url_scheme

Returns:

  • (Boolean)


21
22
23
# File 'lib/jekyll-github-metadata/pages.rb', line 21

def ssl?
  env_var("SSL") == "true" || test?
end

.subdomain_isolation?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/jekyll-github-metadata/pages.rb', line 29

def subdomain_isolation?
  env_var("SUBDOMAIN_ISOLATION").eql? "true"
end

.test?Boolean

Returns:

  • (Boolean)


33
# File 'lib/jekyll-github-metadata/pages.rb', line 33

def test?;        env == "test" end