govuk_publishing_components 16.13.0 → 16.14.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 +4 -4
- data/app/assets/stylesheets/component_guide/application.scss +5 -0
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_attachment-link.scss +4 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +2 -139
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +144 -0
- data/app/models/govuk_publishing_components/component_doc.rb +4 -4
- data/app/models/govuk_publishing_components/component_example.rb +3 -3
- data/app/views/govuk_publishing_components/component_guide/example.html.erb +3 -1
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +1 -1
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +11 -5
- data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +28 -0
- data/app/views/govuk_publishing_components/components/docs/attachment_link.yml +45 -0
- data/lib/govuk_publishing_components.rb +19 -1
- data/lib/govuk_publishing_components/engine.rb +4 -1
- data/lib/govuk_publishing_components/presenters/attachment.rb +114 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/package.json +1 -1
- metadata +42 -10
- data/lib/govuk_publishing_components/presenters/services.rb +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e1561e655072e39b952b72b04117d705aca387289c84754e6260996186c1cdb
|
|
4
|
+
data.tar.gz: 49ea1ba1d5d37ccbbb2c7f87be315ce9945d74a8795eedd4440ac2f0e4ab9ee2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea203317b7d1c8abcabc8011a19bce5eff879f2d3ba3fd132780a22334427dd42ca85af6cc60f5942f9a143339a29bf9db5c0c40575940a52d66a73c4e5202de
|
|
7
|
+
data.tar.gz: d4c8f0249e8642554b686ac50e7a6b1185be6b4a0a5d6b804b689d412d64a4d6d49330cb6d4c70ec5a19e2facd9d7bcdc2898166515b45f1c5aa28c56aa4881e
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// This file contains the styles for the Component Guide.
|
|
2
2
|
|
|
3
3
|
@import "govuk_publishing_components/components/helpers/govuk-frontend-settings";
|
|
4
|
+
@import "govuk_publishing_components/components/helpers/markdown-typography";
|
|
4
5
|
@import "govuk-frontend/settings/all";
|
|
5
6
|
@import "govuk-frontend/tools/all";
|
|
6
7
|
@import "govuk-frontend/helpers/all";
|
|
@@ -234,6 +235,10 @@
|
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
|
|
238
|
+
.component-markdown {
|
|
239
|
+
@include markdown-typography;
|
|
240
|
+
}
|
|
241
|
+
|
|
237
242
|
// Preview Page Styling
|
|
238
243
|
html {
|
|
239
244
|
background: govuk-colour("white");
|
data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@import "../helpers/markdown-typography";
|
|
1
2
|
// Govspeak typography
|
|
2
3
|
// https://govuk-publishing-components.herokuapp.com/component-guide/govspeak/heading_levels
|
|
3
4
|
// https://govuk-publishing-components.herokuapp.com/component-guide/govspeak/lists
|
|
@@ -9,126 +10,7 @@
|
|
|
9
10
|
// - alphagov/govspeak: ✔︎
|
|
10
11
|
|
|
11
12
|
.gem-c-govspeak {
|
|
12
|
-
@include
|
|
13
|
-
|
|
14
|
-
@include govuk-font($size: 16);
|
|
15
|
-
|
|
16
|
-
ol,
|
|
17
|
-
ul,
|
|
18
|
-
p {
|
|
19
|
-
@include govuk-font($size: 19);
|
|
20
|
-
margin-top: $gutter-half;
|
|
21
|
-
margin-bottom: $gutter-half;
|
|
22
|
-
|
|
23
|
-
@include govuk-media-query($from: tablet) {
|
|
24
|
-
margin-top: $gutter-two-thirds;
|
|
25
|
-
margin-bottom: $gutter-two-thirds;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Headings
|
|
30
|
-
|
|
31
|
-
// H1's are not allowed and thus are styled bare
|
|
32
|
-
h1 {
|
|
33
|
-
@include govuk-font($size: 19);
|
|
34
|
-
margin: 0;
|
|
35
|
-
padding: 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
h2 {
|
|
39
|
-
@include govuk-font($size: 27, $weight: bold);
|
|
40
|
-
margin-top: $gutter;
|
|
41
|
-
margin-bottom: 0;
|
|
42
|
-
|
|
43
|
-
@include govuk-media-query($from: desktop) {
|
|
44
|
-
margin-top: $gutter * 1.5;
|
|
45
|
-
margin-bottom: 0;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
h3 {
|
|
50
|
-
@include govuk-font($size: 19, $weight: bold);
|
|
51
|
-
margin-top: $gutter + 5px;
|
|
52
|
-
margin-bottom: 0;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
h4,
|
|
56
|
-
h5,
|
|
57
|
-
h6 {
|
|
58
|
-
@include govuk-font($size: 19, $weight: bold);
|
|
59
|
-
margin-top: $gutter + 5px;
|
|
60
|
-
margin-bottom: 0;
|
|
61
|
-
|
|
62
|
-
+ p {
|
|
63
|
-
margin-top: 5px;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
h5,
|
|
68
|
-
h6 {
|
|
69
|
-
margin: 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
h2:first-child,
|
|
73
|
-
h3:first-child,
|
|
74
|
-
h4:first-child,
|
|
75
|
-
p:first-child {
|
|
76
|
-
margin-top: 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Links
|
|
80
|
-
a {
|
|
81
|
-
@include govuk-link-style-default;
|
|
82
|
-
@include govuk-focusable-fill;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Lists
|
|
86
|
-
|
|
87
|
-
ol,
|
|
88
|
-
ul {
|
|
89
|
-
list-style: decimal;
|
|
90
|
-
list-style-position: outside;
|
|
91
|
-
margin-left: $gutter-two-thirds;
|
|
92
|
-
padding: 0;
|
|
93
|
-
|
|
94
|
-
ul,
|
|
95
|
-
ol {
|
|
96
|
-
margin-top: 0;
|
|
97
|
-
margin-bottom: 0;
|
|
98
|
-
padding: 0;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@include ie(7) {
|
|
102
|
-
li {
|
|
103
|
-
margin-left: $gutter;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
ul {
|
|
109
|
-
list-style: disc;
|
|
110
|
-
list-style-position: outside;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
li {
|
|
114
|
-
margin: 0 0 5px 0;
|
|
115
|
-
padding: 0;
|
|
116
|
-
|
|
117
|
-
p {
|
|
118
|
-
margin: 0;
|
|
119
|
-
padding: 0;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
p + p,
|
|
123
|
-
p + ul,
|
|
124
|
-
p + ol,
|
|
125
|
-
ul + p,
|
|
126
|
-
ul + ol,
|
|
127
|
-
ol + p,
|
|
128
|
-
ol + ul {
|
|
129
|
-
margin-top: 5px;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
13
|
+
@include markdown-typography;
|
|
132
14
|
|
|
133
15
|
&.direction-rtl ol,
|
|
134
16
|
&.direction-rtl ul {
|
|
@@ -209,23 +91,4 @@
|
|
|
209
91
|
font-style: normal;
|
|
210
92
|
font-weight: inherit;
|
|
211
93
|
}
|
|
212
|
-
|
|
213
|
-
sup {
|
|
214
|
-
font-size: 0.8em;
|
|
215
|
-
line-height: 0.7em;
|
|
216
|
-
vertical-align: super;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
abbr {
|
|
220
|
-
cursor: help;
|
|
221
|
-
text-decoration: none;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Horizontal Rule
|
|
225
|
-
|
|
226
|
-
hr {
|
|
227
|
-
margin-top: $gutter - 1px;
|
|
228
|
-
margin-bottom: $gutter;
|
|
229
|
-
border-top: 1px solid $border-colour;
|
|
230
|
-
}
|
|
231
94
|
}
|
data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
@mixin markdown-typography {
|
|
2
|
+
@include govuk-text-colour;
|
|
3
|
+
|
|
4
|
+
@include govuk-font($size: 16);
|
|
5
|
+
|
|
6
|
+
$gutter-two-thirds: $govuk-gutter - ($govuk-gutter / 3);
|
|
7
|
+
|
|
8
|
+
ol,
|
|
9
|
+
ul,
|
|
10
|
+
p {
|
|
11
|
+
@include govuk-font($size: 19);
|
|
12
|
+
margin-top: $govuk-gutter-half;
|
|
13
|
+
margin-bottom: $govuk-gutter-half;
|
|
14
|
+
|
|
15
|
+
@include govuk-media-query($from: tablet) {
|
|
16
|
+
margin-top: $gutter-two-thirds;
|
|
17
|
+
margin-bottom: $gutter-two-thirds;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Headings
|
|
22
|
+
|
|
23
|
+
// Markdown is expected to be styled within a document with a H1 title
|
|
24
|
+
// thus H1's are not expected and are discouraged by bare styling
|
|
25
|
+
|
|
26
|
+
h1 {
|
|
27
|
+
@include govuk-font($size: 19);
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
h2 {
|
|
33
|
+
@include govuk-font($size: 27, $weight: bold);
|
|
34
|
+
margin-top: $govuk-gutter;
|
|
35
|
+
margin-bottom: 0;
|
|
36
|
+
|
|
37
|
+
@include govuk-media-query($from: desktop) {
|
|
38
|
+
margin-top: $govuk-gutter * 1.5;
|
|
39
|
+
margin-bottom: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
h3 {
|
|
44
|
+
@include govuk-font($size: 19, $weight: bold);
|
|
45
|
+
margin-top: $govuk-gutter + 5px;
|
|
46
|
+
margin-bottom: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// H4, H5 and H6 are discouraged and thus styled the same
|
|
50
|
+
|
|
51
|
+
h4,
|
|
52
|
+
h5,
|
|
53
|
+
h6 {
|
|
54
|
+
@include govuk-font($size: 19, $weight: bold);
|
|
55
|
+
margin-top: $govuk-gutter + 5px;
|
|
56
|
+
margin-bottom: 0;
|
|
57
|
+
|
|
58
|
+
+ p {
|
|
59
|
+
margin-top: 5px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
h5,
|
|
64
|
+
h6 {
|
|
65
|
+
margin: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
h2:first-child,
|
|
69
|
+
h3:first-child,
|
|
70
|
+
h4:first-child,
|
|
71
|
+
p:first-child {
|
|
72
|
+
margin-top: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Links
|
|
76
|
+
|
|
77
|
+
a {
|
|
78
|
+
@include govuk-link-style-default;
|
|
79
|
+
@include govuk-focusable-fill;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Lists
|
|
83
|
+
|
|
84
|
+
ol,
|
|
85
|
+
ul {
|
|
86
|
+
list-style: decimal;
|
|
87
|
+
list-style-position: outside;
|
|
88
|
+
margin-left: $gutter-two-thirds;
|
|
89
|
+
padding: 0;
|
|
90
|
+
|
|
91
|
+
ul,
|
|
92
|
+
ol {
|
|
93
|
+
margin-top: 0;
|
|
94
|
+
margin-bottom: 0;
|
|
95
|
+
padding: 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
ul {
|
|
100
|
+
list-style: disc;
|
|
101
|
+
list-style-position: outside;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
li {
|
|
105
|
+
margin: 0 0 5px 0;
|
|
106
|
+
padding: 0;
|
|
107
|
+
|
|
108
|
+
p {
|
|
109
|
+
margin: 0;
|
|
110
|
+
padding: 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
p + p,
|
|
114
|
+
p + ul,
|
|
115
|
+
p + ol,
|
|
116
|
+
ul + p,
|
|
117
|
+
ul + ol,
|
|
118
|
+
ol + p,
|
|
119
|
+
ol + ul {
|
|
120
|
+
margin-top: 5px;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Text styles
|
|
125
|
+
|
|
126
|
+
sup {
|
|
127
|
+
font-size: 0.8em;
|
|
128
|
+
line-height: 0.7em;
|
|
129
|
+
vertical-align: super;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
abbr {
|
|
133
|
+
cursor: help;
|
|
134
|
+
text-decoration: none;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Horizontal Rule
|
|
138
|
+
|
|
139
|
+
hr {
|
|
140
|
+
margin-top: $govuk-gutter - 1px;
|
|
141
|
+
margin-bottom: $govuk-gutter;
|
|
142
|
+
border-top: 1px solid $govuk-border-colour;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -49,11 +49,11 @@ module GovukPublishingComponents
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def html_body
|
|
52
|
-
|
|
52
|
+
markdown_to_html(body) if body.present?
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def html_accessibility_criteria
|
|
56
|
-
|
|
56
|
+
markdown_to_html(accessibility_criteria) if accessibility_criteria.present?
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def partial_path
|
|
@@ -83,8 +83,8 @@ module GovukPublishingComponents
|
|
|
83
83
|
|
|
84
84
|
private
|
|
85
85
|
|
|
86
|
-
def
|
|
87
|
-
|
|
86
|
+
def markdown_to_html(markdown)
|
|
87
|
+
Kramdown::Document.new(markdown).to_html
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
end
|
|
@@ -68,7 +68,7 @@ module GovukPublishingComponents
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def html_description
|
|
71
|
-
|
|
71
|
+
markdown_to_html(description) if description.present?
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def has_block?
|
|
@@ -81,8 +81,8 @@ module GovukPublishingComponents
|
|
|
81
81
|
|
|
82
82
|
private
|
|
83
83
|
|
|
84
|
-
def
|
|
85
|
-
|
|
84
|
+
def markdown_to_html(markdown)
|
|
85
|
+
Kramdown::Document.new(markdown).to_html
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
end
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
<div class="component-show">
|
|
5
5
|
<div class="component-doc">
|
|
6
|
-
|
|
6
|
+
<div class="component-markdown">
|
|
7
|
+
<%= raw(@component_example.html_description) %>
|
|
8
|
+
</div>
|
|
7
9
|
<h2 class="component-doc-h2">How to call this example</h2>
|
|
8
10
|
<%= render partial: "govuk_publishing_components/component_guide/component_doc/call", locals: { component_doc: @component_doc, example: @component_example } %>
|
|
9
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%= render 'govuk_publishing_components/components/title', title: GovukPublishingComponents::Config.component_guide_title %>
|
|
2
2
|
|
|
3
|
-
<div class="
|
|
3
|
+
<div class="component-markdown">
|
|
4
4
|
<p>Components are packages of template, style, behaviour and documentation that live in your application.</p>
|
|
5
5
|
<p>A component must:</p>
|
|
6
6
|
<ul>
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
<%= render 'govuk_publishing_components/components/lead_paragraph', text: @component_doc.description %>
|
|
14
14
|
<% if @component_doc.body.present? %>
|
|
15
15
|
<div class="component-body">
|
|
16
|
-
|
|
16
|
+
<div class="component-markdown">
|
|
17
|
+
<%= raw(@component_doc.html_body) %>
|
|
18
|
+
</div>
|
|
17
19
|
</div>
|
|
18
20
|
<% end %>
|
|
19
21
|
</div>
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
|
|
31
33
|
<% if @component_doc.govuk_frontend_components.any? %>
|
|
32
34
|
<h2 class="component-doc-h2">GOV.UK Design System</h2>
|
|
33
|
-
|
|
35
|
+
<div class="component-markdown">
|
|
34
36
|
<p>This component incorporates components from the <%= link_to "GOV.UK Design System", "https://design-system.service.gov.uk" %>:</p>
|
|
35
37
|
|
|
36
38
|
<ul>
|
|
@@ -38,14 +40,16 @@
|
|
|
38
40
|
<li><%= link_to component.humanize, "https://design-system.service.gov.uk/components/#{component}" %></li>
|
|
39
41
|
<% end %>
|
|
40
42
|
</ul>
|
|
41
|
-
|
|
43
|
+
</div>
|
|
42
44
|
<% end %>
|
|
43
45
|
|
|
44
46
|
<% if @component_doc.accessibility_criteria.present? %>
|
|
45
47
|
<div class="govuk-grid-row component-accessibility-criteria">
|
|
46
48
|
<div class="govuk-grid-column-two-thirds">
|
|
47
49
|
<h2 class="component-doc-h2">Accessibility acceptance criteria</h2>
|
|
48
|
-
|
|
50
|
+
<div class="component-markdown">
|
|
51
|
+
<%= raw(@component_doc.html_accessibility_criteria) %>
|
|
52
|
+
</div>
|
|
49
53
|
</div>
|
|
50
54
|
</div>
|
|
51
55
|
<% end %>
|
|
@@ -61,7 +65,9 @@
|
|
|
61
65
|
<a href="<%= component_example_path(@component_doc.id, example.id) %>" class="govuk-link"><%= example.name %></a>
|
|
62
66
|
<small>(<a href="<%= component_preview_path(@component_doc.id, example.id) %>" class="govuk-link">preview</a>)</small>
|
|
63
67
|
</h3>
|
|
64
|
-
|
|
68
|
+
<div class="component-markdown">
|
|
69
|
+
<%= raw(example.html_description) %>
|
|
70
|
+
</div>
|
|
65
71
|
<%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, example: example %>
|
|
66
72
|
<%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: example %>
|
|
67
73
|
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<%
|
|
2
|
+
attachment = GovukPublishingComponents::Presenters::Attachment.new(attachment)
|
|
3
|
+
target ||= nil
|
|
4
|
+
attributes = []
|
|
5
|
+
if attachment.readable_content_type
|
|
6
|
+
content = if attachment.content_type_abbr
|
|
7
|
+
raw tag.abbr(attachment.content_type.abbr,
|
|
8
|
+
title: attachment.readable_content_type,
|
|
9
|
+
class: "gem-c-attachment-link__abbr")
|
|
10
|
+
else
|
|
11
|
+
attachment.readable_content_type
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attributes << tag.span(content, class: "gem-c-attachment-link__attribute")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if attachment.readable_file_size
|
|
18
|
+
attributes << tag.span(attachment.readable_file_size, class: "gem-c-attachment-link__attribute")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
if attachment.readable_number_of_pages
|
|
22
|
+
attributes << tag.span(attachment.readable_number_of_pages, class: "gem-c-attachment-link__attribute")
|
|
23
|
+
end
|
|
24
|
+
%>
|
|
25
|
+
<%= tag.span(class: "gem-c-attachment-link") do %>
|
|
26
|
+
<%= link_to(attachment.title, attachment.url, class: "govuk-link", target: target) %>
|
|
27
|
+
<%= raw("(#{attributes.join(', ')})") if attributes.any? %>
|
|
28
|
+
<% end %>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Attachment link (experimental)
|
|
2
|
+
description: A link to a file with metadata of the file contents
|
|
3
|
+
body: |
|
|
4
|
+
This component is marked as experimental as it is part of a drive to provide
|
|
5
|
+
a consistent place for attachment presentation logic (currently this logic is
|
|
6
|
+
within [Govspeak][] and [Whitehall][]). The API for this
|
|
7
|
+
component may change during this process.
|
|
8
|
+
|
|
9
|
+
It provides a means to show a link to an attachment with some
|
|
10
|
+
relevant file data.
|
|
11
|
+
|
|
12
|
+
It is expected to be embedded inside an element that provides text styles
|
|
13
|
+
(such as `.govuk-body`) so does not provide its own text styling.
|
|
14
|
+
|
|
15
|
+
[Govspeak]: https://github.com/alphagov/govspeak/blob/c3a0742c87537a371108d097cea23688efa90a14/lib/govspeak/presenters/attachment_presenter.rb
|
|
16
|
+
[Whitehall]: https://github.com/alphagov/whitehall/blob/5c760eea912320c5a80ef59791df47161d889f2f/app/helpers/document_helper.rb
|
|
17
|
+
shared_accessibility_criteria:
|
|
18
|
+
- link
|
|
19
|
+
examples:
|
|
20
|
+
default:
|
|
21
|
+
data:
|
|
22
|
+
attachment:
|
|
23
|
+
title: "Temporary snow ploughs: guidance note"
|
|
24
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
|
|
25
|
+
content_type: application/pdf
|
|
26
|
+
file_size: 20000
|
|
27
|
+
number_of_pages: 1
|
|
28
|
+
embedded_in_govuk_body:
|
|
29
|
+
embed: |
|
|
30
|
+
<p class="govuk-body">
|
|
31
|
+
<%= component %>
|
|
32
|
+
</p>
|
|
33
|
+
data:
|
|
34
|
+
attachment:
|
|
35
|
+
title: "Temporary snow ploughs: guidance note"
|
|
36
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
|
|
37
|
+
content_type: application/pdf
|
|
38
|
+
file_size: 20000
|
|
39
|
+
number_of_pages: 1
|
|
40
|
+
with_target_blank:
|
|
41
|
+
data:
|
|
42
|
+
attachment:
|
|
43
|
+
title: "Temporary snow ploughs: guidance note"
|
|
44
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
|
|
45
|
+
target: _blank
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
require "active_support"
|
|
2
|
+
require "action_controller"
|
|
3
|
+
require "action_view"
|
|
1
4
|
require "govuk_publishing_components/config"
|
|
2
5
|
require "govuk_publishing_components/engine"
|
|
3
6
|
require "govuk_publishing_components/presenters/shared_helper"
|
|
7
|
+
require "govuk_publishing_components/presenters/attachment"
|
|
4
8
|
require "govuk_publishing_components/presenters/breadcrumbs"
|
|
5
9
|
require "govuk_publishing_components/presenters/button_helper"
|
|
6
10
|
require "govuk_publishing_components/presenters/contextual_navigation"
|
|
@@ -10,7 +14,6 @@ require "govuk_publishing_components/presenters/page_with_step_by_step_navigatio
|
|
|
10
14
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_parent"
|
|
11
15
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
|
|
12
16
|
require "govuk_publishing_components/presenters/checkboxes_helper"
|
|
13
|
-
require "govuk_publishing_components/presenters/services"
|
|
14
17
|
require "govuk_publishing_components/presenters/select"
|
|
15
18
|
require "govuk_publishing_components/presenters/meta_tags"
|
|
16
19
|
require "govuk_publishing_components/presenters/content_item"
|
|
@@ -29,5 +32,20 @@ require "govuk_publishing_components/app_helpers/table_helper"
|
|
|
29
32
|
require "govuk_publishing_components/app_helpers/brand_helper"
|
|
30
33
|
require "govuk_publishing_components/app_helpers/environment"
|
|
31
34
|
|
|
35
|
+
# Add view and i18n paths for usage outside of a Rails app
|
|
36
|
+
ActionController::Base.append_view_path(
|
|
37
|
+
File.expand_path("app/views", GovukPublishingComponents::Config.gem_directory)
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
I18n.load_path.unshift(
|
|
41
|
+
*Dir.glob(File.expand_path("config/locales/*.yml", GovukPublishingComponents::Config.gem_directory))
|
|
42
|
+
)
|
|
43
|
+
|
|
32
44
|
module GovukPublishingComponents
|
|
45
|
+
def self.render(component, options = {})
|
|
46
|
+
I18n.with_locale(options.fetch(:locale, "en")) do
|
|
47
|
+
renderer = ActionController::Base.renderer
|
|
48
|
+
renderer.render(partial: component, locals: options)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
33
51
|
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
module GovukPublishingComponents
|
|
2
|
+
module Presenters
|
|
3
|
+
class Attachment
|
|
4
|
+
include ActionView::Helpers::NumberHelper
|
|
5
|
+
include ActionView::Helpers::TextHelper
|
|
6
|
+
|
|
7
|
+
attr_reader :attachment_data
|
|
8
|
+
|
|
9
|
+
# Expects a hash of attachment data
|
|
10
|
+
# * title and url are required
|
|
11
|
+
# * content_type, filename, file_size, number of pages can be provided
|
|
12
|
+
def initialize(attachment_data)
|
|
13
|
+
@attachment_data = attachment_data.with_indifferent_access
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def title
|
|
17
|
+
attachment_data.fetch(:title)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def url
|
|
21
|
+
attachment_data.fetch(:url)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def content_type
|
|
25
|
+
@content_type ||= SupportedContentType.find(
|
|
26
|
+
attachment_data[:content_type],
|
|
27
|
+
attachment_data[:filename] ? File.extname(attachment_data[:filename]) : nil,
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def content_type_abbr
|
|
32
|
+
content_type.abbr
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def readable_content_type
|
|
36
|
+
content_type.name
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def readable_file_size
|
|
40
|
+
return unless attachment_data[:file_size]
|
|
41
|
+
|
|
42
|
+
number_to_human_size(attachment_data[:file_size])
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def readable_number_of_pages
|
|
46
|
+
return unless attachment_data[:number_of_pages]
|
|
47
|
+
|
|
48
|
+
pluralize(attachment_data[:number_of_pages], "page")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class SupportedContentType
|
|
52
|
+
attr_reader :content_type, :name, :abbr
|
|
53
|
+
|
|
54
|
+
TYPES = [
|
|
55
|
+
{ content_type: "application/msword", name: "MS Word Document" }.freeze, # doc
|
|
56
|
+
{ content_type: "application/pdf", abbr: "PDF", name: "Portable Document Format" }.freeze,
|
|
57
|
+
{ content_type: "application/postscript", extension: ".ps", abbr: "PS", name: "PostScript" }.freeze,
|
|
58
|
+
{ content_type: "application/postscript", extension: ".eps", abbr: "EPS", name: "Encapsulated PostScript" }.freeze,
|
|
59
|
+
{ content_type: "application/rtf", abbr: "RTF", name: "Rich Text Format" }.freeze,
|
|
60
|
+
{ content_type: "application/vnd.ms-excel", name: "MS Excel Spreadsheet" }.freeze,
|
|
61
|
+
{ content_type: "application/vnd.ms-excel.sheet.macroenabled.12", abbr: "XLSM", name: "MS Excel Macro-Enabled Workbook" }.freeze,
|
|
62
|
+
{ content_type: "application/vnd.ms-powerpoint", name: "MS Powerpoint Presentation" }.freeze, # ppt
|
|
63
|
+
{ content_type: "application/vnd.oasis.opendocument.presentation", abbr: "ODP", name: "OpenDocument Presentation" }.freeze,
|
|
64
|
+
{ content_type: "application/vnd.oasis.opendocument.spreadsheet", abbr: "ODS", name: "OpenDocument Spreadsheet" }.freeze,
|
|
65
|
+
{ content_type: "application/vnd.oasis.opendocument.text", abbr: "ODT", name: "OpenDocument Text document" }.freeze,
|
|
66
|
+
{ content_type: "application/vnd.openxmlformats-officedocument.presentationml.presentation", name: "MS Powerpoint Presentation" }.freeze, # pptx
|
|
67
|
+
{ content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", name: "MS Excel Spreadsheet" }.freeze, # xlsx
|
|
68
|
+
{ content_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", name: "MS Word Document" }.freeze, # docx
|
|
69
|
+
{ content_type: "application/xml", abbr: "XML", name: "XML Document" }.freeze,
|
|
70
|
+
{ content_type: "image/gif", abbr: "GIF", name: "Graphics Interchange Format" }.freeze,
|
|
71
|
+
{ content_type: "image/jpeg", name: "JPEG" }.freeze,
|
|
72
|
+
{ content_type: "image/png", abbr: "PNG", name: "Portable Network Graphic" }.freeze,
|
|
73
|
+
{ content_type: "image/vnd.dxf", abbr: "DXF", name: "AutoCAD Drawing Exchange Format" }.freeze,
|
|
74
|
+
{ content_type: "text/csv", abbr: "CSV", name: "Comma-separated Values" }.freeze,
|
|
75
|
+
{ content_type: "text/plain", name: "Plain Text" }.freeze,
|
|
76
|
+
{ content_type: "text/xml", extension: ".xml", abbr: "XML", name: "XML Document" }.freeze,
|
|
77
|
+
{ content_type: "text/xml", extension: ".xsd", abbr: "XSD", name: "XML Schema" }.freeze,
|
|
78
|
+
].freeze
|
|
79
|
+
|
|
80
|
+
def self.find(content_type, extension = nil)
|
|
81
|
+
matching_types = TYPES.select { |type| type[:content_type] == content_type }
|
|
82
|
+
|
|
83
|
+
return UnsupportedContentType.new(content_type: content_type) if matching_types.empty?
|
|
84
|
+
|
|
85
|
+
extension_match = if matching_types.length > 1
|
|
86
|
+
matching_types.find { |type| type[:extension] == extension }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
content_type = extension_match || matching_types.first
|
|
90
|
+
|
|
91
|
+
new(content_type)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def initialize(content_type)
|
|
95
|
+
@content_type = content_type[:content_type]
|
|
96
|
+
@name = content_type[:name]
|
|
97
|
+
@abbr = content_type[:abbr]
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
class UnsupportedContentType
|
|
102
|
+
attr_reader :content_type
|
|
103
|
+
|
|
104
|
+
def initialize(content_type:)
|
|
105
|
+
@content_type = content_type
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def name; end
|
|
109
|
+
|
|
110
|
+
def abbr; end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"/"
|
|
50
50
|
],
|
|
51
51
|
"_resolved": "git://github.com/alphagov/accessible-autocomplete.git#0c518b4fa79b9a95b544410858486ed9e6403c84",
|
|
52
|
-
"_shasum": "
|
|
52
|
+
"_shasum": "a6d2bc517641fa0b894674f7cfd965493cd1a094",
|
|
53
53
|
"_shrinkwrap": null,
|
|
54
54
|
"_spec": "accessible-autocomplete@git://github.com/alphagov/accessible-autocomplete.git#add-multiselect-support",
|
|
55
55
|
"_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ",
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: govuk_publishing_components
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 16.
|
|
4
|
+
version: 16.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: gds-api-adapters
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: '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: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: govuk_app_config
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,6 +52,34 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: kramdown
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: plek
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
55
83
|
- !ruby/object:Gem::Dependency
|
|
56
84
|
name: rails
|
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -140,16 +168,16 @@ dependencies:
|
|
|
140
168
|
name: gds-api-adapters
|
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
|
142
170
|
requirements:
|
|
143
|
-
- - "
|
|
171
|
+
- - "~>"
|
|
144
172
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: '
|
|
173
|
+
version: '59.1'
|
|
146
174
|
type: :development
|
|
147
175
|
prerelease: false
|
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
177
|
requirements:
|
|
150
|
-
- - "
|
|
178
|
+
- - "~>"
|
|
151
179
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: '
|
|
180
|
+
version: '59.1'
|
|
153
181
|
- !ruby/object:Gem::Dependency
|
|
154
182
|
name: govuk-lint
|
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -340,6 +368,7 @@ files:
|
|
|
340
368
|
- app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss
|
|
341
369
|
- app/assets/stylesheets/govuk_publishing_components/components/_accessible-autocomplete.scss
|
|
342
370
|
- app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss
|
|
371
|
+
- app/assets/stylesheets/govuk_publishing_components/components/_attachment-link.scss
|
|
343
372
|
- app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss
|
|
344
373
|
- app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss
|
|
345
374
|
- app/assets/stylesheets/govuk_publishing_components/components/_button.scss
|
|
@@ -422,6 +451,7 @@ files:
|
|
|
422
451
|
- app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss
|
|
423
452
|
- app/assets/stylesheets/govuk_publishing_components/components/helpers/_contents-list-helper.scss
|
|
424
453
|
- app/assets/stylesheets/govuk_publishing_components/components/helpers/_govuk-frontend-settings.scss
|
|
454
|
+
- app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss
|
|
425
455
|
- app/assets/stylesheets/govuk_publishing_components/components/helpers/_px-to-em.scss
|
|
426
456
|
- app/assets/stylesheets/govuk_publishing_components/components/helpers/_variables.scss
|
|
427
457
|
- app/assets/stylesheets/govuk_publishing_components/components/mixins/_back-arrow.scss
|
|
@@ -455,6 +485,7 @@ files:
|
|
|
455
485
|
- app/views/govuk_publishing_components/components/_accessible_autocomplete.html.erb
|
|
456
486
|
- app/views/govuk_publishing_components/components/_accordion.html.erb
|
|
457
487
|
- app/views/govuk_publishing_components/components/_admin_analytics.html.erb
|
|
488
|
+
- app/views/govuk_publishing_components/components/_attachment_link.html.erb
|
|
458
489
|
- app/views/govuk_publishing_components/components/_back_link.html.erb
|
|
459
490
|
- app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
|
|
460
491
|
- app/views/govuk_publishing_components/components/_button.html.erb
|
|
@@ -521,6 +552,7 @@ files:
|
|
|
521
552
|
- app/views/govuk_publishing_components/components/docs/accessible_autocomplete.yml
|
|
522
553
|
- app/views/govuk_publishing_components/components/docs/accordion.yml
|
|
523
554
|
- app/views/govuk_publishing_components/components/docs/admin_analytics.yml
|
|
555
|
+
- app/views/govuk_publishing_components/components/docs/attachment_link.yml
|
|
524
556
|
- app/views/govuk_publishing_components/components/docs/back_link.yml
|
|
525
557
|
- app/views/govuk_publishing_components/components/docs/breadcrumbs.yml
|
|
526
558
|
- app/views/govuk_publishing_components/components/docs/button.yml
|
|
@@ -607,6 +639,7 @@ files:
|
|
|
607
639
|
- lib/govuk_publishing_components/config.rb
|
|
608
640
|
- lib/govuk_publishing_components/engine.rb
|
|
609
641
|
- lib/govuk_publishing_components/minitest/component_guide_test.rb
|
|
642
|
+
- lib/govuk_publishing_components/presenters/attachment.rb
|
|
610
643
|
- lib/govuk_publishing_components/presenters/breadcrumbs.rb
|
|
611
644
|
- lib/govuk_publishing_components/presenters/button_helper.rb
|
|
612
645
|
- lib/govuk_publishing_components/presenters/checkboxes_helper.rb
|
|
@@ -633,7 +666,6 @@ files:
|
|
|
633
666
|
- lib/govuk_publishing_components/presenters/related_navigation_helper.rb
|
|
634
667
|
- lib/govuk_publishing_components/presenters/schema_org.rb
|
|
635
668
|
- lib/govuk_publishing_components/presenters/select.rb
|
|
636
|
-
- lib/govuk_publishing_components/presenters/services.rb
|
|
637
669
|
- lib/govuk_publishing_components/presenters/shared_helper.rb
|
|
638
670
|
- lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb
|
|
639
671
|
- lib/govuk_publishing_components/presenters/subscription_links_helper.rb
|