jekyll-github-metadata 1.11.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f07771ea8191004f2fab71e394183dcabb8d981
4
- data.tar.gz: 6d29056a327bc7a7aedce28c6e62f748f40098e1
3
+ metadata.gz: 36d8bc2d3f2c09462d4b9f58e2b2b0b20b832a6f
4
+ data.tar.gz: 8944c7a5339f8995dc0fc08a1f5c888dbda019de
5
5
  SHA512:
6
- metadata.gz: d935defa748eccfcc5a4fa2a878ff5b1b6968d9f34d048d30d1113d44c4e20aff589e4f2eb944eb5dee0a54f7d1ba91c1b5f7f6c3e32f0d358595661583cc713
7
- data.tar.gz: 03d75028ef710a118e7702b8a9e06ca093ba50396e7b9f592dcf913bd7fb8ff8a28b93a66229ec094949736bdf111f031f235f2462d78ea2cfcf058a339d0802
6
+ metadata.gz: 1b08ec39f71edc7f798d33ba35a3695b2361092c0b55719e13e3f2bb05656d5a402a6c2e8cbde4187ba54d30b960aea39617153f546262575393bf08f3296af8
7
+ data.tar.gz: cbf03c38175bd52c30104b763e34955295fe5c2f589b2b1fd1d4b89308e6601c880b192dd6805427247e98f7a682b23ff8be1636873456ea8be341e9e7316667
@@ -1,4 +1,6 @@
1
1
  require 'octokit'
2
+ require 'logger'
3
+
2
4
  if defined?(Jekyll) && Jekyll.respond_to?(:env) && Jekyll.env == 'development'
3
5
  begin
4
6
  require 'dotenv'
@@ -17,104 +19,51 @@ module Jekyll
17
19
  module GitHubMetadata
18
20
  NoRepositoryError = Class.new(Jekyll::Errors::FatalException)
19
21
 
20
- autoload :Client, 'jekyll-github-metadata/client'
21
- autoload :Pages, 'jekyll-github-metadata/pages'
22
- autoload :Repository, 'jekyll-github-metadata/repository'
23
- autoload :Sanitizer, 'jekyll-github-metadata/sanitizer'
24
- autoload :Value, 'jekyll-github-metadata/value'
25
- autoload :VERSION, 'jekyll-github-metadata/version'
22
+ autoload :Client, 'jekyll-github-metadata/client'
23
+ autoload :MetadataDrop, 'jekyll-github-metadata/metadata_drop'
24
+ autoload :Pages, 'jekyll-github-metadata/pages'
25
+ autoload :Repository, 'jekyll-github-metadata/repository'
26
+ autoload :RepositoryCompat, 'jekyll-github-metadata/repository_compat'
27
+ autoload :Sanitizer, 'jekyll-github-metadata/sanitizer'
28
+ autoload :Value, 'jekyll-github-metadata/value'
29
+ autoload :VERSION, 'jekyll-github-metadata/version'
30
+
31
+ if Jekyll.const_defined? :Site
32
+ require_relative 'jekyll-github-metadata/ghp_metadata_generator'
33
+ end
26
34
 
27
35
  class << self
28
36
  attr_accessor :repository
29
- attr_writer :client
37
+ attr_writer :client, :logger
30
38
 
31
39
  def environment
32
40
  Jekyll.respond_to?(:env) ? Jekyll.env : (Pages.env || 'development')
33
41
  end
34
42
 
35
- def client
36
- @client ||= Client.new
43
+ def logger
44
+ @logger ||= if Jekyll.respond_to?(:logger)
45
+ Jekyll.logger
46
+ else
47
+ Logger.new($stdout)
48
+ end
37
49
  end
38
50
 
39
- def values
40
- @values ||= Hash.new
51
+ def log(severity, message)
52
+ if logger.method(severity).arity.abs >= 2
53
+ logger.public_send(severity, "GitHub Metadata:", message.to_s)
54
+ else
55
+ logger.public_send(severity, "GitHub Metadata: #{message}")
56
+ end
41
57
  end
