jekyll-theme-open-project-helpers 1.1.24 → 1.1.25

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
  SHA256:
3
- metadata.gz: 2ff260a10532e72a2e3d117c383e0970b2f7eb4bf12a1f2b55e9a800a4541a62
4
- data.tar.gz: 1a6ce67cdc2ca0d1b02c30f63e72559ec0dd27d42017a4e8758dc31dc572452f
3
+ metadata.gz: c192c0b3ad2c0a163331115f647f7d40821573c0b519ea879c90f4309bbe1ffb
4
+ data.tar.gz: e02887c7c4e8c046d2ebf3a06cf659b4fc744f8cc6ca7c40c9bbd8657ace5d23
5
5
  SHA512:
6
- metadata.gz: 38fcfdd49087c7caa030d85a250986000d2f2802228a9a2a0e1a58c613cabda6727a93e97f26c0607f021d50b1d82c66c6e1ee7dcfeb223d0b6e4c633e697f87
7
- data.tar.gz: 7875178aae1b268e398bebf5357980cf2dc8d9ec799100c27dcd252c2fb25ea3ebd8f79f5e884e2f5a4dfab58e2d0712575fac7eac7d0d4dfa870c571528918b
6
+ metadata.gz: 664b3e7464608435eb4dac2f31b75413279297d2894d391bcf04baf316d400bed0c35f1813b7373093c153c8dc1aa68ba5b54d23eda2b174d8c7bb8248c9dc8a
7
+ data.tar.gz: 1adce0e0cf30a8284797ce9464caf33d2662864a025d0c2d5915227020971ca61878ba70d16aaf5c27b6ae6250e86bffb726223766fe458fbfdd0a57f075ab19
@@ -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 = '1.1.24'
5
+ s.version = '1.1.25'
6
6
  s.authors = ['Ribose Inc.']
7
7
  s.email = ['open.source@ribose.com']
8
8
 
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_runtime_dependency 'jekyll', '~> 3.8'
16
16
  s.add_runtime_dependency 'git', '~> 1.4'
17
+ s.add_runtime_dependency 'fastimage', '~> 2.1.4'
17
18
  s.add_development_dependency 'rake', '~> 12.0'
18
19
  s.add_development_dependency 'rubocop', '~> 0.50'
19
20
 
@@ -8,6 +8,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
10
  require 'jekyll-theme-open-project-helpers/external_links'
11
+ require 'jekyll-theme-open-project-helpers/spec_builders/spec_builder'
11
12
 
12
13
 
13
14
  module Jekyll
@@ -69,8 +69,8 @@ module Jekyll
69
69
  if @site.config['is_hub']
70
70
  fetch_and_read_projects
71
71
  else
72
- fetch_and_read_docs_for_items('software')
73
- fetch_and_read_docs_for_items('specs')
72
+ fetch_and_read_software('software')
73
+ fetch_and_read_specs('specs')
74
74
  fetch_hub_logo
75
75
  end
76
76
  end
@@ -99,18 +99,76 @@ module Jekyll
99
99
  project['site']['git_repo_url'],
100
100
  ['assets', '_posts', '_software', '_specs'])
101
101
 
102
- fetch_and_read_docs_for_items('projects', 'software')
103
- fetch_and_read_docs_for_items('projects', 'specs')
102
+ fetch_and_read_software('projects')
103
+ fetch_and_read_specs('projects')
104
104
  end
105
105
  end
106
106
 
107
- def fetch_and_read_docs_for_items(collection_name, index_collection_name=nil)
108
- # collection_name would be either software, specs, or (for hub site) projects
109
- # index_collection_name would be either software, specs or (for project site) nil
107
+ def build_and_read_spec_pages(collection_name, index_doc)
108
+ item_name = index_doc.id.split('/')[-1]
109
+
110
+ repo_checkout = nil
111
+ src = index_doc.data['spec_source']
112
+ repo_url = src['git_repo_url']
113
+ repo_subtree = src['git_repo_subtree']
114
+ build = src['build']
115
+ engine = build['engine']
116
+ engine_opts = build['options'] || {}
117
+
118
+ spec_checkout_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
119
+ spec_root = if repo_subtree
120
+ "#{spec_checkout_path}/#{repo_subtree}"
121
+ else
122
+ spec_checkout_path
123
+ end
124
+
125
+ begin
126
+ repo_checkout = git_shallow_checkout(spec_checkout_path, repo_url, [repo_subtree])
127
+ rescue
128
+ repo_checkout = nil
129
+ end
130
+
131
+ if repo_checkout
132
+ builder = Jekyll::OpenProjectHelpers::SpecBuilder::new(
133
+ @site,
134
+ index_doc,
135
+ spec_root,
136
+ "specs/#{item_name}",
137
+ engine,
138
+ engine_opts)
139
+
140
+ builder.build()
141
+ builder.built_pages.each do |page|
142
+ @site.pages << page
143
+ end
144
+
145
+ CollectionDocReader.new(site).read(
146
+ spec_checkout_path,
147
+ @site.collections[collection_name])
148
+
149
+ index_doc.merge_data!({ 'last_update' => repo_checkout[:modified_at] })
150
+ end
151
+ end
152
+
153
+ def fetch_and_read_specs(collection_name)
154
+ # collection_name would be either specs or (for hub site) projects
110
155
 
