govuk_tech_docs 3.0.1 → 3.2.1
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/CHANGELOG.md +25 -0
- data/example/source/code.html.md +3 -26
- data/lib/assets/javascripts/_modules/collapsible-navigation.js +13 -7
- data/lib/assets/javascripts/_modules/in-page-navigation.js +9 -4
- data/lib/assets/javascripts/_modules/search.js +11 -7
- data/lib/assets/stylesheets/_govuk_tech_docs.scss +1 -1
- data/lib/assets/stylesheets/modules/_anchored-heading.scss +2 -2
- data/lib/assets/stylesheets/modules/_search.scss +2 -2
- data/lib/assets/stylesheets/modules/_toc.scss +4 -4
- data/lib/govuk_tech_docs/pages.rb +4 -2
- data/lib/govuk_tech_docs/path_helpers.rb +30 -0
- data/lib/govuk_tech_docs/table_of_contents/helpers.rb +7 -7
- data/lib/govuk_tech_docs/tech_docs_html_renderer.rb +3 -3
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/govuk_tech_docs.rb +1 -0
- data/lib/source/api/pages.json.erb +1 -1
- data/lib/source/layouts/_header.erb +3 -3
- data/lib/source/layouts/_search.erb +1 -1
- data/lib/source/layouts/core.erb +1 -1
- data/node_modules/govuk-frontend/govuk/all.js +272 -75
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +275 -98
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +169 -65
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +3 -4
- data/node_modules/govuk-frontend/govuk/components/button/button.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +3 -3
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +14 -0
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +8 -10
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/details/_index.scss +2 -1
- data/node_modules/govuk-frontend/govuk/components/details/details.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +1 -0
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +1 -0
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +6 -37
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +10 -4
- data/node_modules/govuk-frontend/govuk/components/header/header.js +4 -4
- data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +1 -3
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +499 -2
- data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +13 -1
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +14 -0
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +4 -4
- data/node_modules/govuk-frontend/govuk/components/select/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +13 -0
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1108 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +15 -23
- data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +2 -2
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +2 -2
- data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +0 -5
- data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/core/_all.scss +0 -1
- data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_links.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_lists.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_section-break.scss +0 -6
- data/node_modules/govuk-frontend/govuk/core/_typography.scss +0 -6
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +22 -4
- data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +15 -30
- data/node_modules/govuk-frontend/govuk/{core → objects}/_template.scss +1 -5
- data/node_modules/govuk-frontend/govuk/overrides/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/overrides/_display.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_text-align.scss +14 -0
- data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +0 -6
- data/node_modules/govuk-frontend/govuk/overrides/_width.scss +0 -6
- data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
- data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +0 -10
- data/node_modules/govuk-frontend/govuk/tools/_all.scss +0 -1
- data/package-lock.json +3 -3
- data/package.json +1 -1
- metadata +9 -7
- data/node_modules/govuk-frontend/govuk/tools/_iff.scss +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79d38e9facb7df0c0a08151b51ce448759efa6e61bcf8ec0c5e6efb0b4e92332
|
4
|
+
data.tar.gz: 0a47d960ef878bf334104c7f0ff3e3e07e0411e3b12d061dc72ca4c474c988a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a6e9076fc8b8a6ade8cca61c139256b6f8a455e851c64e68132ee25e9ec0fe09876e3cfb1bf813297779d376e91ac0f1abd49cd30319944249c6fff4117c902
|
7
|
+
data.tar.gz: 98748cf227f452712eb2ffcd780d89a7b56b9beed437f0a775adb1eba81a0acfca7de59c89db7437484a8f8e9e63a1e71c513475f1f55affc8ff48b5da2fe64a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 3.2.1
|
6
|
+
|
7
|
+
### Fixes
|
8
|
+
|
9
|
+
- [#296: Fix Nokogiri Node.new deprecation warnings](https://github.com/alphagov/tech-docs-gem/pull/296) (thanks [@timja](https://github.com/timja))
|
10
|
+
|
11
|
+
## 3.2.0
|
12
|
+
|
13
|
+
### New features
|
14
|
+
|
15
|
+
You can now [configure your Tech Docs Template (TDT) to build your documentation site to use relative links to pages and assets](https://tdt-documentation.london.cloudapps.digital/configure_project/global_configuration/#build-your-site-using-relative-links).
|
16
|
+
|
17
|
+
Thanks [@eddgrant](https://github.com/eddgrant) for contributing this feature and the associated fixes.
|
18
|
+
|
19
|
+
This change was introduced in [pull request #291: Support sites deployed on paths other than "/" (by generating relative links)](https://github.com/alphagov/tech-docs-gem/pull/291).
|
20
|
+
|
21
|
+
## 3.1.0
|
22
|
+
|
23
|
+
### New features
|
24
|
+
|
25
|
+
There are some steps you should follow as the Technical Documentation Template (TDT) now uses GOV.UK Frontend 4.0.0.
|
26
|
+
|
27
|
+
1. Update your documentation site to use the latest template version. You can [follow the TDT guidance on using the latest template version](https://tdt-documentation.london.cloudapps.digital/maintain_project/use_latest_template/).
|
28
|
+
2. Check your documentation site displays correctly. If your site does not display correctly, you can refer to the [GOV.UK Frontend 4.0.0 release note](https://github.com/alphagov/govuk-frontend/releases/tag/v4.0.0) for more information.
|
29
|
+
|
5
30
|
## 3.0.1
|
6
31
|
|
7
32
|
### Fixes
|
data/example/source/code.html.md
CHANGED
@@ -10,32 +10,9 @@ A paragraph with a `code` element within it.
|
|
10
10
|
|
11
11
|
An example of a table with a `code` element within it.
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<tr>
|
17
|
-
<th style="text-align:left">httpResult</th>
|
18
|
-
<th style="text-align:left">Message</th>
|
19
|
-
<th style="text-align:left">How to fix</th>
|
20
|
-
</tr>
|
21
|
-
</thead>
|
22
|
-
<tbody>
|
23
|
-
<tr>
|
24
|
-
<td style="text-align:left"><code>400</code></td>
|
25
|
-
<td style="text-align:left">
|
26
|
-
<code>[{</code>
|
27
|
-
<br />
|
28
|
-
<code>"error": "BadRequestError",</code>
|
29
|
-
<br />
|
30
|
-
<code>"message": "Can't send to this recipient using a team-only API key"</code>
|
31
|
-
<br />
|
32
|
-
<code>]}</code>
|
33
|
-
</td>
|
34
|
-
<td style="text-align:left">Use the correct type of API key</td>
|
35
|
-
</tr>
|
36
|
-
</tbody>
|
37
|
-
</table>
|
38
|
-
</div>
|
13
|
+
| httpResult | Message | How to fix |
|
14
|
+
| - | - | - |
|
15
|
+
| `400` | `[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}` | Use the correct type of API key |
|
39
16
|
|
40
17
|
An example of a code block with a long line length
|
41
18
|
|
@@ -57,25 +57,31 @@
|
|
57
57
|
$toggleLabel.text(setOpen ? 'Collapse ' + $heading.text() : 'Expand ' + $heading.text())
|
58
58
|
}
|
59
59
|
|
60
|
+
/**
|
61
|
+
* Returns an absolute pathname to $target by combining it with window.location.href
|
62
|
+
* @param $target The target whose pathname to return. This may be an anchor with an absolute or relative href.
|
63
|
+
* @returns {string} The absolute pathname of $target
|
64
|
+
*/
|
65
|
+
function getAbsolutePath ($target) {
|
66
|
+
return new URL($target.attr('href'), window.location.href).pathname
|
67
|
+
}
|
68
|
+
|
60
69
|
function openActiveHeading () {
|
61
70
|
var $activeElement
|
62
71
|
var currentPath = window.location.pathname
|
63
|
-
var isActiveTrail = '[href*="' + currentPath + '"]'
|
64
|
-
// Add an exception for the root page, as every href includes /
|
65
|
-
if (currentPath === '/') {
|
66
|
-
isActiveTrail = '[href="' + currentPath + window.location.hash + '"]'
|
67
|
-
}
|
68
72
|
for (var i = $topLevelItems.length - 1; i >= 0; i--) {
|
69
73
|
var $element = $($topLevelItems[i])
|
70
74
|
var $heading = $element.find('> a')
|
71
75
|
// Check if this item href matches
|
72
|
-
if ($heading
|
76
|
+
if (getAbsolutePath($heading) === currentPath) {
|
73
77
|
$activeElement = $element
|
74
78
|
break
|
75
79
|
}
|
76
80
|
// Otherwise check the children
|
77
81
|
var $children = $element.find('li > a')
|
78
|
-
var $matchingChildren = $children.filter(
|
82
|
+
var $matchingChildren = $children.filter(function (_) {
|
83
|
+
return getAbsolutePath($(this)) === currentPath
|
84
|
+
})
|
79
85
|
if ($matchingChildren.length) {
|
80
86
|
$activeElement = $element
|
81
87
|
break
|
@@ -70,13 +70,18 @@
|
|
70
70
|
function highlightActiveItemInToc (fragment) {
|
71
71
|
// Navigation items for single page navigation don't necessarily include the path name, but
|
72
72
|
// navigation items for multipage navigation items do include it. This checks for either case.
|
73
|
-
var $activeTocItem = $tocItems.filter(
|
74
|
-
'
|
75
|
-
|
73
|
+
var $activeTocItem = $tocItems.filter(function (_) {
|
74
|
+
var url = new URL($(this).attr('href'), window.location.href)
|
75
|
+
return url.href === window.location.href
|
76
|
+
})
|
77
|
+
|
76
78
|
// Navigation items with children don't contain fragments in their url
|
77
79
|
// Check to see if any nav items contain just the path name.
|
78
80
|
if (!$activeTocItem.get(0)) {
|
79
|
-
$activeTocItem = $tocItems.filter(
|
81
|
+
$activeTocItem = $tocItems.filter(function (_) {
|
82
|
+
var url = new URL($(this).attr('href'), window.location.href)
|
83
|
+
return url.hash === '' && url.pathname === window.location.pathname
|
84
|
+
})
|
80
85
|
}
|
81
86
|
if ($activeTocItem.get(0)) {
|
82
87
|
$tocItems.removeClass('toc-link--in-view')
|
@@ -16,6 +16,7 @@
|
|
16
16
|
var results
|
17
17
|
var query
|
18
18
|
var maxSearchEntries = 20
|
19
|
+
var pathToSiteRoot
|
19
20
|
|
20
21
|
this.start = function start ($element) {
|
21
22
|
$searchForm = $element.find('form')
|
@@ -25,6 +26,7 @@
|
|
25
26
|
$searchResults = $searchResultsWrapper.find('.search-results__content')
|
26
27
|
$searchResultsTitle = $searchResultsWrapper.find('.search-results__title')
|
27
28
|
$searchHelp = $('#search-help')
|
29
|
+
pathToSiteRoot = $element.data('pathToSiteRoot')
|
28
30
|
|
29
31
|
changeSearchAction()
|
30
32
|
changeSearchLabel()
|
@@ -38,7 +40,7 @@
|
|
38
40
|
query = s.getQuery()
|
39
41
|
if (query) {
|
40
42
|
$searchInput.val(query)
|
41
|
-
doSearch(query)
|
43
|
+
doSearch(query, pathToSiteRoot)
|
42
44
|
doAnalytics()
|
43
45
|
document.title = query + ' - ' + document.title
|
44
46
|
}
|
@@ -49,7 +51,7 @@
|
|
49
51
|
this.downloadSearchIndex = function downloadSearchIndex () {
|
50
52
|
updateTitle('Loading search results')
|
51
53
|
$.ajax({
|
52
|
-
url: '
|
54
|
+
url: pathToSiteRoot + 'search.json',
|
53
55
|
cache: true,
|
54
56
|
method: 'GET',
|
55
57
|
success: function (data) {
|
@@ -65,7 +67,7 @@
|
|
65
67
|
// We need JavaScript to do search, so if JS is not available the search
|
66
68
|
// input sends the query string to Google. This JS function changes the
|
67
69
|
// input to instead send it to the search page.
|
68
|
-
$searchForm.prop('action', '/
|
70
|
+
$searchForm.prop('action', pathToSiteRoot + 'search/index.html')
|
69
71
|
$searchForm.find('input[name="as_sitesearch"]').remove()
|
70
72
|
}
|
71
73
|
|
@@ -86,10 +88,10 @@
|
|
86
88
|
return query
|
87
89
|
}
|
88
90
|
|
89
|
-
function doSearch (query) {
|
91
|
+
function doSearch (query, pathToSiteRoot) {
|
90
92
|
s.search(query, function (r) {
|
91
93
|
results = r
|
92
|
-
renderResults(query)
|
94
|
+
renderResults(query, pathToSiteRoot)
|
93
95
|
updateTitle()
|
94
96
|
})
|
95
97
|
}
|
@@ -138,7 +140,7 @@
|
|
138
140
|
callback(getResults(query))
|
139
141
|
}
|
140
142
|
|
141
|
-
function renderResults (query) {
|
143
|
+
function renderResults (query, pathToSiteRoot) {
|
142
144
|
var output = ''
|
143
145
|
if (results.length === 0) {
|
144
146
|
output += '<p>Nothing found</p>'
|
@@ -149,7 +151,9 @@
|
|
149
151
|
var content = s.processContent(result.content, query)
|
150
152
|
output += '<li class="search-result">'
|
151
153
|
output += '<h3 class="search-result__title">'
|
152
|
-
|
154
|
+
var pagePathWithoutLeadingSlash = result.url.startsWith('/') ? result.url.slice(1) : result.url
|
155
|
+
var url = pathToSiteRoot.startsWith('.') ? pathToSiteRoot + pagePathWithoutLeadingSlash : '/' + pagePathWithoutLeadingSlash
|
156
|
+
output += '<a href="' + url + '">'
|
153
157
|
output += result.title
|
154
158
|
output += '</a>'
|
155
159
|
output += '</h3>'
|
@@ -18,12 +18,12 @@
|
|
18
18
|
text-decoration: none;
|
19
19
|
text-indent: -9999em;
|
20
20
|
|
21
|
-
background-image: url('/images/anchored-heading-icon.png');
|
21
|
+
background-image: image-url('/images/anchored-heading-icon.png');
|
22
22
|
background-repeat: no-repeat;
|
23
23
|
background-position: center center;
|
24
24
|
|
25
25
|
@include govuk-device-pixel-ratio {
|
26
|
-
background-image: url('/images/anchored-heading-icon-2x.png');
|
26
|
+
background-image: image-url('/images/anchored-heading-icon-2x.png');
|
27
27
|
background-size: $icon-width $icon-height;
|
28
28
|
}
|
29
29
|
|
@@ -36,7 +36,7 @@ $input-size: 40px;
|
|
36
36
|
padding: 0;
|
37
37
|
width: $input-size;
|
38
38
|
height: 100%;
|
39
|
-
background-image: url('/images/search-button.png');
|
39
|
+
background-image: image-url('/images/search-button.png');
|
40
40
|
background-repeat: no-repeat;
|
41
41
|
background-position: 2px 50%;
|
42
42
|
text-indent: -5000px;
|
@@ -104,7 +104,7 @@ $input-size: 40px;
|
|
104
104
|
left: -9px;
|
105
105
|
width: 10px;
|
106
106
|
height: 20px;
|
107
|
-
background: no-repeat url('/images/search-result-caret.svg') center right;
|
107
|
+
background: no-repeat image-url('/images/search-result-caret.svg') center right;
|
108
108
|
background-size: contain;
|
109
109
|
}
|
110
110
|
}
|
@@ -152,12 +152,12 @@
|
|
152
152
|
height: 20px;
|
153
153
|
float: right;
|
154
154
|
|
155
|
-
background-image: url('/images/govuk-icn-numbered-list.png');
|
155
|
+
background-image: image-url('/images/govuk-icn-numbered-list.png');
|
156
156
|
background-repeat: no-repeat;
|
157
157
|
background-position: left center;
|
158
158
|
|
159
159
|
@include govuk-device-pixel-ratio {
|
160
|
-
background-image: url('/images/govuk-icn-numbered-list@2x.png');
|
160
|
+
background-image: image-url('/images/govuk-icn-numbered-list@2x.png');
|
161
161
|
background-size: 20px 20px;
|
162
162
|
}
|
163
163
|
}
|
@@ -178,12 +178,12 @@
|
|
178
178
|
height: 20px;
|
179
179
|
cursor: pointer;
|
180
180
|
|
181
|
-
background-image: url('/images/govuk-icn-close.png');
|
181
|
+
background-image: image-url('/images/govuk-icn-close.png');
|
182
182
|
background-repeat: no-repeat;
|
183
183
|
background-position: left center;
|
184
184
|
|
185
185
|
@include govuk-device-pixel-ratio {
|
186
|
-
background-image: url('/images/govuk-icn-close@2x.png');
|
186
|
+
background-image: image-url('/images/govuk-icn-close@2x.png');
|
187
187
|
background-size: 20px 20px;
|
188
188
|
}
|
189
189
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module GovukTechDocs
|
2
2
|
class Pages
|
3
|
+
include GovukTechDocs::PathHelpers
|
3
4
|
attr_reader :sitemap
|
4
5
|
|
5
|
-
def initialize(sitemap, config)
|
6
|
+
def initialize(sitemap, config, current_page)
|
6
7
|
@sitemap = sitemap
|
7
8
|
@config = config
|
9
|
+
@current_page = current_page
|
8
10
|
end
|
9
11
|
|
10
12
|
def to_json(*_args)
|
@@ -18,7 +20,7 @@ module GovukTechDocs
|
|
18
20
|
review = PageReview.new(page, @config)
|
19
21
|
{
|
20
22
|
title: page.data.title,
|
21
|
-
url:
|
23
|
+
url: get_path_to_resource(@config, page, @current_page).to_s,
|
22
24
|
review_by: review.review_by,
|
23
25
|
owner_slack: review.owner_slack,
|
24
26
|
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module GovukTechDocs
|
2
|
+
module PathHelpers
|
3
|
+
def get_path_to_resource(config, resource, current_page)
|
4
|
+
if config[:relative_links]
|
5
|
+
resource_path_segments = resource.path.split("/").reject(&:empty?)[0..-2]
|
6
|
+
resource_file_name = resource.path.split("/")[-1]
|
7
|
+
|
8
|
+
path_to_site_root = path_to_site_root config, current_page.path
|
9
|
+
resource_path = path_to_site_root + resource_path_segments
|
10
|
+
.push(resource_file_name)
|
11
|
+
.join("/")
|
12
|
+
else
|
13
|
+
resource_path = resource.url
|
14
|
+
end
|
15
|
+
resource_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def path_to_site_root(config, page_path)
|
19
|
+
if config[:relative_links]
|
20
|
+
number_of_ascents_to_site_root = page_path.to_s.split("/").reject(&:empty?)[0..-2].length
|
21
|
+
ascents = number_of_ascents_to_site_root.zero? ? ["."] : number_of_ascents_to_site_root.times.collect { ".." }
|
22
|
+
path_to_site_root = ascents.join("/").concat("/")
|
23
|
+
else
|
24
|
+
middleman_http_prefix = config[:http_prefix]
|
25
|
+
path_to_site_root = middleman_http_prefix.end_with?("/") ? middleman_http_prefix : "#{middleman_http_prefix}/"
|
26
|
+
end
|
27
|
+
path_to_site_root
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "govuk_tech_docs/path_helpers"
|
1
2
|
require "govuk_tech_docs/table_of_contents/heading_tree_builder"
|
2
3
|
require "govuk_tech_docs/table_of_contents/heading_tree_renderer"
|
3
4
|
require "govuk_tech_docs/table_of_contents/heading_tree"
|
@@ -7,6 +8,8 @@ require "govuk_tech_docs/table_of_contents/headings_builder"
|
|
7
8
|
module GovukTechDocs
|
8
9
|
module TableOfContents
|
9
10
|
module Helpers
|
11
|
+
include GovukTechDocs::PathHelpers
|
12
|
+
|
10
13
|
def single_page_table_of_contents(html, url: "", max_level: nil)
|
11
14
|
output = "<ul>\n"
|
12
15
|
output += list_items_from_headings(html, url: url, max_level: max_level)
|
@@ -48,11 +51,7 @@ module GovukTechDocs
|
|
48
51
|
|
49
52
|
# Reuse the generated content for the active page
|
50
53
|
# If we generate it twice it increments the heading ids
|
51
|
-
content =
|
52
|
-
current_page_html
|
53
|
-
else
|
54
|
-
resource.render(layout: false)
|
55
|
-
end
|
54
|
+
content = current_page.url == resource.url && current_page_html ? current_page_html : resource.render(layout: false)
|
56
55
|
# Avoid redirect pages
|
57
56
|
next if content.include? "http-equiv=refresh"
|
58
57
|
|
@@ -71,15 +70,16 @@ module GovukTechDocs
|
|
71
70
|
config[:http_prefix] + "/"
|
72
71
|
end
|
73
72
|
|
73
|
+
link_value = get_path_to_resource(config, resource, current_page)
|
74
74
|
if resource.children.any? && resource.url != home_url
|
75
|
-
output += %{<li><a href="#{
|
75
|
+
output += %{<li><a href="#{link_value}"><span>#{resource.data.title}</span></a>\n}
|
76
76
|
output += render_page_tree(resource.children, current_page, config, current_page_html)
|
77
77
|
output += "</li>\n"
|
78
78
|
else
|
79
79
|
output +=
|
80
80
|
list_items_from_headings(
|
81
81
|
content,
|
82
|
-
url:
|
82
|
+
url: link_value,
|
83
83
|
max_level: config[:tech_docs][:max_toc_heading_level],
|
84
84
|
)
|
85
85
|
end
|
@@ -69,7 +69,7 @@ module GovukTechDocs
|
|
69
69
|
first_child.content = leading_text.sub(/# */, "")
|
70
70
|
end
|
71
71
|
|
72
|
-
tr = Nokogiri::XML::Node.new "tr", fragment
|
72
|
+
tr = Nokogiri::XML::Node.new "tr", fragment.document
|
73
73
|
tr.children = fragment.children
|
74
74
|
|
75
75
|
tr.to_html
|
@@ -95,9 +95,9 @@ module GovukTechDocs
|
|
95
95
|
# be `defined?`, so we can jump straight to rendering HTML ourselves.
|
96
96
|
|
97
97
|
fragment = Nokogiri::HTML::DocumentFragment.parse("")
|
98
|
-
pre = Nokogiri::XML::Node.new "pre", fragment
|
98
|
+
pre = Nokogiri::XML::Node.new "pre", fragment.document
|
99
99
|
pre["tabindex"] = "0"
|
100
|
-
code = Nokogiri::XML::Node.new "code", fragment
|
100
|
+
code = Nokogiri::XML::Node.new "code", fragment.document
|
101
101
|
code["class"] = lang
|
102
102
|
code.content = text
|
103
103
|
pre.add_child code
|
data/lib/govuk_tech_docs.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<%= GovukTechDocs::Pages.new(sitemap, config).to_json %>
|
1
|
+
<%= GovukTechDocs::Pages.new(sitemap, config, current_page).to_json %>
|
@@ -41,9 +41,9 @@
|
|
41
41
|
</div>
|
42
42
|
<% if config[:tech_docs][:header_links] %>
|
43
43
|
<div class="govuk-header__content">
|
44
|
-
<
|
45
|
-
|
46
|
-
<ul id="navigation" class="govuk-header__navigation
|
44
|
+
<nav class="govuk-header__navigation govuk-header__navigation--end" aria-label="Menu">
|
45
|
+
<button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide menu">Menu</button>
|
46
|
+
<ul id="navigation" class="govuk-header__navigation-list">
|
47
47
|
<% config[:tech_docs][:header_links].each do |title, path| %>
|
48
48
|
<li class="govuk-header__navigation-item<% if active_page(path) %> govuk-header__navigation-item--active<% end %>">
|
49
49
|
<a class="govuk-header__link" href="<%= url_for path %>"><%= title %></a>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if config[:tech_docs][:enable_search] %>
|
2
|
-
<div class="search" data-module="search">
|
2
|
+
<div class="search" data-module="search" data-path-to-site-root="<%= path_to_site_root config, current_page.path %>">
|
3
3
|
<form action="https://www.google.co.uk/search" method="get" role="search" class="search__form govuk-!-margin-bottom-4">
|
4
4
|
<input type="hidden" name="as_sitesearch" value="<%= config[:tech_docs][:host] %>"/>
|
5
5
|
<label class="govuk-label search__label" for="search" aria-hidden="true">
|
data/lib/source/layouts/core.erb
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
<div class="app-pane">
|
29
29
|
<div class="app-pane__header toc-open-disabled">
|
30
|
-
<a href="#content" class="govuk-skip-link">Skip to main content</a>
|
30
|
+
<a href="#content" class="govuk-skip-link" data-module="govuk-skip-link">Skip to main content</a>
|
31
31
|
|
32
32
|
<%= partial 'layouts/header' %>
|
33
33
|
</div>
|