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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42888091ccc955f38fa0242da4b03d4175f99e449b4aa238b48e97f6fead244c
4
- data.tar.gz: 1c55a8d051cbcff4d2d7aff5998713d4146a865b7e520e31ae3f94234ff83ad7
3
+ metadata.gz: 4baacc614edb524f53a8b0a23788382fba5ec477f10f08888adf08fcbde24998
4
+ data.tar.gz: 0cb1ef91541ba25c94708789ab05379ea92fc94ea0a7a62c336182f108a62544
5
5
  SHA512:
6
- metadata.gz: ffcd2a6b3d6e0ae90b56cd7945eca08a1ab61cabb93fe7fb35e42d4e48eb9d72e46d1e104c356c071c850a0a4a7aede9fb84150319a116992b9123aa261cb25a
7
- data.tar.gz: a04785e165d25dfccb851beb20397abd6aa7fed6855587b1a1c0769d95a84cb6d23c4bc079322dc52ea76c0d2549179d8c728e7baf08631c0130d1614978c13f
6
+ metadata.gz: 0bf78e21de260346ee939876981e7cfeb2558e74a2d492217a07c4a23bde14018eb746225e7ad5f23420cacf89c2c82e07dc8c008a2ed588e7a5a9934ea2862f
7
+ data.tar.gz: bba4b0c952ee13e087c0e6f38c738d3999874e0670a3881e053b2b7fc58ae5e39ec748af3d64e3548c45efe79e9984539f193340ebaf73263e10ebddcdbe74e4
@@ -19,7 +19,7 @@ Original creator: https://sebnitu.com/2016/10/13/dynamic-menus-in-jekyll/
19
19
  {% endif %}
20
20
 
21
21
  <ul class="main-nav-ul">
22
- {% assign pages = site.pages | sort: 'menu-order' %}
22
+ {% assign pages = site.pages | sort: 'menu_order' %}
23
23
  {% for node in pages %}
24
24
  {% assign node_parts = node.url | split: '/' %}
25
25
  {% assign node_depth = node_parts | size %}
@@ -113,4 +113,3 @@ Original creator: https://sebnitu.com/2016/10/13/dynamic-menus-in-jekyll/
113
113
  </ul>
114
114
  </nav>
115
115
  </div>
116
-
@@ -1,5 +1,4 @@
1
1
  {%- assign title = page.title | default: "PayEx Design Guide theme for Jekyll" -%}
2
- {%- assign front_page = page.front_page | default: false -%}
3
2
  {%- assign description = page.opengraph.description | default: site.opengraph.description -%}
4
3
  {%- assign image = page.opengraph.image | default: site.opengraph.image -%}
5
4
  {%- assign github_branch = site.github.branch | default : "develop" -%}
@@ -80,14 +79,14 @@
80
79
  </div>
81
80
 
82
81
  <main class="doc-view col-xxl-10 col-lg-9">
83
- {% if front_page != true %}
82
+ {% if page.layout != 'front-page' %}
84
83
  {% assign title_lead = title | split: '–' | first %}
85
84
  {% assign title_main = title | split: '–' | last %}
86
85
  {% assign description = page.description %}
87
86
  {% assign estimated_read = page.estimated_read %}
88
87
  <div class="title-header">
89
88
  <div class="title-header-container
90
- {% if page.card_overview%} max-width-card-overview
89
+ {% if page.card_overview %} max-width-card-overview
91
90
  {% else %} max-width
92
91
  {% endif %}">
93
92
  {% if title_lead != title_main %}
@@ -106,8 +105,8 @@
106
105
  </div>
107
106
  </div>
108
107
  {% endif %}
109
- <div class="doc-container{% if front_page == true %} no-padding
110
- {% elsif page.card_overview%} normal-padding max-width-card-overview
108
+ <div class="doc-container{% if page.layout == 'front-page' %} no-padding
109
+ {% elsif page.card_overview %} normal-padding max-width-card-overview
111
110
  {% else %} normal-padding max-width