42
- alias_method :to_h, :values
43
- alias_method :to_liquid, :to_h
44
58
 
45
- def clear_values!
46
- @values = Hash.new
59
+ def client
60
+ @client ||= Client.new
47
61
  end
48
62
 
49
63
  def reset!
50
- clear_values!
64
+ @logger = nil
51
65
  @client = nil
52
- @repository = nil
53
- end
54
-
55
- def [](key)
56
- values[key.to_s]
57
- end
58
-
59
- def register_value(key, value)
60
- values[key.to_s] = Value.new(key.to_s, value)
61
- end
62
-
63
- # Reset our values hash.
64
- def init!
65
- clear_values!
66
-
67
- # Environment-Specific
68
- register_value('environment', proc { Pages.env })
69
- register_value('hostname', proc { Pages.github_hostname })
70
- register_value('pages_env', proc { Pages.env })
71
- register_value('pages_hostname', proc { Pages.pages_hostname })
72
- register_value('api_url', proc { Pages.api_url })
73
- register_value('help_url', proc { Pages.help_url })
74
-
75
- register_value('versions', proc {
76
- begin
77
- require 'github-pages'
78
- GitHubPages.versions
79
- rescue LoadError; Hash.new end
80
- })
81
-
82
- # The Juicy Stuff
83
- register_value('public_repositories', proc { |_,r| r.owner_public_repositories })
84
- register_value('organization_members', proc { |_,r| r.organization_public_members })
85
- register_value('build_revision', proc {
86
- ENV['JEKYLL_BUILD_REVISION'] || `git rev-parse HEAD`.strip
87
- })
88
- register_value('project_title', proc { |_,r| r.name })
89
- register_value('project_tagline', proc { |_,r| r.tagline })
90
- register_value('owner_name', proc { |_,r| r.owner })
91
- register_value('owner_url', proc { |_,r| r.owner_url })
92
- register_value('owner_gravatar_url', proc { |_,r| r.owner_gravatar_url })
93
- register_value('repository_url', proc { |_,r| r.repository_url })
94
- register_value('repository_nwo', proc { |_,r| r.nwo })
95
- register_value('repository_name', proc { |_,r| r.name})
96
- register_value('zip_url', proc { |_,r| r.zip_url })
97
- register_value('tar_url', proc { |_,r| r.tar_url })
98
- register_value('clone_url', proc { |_,r| r.repo_clone_url })
99
- register_value('releases_url', proc { |_,r| r.releases_url })
100
- register_value('issues_url', proc { |_,r| r.issues_url })
101
- register_value('wiki_url', proc { |_,r| r.wiki_url })
102
- register_value('language', proc { |_,r| r.language })
103
- register_value('is_user_page', proc { |_,r| r.user_page? })
104
- register_value('is_project_page', proc { |_,r| r.project_page? })
105
- register_value('show_downloads', proc { |_,r| r.show_downloads? })
106
- register_value('url', proc { |_,r| r.pages_url })
107
- register_value('contributors', proc { |_,r| r.contributors })
108
- register_value('releases', proc { |_,r| r.releases })
109
-
110
- values
111
- end
112
-
113
- if Jekyll.const_defined? :Site
114
- require_relative 'jekyll-github-metadata/ghp_metadata_generator'
115
66
  end
116
67
  end
117
-
118
- init!
119
68
  end
120
69
  end
@@ -48,7 +48,7 @@ module Jekyll
48
48
  method = method_name.to_s
49
49
  if accepts_client_method?(method_name)
50
50
  key = cache_key(method_name, args)
51
- Jekyll.logger.debug "GitHub Metadata:", "Calling @client.#{method}(#{args.map(&:inspect).join(", ")})"
51
+ Jekyll::GitHubMetadata.log :debug, "Calling @client.#{method}(#{args.map(&:inspect).join(", ")})"
52
52
  cache[key] ||= save_from_errors { @client.public_send(method_name, *args, &block) }
