jekyll-theme-open-project-helpers 2.0.18 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +17 -0
- data/jekyll-theme-open-project-helpers.gemspec +2 -2
- data/lib/jekyll-theme-open-project-helpers.rb +0 -1
- data/lib/jekyll-theme-open-project-helpers/filterable_index.rb +8 -2
- data/lib/jekyll-theme-open-project-helpers/project_data_reader.rb +31 -3
- metadata +5 -7
- data/lib/jekyll-theme-open-project-helpers/external_links.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d096dee75cd2701ec861557d024217d5ae9a1ece20af4449b9711404afab5e40
|
4
|
+
data.tar.gz: b00a83ea68cded47ec6a54619ba8a9989de7a99efc366be0192b9dde65f69b6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8edabeaebf34a1dc29863c28387cdaa3f6f530694ce154a6d7dd5f6e3a730a7da4669f5e827b62cbec4ffc768bf584b064ee4be225e14aa272f04828d8ec8cb2
|
7
|
+
data.tar.gz: 2662e8d9aa452712988143669c2d91b1ff709bceaaf838578eb7a05f341431c87bfd32613ae28e8caa373bd6ec038bd2b01170b63b83812bc7dc504cbd9216e1
|
data/README.md
CHANGED
@@ -8,3 +8,20 @@ required by the theme.
|
|
8
8
|
Currently it enables such features as tag-based filtering
|
9
9
|
of open software and specification indexes, unified blog index,
|
10
10
|
fetching open project/software/specification data from their repos.
|
11
|
+
|
12
|
+
## Releasing
|
13
|
+
|
14
|
+
**Release this helpers gem and theme gem in tandem with matching versions.**
|
15
|
+
See [https://github.com/riboseinc/jekyll-theme-open-project-helpers](theme gem docs) for more.
|
16
|
+
|
17
|
+
|
18
|
+
1. Inside .gemspec within this repo’s root, update main gem version to the one being released.
|
19
|
+
|
20
|
+
2. Make a commit for the new release (“chore: Release vX.X.X”).
|
21
|
+
|
22
|
+
3. Execute `./develop/release`. This does the following:
|
23
|
+
|
24
|
+
* Builds new gem version
|
25
|
+
* Pushes gem to rubygems.org
|
26
|
+
* Creates new version tag in this repository
|
27
|
+
* Pushes changes to GitHub
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'jekyll-theme-open-project-helpers'
|
5
|
-
s.version = '2.
|
5
|
+
s.version = '2.1.1'
|
6
6
|
s.authors = ['Ribose Inc.']
|
7
7
|
s.email = ['open.source@ribose.com']
|
8
8
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
14
14
|
|
15
|
-
s.add_runtime_dependency 'jekyll', '~>
|
15
|
+
s.add_runtime_dependency 'jekyll', '~> 4.0'
|
16
16
|
s.add_runtime_dependency 'git', '~> 1.4'
|
17
17
|
s.add_runtime_dependency 'fastimage', '~> 2.1.4'
|
18
18
|
s.add_development_dependency 'rake', '~> 12.0'
|
@@ -7,7 +7,6 @@ require 'jekyll-theme-open-project-helpers/site_type'
|
|
7
7
|
require 'jekyll-theme-open-project-helpers/project_data_reader'
|
8
8
|
require 'jekyll-theme-open-project-helpers/filterable_index'
|
9
9
|
require 'jekyll-theme-open-project-helpers/blog_index'
|
10
|
-
require 'jekyll-theme-open-project-helpers/external_links'
|
11
10
|
require 'jekyll-theme-open-project-helpers/spec_builders/spec_builder'
|
12
11
|
require 'jekyll-theme-open-project-helpers/static_file_fix'
|
13
12
|
|
@@ -55,7 +55,7 @@ module Jekyll
|
|
55
55
|
# Creates a data structure like { tag1: [item1, item2], tag2: [item2, item3] }
|
56
56
|
tags = {}
|
57
57
|
items.each do |item|
|
58
|
-
item.data['tags'].each do |tag|
|
58
|
+
(item.data['tags'] or []).each do |tag|
|
59
59
|
unless tags.key? tag
|
60
60
|
tags[tag] = []
|
61
61
|
end
|
@@ -131,7 +131,13 @@ end
|
|
131
131
|
def get_all_items(site, collection_name, filter_func)
|
132
132
|
# Fetches items of specified type, ordered and prepared for usage in index templates
|
133
133
|
|
134
|
-
|
134
|
+
collection = site.collections[collection_name]
|
135
|
+
|
136
|
+
if collection == nil
|
137
|
+
raise "Collection does not exist: #{collection_name}"
|
138
|
+
end
|
139
|
+
|
140
|
+
items = collection.docs.select { |item|
|
135
141
|
filter_func.call(item)
|
136
142
|
}
|
137
143
|
|
@@ -30,6 +30,8 @@ module Jekyll
|
|
30
30
|
entries.each do |entry|
|
31
31
|
path = File.join(dir, entry)
|
32
32
|
|
33
|
+
Jekyll.logger.debug("OPF:", "Reading entry #{path}")
|
34
|
+
|
33
35
|
if File.directory?(path)
|
34
36
|
read_project_subdir(path, collection, nested=true)
|
35
37
|
|
@@ -41,10 +43,14 @@ module Jekyll
|
|
41
43
|
|
42
44
|
# Add document to Jekyll document database if it refers to software or spec
|
43
45
|
# (as opposed to be some nested document like README)
|
44
|
-
if doc.url.split('/').size == 4
|
46
|
+
if (doc.url.split('/').size == 4) or (doc.url.split('/').size == 5 and collection.label === 'projects')
|
47
|
+
Jekyll.logger.debug("OPF:", "Adding document with URL: #{doc.url}")
|
45
48
|
collection.docs << doc
|
49
|
+
else
|
50
|
+
Jekyll.logger.debug("OPF:", "Did NOT add document with URL (nesting level doesn’t match): #{doc.url}")
|
46
51
|
end
|
47
52
|
else
|
53
|
+
Jekyll.logger.debug("OPF:", "Adding static file: #{path}")
|
48
54
|
collection.files << Jekyll::StaticFile.new(
|
49
55
|
@site,
|
50
56
|
@site.source,
|
@@ -104,6 +110,9 @@ module Jekyll
|
|
104
110
|
project['site']['git_repo_url'],
|
105
111
|
['assets', '_posts', '_software', '_specs'])
|
106
112
|
|
113
|
+
|
114
|
+
Jekyll.logger.debug("OPF:", "Reading files in project #{project_path}")
|
115
|
+
|
107
116
|
CollectionDocReader.new(site).read(
|
108
117
|
project_path,
|
109
118
|
@site.collections['projects'])
|
@@ -131,10 +140,10 @@ module Jekyll
|
|
131
140
|
spec_checkout_path
|
132
141
|
end
|
133
142
|
|
143
|
+
repo_checkout = nil
|
134
144
|
begin
|
135
145
|
repo_checkout = git_shallow_checkout(spec_checkout_path, repo_url, [repo_subtree])
|
136
146
|
rescue
|
137
|
-
repo_checkout = nil
|
138
147
|
end
|
139
148
|
|
140
149
|
if repo_checkout
|
@@ -164,14 +173,23 @@ module Jekyll
|
|
164
173
|
def fetch_and_read_specs(collection_name, build_pages=false)
|
165
174
|
# collection_name would be either specs or (for hub site) projects
|
166
175
|
|
176
|
+
Jekyll.logger.debug("OPF:", "Fetching specs for items in collection #{collection_name} (if it exists)")
|
177
|
+
|
167
178
|
return unless @site.collections.key?(collection_name)
|
168
179
|
|
180
|
+
Jekyll.logger.debug("OPF:", "Fetching specs for items in collection #{collection_name}")
|
181
|
+
|
169
182
|
# Get spec entry points
|
170
183
|
entry_points = @site.collections[collection_name].docs.select do |doc|
|
171
184
|
doc.data['spec_source']
|
172
185
|
end
|
173
186
|
|
187
|
+
if entry_points.size < 1
|
188
|
+
Jekyll.logger.info("OPF:", "Fetching specs for items in collection #{collection_name}: No entry points")
|
189
|
+
end
|
190
|
+
|
174
191
|
entry_points.each do |index_doc|
|
192
|
+
Jekyll.logger.debug("OPF:", "Fetching specs: entry point #{index_doc.id} in collection #{collection_name}")
|
175
193
|
build_and_read_spec_pages(collection_name, index_doc, build_pages)
|
176
194
|
end
|
177
195
|
end
|
@@ -179,14 +197,23 @@ module Jekyll
|
|
179
197
|
def fetch_and_read_software(collection_name)
|
180
198
|
# collection_name would be either software or (for hub site) projects
|
181
199
|
|
200
|
+
Jekyll.logger.debug("OPF:", "Fetching software for items in collection #{collection_name} (if it exists)")
|
201
|
+
|
182
202
|
return unless @site.collections.key?(collection_name)
|
183
203
|
|
204
|
+
Jekyll.logger.debug("OPF:", "Fetching software for items in collection #{collection_name}")
|
205
|
+
|
184
206
|
entry_points = @site.collections[collection_name].docs.select do |doc|
|
185
207
|
doc.data['repo_url']
|
186
208
|
end
|
187
209
|
|
210
|
+
if entry_points.size < 1
|
211
|
+
Jekyll.logger.info("OPF:", "Fetching software for items in collection #{collection_name}: No entry points")
|
212
|
+
end
|
213
|
+
|
188
214
|
entry_points.each do |index_doc|
|
189
215
|
item_name = index_doc.id.split('/')[-1]
|
216
|
+
Jekyll.logger.debug("OPF:", "Fetching software: entry point #{index_doc.id} in collection #{collection_name}")
|
190
217
|
|
191
218
|
docs = index_doc.data['docs']
|
192
219
|
main_repo = index_doc.data['repo_url']
|
@@ -196,10 +223,10 @@ module Jekyll
|
|
196
223
|
|
197
224
|
docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
|
198
225
|
|
226
|
+
sw_docs_checkout = nil
|
199
227
|
begin
|
200
228
|
sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree])
|
201
229
|
rescue
|
202
|
-
sw_docs_checkout = nil
|
203
230
|
end
|
204
231
|
|
205
232
|
if sw_docs_checkout
|
@@ -280,6 +307,7 @@ module Jekyll
|
|
280
307
|
:modified_at => nil,
|
281
308
|
}
|
282
309
|
else
|
310
|
+
Jekyll.logger.debug("OPF:", "Fetching & checking out #{remote_url} for #{repo_path}")
|
283
311
|
repo.fetch(DEFAULT_REPO_REMOTE_NAME, { :depth => 1 })
|
284
312
|
repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
|
285
313
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-theme-open-project-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: git
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,7 +93,6 @@ files:
|
|
93
93
|
- jekyll-theme-open-project-helpers.gemspec
|
94
94
|
- lib/jekyll-theme-open-project-helpers.rb
|
95
95
|
- lib/jekyll-theme-open-project-helpers/blog_index.rb
|
96
|
-
- lib/jekyll-theme-open-project-helpers/external_links.rb
|
97
96
|
- lib/jekyll-theme-open-project-helpers/filterable_index.rb
|
98
97
|
- lib/jekyll-theme-open-project-helpers/project_data_reader.rb
|
99
98
|
- lib/jekyll-theme-open-project-helpers/site_type.rb
|
@@ -120,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
119
|
- !ruby/object:Gem::Version
|
121
120
|
version: '0'
|
122
121
|
requirements: []
|
123
|
-
|
124
|
-
rubygems_version: 2.5.2.3
|
122
|
+
rubygems_version: 3.0.6
|
125
123
|
signing_key:
|
126
124
|
specification_version: 4
|
127
125
|
summary: Helpers for the Open Project Jekyll theme
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
require 'uri'
|
3
|
-
|
4
|
-
# Given hostname and content, updates <a> elements as follows:
|
5
|
-
#
|
6
|
-
# - Adds `rel` attribute
|
7
|
-
# - Appends inner markup for FontAwesome external link icon
|
8
|
-
#
|
9
|
-
# Only processes external links where `href` starts with "http"
|
10
|
-
# and target host does not include given site hostname.
|
11
|
-
def process_content(site_hostname, content, exclude_selectors=[])
|
12
|
-
content = Nokogiri::HTML(content)
|
13
|
-
content.css('body.site--project main a, body.site--hub.layout--post main a').each do |a|
|
14
|
-
next if matches_one_of(a, exclude_selectors)
|
15
|
-
next unless a.get_attribute('href') =~ /\Ahttp/i
|
16
|
-
next if a.get_attribute('href') =~ /\Ahttp(s)?:\/\/#{site_hostname}\//i
|
17
|
-
next if a.inner_html.include? "ico-ext"
|
18
|
-
a.set_attribute('rel', 'external')
|
19
|
-
a.inner_html = "#{a.inner_html}<span class='ico-ext'><i class='fas fa-external-link-square-alt'></i></span>"
|
20
|
-
end
|
21
|
-
return content.to_s
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns true if Nokogiri’s Node matches one of selectors,
|
25
|
-
# otherwise return false
|
26
|
-
def matches_one_of(node, selectors)
|
27
|
-
for selector in selectors
|
28
|
-
if node.matches? selector
|
29
|
-
return true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
return false
|
33
|
-
end
|
34
|
-
|
35
|
-
Jekyll::Hooks.register :documents, :post_render do |doc|
|
36
|
-
site_hostname = URI(doc.site.config['url']).host
|
37
|
-
unmarked_link_selectors = doc.site.config['unmarked_external_link_selectors']
|
38
|
-
unless doc.asset_file?
|
39
|
-
doc.output = process_content(site_hostname, doc.output, unmarked_link_selectors)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
Jekyll::Hooks.register :pages, :post_render do |page|
|
44
|
-
site_hostname = URI(page.site.config['url']).host
|
45
|
-
unmarked_link_selectors = page.site.config['unmarked_external_link_selectors']
|
46
|
-
unless page.asset_file?
|
47
|
-
page.output = process_content(site_hostname, page.output, unmarked_link_selectors)
|
48
|
-
end
|
49
|
-
end
|