112
111
  {% endif %}">
113
112
  <article>
@@ -0,0 +1,112 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ {% assign show_merchants_bar = page.front_page.show_merchants_bar | default: false %}
6
+ {% assign front_page_title = page.front_page.title | default: 'developer portal' %}
7
+ {% assign front_page_hero = page.front_page.hero | default: "Welcome to the Swedbank Pay" %}
8
+ {% assign front_page_ingress = page.front_page.ingress | default: "Our developer portal gives you the full tool box for integrating our payment instruments and getting started with easy, flexible and safe payments on your e-commerce website." %}
9
+ {% assign front_page_start_heading = page.front_page.start_heading | default: "Start your integration" %}
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>{{ front_page_hero }}</h3>
16
+ <div class="front-page-hero-name">
17
+ {<span>{{ front_page_title }}</span>}
18
+ </div>
19
+ <p>{{ front_page_ingress }}</p>
20
+ </div>
21
+ <div class="front-page-intro-cards">
22
+ <h2 id="front-page-start" class="heading-line heading-line-white">{{ front_page_start_heading }}</h2>
23
+ {% contentblock start %}
24
+ </div>
25
+ </div>
26
+ {% if show_merchants_bar == true %}
27
+ <div class="front-page-merchants">
28
+ <h6>Trusted by</h6>
29
+ <div class="merchants-container justify-content-xxl-between">
30
+ <a class="merchant-link">
31
+ {% include img/merchants/logo-schibsted.svg %}
32
+ </a>
33
+ <a class="merchant-link">
34
+ {% include img/merchants/logo-ica.svg %}
35
+ </a>
36
+ <a class="merchant-link">
37
+ {% include img/merchants/logo-elkjop.svg %}
38
+ </a>
39
+ <a class="merchant-link">
40
+ {% include img/merchants/logo-synsam.svg %}
41
+ </a>
42
+ <a class="merchant-link">
43
+ {% include img/merchants/logo-coop.svg %}
44
+ </a>
45
+ <a class="merchant-link">
46
+ {% include img/merchants/logo-svenskaspel.svg %}
47
+ </a>
48
+ <a class="merchant-link">
49
+ {% include img/merchants/logo-skanetrafiken.svg %}
50
+ </a>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ {% endif %}
55
+ <a href="https://ecom.externalintegration.payex.com/pspdemoshop" class="front-page-demoshop">
56
+ <span class="front-page-demoshop-text">
57
+ <span class="h2">Try our Demoshop<span>.</span></span>
58
+ <span class="demoshop-text-description">
59
+ Unsure about how it all works? See how our checkout and payment methods are used
60
+ in practice!
61
+ </span>
62
+ </span>
63
+ <span class="front-page-demoshop-link">
64
+ <span class="h3">Go to the demoshop</span>
65
+ <i class="material-icons">arrow_forward</i>
66
+ <span class="demoshop-link-img">
67
+ <img class="demoshop-link-img-mobile d-md-none d-lg-flex d-xl-none d-xxl-flex"
68
+ src="/assets/img/demoshop-mobile.svg" alt="demoshop-mobile" />
69
+ <img class="demoshop-link-img-mobile d-none d-md-none d-lg-flex d-xl-none"
70
+ src="/assets/img/demoshop-mobile2.svg" alt="demoshop-mobile2" />
71
+ <img class="demoshop-link-img-web d-none d-sm-none d-md-flex d-lg-none d-xl-flex"
72
+ src="/assets/img/demoshop-web.svg" alt="demoshop-web" />
73
+ </span>
74
+ </span>
75
+ </a>
76
+
77
+ <div class="front-page-container">
78
+ <div class="front-page-cards-sdk">
79
+ {% contentblock sdks %}
80
+ </div>
81
+
82
+ <div class="front-page-cards-module">
83
+ {% contentblock modules %}
84
+ </div>
85
+
86
+ <div class="front-page-release-notes">
87
+ {% contentblock release_notes %}
88
+ </div>
89
+
90
+ <div class="front-page-cards-extra">
91
+ {% contentblock extras %}
92
+ </div>
93
+
94
+ <div class="front-page-contact">
95
+ <div class="front-page-contact-content">
96
+ <div class="row">
97
+ <div class="col-xl-7">
98
+ <h2 id="front-page-contact" class="heading-line heading-line-long">Can't find what you are
99
+ looking for?</h2>
100
+ <p>
101
+ We are always trying to make the developer portal as
102
+ good as it can be please don’t hesitate to contact us.
103
+ </p>
104
+ </div>
105
+ <div class="col-xl-5 d-flex align-items-center justify-content-center">
106
+ <button class="btn">Contact us here</button>
107
+ </div>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ </div>
@@ -1,2 +1,3 @@
1
1
  # frozen_string_literal: false
