govuk_tech_docs 2.4.0 → 3.0.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/.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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbe80b6133cdaf41e2ab339250489d0a8c72f86cc88dc89f7e51c2340306a4c9
|
|
4
|
+
data.tar.gz: f79167cb25923c99056e776a289dfa7124643c251b19633e2f01b7995d04df2a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a32ec9f65bf6a326b7300575fd101a36663a982160b81462b0b57854ecd13b8a3fa9116cc93a4702f4bd0fcfb04480a1d787f61522b23a974cd7878250a86086
|
|
7
|
+
data.tar.gz: a978877e74111d7055b07682d32dc8e09c5e5aa972e6e143c144a3261a734b57b8257273e7afd3f850d657fd87d9b35744bfa87283a88450c3ca2eb7b1b0c33a
|
data/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
14
|
data/.travis.yml
CHANGED
|
@@ -13,7 +13,7 @@ deploy:
|
|
|
13
13
|
provider: rubygems
|
|
14
14
|
gem: govuk_tech_docs
|
|
15
15
|
api_key:
|
|
16
|
-
secure:
|
|
16
|
+
secure: "pFaDlf2VfJAv/EwTFQTdHQFlFRLxtNnipcJyFG0Dvn7itvETKzs5+91gnXQAJuUzGBgXSidHgMkmPTsmWM4k2wbOcHopir9ThSKf0OUtI6o/5GqCU92BpLNJ/Ykhf+wyz9ai6HWX+HN5KRDqpeiuwhraiQjy/tg6lwsauBU8sB80wvUgYYM6oXijHfVwPUkXdhqYTIj20S0M868yYGtf4IInHds8M85TSNor79TFvRd0SFLO7cS+bftqxnNo1mYuBzVXls3POjq59WX+yG8+vS9Sr/tHHuKxw1nho95Fnjf8RYzdxD45osCrXAu3JIbWyJjF6AmQd87zILhdl8n0KNf4tbpFVM+SXVUjMZ2ERvcS1v+nBybVzU3uPwskGZNfWMtCOS401yRF3A21xzNoS916gZrTUSvHjsMcNhzJAZCsEx6MGFVTMzfe5slfWQCPk8k9wBHjyUyC7dl0h5g9qo3jTDnafcpQdnWGOSGgwCxgTaYT1NFfV3M5YpdGevorkOnE6EmWtU67mdtjzRyVvMWc8obqBWdyYnxqrBYKnHDeu/LhtJq3Gvqt/IExwAI8Q1Q7j296hzfmYMcgnETctLNZWoIa4sESDDVMlspcZKqCsrxytDeBFm/yMqVp12S7cjoQbt+fItTl3Bh3BP56j+3fqJlFvTPX4FIKUaaRLy0="
|
|
17
17
|
on:
|
|
18
18
|
repo: alphagov/tech-docs-gem
|
|
19
19
|
branch: master
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 3.0.0
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
The search user experience is now more accessible for screenreader users. Search results are now on a separate page instead of a modal window.
|
|
10
|
+
|
|
11
|
+
Users can no longer see search results as they type. They must press the Return key or select the search button to see the search results page.
|
|
12
|
+
|
|
13
|
+
This was added in [pull request #263: Change search to only show results after submit](https://github.com/alphagov/tech-docs-gem/pull/263).
|
|
14
|
+
|
|
15
|
+
### Fixes
|
|
16
|
+
|
|
17
|
+
- [#265: Fix mark styles in Windows High Contrast Mode](https://github.com/alphagov/tech-docs-gem/pull/265)
|
|
18
|
+
|
|
19
|
+
## 2.4.3
|
|
20
|
+
|
|
21
|
+
- [#236: Fix search 'autocomplete' behaviour](https://github.com/alphagov/tech-docs-gem/pull/236)
|
|
22
|
+
- [#203: Update vendored javascripts](https://github.com/alphagov/tech-docs-gem/pull/203)
|
|
23
|
+
|
|
24
|
+
## 2.4.2
|
|
25
|
+
|
|
26
|
+
- [#251 Fix missing `<ul>` in single page navigation](https://github.com/alphagov/tech-docs-gem/pull/251)
|
|
27
|
+
|
|
28
|
+
## 2.4.1
|
|
29
|
+
|
|
30
|
+
- [#248: Remove IE8 fallback PNG with broken image reference](https://github.com/alphagov/tech-docs-gem/pull/248)
|
|
31
|
+
|
|
5
32
|
## 2.4.0
|
|
6
33
|
|
|
7
34
|
- [Bump redcarpet to 3.5.1 to fix CVE-2020-26298](https://github.com/alphagov/tech-docs-gem/pull/226)
|
data/README.md
CHANGED
|
@@ -9,7 +9,7 @@ To find out more about setting up and managing content for a website using this
|
|
|
9
9
|
|
|
10
10
|
Everybody who uses this project is encouraged to contribute.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Find out how to [contribute](https://tdt-documentation.london.cloudapps.digital/support/#contribute).
|
|
13
13
|
|
|
14
14
|
## GOV.UK frontend
|
|
15
15
|
|
|
@@ -34,6 +34,8 @@ gem 'govuk_tech_docs', path: '../tech-docs-gem'
|
|
|
34
34
|
|
|
35
35
|
To preview your documentation changes locally, see the [Tech Docs Template documentation on previewing your documentation](https://tdt-documentation.london.cloudapps.digital/create_project/preview/#preview-your-documentation).
|
|
36
36
|
|
|
37
|
+
If you experience [the FFI gem issue for Mojave users](https://github.com/alphagov/tech-docs-gem/issues/254), you should refer to this [list of possible fixes](#issue-with-ffi-on-osx-mohave).
|
|
38
|
+
|
|
37
39
|
### Use the example in this repo
|
|
38
40
|
|
|
39
41
|
To start the example in this repo, run:
|
|
@@ -46,6 +48,8 @@ bundle exec middleman server
|
|
|
46
48
|
|
|
47
49
|
See your website on `http://localhost:4567` in your browser.
|
|
48
50
|
|
|
51
|
+
If you experience [the FFI gem issue for Mojave users](https://github.com/alphagov/tech-docs-gem/issues/254), you should refer to this [list of possible fixes](#issue-with-ffi-on-osx-mohave).
|
|
52
|
+
|
|
49
53
|
For more information on previewing your documentation locally, see the [Tech Docs template documentation on previewing your documentation](https://tdt-documentation.london.cloudapps.digital/create_project/preview/#preview-your-documentation).
|
|
50
54
|
|
|
51
55
|
## Tests
|
|
@@ -63,6 +67,16 @@ To run the tests and see the results in your terminal, run:
|
|
|
63
67
|
bundle exec rake jasmine:ci
|
|
64
68
|
```
|
|
65
69
|
|
|
70
|
+
## Issue with FFI on OSX Mojave
|
|
71
|
+
|
|
72
|
+
Users on OSX Mojave (10.14) may get this error when running `bundle exec middleman serve` on apps that use this gem.
|
|
73
|
+
|
|
74
|
+
There are 3 possible ways to solve this. From best to worst, you can:
|
|
75
|
+
|
|
76
|
+
* upgrade to macOS 10.15 (Catalina) or higher
|
|
77
|
+
* tell rubygems not to use the system ffi by running `gem install ffi -- --disable-system-libffi` in the command line when the error shows
|
|
78
|
+
* pin the ffi version back to 1.12.2 by editing the Gemfile of your app
|
|
79
|
+
|
|
66
80
|
## Releasing new versions
|
|
67
81
|
|
|
68
82
|
To release a new version, create a new pull request (PR) that updates [version.rb](lib/govuk_tech_docs/version.rb) and [CHANGELOG.md](CHANGELOG.md).
|
|
@@ -6,35 +6,48 @@
|
|
|
6
6
|
Modules.Search = function Search () {
|
|
7
7
|
var s = this
|
|
8
8
|
var $html = $('html')
|
|
9
|
-
var $tocNav
|
|
10
9
|
var $searchForm
|
|
11
10
|
var $searchLabel
|
|
12
11
|
var $searchInput
|
|
13
12
|
var $searchResults
|
|
14
13
|
var $searchResultsTitle
|
|
15
14
|
var $searchResultsWrapper
|
|
16
|
-
var $
|
|
15
|
+
var $searchHelp
|
|
17
16
|
var results
|
|
18
17
|
var query
|
|
19
|
-
var queryTimer
|
|
20
18
|
var maxSearchEntries = 20
|
|
21
19
|
|
|
22
20
|
this.start = function start ($element) {
|
|
23
21
|
$searchForm = $element.find('form')
|
|
24
22
|
$searchInput = $element.find('#search')
|
|
25
23
|
$searchLabel = $element.find('.search__label')
|
|
26
|
-
$searchResultsWrapper = $
|
|
24
|
+
$searchResultsWrapper = $('#search-results')
|
|
27
25
|
$searchResults = $searchResultsWrapper.find('.search-results__content')
|
|
28
26
|
$searchResultsTitle = $searchResultsWrapper.find('.search-results__title')
|
|
29
|
-
$
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
attach()
|
|
27
|
+
$searchHelp = $('#search-help')
|
|
28
|
+
|
|
29
|
+
changeSearchAction()
|
|
33
30
|
changeSearchLabel()
|
|
31
|
+
|
|
32
|
+
// Only do searches on the search page
|
|
33
|
+
if (s.isOnSearchPage()) {
|
|
34
|
+
s.downloadSearchIndex()
|
|
35
|
+
$html.addClass('has-search-results-open')
|
|
36
|
+
|
|
37
|
+
if (window.location.search) {
|
|
38
|
+
query = s.getQuery()
|
|
39
|
+
if (query) {
|
|
40
|
+
$searchInput.val(query)
|
|
41
|
+
doSearch(query)
|
|
42
|
+
doAnalytics()
|
|
43
|
+
document.title = query + ' - ' + document.title
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
this.downloadSearchIndex = function downloadSearchIndex () {
|
|
37
|
-
updateTitle('Loading search
|
|
50
|
+
updateTitle('Loading search results')
|
|
38
51
|
$.ajax({
|
|
39
52
|
url: '/search.json',
|
|
40
53
|
cache: true,
|
|
@@ -48,46 +61,45 @@
|
|
|
48
61
|
})
|
|
49
62
|
}
|
|
50
63
|
|
|
51
|
-
function
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
renderResults(query)
|
|
59
|
-
updateTitle()
|
|
60
|
-
})
|
|
61
|
-
if (window.ga) {
|
|
62
|
-
window.clearTimeout(queryTimer)
|
|
63
|
-
queryTimer = window.setTimeout(sendQueryToAnalytics, 1000)
|
|
64
|
-
}
|
|
65
|
-
})
|
|
64
|
+
function changeSearchAction () {
|
|
65
|
+
// We need JavaScript to do search, so if JS is not available the search
|
|
66
|
+
// input sends the query string to Google. This JS function changes the
|
|
67
|
+
// input to instead send it to the search page.
|
|
68
|
+
$searchForm.prop('action', '/search')
|
|
69
|
+
$searchForm.find('input[name="as_sitesearch"]').remove()
|
|
70
|
+
}
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
e.preventDefault()
|
|
71
|
-
showResults()
|
|
72
|
-
var $firstResult = $searchResults.find('.search-result__title a').first()
|
|
73
|
-
if ($firstResult.length) {
|
|
74
|
-
$firstResult.focus()
|
|
75
|
-
} else {
|
|
76
|
-
// if there are no results, show the "0 results" state
|
|
77
|
-
results = []
|
|
78
|
-
updateTitle()
|
|
79
|
-
}
|
|
80
|
-
})
|
|
72
|
+
function changeSearchLabel () {
|
|
73
|
+
$searchLabel.text('Search this documentation')
|
|
74
|
+
}
|
|
81
75
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
this.isOnSearchPage = function isOnSearchPage () {
|
|
77
|
+
return Boolean(window.location.pathname.match(/\/search(\/|\/index.html)?$/))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.getQuery = function getQuery () {
|
|
81
|
+
var query = decodeURIComponent(
|
|
82
|
+
window.location.search
|
|
83
|
+
.match(/q=([^&]*)/)[1]
|
|
84
|
+
.replace(/\+/g, ' ')
|
|
85
|
+
)
|
|
86
|
+
return query
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function doSearch (query) {
|
|
90
|
+
s.search(query, function (r) {
|
|
91
|
+
results = r
|
|
92
|
+
renderResults(query)
|
|
93
|
+
updateTitle()
|
|
87
94
|
})
|
|
95
|
+
}
|
|
88
96
|
|
|
89
|
-
|
|
97
|
+
// TODO: remove this and sendQueryToAnalytics in a future breaking release
|
|
98
|
+
function doAnalytics () {
|
|
90
99
|
if (window.ga) {
|
|
100
|
+
sendQueryToAnalytics()
|
|
101
|
+
|
|
102
|
+
// Attach analytics events to search result clicks
|
|
91
103
|
$searchResults.on('click', '.search-result__title a', function () {
|
|
92
104
|
var href = $(this).attr('href')
|
|
93
105
|
ga('send', {
|
|
@@ -99,15 +111,6 @@
|
|
|
99
111
|
})
|
|
100
112
|
})
|
|
101
113
|
}
|
|
102
|
-
|
|
103
|
-
// When selecting navigation link, close the search results.
|
|
104
|
-
$('#toc').on('click', 'a', function (e) {
|
|
105
|
-
hideResults()
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function changeSearchLabel () {
|
|
110
|
-
$searchLabel.text('Search this documentation')
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
function getResults (query) {
|
|
@@ -122,7 +125,6 @@
|
|
|
122
125
|
|
|
123
126
|
this.search = function search (query, callback) {
|
|
124
127
|
if (query === '') {
|
|
125
|
-
hideResults()
|
|
126
128
|
return
|
|
127
129
|
}
|
|
128
130
|
showResults()
|
|
@@ -192,23 +194,14 @@
|
|
|
192
194
|
function updateTitle (text) {
|
|
193
195
|
if (typeof text === 'undefined') {
|
|
194
196
|
var count = results.length
|
|
195
|
-
var resultsText = count + ' results'
|
|
197
|
+
var resultsText = 'Search - ' + query + ' - ' + count + ' results'
|
|
196
198
|
}
|
|
197
199
|
$searchResultsTitle.text(text || resultsText)
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
function showResults () {
|
|
201
|
-
$searchResultsWrapper.
|
|
202
|
-
|
|
203
|
-
$html.addClass('has-search-results-open')
|
|
204
|
-
$tocNav.addClass('search-results-open')
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function hideResults () {
|
|
208
|
-
$searchResultsWrapper.removeClass('is-open')
|
|
209
|
-
.attr('aria-hidden', 'true')
|
|
210
|
-
$html.removeClass('has-search-results-open')
|
|
211
|
-
$tocNav.removeClass('search-results-open')
|
|
203
|
+
$searchResultsWrapper.removeAttr('hidden')
|
|
204
|
+
$searchHelp.attr('hidden', 'true')
|
|
212
205
|
}
|
|
213
206
|
|
|
214
207
|
function sendQueryToAnalytics () {
|