Class: Jekyll::GitHubMetadata::Pages

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

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.api_urlObject


71
72
73
# File 'lib/jekyll-github-metadata/pages.rb', line 71

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

.configurationObject


93
94
95
96
97
# File 'lib/jekyll-github-metadata/pages.rb', line 93

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)

51
52
53
# File 'lib/jekyll-github-metadata/pages.rb', line 51

def custom_domains_enabled?
  dotcom? || test?
end

.development?Boolean

Returns:

  • (Boolean)

47
48
49
# File 'lib/jekyll-github-metadata/pages.rb', line 47

def development?
  env == "development"
end

.dotcom?Boolean

Returns:

  • (Boolean)

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

def dotcom?
  env == "dotcom"
end

.enterprise?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'lib/jekyll-github-metadata/pages.rb', line 43

def enterprise?
  env == "enterprise"
end

.envObject


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

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

.github_hostnameObject


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

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

.github_urlObject


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

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

.help_urlObject


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

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

.page_build?Boolean

Returns:

  • (Boolean)

89
90
91
# File 'lib/jekyll-github-metadata/pages.rb', line 89

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

.pages_hostnameObject


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

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)

59
60
61
# File 'lib/jekyll-github-metadata/pages.rb', line 59

def repo_pages_html_url_preview?
  env_var "PAGES_PREVIEW_HTML_URL"
end

.schemeObject


27
28
29
# File 'lib/jekyll-github-metadata/pages.rb', line 27

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)

23
24
25
# File 'lib/jekyll-github-metadata/pages.rb', line 23

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

.subdomain_isolation?Boolean

Returns:

  • (Boolean)

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

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

.test?Boolean

Returns:

  • (Boolean)

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

def test?
  env == "test"
end