swedbank-pay-design-guide-jekyll-theme 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/title-header.html +32 -0
- data/_layouts/default.html +1 -24
- data/_layouts/front-page.html +17 -17
- data/_sass/breakpoints.scss +5 -0
- data/_sass/card.scss +1 -0
- data/_sass/front-page.scss +93 -58
- data/_sass/swedbank-pay-design-guide-theme.scss +5 -0
- data/_sass/variables.scss +1 -1
- data/lib/gem_version.rb +1 -1
- data/lib/sidebar.rb +11 -20
- data/lib/sidebar_html_builder.rb +36 -41
- data/lib/sidebar_page.rb +67 -20
- data/lib/sidebar_page_title.rb +48 -6
- data/lib/sidebar_parser.rb +22 -2
- data/lib/sidebar_renderer.rb +22 -3
- data/lib/sidebar_text_builder.rb +2 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e647f0131f3c08e0a12439a2c614440abf1490e8daddad219fb7d07abf2a20ec
|
4
|
+
data.tar.gz: 9a662eb6a96daca6040b5bd41077a956d79cac4dacfce609d46eb574efaab328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c68104d9e39d320d6f7d02ce71ae26bb8f413fc85ebcfc3af07573a46fff395a8ef1b6764e9ef9cb6358e5eab593e4143788038f5353e68c05b16d362fae89a
|
7
|
+
data.tar.gz: c076139876f3d855ee1ee9b0d483c78979f6fd2f241c0ae932fe2572e73170a0527688fe48c12e6c6bd0bddd606350f25be541b4215ed32776c95174d223b8dd
|
@@ -0,0 +1,32 @@
|
|
1
|
+
{% assign lead_title = page.lead_title %}
|
2
|
+
{% assign main_title = page.main_title | default: page.title %}
|
3
|
+
{% assign description = page.description %}
|
4
|
+
{% assign estimated_read = page.estimated_read %}
|
5
|
+
{% capture max_width_class %}
|
6
|
+
{% if page.card_overview %}
|
7
|
+
max-width-card-overview
|
8
|
+
{% else %}
|
9
|
+
max-width
|
10
|
+
{% endif %}
|
11
|
+
{% endcapture %}
|
12
|
+
|
13
|
+
<div class="title-header">
|
14
|
+
<div class="title-header-container {{ max_width_class | strip }}">
|
15
|
+
{% if lead_title != nil %}
|
16
|
+
<h4>{{ lead_title }}</h4>
|
17
|
+
{% endif %}
|
18
|
+
|
19
|
+
<h1>{{ main_title }}</h1>
|
20
|
+
|
21
|
+
{% if estimated_read %}
|
22
|
+
<div class="title-header-estimated-read">
|
23
|
+
<i class="material-icons">schedule</i>
|
24
|
+
{{ estimated_read }} min read
|
25
|
+
</div>
|
26
|
+
{% endif %}
|
27
|
+
|
28
|
+
{% if description %}
|
29
|
+
<p>{{ description | markdownify }}</p>
|
30
|
+
{% endif %}
|
31
|
+
</div>
|
32
|
+
</div>
|
data/_layouts/default.html
CHANGED
@@ -80,30 +80,7 @@
|
|
80
80
|
|
81
81
|
<main class="doc-view col-xxl-10 col-lg-9">
|
82
82
|
{% if page.layout != 'front-page' %}
|
83
|
-
|
84
|
-
{% assign title_main = title | split: '–' | last %}
|
85
|
-
{% assign description = page.description %}
|
86
|
-
{% assign estimated_read = page.estimated_read %}
|
87
|
-
<div class="title-header">
|
88
|
-
<div class="title-header-container
|
89
|
-
{% if page.card_overview %} max-width-card-overview
|
90
|
-
{% else %} max-width
|
91
|
-
{% endif %}">
|
92
|
-
{% if title_lead != title_main %}
|
93
|
-
<h4>{{ title_lead }}</h4>
|
94
|
-
{% endif %}
|
95
|
-
<h1>{{ title_main }}</h1>
|
96
|
-
{% if estimated_read %}
|
97
|
-
<div class="title-header-estimated-read">
|
98
|
-
<i class="material-icons">schedule</i>
|
99
|
-
{{ estimated_read }} min read
|
100
|
-
</div>
|
101
|
-
{% endif %}
|
102
|
-
{% if description %}
|
103
|
-
<p>{{ description | markdownify }}</p>
|
104
|
-
{% endif %}
|
105
|
-
</div>
|
106
|
-
</div>
|
83
|
+
{% include title-header.html %}
|
107
84
|
{% endif %}
|
108
85
|
<div class="doc-container{% if page.layout == 'front-page' %} no-padding
|
109
86
|
{% elsif page.card_overview %} normal-padding max-width-card-overview
|
data/_layouts/front-page.html
CHANGED
@@ -9,20 +9,20 @@ layout: default
|
|
9
9
|
{% assign front_page_start_heading = page.front_page.start_heading | default: "Start your integration" %}
|
10
10
|
|
11
11
|
<div class="front-page">
|
12
|
-
<div class="front-page-
|
13
|
-
<div class="front-page-
|
14
|
-
<
|
15
|
-
|
16
|
-
<
|
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 %}
|
12
|
+
<div class="front-page-top">
|
13
|
+
<div class="front-page-hero">
|
14
|
+
<h3>{{ front_page_hero }}</h3>
|
15
|
+
<div class="front-page-hero-name">
|
16
|
+
{<span>{{ front_page_title }}</span>}
|
24
17
|
</div>
|
18
|
+
<p>{{ front_page_ingress }}</p>
|
25
19
|
</div>
|
20
|
+
<div class="front-page-intro-cards">
|
21
|
+
<h2 id="front-page-start" class="heading-line heading-line-white">{{ front_page_start_heading }}</h2>
|
22
|
+
{% contentblock start %}
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<div class="front-page-container">
|
26
26
|
{% if show_merchants_bar == true %}
|
27
27
|
<div class="front-page-merchants">
|
28
28
|
<h6>Trusted by</h6>
|
@@ -54,9 +54,9 @@ layout: default
|
|
54
54
|
{% endif %}
|
55
55
|
<a href="https://ecom.externalintegration.payex.com/pspdemoshop" class="front-page-demoshop">
|
56
56
|
<span class="front-page-demoshop-text">
|
57
|
-
<span class="h2">Try our Demoshop
|
57
|
+
<span class="h2">Try our Demoshop</span>
|
58
58
|
<span class="demoshop-text-description">
|
59
|
-
|
59
|
+
See how our checkout and payment methods are used
|
60
60
|
in practice!
|
61
61
|
</span>
|
62
62
|
</span>
|
@@ -64,11 +64,11 @@ layout: default
|
|
64
64
|
<span class="h3">Go to the demoshop</span>
|
65
65
|
<i class="material-icons">arrow_forward</i>
|
66
66
|
<span class="demoshop-link-img">
|
67
|
-
<img class="demoshop-link-img-mobile d-
|
67
|
+
<img class="demoshop-link-img-mobile d-none d-md-flex"
|
68
68
|
src="/assets/img/demoshop-mobile.svg" alt="demoshop-mobile" />
|
69
|
-
<img class="demoshop-link-img-mobile d-none d-
|
69
|
+
<img class="demoshop-link-img-mobile d-none d-xl-flex d-xxl-none"
|
70
70
|
src="/assets/img/demoshop-mobile2.svg" alt="demoshop-mobile2" />
|
71
|
-
<img class="demoshop-link-img-web d-none d-
|
71
|
+
<img class="demoshop-link-img-web d-none d-xxl-flex"
|
72
72
|
src="/assets/img/demoshop-web.svg" alt="demoshop-web" />
|
73
73
|
</span>
|
74
74
|
</span>
|
data/_sass/card.scss
CHANGED
data/_sass/front-page.scss
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
@import 'colors.scss';
|
2
2
|
@import 'fonts.scss';
|
3
|
+
@import 'breakpoints.scss';
|
3
4
|
|
4
5
|
$front-page-padding: 0 4rem;
|
5
|
-
$front-page-max-width:
|
6
|
+
$front-page-max-width: 1312px;
|
6
7
|
|
7
8
|
@mixin row-cards {
|
8
9
|
>[class*='col-'] {
|
@@ -49,77 +50,88 @@ $front-page-max-width: 1280px;
|
|
49
50
|
}
|
50
51
|
|
51
52
|
.front-page {
|
53
|
+
margin: 3rem 2rem 0;
|
52
54
|
position: relative;
|
53
55
|
display: flex;
|
54
56
|
flex-direction: column;
|
55
57
|
align-items: center;
|
58
|
+
|
59
|
+
.front-page-top {
|
60
|
+
position: relative;
|
61
|
+
padding: 4rem 4rem 2rem;
|
62
|
+
width: 100%;
|
63
|
+
margin-bottom: 3rem;
|
64
|
+
max-width: 1432px;
|
65
|
+
background-color: $dark-brown;
|
66
|
+
z-index: 0;
|
67
|
+
border-radius: 1rem;
|
68
|
+
min-height: 33rem;
|
56
69
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
.front-page-top {
|
62
|
-
padding-top: 4rem;
|
63
|
-
width: 100%;
|
70
|
+
.front-page-hero {
|
71
|
+
position: relative;
|
72
|
+
max-width: 38rem;
|
64
73
|
margin-bottom: 3rem;
|
74
|
+
z-index: 1;
|
65
75
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
top: 0;
|
71
|
-
left: 0;
|
72
|
-
background-color: $dark-brown;
|
73
|
-
width: 100%;
|
74
|
-
height: 34rem;
|
75
|
-
z-index: 0;
|
76
|
+
h3 {
|
77
|
+
color: $yellow;
|
78
|
+
font-family: $headline;
|
79
|
+
margin-bottom: 0;
|
76
80
|
}
|
77
81
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
z-index: 1;
|
82
|
+
p {
|
83
|
+
color: $white;
|
84
|
+
font-size: 1.125rem;
|
85
|
+
}
|
83
86
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
87
|
+
.front-page-hero-name {
|
88
|
+
font-family: $mono;
|
89
|
+
font-weight: bold;
|
90
|
+
font-size: 2rem;
|
91
|
+
color: $yellow;
|
92
|
+
margin-bottom: 1rem;
|
89
93
|
|
90
|
-
|
94
|
+
span {
|
91
95
|
color: $white;
|
92
|
-
font-size: 1.125rem;
|
93
96
|
}
|
97
|
+
}
|
94
98
|
|
95
|
-
|
96
|
-
font-family: $mono;
|
97
|
-
font-weight: bold;
|
98
|
-
font-size: 2rem;
|
99
|
-
color: $yellow;
|
100
|
-
margin-bottom: 1rem;
|
99
|
+
}
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
.front-page-intro-cards {
|
102
|
+
h2 {
|
103
|
+
color: $white;
|
104
|
+
|
105
|
+
.header-anchor {
|
106
|
+
display: none;
|
105
107
|
}
|
108
|
+
}
|
106
109
|
|
110
|
+
.row {
|
111
|
+
@include row-cards();
|
107
112
|
}
|
113
|
+
}
|
108
114
|
|
115
|
+
@media screen and (min-width: $breakpoint-xxl) {
|
116
|
+
margin-bottom: 9rem;
|
117
|
+
|
109
118
|
.front-page-intro-cards {
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
}
|
116
|
-
}
|
117
|
-
|
118
|
-
.row {
|
119
|
-
@include row-cards();
|
120
|
-
}
|
119
|
+
position: absolute;
|
120
|
+
bottom: -7rem;
|
121
|
+
left: 0;
|
122
|
+
width: 100%;
|
123
|
+
padding: 0 4rem;
|
121
124
|
}
|
122
125
|
}
|
126
|
+
}
|
127
|
+
.front-page-container {
|
128
|
+
max-width: $front-page-max-width;
|
129
|
+
margin: $front-page-padding;
|
130
|
+
position: relative;
|
131
|
+
|
132
|
+
@media screen and (max-width: $breakpoint-md) {
|
133
|
+
margin: 0;
|
134
|
+
}
|
123
135
|
|
124
136
|
.front-page-merchants {
|
125
137
|
margin-bottom: 3.75rem;
|
@@ -221,6 +233,7 @@ $front-page-max-width: 1280px;
|
|
221
233
|
height: 22.5rem;
|
222
234
|
background-color: $dark-brown;
|
223
235
|
text-decoration: none;
|
236
|
+
border-radius: 1rem;
|
224
237
|
|
225
238
|
&:hover,
|
226
239
|
&:focus {
|
@@ -249,17 +262,29 @@ $front-page-max-width: 1280px;
|
|
249
262
|
|
250
263
|
.h2 {
|
251
264
|
color: $white;
|
252
|
-
|
253
|
-
span {
|
254
|
-
color: $yellow;
|
255
|
-
}
|
256
265
|
}
|
257
266
|
|
258
267
|
.demoshop-text-description {
|
259
268
|
color: $white;
|
260
|
-
width:
|
261
|
-
height: 4.5rem;
|
269
|
+
width: 40%;
|
270
|
+
min-height: 4.5rem;
|
271
|
+
font-size: 1rem;
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
@media screen and (max-width: $breakpoint-md) {
|
278
|
+
padding-top: 3rem;
|
279
|
+
height: 18rem;
|
280
|
+
|
281
|
+
.front-page-demoshop-text {
|
282
|
+
.demoshop-text-description {
|
283
|
+
width: 100%;
|
284
|
+
min-height: 2.25rem;
|
285
|
+
}
|
262
286
|
}
|
287
|
+
|
263
288
|
}
|
264
289
|
|
265
290
|
.front-page-demoshop-link {
|
@@ -297,8 +322,6 @@ $front-page-max-width: 1280px;
|
|
297
322
|
}
|
298
323
|
}
|
299
324
|
|
300
|
-
|
301
|
-
|
302
325
|
.h3 {
|
303
326
|
color: $white;
|
304
327
|
padding-right: 1rem;
|
@@ -306,6 +329,18 @@ $front-page-max-width: 1280px;
|
|
306
329
|
margin: 0;
|
307
330
|
}
|
308
331
|
}
|
332
|
+
|
333
|
+
@media screen and (min-width: $breakpoint-xxl) {
|
334
|
+
.front-page-demoshop-text {
|
335
|
+
margin-bottom: 1rem;
|
336
|
+
}
|
337
|
+
|
338
|
+
.front-page-demoshop-link {
|
339
|
+
.demoshop-link-img {
|
340
|
+
bottom: -2rem;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
}
|
309
344
|
}
|
310
345
|
|
311
346
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
@import 'colors.scss';
|
2
2
|
@import 'fonts.scss';
|
3
3
|
@import 'variables.scss';
|
4
|
+
@import 'breakpoints.scss';
|
4
5
|
|
5
6
|
@import 'card.scss';
|
6
7
|
@import 'code-view.scss';
|
@@ -17,6 +18,10 @@ img {
|
|
17
18
|
max-width: 100%;
|
18
19
|
}
|
19
20
|
|
21
|
+
body {
|
22
|
+
font-size: 1.125rem;
|
23
|
+
}
|
24
|
+
|
20
25
|
.table {
|
21
26
|
|
22
27
|
th,
|
data/_sass/variables.scss
CHANGED
@@ -1 +1 @@
|
|
1
|
-
$max-width:
|
1
|
+
$max-width: 880px;
|
data/lib/gem_version.rb
CHANGED
data/lib/sidebar.rb
CHANGED
@@ -14,35 +14,26 @@ module SwedbankPay
|
|
14
14
|
class << self
|
15
15
|
attr_reader :pages
|
16
16
|
|
17
|
-
def
|
18
|
-
@pages_hash = {}
|
19
|
-
end
|
20
|
-
|
21
|
-
def pre_render(jekyll_page)
|
22
|
-
sidebar_page = SidebarPage.new(jekyll_page)
|
23
|
-
@pages_hash[sidebar_page.path] = sidebar_page
|
24
|
-
end
|
25
|
-
|
26
|
-
def post_write(site)
|
17
|
+
def pre_render(site)
|
27
18
|
parser = SidebarParser.new(site)
|
28
|
-
pages = parser.parse
|
19
|
+
pages = parser.parse
|
29
20
|
@pages = SidebarTreeBuilder.new(pages)
|
30
21
|
Jekyll.logger.debug(" Sidebar: #{@pages.inspect}")
|
31
|
-
|
32
|
-
|
22
|
+
@sidebar_renderer = SidebarRenderer.new(@pages)
|
23
|
+
@sidebar_renderer.enrich_jekyll
|
24
|
+
end
|
25
|
+
|
26
|
+
def post_write
|
27
|
+
@sidebar_renderer.render
|
33
28
|
end
|
34
29
|
end
|
35
30
|
end
|
36
31
|
end
|
37
32
|
|
38
|
-
SwedbankPay::Sidebar.init
|
39
|
-
|
40
33
|
Jekyll::Hooks.register :site, :pre_render do |site, _|
|
41
|
-
|
42
|
-
SwedbankPay::Sidebar.pre_render page
|
43
|
-
end
|
34
|
+
SwedbankPay::Sidebar.pre_render site
|
44
35
|
end
|
45
36
|
|
46
|
-
Jekyll::Hooks.register :site, :post_write do |
|
47
|
-
SwedbankPay::Sidebar.post_write
|
37
|
+
Jekyll::Hooks.register :site, :post_write do |_|
|
38
|
+
SwedbankPay::Sidebar.post_write
|
48
39
|
end
|
data/lib/sidebar_html_builder.rb
CHANGED
@@ -21,36 +21,28 @@ module SwedbankPay
|
|
21
21
|
def build_markup(pages, current_page)
|
22
22
|
return '' if pages.empty?
|
23
23
|
|
24
|
-
current_path = current_path(current_page)
|
25
24
|
markup = ''
|
26
25
|
|
27
26
|
pages.each do |page|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
if page.hidden_for?(current_page)
|
28
|
+
name = current_page.respond_to?(:name) ? current_page.name : current_page.to_s
|
29
|
+
Jekyll.logger.debug(" Sidebar: #{page.name} is hidden for #{name}")
|
30
|
+
next
|
31
|
+
end
|
32
|
+
|
33
|
+
sub_items_markup = sub_items_markup(page, current_page)
|
34
|
+
markup << item_markup(page, current_page, sub_items_markup, false)
|
32
35
|
end
|
33
36
|
|
34
37
|
markup
|
35
38
|
end
|
36
39
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
return current_page if current_page.is_a? String
|
44
|
-
return current_page.path if current_page.respond_to?(:path)
|
45
|
-
|
46
|
-
Jekyll.logger.warn(" Sidebar: #{current_page.class} ('#{current_page}') does not respond to :path.")
|
47
|
-
|
48
|
-
''
|
49
|
-
end
|
50
|
-
|
51
|
-
def item_markup(page, current_path, level, sub_items_markup)
|
40
|
+
def item_markup(page, current_page, sub_items_markup, is_leaf)
|
41
|
+
# If we're rendering a leaf node, just set the level to a non-zero value
|
42
|
+
# to get the 'nav-subgroup' class and such.
|
43
|
+
level = is_leaf ? -1 : page.level
|
52
44
|
title_markup = title_markup(page, level)
|
53
|
-
item_class = item_class(page,
|
45
|
+
item_class = item_class(page, current_page, level, is_leaf)
|
54
46
|
group_heading_class = group_heading_class(level)
|
55
47
|
|
56
48
|
"<li class=\"#{item_class}\">
|
@@ -62,8 +54,8 @@ module SwedbankPay
|
|
62
54
|
</li>"
|
63
55
|
end
|
64
56
|
|
65
|
-
def item_class(page,
|
66
|
-
active = active?(
|
57
|
+
def item_class(page, current_page, level, is_leaf)
|
58
|
+
active = page.active?(current_page, is_leaf: is_leaf)
|
67
59
|
item_class = group_class(level)
|
68
60
|
item_class += ' active' if active
|
69
61
|
item_class
|
@@ -79,16 +71,16 @@ module SwedbankPay
|
|
79
71
|
end
|
80
72
|
|
81
73
|
def title_markup(page, level)
|
82
|
-
|
83
|
-
return "<span>#{
|
74
|
+
lead_title = lead_title(page)
|
75
|
+
return "<span>#{lead_title}</span>" if level.zero?
|
84
76
|
|
85
|
-
|
86
|
-
"<a href=\"#{page.path}\">#{
|
77
|
+
main_title = main_title(page)
|
78
|
+
"<a href=\"#{page.path}\">#{main_title}</a>"
|
87
79
|
end
|
88
80
|
|
89
|
-
def sub_items_markup(page,
|
90
|
-
headers_markup = headers_markup(page,
|
91
|
-
child_markup = build_markup(page.children,
|
81
|
+
def sub_items_markup(page, current_page)
|
82
|
+
headers_markup = headers_markup(page, current_page)
|
83
|
+
child_markup = build_markup(page.children, current_page)
|
92
84
|
|
93
85
|
return '' if headers_markup.empty? && child_markup.empty?
|
94
86
|
|
@@ -98,9 +90,10 @@ module SwedbankPay
|
|
98
90
|
</ul>"
|
99
91
|
end
|
100
92
|
|
101
|
-
def headers_markup(page,
|
93
|
+
def headers_markup(page, current_page)
|
102
94
|
# If there's no page headers, only return a leaf item for the page itself.
|
103
|
-
|
95
|
+
main_title = page.title.nil? ? nil : page.title.main
|
96
|
+
return leaf_markup(page.path, main_title, page.level) unless page.headers?
|
104
97
|
|
105
98
|
# If there's no children, only return the headers as leaf node items.
|
106
99
|
return page.headers.map { |h| header_markup(page, h) }.join('') if page.children.empty?
|
@@ -108,7 +101,7 @@ module SwedbankPay
|
|
108
101
|
headers_markup = page.headers.map { |h| header_markup(page, h) }.join('')
|
109
102
|
headers_markup = "<ul class=\"nav-ul\">#{headers_markup}</ul>"
|
110
103
|
|
111
|
-
item_markup(page,
|
104
|
+
item_markup(page, current_page, headers_markup, true)
|
112
105
|
end
|
113
106
|
|
114
107
|
def header_markup(page, header)
|
@@ -123,19 +116,21 @@ module SwedbankPay
|
|
123
116
|
"<li class=\"#{leaf_class}\"><a href=\"#{href}\">#{title}</a></li>"
|
124
117
|
end
|
125
118
|
|
126
|
-
def
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
def section_title(page)
|
131
|
-
return page.title.section unless page.title.section.nil?
|
119
|
+
def lead_title(page)
|
120
|
+
return page.title.lead unless page.title.nil? || page.title.lead.nil?
|
132
121
|
return page.parent.title.to_s unless page.parent.nil? || page.parent.title.nil?
|
133
122
|
|
134
123
|
''
|
135
124
|
end
|
136
125
|
|
137
|
-
def
|
138
|
-
page.title.
|
126
|
+
def main_title(page)
|
127
|
+
unless page.nil? || page.title.nil?
|
128
|
+
main = page.title.main
|
129
|
+
|
130
|
+
return main || page.title.to_s
|
131
|
+
end
|
132
|
+
|
133
|
+
''
|
139
134
|
end
|
140
135
|
end
|
141
136
|
end
|
data/lib/sidebar_page.rb
CHANGED
@@ -7,44 +7,71 @@ require_relative 'sidebar_page_collection'
|
|
7
7
|
require_relative 'sidebar_text_builder'
|
8
8
|
|
9
9
|
module SwedbankPay
|
10
|
-
# Represents a
|
10
|
+
# Represents a jekyll_page in the Sidebar
|
11
11
|
class SidebarPage
|
12
12
|
FIXNUM_MAX = (2**(0.size * 8 - 2) - 1)
|
13
13
|
|
14
14
|
attr_reader :path, :title, :level, :order, :children, :name
|
15
15
|
attr_accessor :headers, :filename, :doc, :sidebar_container, :number, :parent
|
16
16
|
|
17
|
-
def initialize(
|
18
|
-
raise ArgumentError, '
|
17
|
+
def initialize(jekyll_page)
|
18
|
+
raise ArgumentError, 'jekyll_page cannot be nil' if jekyll_page.nil?
|
19
|
+
raise ArgumentError, 'jekyll_page must be a Jekyll::Page' unless jekyll_page.is_a? Jekyll::Page
|
19
20
|
|
20
|
-
|
21
|
+
@jekyll_page = jekyll_page
|
22
|
+
sidebar_path = SidebarPath.new(jekyll_page['url'])
|
21
23
|
@path = sidebar_path.to_s
|
22
24
|
@parent = sidebar_path.parent
|
23
25
|
@level = sidebar_path.level
|
24
26
|
@name = sidebar_path.name
|
25
|
-
@hide_from_sidebar =
|
26
|
-
@title =
|
27
|
-
@order = menu_order(
|
27
|
+
@hide_from_sidebar = jekyll_page['hide_from_sidebar'].nil? ? false : jekyll_page['hide_from_sidebar']
|
28
|
+
@title = SidebarPageTitle.parse(jekyll_page, self)
|
29
|
+
@order = menu_order(jekyll_page)
|
28
30
|
@children = SidebarPageCollection.new(self)
|
29
31
|
end
|
30
32
|
|
31
|
-
def active?(
|
33
|
+
def active?(current, is_leaf: false)
|
34
|
+
current_path = find_path(current)
|
35
|
+
|
32
36
|
return true if @path == current_path
|
33
37
|
|
34
|
-
|
35
|
-
|
38
|
+
# If we're on a leaf node item, such as when rendering the first header
|
39
|
+
# item of a sub-group, its children's active state must be disregarded.
|
40
|
+
unless is_leaf
|
41
|
+
@children.each do |child|
|
42
|
+
return true if child.active?(current_path, is_leaf: is_leaf)
|
43
|
+
end
|
36
44
|
end
|
37
45
|
|
38
46
|
false
|
39
47
|
end
|
40
48
|
|
41
|
-
def
|
49
|
+
def hidden?
|
42
50
|
return true if @title.nil?
|
43
51
|
return true if @hide_from_sidebar
|
44
52
|
|
45
53
|
false
|
46
54
|
end
|
47
55
|
|
56
|
+
def hidden_for?(other_page)
|
57
|
+
# The current page should be hidden for the other page unless the
|
58
|
+
# other page is also hidden.
|
59
|
+
#
|
60
|
+
# TODO: Make it so that hiddden pages within a section are visible
|
61
|
+
# for each other, but not for other sections, regardless if
|
62
|
+
# they are hidden or not.
|
63
|
+
hidden = hidden?
|
64
|
+
|
65
|
+
if other_page.nil? || !other_page.is_a?(SidebarPage)
|
66
|
+
Jekyll.logger.debug(" Sidebar: Other page '#{other_page}' is nil or not a SidebarPage")
|
67
|
+
return hidden
|
68
|
+
end
|
69
|
+
|
70
|
+
return false if other_page.hidden?
|
71
|
+
|
72
|
+
hidden
|
73
|
+
end
|
74
|
+
|
48
75
|
def children=(children)
|
49
76
|
@children = SidebarPageCollection.new(self, children)
|
50
77
|
end
|
@@ -71,6 +98,19 @@ module SwedbankPay
|
|
71
98
|
@order <=> other.order
|
72
99
|
end
|
73
100
|
|
101
|
+
def enrich_jekyll
|
102
|
+
if @title.nil?
|
103
|
+
Jekyll.logger.debug(" Sidebar: No title for #{@name}")
|
104
|
+
return
|
105
|
+
end
|
106
|
+
|
107
|
+
Jekyll.logger.debug(" Sidebar: #{@name}.lead_title '#{@title.lead}'")
|
108
|
+
Jekyll.logger.debug(" Sidebar: #{@name}.main_title '#{@title.main}'")
|
109
|
+
|
110
|
+
@jekyll_page.data['lead_title'] = @title.lead
|
111
|
+
@jekyll_page.data['main_title'] = @title.main
|
112
|
+
end
|
113
|
+
|
74
114
|
def save
|
75
115
|
Jekyll.logger.debug(" Writing Sidebar: #{filename}")
|
76
116
|
|
@@ -92,15 +132,8 @@ module SwedbankPay
|
|
92
132
|
|
93
133
|
private
|
94
134
|
|
95
|
-
def
|
96
|
-
|
97
|
-
return nil if title.nil?
|
98
|
-
|
99
|
-
SidebarPageTitle.new(title)
|
100
|
-
end
|
101
|
-
|
102
|
-
def menu_order(page)
|
103
|
-
order = page['menu_order']
|
135
|
+
def menu_order(jekyll_page)
|
136
|
+
order = jekyll_page['menu_order']
|
104
137
|
return FIXNUM_MAX if order.nil? || order.to_s.empty?
|
105
138
|
|
106
139
|
order.to_i
|
@@ -113,5 +146,19 @@ module SwedbankPay
|
|
113
146
|
def child_of?(path)
|
114
147
|
@path.split('/').length > @level && path.start_with?(@path)
|
115
148
|
end
|
149
|
+
|
150
|
+
def find_path(current)
|
151
|
+
if current.nil?
|
152
|
+
Jekyll.logger.warn(' Sidebar: Nil current_page')
|
153
|
+
return ''
|
154
|
+
end
|
155
|
+
|
156
|
+
return current if current.is_a? String
|
157
|
+
return current.path if current.respond_to?(:path)
|
158
|
+
|
159
|
+
Jekyll.logger.warn(" Sidebar: #{current.class} ('#{current}') does not respond to :path.")
|
160
|
+
|
161
|
+
''
|
162
|
+
end
|
116
163
|
end
|
117
164
|
end
|
data/lib/sidebar_page_title.rb
CHANGED
@@ -1,15 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'jekyll'
|
4
|
+
require_relative 'sidebar_page'
|
5
|
+
|
3
6
|
module SwedbankPay
|
4
7
|
# Represents the title of a SidebarPage
|
5
8
|
class SidebarPageTitle
|
6
|
-
attr_reader :
|
9
|
+
attr_reader :main, :section
|
7
10
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def self.parse(jekyll_page, sidebar_page)
|
12
|
+
raise ArgumentError, 'jekyll_page cannot be nil' if jekyll_page.nil?
|
13
|
+
raise ArgumentError, 'jekyll_page must be a Jekyll::Page' unless jekyll_page.is_a? Jekyll::Page
|
14
|
+
raise ArgumentError, 'sidebar_page cannot be nil' if sidebar_page.nil?
|
15
|
+
raise ArgumentError, 'sidebar_page must be a SidebarPage' unless sidebar_page.is_a? SidebarPage
|
16
|
+
|
17
|
+
title = jekyll_page['title']
|
18
|
+
section = jekyll_page['section']
|
19
|
+
return nil if title.nil?
|
20
|
+
|
21
|
+
SidebarPageTitle.new(title, section, sidebar_page)
|
22
|
+
end
|
23
|
+
|
24
|
+
def lead
|
25
|
+
section = find_section(@page)
|
26
|
+
return section unless section.nil?
|
27
|
+
|
28
|
+
@lead
|
13
29
|
end
|
14
30
|
|
15
31
|
def to_s
|
@@ -25,5 +41,31 @@ module SwedbankPay
|
|
25
41
|
|
26
42
|
@title <=> other.to_s
|
27
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def initialize(title, section, page)
|
48
|
+
raise ArgumentError, 'title cannot be nil' if title.nil?
|
49
|
+
raise ArgumentError, 'title must be a String' unless title.is_a? String
|
50
|
+
raise ArgumentError, 'page cannot be nil' if page.nil?
|
51
|
+
raise ArgumentError, 'page must be a SidebarPage' unless page.is_a? SidebarPage
|
52
|
+
|
53
|
+
@page = page
|
54
|
+
@title = title
|
55
|
+
parts = title.split('–')
|
56
|
+
@section = section
|
57
|
+
@lead = parts.first.strip
|
58
|
+
@main = parts.last.strip
|
59
|
+
end
|
60
|
+
|
61
|
+
def find_section(page)
|
62
|
+
# Return the 'section' front matter if it can be found on the current page.
|
63
|
+
return page.title.section unless page.nil? || page.title.nil? || page.title.section.nil? || page.title.section.empty?
|
64
|
+
|
65
|
+
# Recurse upwards to the root (until there is no parent).
|
66
|
+
return find_section(page.parent) unless page.nil? || page.parent.nil?
|
67
|
+
|
68
|
+
nil
|
69
|
+
end
|
28
70
|
end
|
29
71
|
end
|
data/lib/sidebar_parser.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'jekyll'
|
3
4
|
require_relative 'sidebar_path'
|
4
5
|
|
5
6
|
module SwedbankPay
|
6
7
|
# The Sidebar renderer
|
7
8
|
class SidebarParser
|
8
9
|
def initialize(site)
|
10
|
+
raise ArgumentError, 'Site cannot be nil' if site.nil?
|
11
|
+
raise ArgumentError, 'Site must be a Jekyll::Site' unless site.is_a? Jekyll::Site
|
12
|
+
|
9
13
|
@site = site
|
10
14
|
end
|
11
15
|
|
12
|
-
def parse
|
16
|
+
def parse
|
17
|
+
pages = build_pages_hash
|
18
|
+
|
13
19
|
destination = @site.config['destination']
|
14
20
|
|
15
21
|
Dir.glob("#{destination}/**/*.html") do |filename|
|
@@ -17,7 +23,10 @@ module SwedbankPay
|
|
17
23
|
path = SidebarPath.new(filename).to_s
|
18
24
|
page = pages[path]
|
19
25
|
|
20
|
-
|
26
|
+
if page.nil?
|
27
|
+
Jekyll.logger.debug(" Sidebar: No page found for <#{path}>.")
|
28
|
+
next
|
29
|
+
end
|
21
30
|
|
22
31
|
page.doc = doc
|
23
32
|
page.filename = filename
|
@@ -30,6 +39,17 @@ module SwedbankPay
|
|
30
39
|
|
31
40
|
private
|
32
41
|
|
42
|
+
def build_pages_hash
|
43
|
+
pages_hash = {}
|
44
|
+
|
45
|
+
@site.pages.each do |jekyll_page|
|
46
|
+
sidebar_page = SidebarPage.new(jekyll_page)
|
47
|
+
pages_hash[sidebar_page.path] = sidebar_page
|
48
|
+
end
|
49
|
+
|
50
|
+
pages_hash
|
51
|
+
end
|
52
|
+
|
33
53
|
def find_headers(doc)
|
34
54
|
headers = []
|
35
55
|
|
data/lib/sidebar_renderer.rb
CHANGED
@@ -5,15 +5,33 @@ require_relative 'sidebar_html_builder'
|
|
5
5
|
module SwedbankPay
|
6
6
|
# Renders the Sidebar
|
7
7
|
class SidebarRenderer
|
8
|
-
def
|
8
|
+
def initialize(tree)
|
9
|
+
raise ArgumentError, 'pages cannot be nil' if tree.nil?
|
9
10
|
raise ArgumentError, 'pages must be an SidebarTreeBuilder' unless tree.is_a? SidebarTreeBuilder
|
10
11
|
|
11
12
|
@tree = tree
|
12
|
-
|
13
|
+
end
|
14
|
+
|
15
|
+
def enrich_jekyll
|
16
|
+
enrich_jekyll_pages(@tree)
|
17
|
+
end
|
18
|
+
|
19
|
+
def render
|
20
|
+
render_pages(@tree)
|
13
21
|
end
|
14
22
|
|
15
23
|
private
|
16
24
|
|
25
|
+
def enrich_jekyll_pages(pages)
|
26
|
+
return if pages.empty?
|
27
|
+
|
28
|
+
pages.each do |page|
|
29
|
+
page.enrich_jekyll
|
30
|
+
|
31
|
+
enrich_jekyll_pages(page.children)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
17
35
|
def render_pages(pages)
|
18
36
|
return if pages.empty?
|
19
37
|
|
@@ -40,7 +58,8 @@ module SwedbankPay
|
|
40
58
|
|
41
59
|
File.open('_site/sidebar.html', 'w') { |f| f.write(sidebar_html) }
|
42
60
|
rescue StandardError => e
|
43
|
-
|
61
|
+
name = page.filename || page.name
|
62
|
+
Jekyll.logger.error(" Sidebar: Unable to render sidebar for '#{name}'.")
|
44
63
|
Jekyll.logger.debug(" Sidebar: #{e.message}. #{e.backtrace.inspect}")
|
45
64
|
return nil
|
46
65
|
end
|
data/lib/sidebar_text_builder.rb
CHANGED
@@ -13,7 +13,7 @@ module SwedbankPay
|
|
13
13
|
|
14
14
|
def to_s
|
15
15
|
name = @page.name == '/' ? '/' : "/#{@page.name}"
|
16
|
-
title = @page.title.nil? ? '?' : @page.title.
|
16
|
+
title = @page.title.nil? ? '?' : @page.title.main
|
17
17
|
s = "#{indent} #{name}: #{title} (#{@page.coordinate})\n"
|
18
18
|
|
19
19
|
unless @page.children.empty?
|
@@ -34,7 +34,7 @@ module SwedbankPay
|
|
34
34
|
|
35
35
|
increment = @page.level > 1 ? @page.level + 1 : @page.level
|
36
36
|
|
37
|
-
"┝╾#{
|
37
|
+
"┝╾#{'─' * increment}"
|
38
38
|
end
|
39
39
|
|
40
40
|
def todo
|
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.9.
|
4
|
+
version: 1.9.1
|
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-10-
|
11
|
+
date: 2020-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -239,10 +239,12 @@ files:
|
|
239
239
|
- _includes/paragraph-highlight.html
|
240
240
|
- _includes/release_notes.html
|
241
241
|
- _includes/sidebar.html
|
242
|
+
- _includes/title-header.html
|
242
243
|
- _includes/toc.html
|
243
244
|
- _layouts/default.html
|
244
245
|
- _layouts/front-page.html
|
245
246
|
- _plugins/sidebar.rb
|
247
|
+
- _sass/breakpoints.scss
|
246
248
|
- _sass/card.scss
|
247
249
|
- _sass/code-view.scss
|
248
250
|
- _sass/colors.scss
|
@@ -300,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
302
|
- !ruby/object:Gem::Version
|
301
303
|
version: '0'
|
302
304
|
requirements: []
|
303
|
-
rubygems_version: 3.1.
|
305
|
+
rubygems_version: 3.1.4
|
304
306
|
signing_key:
|
305
307
|
specification_version: 4
|
306
308
|
summary: Swedbank Pay Design Guide theme for Jekyll
|