2
- require_relative '../lib/sidebar.rb'
2
+
3
+ require_relative '../lib/sidebar'
@@ -4,7 +4,7 @@ module Gem
4
4
  # Gem Specification
5
5
  class Specification
6
6
  def self.gem_version
7
- '1.6.1-PullRequest0137-0064'
7
+ '1.9.0'
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The Hash class
4
+ class Hash
5
+ # Safely merges the current Hash with an 'other' Hash.
6
+ def safe_merge(other)
7
+ all_keys = keys | other.keys
8
+ result_hash = {}
9
+
10
+ all_keys.each do |key|
11
+ hash_value = {}
12
+
13
+ if key? key
14
+ value = self[key]
15
+ hash_value = value unless value.nil?
16
+ end
17
+
18
+ if other.key? key
19
+ value = other[key]
20
+ hash_value = hash_value.merge(value) unless value.nil?
21
+ end
22
+
23
+ result_hash[key] = hash_value
24
+ end
25
+
26
+ result_hash
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The String class
4
+ class String
5
+ # Sanitizes a filename
6
+ def sanitized
7
+ match = match(/(?m)(?<=\b_site).*$/)
8
+ sanitized_filename = match ? match[0] : self
9
+ sanitized_filename = sanitized_filename.gsub('index.html', '')
10
+ sanitized_filename.gsub('.html', '')
11
+ end
12
+ end
@@ -3,209 +3,46 @@
3
3
  require 'jekyll'
4
4
  require 'nokogiri'
5
5
  require 'json'