53
53
  elsif @client.respond_to?(method_name)
54
54
  raise InvalidMethodError, "#{method_name} is not whitelisted on #{inspect}"
@@ -90,7 +90,7 @@ module Jekyll
90
90
  elsif !ENV['NO_NETRC'] && File.exist?(File.join(ENV['HOME'], '.netrc')) && safe_require('netrc')
91
91
  { :netrc => true }
92
92
  else
93
- Jekyll.logger.warn "GitHub Metadata:", "No GitHub API authentication could be found." +
93
+ Jekyll::GitHubMetadata.log :warn, "No GitHub API authentication could be found." \
94
94
  " Some fields may be missing or have incorrect data."
95
95
  {}.freeze
96
96
  end
@@ -1,75 +1,24 @@
1
+ require 'jekyll'
2
+
1
3
  module Jekyll
2
4
  module GitHubMetadata
3
5
  class GHPMetadataGenerator < Jekyll::Generator
4
6
  safe true
5
7
 
6
8
  def generate(site)
7
- Jekyll.logger.debug "Generator:", "Calling GHPMetadataGenerator"
8
- initialize_repo! nwo(site)
9
- Jekyll.logger.debug "GitHub Metadata:", "Generating for #{GitHubMetadata.repository.nwo}"
9
+ Jekyll::GitHubMetadata.log :debug, "Initializing..."
10
10
 
11
+ drop = MetadataDrop.new(site)
11
12
  site.config['github'] =
12
13
  case site.config['github']
13
14
  when nil
14
- GitHubMetadata.to_liquid
15
- when Hash
16
- Jekyll::Utils.deep_merge_hashes(GitHubMetadata.to_liquid, site.config['github'])
15
+ MetadataDrop.new(site)
16
+ when Hash, Liquid::Drop
17
+ Jekyll::Utils.deep_merge_hashes(MetadataDrop.new(site), site.config['github'])
17
18
  else
18
19
  site.config['github']
19
20
  end
20
21
  end
21
-
22
- private
23
-
24
- def initialize_repo!(repo_nwo)
25
- if GitHubMetadata.repository.nil? || GitHubMetadata.repository.nwo != repo_nwo
26
- GitHubMetadata.init!
27
- GitHubMetadata.repository = GitHubMetadata::Repository.new(repo_nwo)
28
- end
29
- end
30
-
31
- def git_remote_url
32
- `git remote --verbose`.split("\n").grep(%r{\Aorigin\t}).map do |remote|
33
- remote.sub(/\Aorigin\t(.*) \([a-z]+\)/, "\\1")
34
- end.uniq.first || ""
35
- end
36
-
37
- def nwo_from_git_origin_remote
38
- return unless Jekyll.env == "development"
39
- matches = git_remote_url.match %r{github.com(:|/)([\w-]+)/([\w-]+)}
40
- matches[2..3].join("/") if matches
41
- end
42
-
43
- def nwo_from_env
44
- ENV['PAGES_REPO_NWO']
45
- end
46
-
47
- def nwo_from_config(site)
48
- repo = site.config['repository']
49
- repo if repo && repo.is_a?(String) && repo.include?('/')
50
- end
51
-
52
- # Public: fetches the repository name with owner to fetch metadata for.
53
- # In order of precedence, this method uses:
54
- # 1. the environment variable $PAGES_REPO_NWO
55
- # 2. 'repository' variable in the site config
56
- # 3. the 'origin' git remote's URL
57
- #
58
- # site - the Jekyll::Site being processed
59
- #
60
- # Return the name with owner (e.g. 'parkr/my-repo') or raises an
61
- # error if one cannot be found.
62
- def nwo(site)
63
- nwo_from_env || \
64
- nwo_from_config(site) || \
65
- nwo_from_git_origin_remote || \
66
- proc {
67
- raise GitHubMetadata::NoRepositoryError, "No repo name found. " \
68
- "Specify using PAGES_REPO_NWO environment variables, " \
69
- "'repository' in your configuration, or set up an 'origin' " \
70
- "git remote pointing to your github.com repository."
71
- }.call
72
- end
73
22
  end
