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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67ad7c3f867522ea35890520f14663c8e12dfd48506cdc8d59cb1f74c7d263be
4
- data.tar.gz: 10976db4f9c215001924964cde8aa82ed900eb205af720fc6ee1930ce3f34383
3
+ metadata.gz: dbe80b6133cdaf41e2ab339250489d0a8c72f86cc88dc89f7e51c2340306a4c9
4
+ data.tar.gz: f79167cb25923c99056e776a289dfa7124643c251b19633e2f01b7995d04df2a
5
5
  SHA512:
6
- metadata.gz: ffd8c3389b4042b84f468823674df37c04eaae5a6c031b85d0200327a33ebd7a864e97e22a95d5c3ebb46ae4360b3ddc25cfefd940e2bb1e1f69ff1332fc744a
7
- data.tar.gz: dc1402bf0283a38361f77691e45a09c861cca5430ba9cdc9a270e84718a027c57877a056c36a2a11902ee30c3d199805a6db466a31ea73ba8d953706cd1d29ca
6
+ metadata.gz: a32ec9f65bf6a326b7300575fd101a36663a982160b81462b0b57854ecd13b8a3fa9116cc93a4702f4bd0fcfb04480a1d787f61522b23a974cd7878250a86086
7
+ data.tar.gz: a978877e74111d7055b07682d32dc8e09c5e5aa972e6e143c144a3261a734b57b8257273e7afd3f850d657fd87d9b35744bfa87283a88450c3ca2eb7b1b0c33a
data/.nvmrc CHANGED
@@ -1 +1 @@
1
- 10
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: CY9C+IUqUeYWqXSyQgfF5swdYw1rRtYi0ai1xasD3R5rwARF6Qr8CnmdSBjfT2S84fXQiMza45Jto4w1jiy3o4wpxuKN68xEB7J4W/YEpFcZectzsmXwcMJH+DXh720KFIX2xiHaG5N0nWzAoV+6zgw6Vq24IXYE33wO6BgCmTe3vtO+Apg0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wAI8Q1Q7j296hzfmYMcgnETctLNZWoIa4sESDDVMlspcZKqCsrxytDeBFm/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
- You can find out more about contributing to this project from the[CONTRIBUTING.md file](CONTRIBUTING.md).
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).
@@ -13,6 +13,7 @@ header_links:
13
13
  Expired page: /expired-page.html
14
14
  Expired with owner: /expired-page-with-owner.html
15
15
  Not expired page: /not-expired-page.html
16
+ Single page nav: /single-page-nav.html
16
17
 
17
18
  footer_links:
18
19
  Accessibility: /hidden-page.html
@@ -0,0 +1,13 @@
1
+ ---
2
+ layout: layout
3
+ multipage_nav: false
4
+ hide_in_navigation: true
5
+ ---
6
+
7
+ # A page that does not use multi-page navigation
8
+
9
+ ## A subheader
10
+
11
+ ### A h3 subheader
12
+
13
+ ## Another subheader
@@ -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 $searchResultsClose
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 = $element.find('.search-results')
24
+ $searchResultsWrapper = $('#search-results')
27
25
  $searchResults = $searchResultsWrapper.find('.search-results__content')
28
26
  $searchResultsTitle = $searchResultsWrapper.find('.search-results__title')
29
- $searchResultsClose = $searchResultsWrapper.find('.search-results__close')
30
- $tocNav = $('#toc')
31
- s.downloadSearchIndex()
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 index')
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 attach () {
52
- // Search functionality on search text input
53
- $searchInput.on('input', function (e) {
54
- e.preventDefault()
55
- query = $(this).val()
56
- s.search(query, function (r) {
57
- results = r
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
- // Set focus on the first search result instead of submiting the search
68
- // form to Google
69
- $searchForm.on('submit', function (e) {
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
- // Closing the search results, move focus back to the search input
83
- $searchResultsClose.on('click', function (e) {
84
- e.preventDefault()
85
- $searchInput.focus()
86
- hideResults()
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
- // Attach analytics events to search result clicks
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.addClass('is-open')
202
- .attr('aria-hidden', 'false')
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 () {
@@ -69,7 +69,6 @@
69
69
 
70
70
  function closeNavigation () {
71
71
  $html.removeClass('toc-open')
72
- $html.removeClass('has-search-results-open')
73
72
 
74
73
  toggleBackgroundVisiblity(true)
75
74
  updateAriaAttributes()