govuk_tech_docs 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of govuk_tech_docs might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.nvmrc +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +27 -0
- data/README.md +15 -1
- data/example/config/tech-docs.yml +1 -0
- data/example/source/single-page-nav.html.md +13 -0
- data/lib/assets/javascripts/_modules/search.js +59 -66
- data/lib/assets/javascripts/_modules/table-of-contents.js +0 -1
- data/lib/assets/javascripts/_vendor/jquery.js +2 -5
- data/lib/assets/javascripts/_vendor/lodash.js +5 -3
- data/lib/assets/stylesheets/modules/_search.scss +51 -73
- data/lib/assets/stylesheets/modules/_technical-documentation.scss +0 -4
- data/lib/assets/stylesheets/modules/_toc.scss +0 -3
- data/lib/govuk_tech_docs/table_of_contents/helpers.rb +16 -8
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/govuk_tech_docs.rb +3 -1
- data/lib/source/layouts/_header.erb +0 -5
- data/lib/source/layouts/_search.erb +0 -7
- data/lib/source/layouts/layout.erb +3 -1
- data/lib/source/search/index.html.erb +31 -0
- metadata +4 -3
- data/CONTRIBUTING.md +0 -12
@@ -52,48 +52,44 @@ $input-size: 40px;
|
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
@include govuk-media-query($until: tablet) {
|
56
|
+
html.js.has-search-results-open:not(.toc-open) {
|
57
|
+
.toc {
|
58
|
+
display: block;
|
59
|
+
padding-bottom: 0;
|
60
|
+
}
|
61
|
+
|
62
|
+
.toc__close {
|
63
|
+
display: none;
|
64
|
+
}
|
65
|
+
|
66
|
+
.toc__list {
|
67
|
+
display: none;
|
68
|
+
}
|
63
69
|
}
|
64
70
|
}
|
71
|
+
|
65
72
|
.search-results {
|
66
|
-
|
67
|
-
|
68
|
-
|
73
|
+
@include govuk-media-query(tablet) {
|
74
|
+
// Create basis for the search results caret (below)
|
75
|
+
position: relative;
|
76
|
+
|
77
|
+
@include govuk-font($size: 16);
|
78
|
+
padding-top: govuk-spacing(6);
|
69
79
|
}
|
70
|
-
}
|
71
80
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
right: 0;
|
77
|
-
bottom: 0;
|
78
|
-
z-index: 600;
|
79
|
-
overflow-x: scroll;
|
80
|
-
-webkit-overflow-scrolling: touch;
|
81
|
-
-ms-overflow-style: none;
|
82
|
-
@include govuk-media-query(tablet) {
|
83
|
-
padding: govuk-spacing(6);
|
84
|
-
top: 0;
|
85
|
-
// The width of the sidebar
|
86
|
-
left: 330px;
|
87
|
-
min-height: auto;
|
88
|
-
}
|
81
|
+
a {
|
82
|
+
@include govuk-link-common;
|
83
|
+
@include govuk-link-style-no-visited-state;
|
84
|
+
}
|
89
85
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
86
|
+
ul {
|
87
|
+
list-style: none;
|
88
|
+
padding: 0;
|
89
|
+
margin: 0;
|
94
90
|
}
|
91
|
+
}
|
95
92
|
.search-results__inner {
|
96
|
-
position: relative;
|
97
93
|
background: govuk-colour("white");
|
98
94
|
border-top: 1px solid govuk-colour("mid-grey");
|
99
95
|
max-width: 40rem;
|
@@ -104,7 +100,7 @@ html.has-search-results-open {
|
|
104
100
|
&::after {
|
105
101
|
content: '';
|
106
102
|
position: absolute;
|
107
|
-
top:
|
103
|
+
top: 35px;
|
108
104
|
left: -9px;
|
109
105
|
width: 10px;
|
110
106
|
height: 20px;
|
@@ -117,44 +113,6 @@ html.has-search-results-open {
|
|
117
113
|
@include govuk-font($size: 27, $weight: bold);
|
118
114
|
margin-bottom: govuk-spacing(6);
|
119
115
|
}
|
120
|
-
.search-results__close {
|
121
|
-
@include govuk-font($size: 16);
|
122
|
-
position: absolute;
|
123
|
-
top: 18px;
|
124
|
-
right: 20px;
|
125
|
-
appearance: none;
|
126
|
-
-webkit-appearance: none;
|
127
|
-
background: none;
|
128
|
-
border: 0;
|
129
|
-
padding: 0;
|
130
|
-
cursor: pointer;
|
131
|
-
|
132
|
-
&:focus {
|
133
|
-
@include govuk-focused-text;
|
134
|
-
}
|
135
|
-
|
136
|
-
&::after {
|
137
|
-
content: '';
|
138
|
-
display: inline-block;
|
139
|
-
vertical-align: middle;
|
140
|
-
padding-left: 8px;
|
141
|
-
height: 18px;
|
142
|
-
width: 18px;
|
143
|
-
background: no-repeat url('/images/govuk-icn-close.png') center right;
|
144
|
-
@include govuk-device-pixel-ratio {
|
145
|
-
background-image: url('/images/govuk-icn-close@2x.png');
|
146
|
-
}
|
147
|
-
background-size: contain;
|
148
|
-
}
|
149
|
-
}
|
150
|
-
.search-results__close-label {
|
151
|
-
position: absolute;
|
152
|
-
left: -9999em;
|
153
|
-
top: auto;
|
154
|
-
width: 1px;
|
155
|
-
height: 1px;
|
156
|
-
overflow: hidden;
|
157
|
-
}
|
158
116
|
.search-result {
|
159
117
|
margin-bottom: govuk-spacing(6);
|
160
118
|
}
|
@@ -162,4 +120,24 @@ html.has-search-results-open {
|
|
162
120
|
background-color: transparent;
|
163
121
|
color: inherit;
|
164
122
|
font-weight: bold;
|
123
|
+
|
124
|
+
// In forced color mode some browsers will keep the background transparent
|
125
|
+
// but set the text colour black, making the highlighted text unreadable.
|
126
|
+
// The following blocks fix this by setting the text colour to be the same as
|
127
|
+
// other text in a way that forced color mode will respect.
|
128
|
+
|
129
|
+
@media screen and (-ms-high-contrast: active) {
|
130
|
+
// IE does not support `CanvasText`,
|
131
|
+
// and `currentColor` does not work with Blink
|
132
|
+
color: currentColor;
|
133
|
+
}
|
134
|
+
|
135
|
+
@media screen and (forced-colors: active) {
|
136
|
+
background-color: Canvas; // needed for Firefox
|
137
|
+
color: CanvasText;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
.js .search-help__no-js {
|
142
|
+
display: none;
|
165
143
|
}
|
@@ -8,14 +8,11 @@ module GovukTechDocs
|
|
8
8
|
module TableOfContents
|
9
9
|
module Helpers
|
10
10
|
def single_page_table_of_contents(html, url: "", max_level: nil)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
raise "No H1 tag found. You have to at least add one H1 heading to the page: " + url
|
15
|
-
end
|
11
|
+
output = "<ul>\n"
|
12
|
+
output += list_items_from_headings(html, url: url, max_level: max_level)
|
13
|
+
output += "</ul>\n"
|
16
14
|
|
17
|
-
|
18
|
-
HeadingTreeRenderer.new(tree, max_level: max_level).html
|
15
|
+
output
|
19
16
|
end
|
20
17
|
|
21
18
|
def multi_page_table_of_contents(resources, current_page, config, current_page_html = nil)
|
@@ -28,6 +25,17 @@ module GovukTechDocs
|
|
28
25
|
render_page_tree(resources, current_page, config, current_page_html)
|
29
26
|
end
|
30
27
|
|
28
|
+
def list_items_from_headings(html, url: "", max_level: nil)
|
29
|
+
headings = HeadingsBuilder.new(html, url).headings
|
30
|
+
|
31
|
+
if headings.none? { |heading| heading.size == 1 }
|
32
|
+
raise "No H1 tag found. You have to at least add one H1 heading to the page: " + url
|
33
|
+
end
|
34
|
+
|
35
|
+
tree = HeadingTreeBuilder.new(headings).tree
|
36
|
+
HeadingTreeRenderer.new(tree, max_level: max_level).html
|
37
|
+
end
|
38
|
+
|
31
39
|
def render_page_tree(resources, current_page, config, current_page_html)
|
32
40
|
# Sort by weight frontmatter
|
33
41
|
resources = resources
|
@@ -69,7 +77,7 @@ module GovukTechDocs
|
|
69
77
|
output += "</li>\n"
|
70
78
|
else
|
71
79
|
output +=
|
72
|
-
|
80
|
+
list_items_from_headings(
|
73
81
|
content,
|
74
82
|
url: resource.url,
|
75
83
|
max_level: config[:tech_docs][:max_toc_heading_level],
|
data/lib/govuk_tech_docs.rb
CHANGED
@@ -113,10 +113,12 @@ module GovukTechDocs
|
|
113
113
|
url: { index: false, store: true },
|
114
114
|
}
|
115
115
|
|
116
|
-
search.pipeline_remove = %w[stopWordFilter]
|
116
|
+
search.pipeline_remove = %w[stemmer stopWordFilter]
|
117
117
|
|
118
118
|
search.tokenizer_separator = '/[\s\-/]+/'
|
119
119
|
end
|
120
|
+
else
|
121
|
+
context.ignore "search/*"
|
120
122
|
end
|
121
123
|
end
|
122
124
|
end
|
@@ -8,7 +8,6 @@
|
|
8
8
|
<% end %>
|
9
9
|
<% if config[:tech_docs][:show_govuk_logo] %>
|
10
10
|
<span class="govuk-header__logotype">
|
11
|
-
<!--[if gt IE 8]><!-->
|
12
11
|
<svg
|
13
12
|
aria-hidden="true"
|
14
13
|
focusable="false"
|
@@ -23,10 +22,6 @@
|
|
23
22
|
d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.3 3.5-.4 7.6-3.9 9.1zM89.3 35.8c-3.6 1.5-7.8-.2-9.2-3.8-1.4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3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"
|
24
23
|
></path>
|
25
24
|
</svg>
|
26
|
-
<!--<![endif]-->
|
27
|
-
<!--[if IE 8]>
|
28
|
-
<img src="/assets/images/govuk-logotype-crown.png" class="govuk-header__logotype-crown-fallback-image" width="36" height="32">
|
29
|
-
<![endif]-->
|
30
25
|
<span class="govuk-header__logotype-text">
|
31
26
|
GOV.UK
|
32
27
|
</span>
|
@@ -13,12 +13,5 @@
|
|
13
13
|
placeholder="Search">
|
14
14
|
<button type="submit" class="search__button">Search</button>
|
15
15
|
</form>
|
16
|
-
<div id="search-results" class="search-results" aria-hidden="true" role="dialog" aria-labelledby="search-results-title">
|
17
|
-
<div class="search-results__inner">
|
18
|
-
<button class="search-results__close">Close<span class="search-results__close-label"> search results</span></button>
|
19
|
-
<h2 id="search-results-title" class="search-results__title" aria-live="assertive" role="alert">Results</h2>
|
20
|
-
<div class="search-results__content"></div>
|
21
|
-
</div>
|
22
|
-
</div>
|
23
16
|
</div>
|
24
17
|
<% end %>
|
@@ -4,8 +4,10 @@ wrap_layout :core do
|
|
4
4
|
|
5
5
|
content_for(:toc_module, "in-page-navigation")
|
6
6
|
|
7
|
+
use_multipage_nav = current_page.data.fetch(:multipage_nav, config[:tech_docs][:multipage_nav])
|
8
|
+
|
7
9
|
content_for :sidebar do
|
8
|
-
if
|
10
|
+
if use_multipage_nav %>
|
9
11
|
<%= multi_page_table_of_contents(sitemap.resources, current_page, config, html) %>
|
10
12
|
<% else %>
|
11
13
|
<%= single_page_table_of_contents(html, max_level: config[:tech_docs][:max_toc_heading_level]) %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
title: Search
|
3
|
+
index: false
|
4
|
+
prevent_indexing: true
|
5
|
+
hide_in_navigation: true
|
6
|
+
---
|
7
|
+
|
8
|
+
<div id="search-help" class="search-help">
|
9
|
+
<%# strange id is to avoid clash with search input id #%>
|
10
|
+
<h1 id="how-to-search">Search</h1>
|
11
|
+
|
12
|
+
<p class="govuk-body search-help__no-js">
|
13
|
+
You need to turn on JavaScript in your browser to search this site. You can either:
|
14
|
+
|
15
|
+
<ul>
|
16
|
+
<li>turn on JavaScript in your browser</li>
|
17
|
+
<li>search this site using Google</li>
|
18
|
+
</ul>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p class="govuk-body">
|
22
|
+
Enter a search term in the search box, then select the search button.
|
23
|
+
</p>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div id="search-results" class="search-results" hidden aria-labelledby="search-results-title">
|
27
|
+
<div class="search-results__inner">
|
28
|
+
<h1 id="search-results-title" class="search-results__title" aria-live="assertive">Results</h1>
|
29
|
+
<div class="search-results__content"></div>
|
30
|
+
</div>
|
31
|
+
</div>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_tech_docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Government Digital Service
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autoprefixer-rails
|
@@ -279,7 +279,6 @@ files:
|
|
279
279
|
- ".ruby-version"
|
280
280
|
- ".travis.yml"
|
281
281
|
- CHANGELOG.md
|
282
|
-
- CONTRIBUTING.md
|
283
282
|
- Gemfile
|
284
283
|
- LICENCE
|
285
284
|
- README.md
|
@@ -309,6 +308,7 @@ files:
|
|
309
308
|
- example/source/not-expired-page.html.md
|
310
309
|
- example/source/pets.yml
|
311
310
|
- example/source/prevent-index-page.html.md
|
311
|
+
- example/source/single-page-nav.html.md
|
312
312
|
- example/source/stylesheets/print.css.scss
|
313
313
|
- example/source/stylesheets/screen-old-ie.css.scss
|
314
314
|
- example/source/stylesheets/screen.css.scss
|
@@ -387,6 +387,7 @@ files:
|
|
387
387
|
- lib/source/layouts/_search.erb
|
388
388
|
- lib/source/layouts/core.erb
|
389
389
|
- lib/source/layouts/layout.erb
|
390
|
+
- lib/source/search/index.html.erb
|
390
391
|
- lib/source/stylesheets/manifest.css
|
391
392
|
- node_modules/govuk-frontend/govuk/_base.scss
|
392
393
|
- node_modules/govuk-frontend/govuk/all-ie8.scss
|
data/CONTRIBUTING.md
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
## Contributing to this project
|
2
|
-
|
3
|
-
Everybody who uses this project is encouraged to contribute to this project. If you're part of the [alphagov GitHub organisation](https://www.github.com/alphagov) you probably have write access to this repo. If you don't, ask a GitHub admin or #tech-docs-format on Slack.
|
4
|
-
|
5
|
-
- Before adding your feature, [check the backlog to see if someone is already talking about it](https://github.com/alphagov/tech-docs-template/issues)
|
6
|
-
- If you add a new option to `config/tech-docs.yml`, make sure you [document the new configuration option][configuration]
|
7
|
-
- If you add a new option to the page frontmatter, make sure you [document the new frontmatter configuration](docs/frontmatter.md)
|
8
|
-
- You can test your contribution using [unit tests](spec/govuk_tech_docs), [javascript tests](spec/javascripts) or [integration tests](spec/features)
|
9
|
-
- If your change is relevant to the users of the gem, add something to [CHANGELOG](CHANGELOG.md). You don't have to do this if it's just refactoring. Make sure that you include any upgrade instructions.
|
10
|
-
|
11
|
-
[configuration]: https://github.com/alphagov/tdt-documentation/blob/master/source/amend_project/configuration/index.html.md.erb
|
12
|
-
[frontmatter]: https://github.com/alphagov/tdt-documentation/blob/master/source/frontmatter.html.md.erb
|