74
23
  end
75
24
  end
@@ -0,0 +1,124 @@
1
+ require 'jekyll'
2
+ require 'forwardable'
3
+
4
+ module Jekyll
5
+ module GitHubMetadata
6
+ class MetadataDrop < Jekyll::Drops::Drop
7
+ extend Forwardable
8
+
9
+ mutable true
10
+
11
+ def initialize(site)
12
+ @site = site
13
+ super(nil)
14
+ end
15
+
16
+ def keys
17
+ super.sort
18
+ end
19
+
20
+ def_delegator :"Jekyll::GitHubMetadata::Pages", :env, :environment
21
+ def_delegator :"Jekyll::GitHubMetadata::Pages", :env, :pages_env
22
+ def_delegator :"Jekyll::GitHubMetadata::Pages", :github_hostname, :hostname
23
+ def_delegator :"Jekyll::GitHubMetadata::Pages", :pages_hostname, :pages_hostname
24
+ def_delegator :"Jekyll::GitHubMetadata::Pages", :api_url, :api_url
25
+ def_delegator :"Jekyll::GitHubMetadata::Pages", :help_url, :help_url
26
+
27
+ def versions
28
+ @versions ||= begin
29
+ require 'github-pages'
30
+ GitHubPages.versions
31
+ rescue LoadError
32
+ {}
33
+ end
34
+ end
35
+
36
+ def build_revision
37
+ @build_revision ||= (
38
+ ENV['JEKYLL_BUILD_REVISION'] || `git rev-parse HEAD`.strip
39
+ )
40
+ end
41
+
42
+ def_delegator :repository, :owner_public_repositories, :public_repositories
43
+ def_delegator :repository, :organization_public_members, :organization_members
44
+ def_delegator :repository, :name, :project_title
45
+ def_delegator :repository, :tagline, :project_tagline
46
+ def_delegator :repository, :owner, :owner_name
47
+ def_delegator :repository, :owner_url, :owner_url
48
+ def_delegator :repository, :owner_gravatar_url, :owner_gravatar_url
49
+ def_delegator :repository, :repository_url, :repository_url
50
+ def_delegator :repository, :nwo, :repository_nwo
51
+ def_delegator :repository, :name, :repository_name
52
+ def_delegator :repository, :zip_url, :zip_url
53
+ def_delegator :repository, :tar_url, :tar_url
54
+ def_delegator :repository, :repo_clone_url, :clone_url
55
+ def_delegator :repository, :releases_url, :releases_url
56
+ def_delegator :repository, :issues_url, :issues_url
57
+ def_delegator :repository, :wiki_url, :wiki_url
58
+ def_delegator :repository, :language, :language
59
+ def_delegator :repository, :user_page?, :is_user_page
60
+ def_delegator :repository, :project_page?, :is_project_page
61
+ def_delegator :repository, :show_downloads?, :show_downloads
62
+ def_delegator :repository, :html_url, :url
63
+ def_delegator :repository, :contributors, :contributors
64
+ def_delegator :repository, :releases, :releases
65
+
66
+ private
67
+ attr_reader :site
68
+
69
+ def repository
70
+ @repository ||= GitHubMetadata::Repository.new(nwo(site)).tap do |repo|
71
+ Jekyll::GitHubMetadata.log :debug, "Generating for #{repo.nwo}"
72
+ end
73
+ end
74
+
75
+ def git_remote_url
76
+ `git remote --verbose`.split("\n").grep(%r{\Aorigin\t}).map do |remote|
77
+ remote.sub(/\Aorigin\t(.*) \([a-z]+\)/, "\\1")
78
+ end.uniq.first || ""
79
+ end
80
+
81
+ def nwo_from_git_origin_remote
82
+ return unless Jekyll.env == "development"
83
+ matches = git_remote_url.match %r{github.com(:|/)([\w-]+)/([\w-]+)}
84
+ matches[2..3].join("/") if matches
85
+ end
86
+
87
+ def nwo_from_env
88
+ ENV['PAGES_REPO_NWO']
89
+ end
90
+
91
+ def nwo_from_config(site)
92
+ repo = site.config['repository']
93
+ repo if repo && repo.is_a?(String) && repo.include?('/')
94
+ end
95
+
96
+ # Public: fetches the repository name with owner to fetch metadata for.
97
+ # In order of precedence, this method uses:
98
+ # 1. the environment variable $PAGES_REPO_NWO
99
+ # 2. 'repository' variable in the site config
100
+ # 3. the 'origin' git remote's URL
101
+ #
102
+ # site - the Jekyll::Site being processed
103
+ #
104
+ # Return the name with owner (e.g. 'parkr/my-repo') or raises an
105
+ # error if one cannot be found.
106
+ def nwo(site)
107
+ nwo_from_env || \
108
+ nwo_from_config(site) || \
109
+ nwo_from_git_origin_remote || \
110
+ proc {
111
+ raise GitHubMetadata::NoRepositoryError, "No repo name found. " \
112
+ "Specify using PAGES_REPO_NWO environment variables, " \
113
+ "'repository' in your configuration, or set up an 'origin' " \
114
+ "git remote pointing to your github.com repository."
115
+ }.call
116
+ end
117
+
118
+ # Nothing to see here.
119
+ def fallback_data
120
+ @fallback_data ||= {}
121
+ end
122
+ end
123
+ end
124
+ end
@@ -3,13 +3,14 @@ module Jekyll
3
3
  class Pages
