swedbank-pay-design-guide-jekyll-theme 1.6.1.pre.PullRequest0137.pre.0064 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'sidebar_html_builder'
4
+
5
+ module SwedbankPay
6
+ # Renders the Sidebar
7
+ class SidebarRenderer
8
+ def render(tree)
9
+ raise ArgumentError, 'pages must be an SidebarTreeBuilder' unless tree.is_a? SidebarTreeBuilder
10
+
11
+ @tree = tree
12
+ render_pages(tree)
13
+ end
14
+
15
+ private
16
+
17
+ def render_pages(pages)
18
+ return if pages.empty?
19
+
20
+ pages.each do |page|
21
+ sidebar_html = render_page(page)
22
+
23
+ next if sidebar_html.nil?
24
+ next if page.sidebar_container.nil?
25
+
26
+ page.sidebar_container.inner_html = sidebar_html
27
+
28
+ page.save
29
+
30
+ render_pages(page.children)
31
+ end
32
+ end
33
+
34
+ def render_page(page)
35
+ sidebar_html = nil
36
+
37
+ begin
38
+ builder = SidebarHTMLBuilder.new(@tree)
39
+ sidebar_html = builder.build(page)
40
+
41
+ File.open('_site/sidebar.html', 'w') { |f| f.write(sidebar_html) }
42
+ rescue StandardError => e
43
+ Jekyll.logger.error(" Sidebar: Unable to render sidebar for '#{page.filename}'.")
44
+ Jekyll.logger.debug(" Sidebar: #{e.message}. #{e.backtrace.inspect}")
45
+ return nil
46
+ end
47
+
48
+ sidebar_html
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: false
2
+
3
+ require_relative 'sidebar_page'
4
+
5
+ module SwedbankPay
6
+ # Builds a plain text representation of a Sidebar, suitable for a terminal.
7
+ class SidebarTextBuilder
8
+ def initialize(page)
9
+ raise ArgumentError, 'Page must be a SidebarPage' unless page.is_a? SidebarPage
10
+
11
+ @page = page
12
+ end
13
+
14
+ def to_s
15
+ name = @page.name == '/' ? '/' : "/#{@page.name}"
16
+ title = @page.title.nil? ? '?' : @page.title.item
17
+ s = "#{indent} #{name}: #{title} (#{@page.coordinate})\n"
18
+
19
+ unless @page.children.empty?
20
+ @page.children.each do |child|
21
+ s << child.to_s
22
+ end
23
+ end
24
+
25
+ # Only strip extraneous whitespace at the root page
26
+ @page.level.zero? ? s.strip : s
27
+ end
28
+
29
+ private
30
+
31
+ def indent
32
+ # Return a special character for the first root page
33
+ return '┍╾' if (@page.number.nil? || @page.number.zero?) && @page.parent.nil?
34
+
35
+ increment = @page.level > 1 ? @page.level + 1 : @page.level
36
+
37
+ "┝╾#{('─' * increment)}"
38
+ end
39
+
40
+ def todo
41
+ # This 'todo' method exists to circumvent the following RuboCop error:
42
+ # lib/sidebar_text_builder.rb:39:97: C: Style/AsciiComments: Use only ascii symbols in comments.
43
+ "TODO: Add logic to find the very last page regardless of level and have indent it with '┕╾─'"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: false
2
+
3
+ require 'forwardable'
4
+ require_relative 'sidebar_page_collection'
5
+
6
+ module SwedbankPay
7
+ # Arranges Sidebar pages into a tree
8
+ class SidebarTreeBuilder
9
+ include Enumerable
10
+ extend Forwardable
11
+ def_delegators :@pages, :each, :length, :empty?, :<<, :[], :count
12
+
13
+ def initialize(pages)
14
+ raise ArgumentError, 'Pages must be a Hash' unless pages.is_a? Hash
15
+
16
+ @pages = tree(pages)
17
+ end
18
+
19
+ def to_s
20
+ stringify
21
+ end
22
+
23
+ def inspect
24
+ stringify(inspection: true)
25
+ end
26
+
27
+ private
28
+
29
+ def stringify(inspection: false)
30
+ output = "<#{self.class} ##{count}"
31
+
32
+ if inspection
33
+ output << ":\n"
34
+ @pages.each do |page|
35
+ output << "#{page}\n"
36
+ end
37
+ end
38
+
39
+ output << '>'
40
+ output
41
+ end
42
+
43
+ def tree(pages)
44
+ tree = []
45
+ children_of = {}
46
+ page_number = 0
47
+
48
+ sort_by_path_reversed(pages).each do |_, page|
49
+ children_of[page.path] = [] if children_of[page.path].nil?
50
+ page.children = children_of[page.path].sort
51
+
52
+ if page.parent.nil?
53
+ # Root pages are pushed directly into the root of the tree
54
+ page.number = page_number
55
+ tree.push(page)
56
+ page_number += 1
57
+ else
58
+ children_of[page.parent] = [] if children_of[page.parent].nil?
59
+ children_of[page.parent].push(page)
60
+ end
61
+ end
62
+
63
+ # Sort the root pages
64
+ tree.sort!
65
+
66
+ SidebarPageCollection.new(nil, tree)
67
+ end
68
+
69
+ def sort_by_path_reversed(pages)
70
+ pages.sort_by { |path, _| path }.reverse
71
+ end
72
+ end
73
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swedbank-pay-design-guide-jekyll-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1.pre.PullRequest0137.pre.0064
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swedbank Pay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-02 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '5.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: jekyll-contentblocks
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: jekyll-github-metadata
63
77
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +100,20 @@ dependencies:
86
100
  - - ">="