6
-
7
- module Jekyll
8
- class Sidebar
9
- attr_accessor :hash_pre_render
10
- attr_accessor :filename_with_headers
11
-
12
- def initialize
13
- @hash_pre_render = {}
14
- @filename_with_headers = {}
15
- end
16
-
17
- def pre_render(page)
18
- menu_order = page['menu-order'].nil? ? 0 : page['menu-order']
19
- hide_from_sidebar = page['hide_from_sidebar'].nil? ? false : page['hide_from_sidebar']
20
- url = page['url'].gsub('index.html', '').gsub('.html', '')
21
- @hash_pre_render[url] = {
22
- title: page['title'],
23
- url: page['url'].gsub('.html', ''),
24
- name: page['name'],
25
- menu_order: menu_order,
26
- hide_from_sidebar: hide_from_sidebar
27
- }
28
- end
29
-
30
- def post_write(site)
31
- files = []
32
- Dir.glob("#{site.config['destination']}/**/*.html") do |filename|
33
- doc = File.open(filename) { |f| Nokogiri::HTML(f) }
34
- files.push(doc)
35
-
36
- headers = []
37
- doc.xpath('//h2 ').each do |header|
38
- next unless header['id']
39
-
40
- child = header.last_element_child
41
- header = {
42
- id: header['id'],
43
- title: header.content.strip,
44
- hash: (child['href']).to_s
45
- }
46
- headers.push(header)
47
- end
48
- sanitized_filename = sanitize_filename(filename)
49
- @filename_with_headers[sanitized_filename] = { headers: headers }
50
- end
51
-
52
- Dir.glob("#{site.config['destination']}/**/*.html") do |filename|
53
- sanitized_filename = sanitize_filename(filename)
54
- sidebar = render(sanitized_filename)
55
- file = File.open(filename) { |f| Nokogiri::HTML(f) }
56
- file.xpath('//*[@id="dx-sidebar-main-nav-ul"]').each do |location|
57
- location.inner_html = sidebar
58
- end
59
- File.open(filename, 'w') { |f| f.write(file.to_html(encoding: 'UTF-8')) }
60
- end
61
-
62
- # File.open('_site/sidebar.html', 'w') { |f| f.write(sidebar) }
63
- end
64
-
65
- private
66
-
67
- def sanitize_filename(filename)
68
- sanitized_filename = filename.match(/(?m)(?<=\b_site).*$/)[0]
69
- sanitized_filename = sanitized_filename.gsub('index.html', '')
70
- sanitized_filename.gsub('.html', '')
71
- end
72
-
73
- def generateSubgroup(filename, key, value, all_subgroups, level)
74
- title = value[:title].split('–').last
75
- subsubgroup_list = all_subgroups.select do |subsubgroup_key, _subsubgroup_value|
76
- subsubgroup_key.include? key and subsubgroup_key != key and \
77
- key.split('/').length > level
78
- end
79
-
80
- subgroup = ''
81
- has_subgroups = !all_subgroups.empty?
82
- if value[:headers].any? || !subsubgroup_list.empty?
83
- if has_subgroups
84
- url = value[:url]
85
- active = active?(filename, url, true)
86
- # puts "#{url}, #{filename}, #{key}" if active
87
- item_class = active || (url.split('/').length > level && filename.start_with?(url)) ? 'nav-subgroup active' : 'nav-subgroup'
88
- subgroup << "<li class=\"#{item_class}\">"
89
- subgroup << "<div class=\"nav-subgroup-heading\"><i class=\"material-icons\">arrow_right</i><a href=\"#{url}\">#{title}</a></div>"
90
- subgroup << '<ul class="nav-ul">'
91
-
92
- if subsubgroup_list.empty?
93
- value[:headers].each do |header|
94
- subgroup << "<li class=\"nav-leaf\"><a href=\"#{value[:url]}#{header[:hash]}\">#{header[:title]}</a></li>"
95
- end
96
- else
97
- subgroup_leaf_class = active ? 'nav-leaf nav-subgroup-leaf active' : 'nav-leaf nav-subgroup-leaf'
98
- subgroup << "<li class=\"#{subgroup_leaf_class}\"><a href=\"#{value[:url]}\">#{title} overview</a></li>"
99
-
100
- subsubgroup_list.each do |subsubgroup_key, subsubgroup_value|
101
- subgroup << generateSubgroup(filename, subsubgroup_key, subsubgroup_value, subsubgroup_list, 3)
102
- end
103
- end
104
-
105
- subgroup << '</ul>'
106
- subgroup << '</li>'
107
- else
108
- value[:headers].each do |header|
109
- subgroup << "<li class=\"nav-leaf\"><a href=\"#{value[:url]}#{header[:hash]}\">#{header[:title]}</a></li>"
110
- end
111
- end
112
- else
113
- subgroup << if has_subgroups
114
- "<li class=\"nav-leaf nav-subgroup-leaf\"><a href=\"#{value[:url]}\">#{title}</a></li>"
115
- else
116
- "<li class=\"nav-leaf\"><a href=\"#{value[:url]}\">#{title}</a></li>"
117
- end
118
- end
119
-
120
- subgroup
121
- end
122
-
123
- def render(filename)
124
- sidebar = ''
125
-
126
- merged = merge(@hash_pre_render, @filename_with_headers).sort_by { |_key, value| value[:menu_order] }
127
- merged.select { |key, _value| key.split('/').length <= 2 }.each do |key, value|
128
- next if value[:title].nil?
129
- next if value[:hide_from_sidebar]
130
-
131
- subgroups = merged.select { |subgroup_key, _subgroup_value| subgroup_key.include? key and subgroup_key != key and key != '/' }
132
-
133
- active = active?(filename, key)
134
- # puts "#{filename}, #{key}" if active
135
- item_class = active ? 'nav-group active' : 'nav-group'
136
-
137
- child = "<li class=\"#{item_class}\">"
138
- child << "<div class=\"nav-group-heading\"><i class=\"material-icons\">arrow_right</i><span>#{value[:title].split('–').first}</span></div>"
139
-
140
- child << '<ul class="nav-ul">'
141
-
142
- subgroup = generateSubgroup(filename, key, value, subgroups, 2)
143
-
144
- child << subgroup
145
-
146
- if subgroups.any?
147
- subgroups.select { |subgroup_key, _subgroup_value| subgroup_key.split('/').length <= 3 }.each do |subgroup_key, subgroup_value|
148
- subgroup = generateSubgroup(filename, subgroup_key, subgroup_value, subgroups, 2)
149
- child << subgroup
150
- end
151
- end
152
-
153
- child << '</ul>'
154
- child << '</li>'
155
- sidebar << child
6
+ require_relative 'sidebar_page'
7
+ require_relative 'sidebar_parser'
8
+ require_relative 'sidebar_renderer'
9
+ require_relative 'sidebar_tree_builder'
10
+
11
+ module SwedbankPay
12
+ # A nice sidebar
13
+ module Sidebar
14
+ class << self
15
+ attr_reader :pages
16
+
17
+ def init
18
+ @pages_hash = {}
156
19
  end