4
4
  class << self
5
5
  DEFAULTS = {
6
- 'PAGES_ENV' => 'dotcom'.freeze,
7
- 'PAGES_API_URL' => 'https://api.github.com'.freeze,
8
- 'PAGES_HELP_URL' => 'https://help.github.com'.freeze,
9
- 'PAGES_GITHUB_HOSTNAME' => 'github.com'.freeze,
10
- 'PAGES_PAGES_HOSTNAME' => 'github.io'.freeze,
11
- 'SSL' => 'false'.freeze,
12
- 'SUBDOMAIN_ISOLATION' => 'false'.freeze
6
+ 'PAGES_ENV' => 'dotcom'.freeze,
7
+ 'PAGES_API_URL' => 'https://api.github.com'.freeze,
8
+ 'PAGES_HELP_URL' => 'https://help.github.com'.freeze,
9
+ 'PAGES_GITHUB_HOSTNAME' => 'github.com'.freeze,
10
+ 'PAGES_PAGES_HOSTNAME' => 'github.io'.freeze,
11
+ 'SSL' => 'false'.freeze,
12
+ 'SUBDOMAIN_ISOLATION' => 'false'.freeze,
13
+ 'PAGES_PREVIEW_HTML_URL' => nil
13
14
  }.freeze
14
15
 
15
16
  # Whether the GitHub instance supports HTTPS
@@ -40,6 +41,10 @@ module Jekyll
40
41
  env_var 'PAGES_ENV'
41
42
  end
42
43
 
44
+ def repo_pages_html_url_preview?
45
+ env_var "PAGES_PREVIEW_HTML_URL"
46
+ end
47
+
43
48
  def github_url
44
49
  if dotcom?
45
50
  "https://github.com".freeze
@@ -8,14 +8,26 @@ module Jekyll
8
8
  @name = nwo.split("/").last
9
9
  end
10
10
 
11
- def git_ref
12
- user_page? ? 'master' : 'gh-pages'
11
+ def repo_compat
12
+ @repo_compat ||= Jekyll::GitHubMetadata::RepositoryCompat.new(self)
13
13
  end
14
14
 
15
15
  def repo_info
16
16
  @repo_info ||= (Value.new(proc { |c| c.repository(nwo) }).render || Hash.new)
17
17
  end