111
156
  return unless @site.collections.key?(collection_name)
112
157
 
113
- index_collection_name = index_collection_name or collection_name
158
+ # Get spec entry points
159
+ entry_points = @site.collections[collection_name].docs.select do |doc|
160
+ doc.data['spec_source']
161
+ end
162
+
163
+ entry_points.each do |index_doc|
164
+ build_and_read_spec_pages(collection_name, index_doc)
165
+ end
166
+ end
167
+
168
+ def fetch_and_read_software(collection_name)
169
+ # collection_name would be either software or (for hub site) projects
170
+
171
+ return unless @site.collections.key?(collection_name)
114
172
 
115
173
  entry_points = @site.collections[collection_name].docs.select do |doc|
116
174
  doc.data['repo_url']
@@ -120,22 +178,24 @@ module Jekyll
120
178
  item_name = index_doc.id.split('/')[-1]
121
179
 
122
180
  if index_doc.data.key?('docs') and index_doc.data['docs']['git_repo_url']
123
- docs_repo = index_doc.data['docs']['git_repo_url']
124
- docs_subtree = index_doc.data['docs']['git_repo_subtree'] || DEFAULT_DOCS_SUBTREE
181
+ sw_docs_repo = index_doc.data['docs']['git_repo_url']
182
+ sw_docs_subtree = index_doc.data['docs']['git_repo_subtree'] || DEFAULT_DOCS_SUBTREE
125
183
  else
126
- docs_repo = index_doc.data['repo_url']
127
- docs_subtree = DEFAULT_DOCS_SUBTREE
184
+ sw_docs_repo = index_doc.data['repo_url']
185
+ sw_docs_subtree = DEFAULT_DOCS_SUBTREE
128
186
  end
129
187
 
188
+ main_repo = index_doc.data['repo_url']
189
+
130
190
  docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
131
191
 
132
192
  begin
133
- docs_checkout = git_shallow_checkout(docs_path, docs_repo, [docs_subtree])
193
+ sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree])
134
194
  rescue
135
- docs_checkout = nil
195
+ sw_docs_checkout = nil
136
196
  end
137
197
 
138
- if docs_checkout
198
+ if sw_docs_checkout
139
199
  CollectionDocReader.new(site).read(
140
200
  docs_path,
141
201
  @site.collections[collection_name])
@@ -144,12 +204,12 @@ module Jekyll
144
204
  # Get last repository modification timestamp.
145
205
  # Fetch the repository for that purpose,
146
206
  # unless it’s the same as the repo where docs are.
147
- if docs_checkout == nil or docs_repo != index_doc.data['repo_url']
207
+ if sw_docs_checkout == nil or sw_docs_repo != main_repo
148
208
  repo_path = "#{index_doc.path.split('/')[0..-2].join('/')}/_#{item_name}_repo"
149
- repo_checkout = git_shallow_checkout(repo_path, index_doc.data['repo_url'])
209
+ repo_checkout = git_shallow_checkout(repo_path, main_repo)
150
210
  index_doc.merge_data!({ 'last_update' => repo_checkout[:modified_at] })
151
211
  else
152
- index_doc.merge_data!({ 'last_update' => docs_checkout[:modified_at] })
212
+ index_doc.merge_data!({ 'last_update' => sw_docs_checkout[:modified_at] })
153
213
  end
154
214
  end
155
215
  end