157
20
 
158
- File.open('_site/sidebar.html', 'w') { |f| f.write(sidebar) }
159
- sidebar
160
- end
161
-
162
- def active?(filename, url, exact = false)
163
- if filename == '/' || url == '/'
164
- if filename == '/' && url == '/'
165
- return true
166
- else
167
- return false
168
- end
21
+ def pre_render(jekyll_page)
22
+ sidebar_page = SidebarPage.new(jekyll_page)
23
+ @pages_hash[sidebar_page.path] = sidebar_page
169
24
  end
170
25
 
171
- exact ? filename == url : filename.start_with?(url)
172
- end
173
-
174
- def merge(hash1, hash2)
175
- all_keys = hash1.keys | hash2.keys
176
- result_hash = {}
177
-
178
- all_keys.each do |key|
179
- hash_value = {}
180
-
181
- if hash1.key? key
182
- value = hash1[key]
183
-
184
- hash_value = value unless value.nil?
185
- end
186
-
187
- if hash2.key? key
188
- value = hash2[key]
189
-
190
- hash_value = hash_value.merge(value) unless value.nil?
191
- end
192
-
193
- result_hash[key] = hash_value
26
+ def post_write(site)
27
+ parser = SidebarParser.new(site)
28
+ pages = parser.parse(@pages_hash)
29
+ @pages = SidebarTreeBuilder.new(pages)
30
+ Jekyll.logger.debug(" Sidebar: #{@pages.inspect}")
31
+ renderer = SidebarRenderer.new
32
+ renderer.render(@pages)
194
33
  end
195
-
196
- result_hash
197
34
  end
198
35
  end
199
36
  end
200
37
 
201
- sidebar = Jekyll::Sidebar.new
38
+ SwedbankPay::Sidebar.init
202
39
 
203
- Jekyll::Hooks.register :site, :pre_render do |site, _payload|
40
+ Jekyll::Hooks.register :site, :pre_render do |site, _|
204
41
  site.pages.each do |page|
205
- sidebar.pre_render page
42
+ SwedbankPay::Sidebar.pre_render page
206
43
  end
207
44
  end
208
45
 
209
46
  Jekyll::Hooks.register :site, :post_write do |site|
210
- sidebar.post_write site
47
+ SwedbankPay::Sidebar.post_write site
211
48
  end