18
18
 
19
+ def repo_pages_info
20
+ @repo_pages_info ||= (Value.new(proc { |c| c.pages(nwo, repo_pages_info_opts) }).render || Hash.new)
21
+ end
22
+
23
+ def repo_pages_info_opts
24
+ if Pages.repo_pages_html_url_preview?
25
+ { :accept => "application/vnd.github.mister-fantastic-preview+json" }
26
+ else
27
+ {}
28
+ end
29
+ end
30
+
19
31
  def language
20
32
  repo_info["language"]
21
33
  end
@@ -86,6 +98,10 @@ module Jekyll
86
98
  memoize_value :@releases, Value.new(proc { |c| c.releases(nwo) })
87
99
  end
88
100
 
101
+ def git_ref
102
+ user_page? ? 'master' : 'gh-pages'
103
+ end
104
+
89
105
  def user_page?
90
106
  primary?
91
107
  end
@@ -106,18 +122,10 @@ module Jekyll
106
122
  end
107
123
  end
108
124
 
109
- # In enterprise, the site's scheme will be the same as the instance's
110
- # In dotcom, this will be `https` for GitHub-owned sites that end with
111
- # `.github.com` and will be `http` for all other sites.
112
- # Note: This is not the same as *instance*'s scheme, which may differ
113
- def url_scheme
114
- if Pages.enterprise?
115
- Pages.scheme
116
- elsif owner == 'github' && domain.end_with?('.github.com')
117
- 'https'
118
- else
119
- 'http'
120
- end
125
+ def user_page_domains
126
+ domains = [default_user_domain]
127
+ domains.push "#{owner}.github.com".downcase unless Pages.enterprise?
128
+ domains
121
129
  end
122
130
 
123
131
  def default_user_domain
@@ -130,56 +138,25 @@ module Jekyll
130
138
  end
131
139
  end
132
140
 
133
- def user_page_domains
134
- domains = [default_user_domain]
135
- domains.push "#{owner}.github.com".downcase unless Pages.enterprise?
136
- domains
141
+ def cname
142
+ return nil unless Pages.custom_domains_enabled?
143
+ repo_pages_info["cname"]
137
144
  end
138
145
 
139
- def user_domain
140
- domain = default_user_domain
141
- user_page_domains.each do |user_repo|
142
- candidate_nwo = "#{owner}/#{user_repo}"
143
- next unless Value.new(proc { |client| client.repository? candidate_nwo }).render
144
- domain = self.class.new(candidate_nwo).domain
145
- end
146
- domain
147
- end
148
-
149
- def pages_url
150
- if !Pages.custom_domains_enabled?
151
- path = user_page? ? owner : nwo
152
- if Pages.subdomain_isolation?
153
- URI.join("#{Pages.scheme}://#{Pages.pages_hostname}/", path).to_s
154
- else
155
- URI.join("#{Pages.github_url}/pages/", path).to_s
156
- end
157
- elsif cname || primary?
158
- "#{url_scheme}://#{domain}"
159
- else
160
- URI.join("#{url_scheme}://#{domain}", name).to_s
161
- end
146
+ def html_url
147
+ @html_url ||= (repo_pages_info["html_url"] || repo_compat.pages_url)
162
148
  end
163
149
 
164
- def cname
165
- memoize_value :@cname, Value.new(proc { |c|
166
- if Pages.custom_domains_enabled?
167
- (c.pages(nwo) || {'cname' => nil})['cname']
168
- end
169
- })
150
+ def uri
151
+ @uri ||= URI(html_url)
170
152
  end
171
153
 
172
154
  def domain
173
- @domain ||=
174
- if !Pages.custom_domains_enabled?
175
- Pages.github_hostname
176
- elsif cname # explicit CNAME
177
- cname
178
- elsif primary? # user/org repo
179
- default_user_domain
180
- else # project repo
181
- user_domain
182
- end
155
+ uri.host
156
+ end
157
+
158
+ def url_scheme
159
+ uri.scheme
183
160
  end