@@ -0,0 +1,31 @@
1
+ {% comment %}Page stub.{% endcomment %}
2
+
3
+ <div id="diagramContainer" style="height: {{ page.image_height }}px"></div>
4
+
5
+ <style>
6
+ .leaflet-container {
7
+ background-color: transparent;
8
+ }
9
+ .documentation.with-expandable-toc > article {
10
+ max-width: none;
11
+ }
12
+ </style>
13
+
14
+ <script>
15
+ (function () {
16
+ var map = L.map('diagramContainer', {
17
+ crs: L.CRS.Simple,
18
+ attributionControl: false,
19
+ scrollWheelZoom: false,
20
+ zoomControl: false,
21
+ minZoom: -10,
22
+ }).
23
+ setView([{{ page.image_height }}/2, {{ page.image_width }}/2]);
24
+
25
+ map.addControl(L.control.zoom({ position: 'bottomleft' }));
26
+
27
+ var bounds = [[0,0], [{{ page.image_height }}, {{ page.image_width }}]];
28
+ var image = L.imageOverlay('{{ page.image_path }}', bounds).addTo(map);
29
+ map.fitBounds(bounds);
30
+ }());
31
+ </script>
@@ -0,0 +1,66 @@
1
+ require 'fastimage'
2
+
3
+ module Builder
4
+
5
+ class PngDiagramPage < Jekyll::Page
6
+ def initialize(site, base, dir, data)
7
+ @site = site
8
+ @base = base
9
+ @dir = dir
10
+ @name = 'index.html'
11
+
12
+ self.process(@name)
13
+ self.data ||= data
14
+
15
+ self.data['extra_stylesheets'] = [{
16
+ "href" => "https://unpkg.com/leaflet@1.3.4/dist/leaflet.css",
17
+ "integrity" => "sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==",
18
+ "crossorigin" => "",
19
+ }]
20
+
21
+ self.data['extra_scripts'] = [{
22
+ "src" => "https://unpkg.com/leaflet@1.3.4/dist/leaflet.js",
23
+ "integrity" => "sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==",
24
+ "crossorigin" => "",
25
+ }]
26
+
27
+ self.data['layout'] = 'spec'
28
+ end
29
+ end
30
+
31
+ def build_spec_pages(site, spec_info, source, destination, opts)
32
+ images_path = source
33
+ spec_root = destination
34
+ stub_path = "#{File.dirname(__FILE__)}/png_diagram.html"
35
+ pages = []
36
+
37
+ Dir.glob("#{images_path}/*.png") do |pngfile|
38
+ png_name = File.basename(pngfile)
39
+ png_name_noext = File.basename(png_name, File.extname(png_name))
40
+
41
+ nav_item = spec_info.data['navigation']['sections'].map { |section|
42
+ section['items']
43
+ } .flatten.select { |item| item['path'] == png_name_noext} [0].clone
44
+
45
+ png_dimensions = FastImage.size(pngfile)
46
+ data = spec_info.data.clone
47
+ data['image_path'] = "/#{spec_root}/images/#{png_name}"
48
+ data['image_width'] = png_dimensions[0]
49
+ data['image_height'] = png_dimensions[1]
50
+ data = data.merge(nav_item)
51
+
52
+ data['title'] = "#{spec_info['title']}: #{nav_item['title']}"
53
+
54
+ page = PngDiagramPage.new(
55
+ site,
56
+ site.source,
57
+ File.join(spec_root, png_name_noext),
58
+ data)
59
+ page.content = File.read(stub_path)
60
+ pages << page
61
+ end
62
+
63
+ return pages
64
+ end
65
+
66
+ end
@@ -0,0 +1,33 @@
1
+ require 'forwardable'
2
+
3
+ module Jekyll
4
+ module OpenProjectHelpers
5
+ class SpecBuilder
6
+
7
+ attr_reader :built_pages
8
+
9
+ def initialize(site, spec_index_doc, spec_source_base, spec_out_base, engine, opts)
10
+ require_relative engine
11
+ extend Builder # adds the build_spec_pages method
12
+
13
+ @site = site
14
+ @spec_index_doc = spec_index_doc
15
+ @spec_source_base = spec_source_base
16
+ @spec_out_base = spec_out_base
17
+ @opts = opts
18
+
19
+ @built_pages = []
20
+ end
21
+
22
+ def build()
23
+ @built_pages = build_spec_pages(
24
+ @site,
25
+ @spec_index_doc,
26
+ @spec_source_base,
27
+ @spec_out_base,
28
+ @opts)
29
+ end
30
+
31
+ end
32
+ end
33
+ 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: 1.1.24
4
+ version: 1.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-16 00:00:00.000000000 Z
11
+ date: 2018-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fastimage
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.1.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.1.4
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -83,6 +97,9 @@ files:
83
97
  - lib/jekyll-theme-open-project-helpers/filterable_index.rb
84
98
  - lib/jekyll-theme-open-project-helpers/project_data_reader.rb
85
99
  - lib/jekyll-theme-open-project-helpers/site_type.rb
100
+ - lib/jekyll-theme-open-project-helpers/spec_builders/png_diagram.html
101
+ - lib/jekyll-theme-open-project-helpers/spec_builders/png_diagrams.rb
102
+ - lib/jekyll-theme-open-project-helpers/spec_builders/spec_builder.rb
86
103
  homepage: https://github.com/riboseinc/jekyll-theme-open-project-helpers/
87
104
  licenses:
88
105
  - MIT