87
101
  - !ruby/object:Gem::Version
88
102
  version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: jekyll-redirect-from
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
89
117
  - !ruby/object:Gem::Dependency
90
118
  name: jemoji
91
119
  requirement: !ruby/object:Gem::Requirement
@@ -189,7 +217,6 @@ files:
189
217
  - _includes/card-horizontal-list.html
190
218
  - _includes/card-list.html
191
219
  - _includes/card.html
192
- - _includes/front-page.html
193
220
  - _includes/google_analytics.html
194
221
  - _includes/img/merchants/logo-coop.svg
195
222
  - _includes/img/merchants/logo-elkjop.svg
@@ -214,6 +241,7 @@ files:
214
241
  - _includes/sidebar.html
215
242
  - _includes/toc.html
216
243
  - _layouts/default.html
244
+ - _layouts/front-page.html
217
245
  - _plugins/sidebar.rb
218
246
  - _sass/card.scss
219
247
  - _sass/code-view.scss
@@ -240,7 +268,18 @@ files:
240
268
  - assets/tipuesearch/tipuesearch_content.js
241
269
  - assets/tipuesearch/tipuesearch_set.js
242
270
  - lib/gem_version.rb
271
+ - lib/safe_merge.rb
272
+ - lib/sanitized_filename.rb
243
273
  - lib/sidebar.rb
274
+ - lib/sidebar_html_builder.rb
275
+ - lib/sidebar_page.rb
276
+ - lib/sidebar_page_collection.rb
277
+ - lib/sidebar_page_title.rb
278
+ - lib/sidebar_parser.rb
279
+ - lib/sidebar_path.rb
280
+ - lib/sidebar_renderer.rb
281
+ - lib/sidebar_text_builder.rb
282
+ - lib/sidebar_tree_builder.rb
244
283
  - lib/swedbank-pay-design-guide-jekyll-theme.rb
245
284
  homepage: https://github.com/SwedbankPay/swedbank-pay-design-guide-jekyll-theme
246
285
  licenses:
@@ -254,12 +293,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
254
293
  requirements:
255
294
  - - ">="
256
295
  - !ruby/object:Gem::Version
257
- version: '0'
296
+ version: 2.4.0
258
297
  required_rubygems_version: !ruby/object:Gem::Requirement
259
298
  requirements:
260
- - - ">"
299
+ - - ">="
261
300
  - !ruby/object:Gem::Version
262
- version: 1.3.1
301
+ version: '0'
263
302
  requirements: []
264
303
  rubygems_version: 3.1.2
265
304
  signing_key:
@@ -1,240 +0,0 @@
1
- {%- comment -%}
2
- **Parameters
3
- card_col_class: Grid column class the cards should be wrapped in
4
- num_dates: Amount of rows (based on dates in release_notes) should be displayed
5
- in release-notes
6
- {%- endcomment -%}
7
-
8
- {% assign card_col_class = include.card_col_class | default: "col-xxl-3 col-xl-6 col-lg-6" %}
9
- {% assign num_dates = include.num_dates | default: 3 %}
10
-
11
- <div class="front-page">
12
- <div class="front-page-container">
13
- <div class="front-page-top">
14
- <div class="front-page-hero">
15
- <h3>Welcome to the Swedbank Pay</h3>
16
- <div class="front-page-hero-name">
17
- {<span>developer portal</span>}
18
- </div>
19
- <p>
20
- Our developer portal gives you the full tool box for integrating
21
- our payment instruments and getting started with easy, flexible and
22
- safe payments on your e-commerce website.
23
- </p>
24
- </div>
25
- <div class="front-page-intro-cards">
26
- <h2 id="front-page-start" class="heading-line heading-line-white">Start your integration</h2>
27
- <div class="row mt-4">
28
- <div class="{{ card_col_class }}">
29
- {% include card.html title='Checkout'
30
- title_type="h2"
31
- text='With our Checkout you get the pre-built all-in-one
32
- payment solution, complete with a checkin interface and
33
- payment menu.'
34
- icon_content='shopping_cart'
35
- icon_outlined=true
36
- to='/checkout'
37
- %}
38
- </div>
39
- <div class="{{ card_col_class }}">
40
- {% include card.html title='Payments'
41
- title_type="h2"
42
- text='Payments gives you a one-by-one integration with more
43
- customization for each payment method to build your own
44
- payment menu.'
45
- icon_content='credit_card'
46
- to='/payments'
47
- %}
48
- </div>
49
- </div>
50
- </div>
51
- </div>
52
-
53
- <div class="front-page-merchants">
54
- <h6>Trusted by</h6>
55
- <div class="merchants-container justify-content-xxl-between">
56
- <a class="merchant-link">
57
- {% include img/merchants/logo-schibsted.svg %}
58
- </a>
59
- <a class="merchant-link">
60
- {% include img/merchants/logo-ica.svg %}
61
- </a>
62
- <a class="merchant-link">
63
- {% include img/merchants/logo-elkjop.svg %}
64
- </a>
65
- <a class="merchant-link">
66
- {% include img/merchants/logo-synsam.svg %}
67
- </a>
68
- <a class="merchant-link">
69
- {% include img/merchants/logo-coop.svg %}
70
- </a>
71
- <a class="merchant-link">
72
- {% include img/merchants/logo-svenskaspel.svg %}
73
- </a>
74
- <a class="merchant-link">
75
- {% include img/merchants/logo-skanetrafiken.svg %}
76
- </a>
77
- </div>
78
- </div>
79
- </div>
80
-
81
- <a href="https://ecom.externalintegration.payex.com/pspdemoshop" class="front-page-demoshop">
82
- <span class="front-page-demoshop-text">
83
- <span class="h2">Try our Demoshop<span>.</span></span>
84
- <span class="demoshop-text-description">
85
- Unsure about how it all works? See how our checkout and payment methods are used
86
- in practice!
87
- </span>
88
- </span>
89
- <span class="front-page-demoshop-link">
90
- <span class="h3">Go to the demoshop</span>
91
- <i class="material-icons">arrow_forward</i>
92
- <span class="demoshop-link-img">
93
- <img class="demoshop-link-img-mobile d-md-none d-lg-flex d-xl-none d-xxl-flex"
94
- src="/assets/img/demoshop-mobile.svg" alt="demoshop-mobile" />
95
- <img class="demoshop-link-img-mobile d-none d-md-none d-lg-flex d-xl-none"
96
- src="/assets/img/demoshop-mobile2.svg" alt="demoshop-mobile2" />
97
- <img class="demoshop-link-img-web d-none d-sm-none d-md-flex d-lg-none d-xl-flex"
98
- src="/assets/img/demoshop-web.svg" alt="demoshop-web" />
99
- </span>
100
- </span>
101
- </a>
102
-
103
- <div class="front-page-container">
104
- <div class="front-page-cards-sdk">
105
- <h2 id="front-page-sdk" class="heading-line heading-line-sdk">Looking for SDKs?</h2>
106
- <div class="row mt-4">
107
- <div class="{{ card_col_class }}">
108
- {% include card.html title='Android SDK'
109
- text='Learn more about how to integrate our Android SDK'
110
- icon_content='img/sdks/logo-android.svg'
111
- icon_svg=true
112
- type='sdk'
113
- to=''
114
- %}
115
- </div>
116
- <div class="{{ card_col_class }}">
117
- {% include card.html title='Swift SDK'
118
- text='Learn more about how to integrate our Swift SDK'
119
- icon_content='img/sdks/logo-swift.svg'
120
- icon_svg=true
121
- type='sdk'
122
- to=''
123
- %}
124
- </div>
125
- <div class="{{ card_col_class }}">
126
- {% include card.html title='.NET SDK'
127
- text='Learn more about how to integrate our .NET SDK'
128
- icon_content='img/sdks/logo-net.svg'
129
- icon_svg=true
130
- type='sdk'
131
- to=''
132
- %}
133
- </div>
134
- <div class="{{ card_col_class }}">
135
- {% include card.html title='PHP SDK'
136
- text='Learn more about how to integrate our PHP SDK'
137
- icon_content='img/sdks/logo-php.svg'
138
- icon_svg=true
139
- type='sdk'
140
- to=''
141
- %}
142
- </div>
143
- </div>
144
- </div>
145
-
146
- <div class="front-page-cards-module">
147
- <h2 id="front-page-module" class="heading-line heading-line-module">Or perhaps modules?</h2>
148
- <div class="row mt-4">
149
- <div class="{{ card_col_class }}">
150
- {% include card.html title='Episerver'
151
- text='See how you can integrate the Episerver module'
152
- icon_content='img/modules/logo-episerver.svg'
153
- icon_svg=true
154
- type='module'
155
- to=''
156
- %}
157
- </div>
158
- <div class="{{ card_col_class }}">
159
- {% include card.html title='Magento 2'
160
- text='See how you can integrate the Magento 2 module'
161
- icon_content='img/modules/logo-magento2.svg'
162
- icon_svg=true
163
- type='module'
164
- to=''
165
- %}
166
- </div>
167
- <div class="{{ card_col_class }}">
168
- {% include card.html title='WooCommerce'
169
- text='See how you can integrate the WooCommerce module'
170
- icon_content='img/modules/logo-woocommerce.svg'
171
- icon_svg=true
172
- type='module'
173
- to=''
174
- %}
175
- </div>
176
- </div>
177
- </div>
178
-
179
- <div class="front-page-release-notes">
180
- <h2 id="front-page-release-notes" class="heading-line heading-line-green">What's new in the documentation
181
- </h2>
182
- {% include release_notes.html num_dates=num_dates %}
183
- <a href="/resources/release-notes">See full release notes</a>
184
- </div>
185
-
186
- <div class="front-page-cards-extra">
187
- <h2 id="front-page-extra-resources" class="heading-line">Extra resources</h2>
188
- <div class="row mt-4">
189
- <div class="{{ card_col_class }}">
190
- {% include card.html title='OS development guidelines'
191
- text='This is how we create an inclusive environment'
192
- icon_content='account_circle'
193
- icon_outlined=true
194
- to=''
195
- %}
196
- </div>
197
- <div class="{{ card_col_class }}">
198
- {% include card.html title='Test data'
199
- text='Get the required data for testing in our interfaces'
200
- icon_content='content_paste'
201
- to=''
202
- %}
203
- </div>
204
- <div class="{{ card_col_class }}">
205
- {% include card.html title='Terminology'
206
- text='Get a better understanding of the terms we use'
207
- icon_content='menu_book'
208
- to=''
209
- %}
210
- </div>
211
- <div class="{{ card_col_class }}">
212
- {% include card.html title='See all resources (7)'
213
- text='Data protection, public migration key etc'
214
- no_icon=true
215
- to=''
216
- %}
217
- </div>
218
- </div>
219
- </div>
220
-
221
- <div class="front-page-contact">
222
- <div class="front-page-contact-content">
223
- <div class="row">
224
- <div class="col-xl-7">
225
- <h2 id="front-page-contact" class="heading-line heading-line-long">Can't find what you are
226
- looking for?</h2>
227
- <p>
228
- We are always trying to make the developer portal as
229
- good as it can be please don’t hesitate to contact us.
230
- </p>
231
- </div>
232
- <div class="col-xl-5 d-flex align-items-center justify-content-center">
233
- <button class="btn">Contact us here</button>
234
- </div>
235
- </div>
236
- </div>
237
- </div>
238
-
239
- </div>
240
- </div>