184
161
 
185
162
  private
@@ -0,0 +1,64 @@
1
+ module Jekyll
2
+ module GitHubMetadata
3
+ class RepositoryCompat
4
+ attr_reader :repo
5
+
6
+ def initialize(repo)
7
+ @repo = repo
8
+ end
9
+
10
+ # In enterprise, the site's scheme will be the same as the instance's
11
+ # In dotcom, this will be `https` for GitHub-owned sites that end with
12
+ # `.github.com` and will be `http` for all other sites.
13
+ # Note: This is not the same as *instance*'s scheme, which may differ
14
+ def url_scheme
15
+ if Pages.enterprise?
16
+ Pages.scheme
17
+ elsif repo.owner == 'github' && domain.end_with?('.github.com')
18
+ 'https'
19
+ else
20
+ 'http'
21
+ end
22
+ end
23
+
24
+ def user_domain
25
+ domain = repo.default_user_domain
26
+ repo.user_page_domains.each do |user_repo|
27
+ candidate_nwo = "#{repo.owner}/#{user_repo}"
28
+ next unless Jekyll::GitHubMetadata.client.repository?(candidate_nwo)
29
+ domain = Jekyll::GitHubMetadata::Repository.new(candidate_nwo).repo_compat.domain
30
+ end
31
+ domain
32
+ end
33
+
34
+ def pages_url
35
+ if !Pages.custom_domains_enabled?
36
+ path = repo.user_page? ? repo.owner : repo.nwo
37
+ if Pages.subdomain_isolation?
38
+ URI.join("#{Pages.scheme}://#{Pages.pages_hostname}/", path).to_s
39
+ else
40
+ URI.join("#{Pages.github_url}/pages/", path).to_s
41
+ end
42
+ elsif repo.cname || repo.primary?
43
+ "#{url_scheme}://#{domain}"
44
+ else
45
+ URI.join("#{url_scheme}://#{domain}", repo.name).to_s
46
+ end
47
+ end
48
+ alias_method :html_url, :pages_url
49
+
50
+ def domain
51
+ @domain ||=
52
+ if !Pages.custom_domains_enabled?
53
+ Pages.github_hostname
54
+ elsif repo.cname # explicit CNAME
55
+ repo.cname
56
+ elsif repo.primary? # user/org repo
57
+ repo.default_user_domain
58
+ else # project repo
59
+ user_domain
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -35,7 +35,7 @@ module Jekyll
35
35
  end
36
36
  @value = Sanitizer.sanitize(@value)
37
37
  rescue RuntimeError, NameError => e
38
- Jekyll.logger.error "GitHubMetadata:", "Error processing value '#{key}':"
38
+ Jekyll::GitHubMetadata.log :error, "Error processing value '#{key}':"
39
39
  raise e
40
40
  end
41
41
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module GitHubMetadata
3
- VERSION = '1.11.1'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-github-metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-22 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -25,35 +25,35 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: jekyll
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.5'
34
- type: :development
33
+ version: '3.1'
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.5'
40
+ version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
- name: netrc
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: netrc
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: jekyll
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '2.0'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '2.0'
96
+ version: '0'
97
97
  description:
98
98
  email:
99
99
  - parkrmoore@gmail.com
@@ -104,8 +104,10 @@ files:
104
104
  - lib/jekyll-github-metadata.rb
105
105
  - lib/jekyll-github-metadata/client.rb
106
106
  - lib/jekyll-github-metadata/ghp_metadata_generator.rb
107
+ - lib/jekyll-github-metadata/metadata_drop.rb
107
108
  - lib/jekyll-github-metadata/pages.rb
108
109
  - lib/jekyll-github-metadata/repository.rb
110
+ - lib/jekyll-github-metadata/repository_compat.rb
109
111
  - lib/jekyll-github-metadata/sanitizer.rb
110
112
  - lib/jekyll-github-metadata/value.rb
111
113
  - lib/jekyll-github-metadata/version.rb