govuk_publishing_components 39.2.0 → 39.2.2

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.
@@ -2,22 +2,38 @@ module GovukPublishingComponents
2
2
  class AuditController < GovukPublishingComponents::ApplicationController
3
3
  def show
4
4
  application_dirs = %w[
5
+ account-api
5
6
  collections
6
7
  collections-publisher
8
+ contacts-admin
7
9
  content-data-admin
8
10
  content-publisher
11
+ content-tagger
9
12
  datagovuk_find
10
13
  email-alert-frontend
11
14
  feedback
12
15
  finder-frontend
13
16
  frontend
14
17
  government-frontend
18
+ govspeak
15
19
  govspeak-preview
20
+ govuk-developer-docs
21
+ local-links-manager
22
+ manuals-publisher
23
+ maslow
24
+ places-manager
25
+ publisher
16
26
  release
17
27
  search-admin
28
+ search-v2-evaluator
29
+ service-manual-publisher
30
+ short-url-manager
18
31
  signon
19
32
  smart-answers
33
+ specialist-publisher
20
34
  static
35
+ support
36
+ transition
21
37
  travel-advice-publisher
22
38
  whitehall
23
39
  ]
@@ -1,5 +1,5 @@
1
1
  <%
2
- title = "Applications"
2
+ title = "Applications (" + @applications.length.to_s + ")"
3
3
  title = "This application" unless ENV["MAIN_COMPONENT_GUIDE"]
4
4
  %>
5
5
  <%= render "govuk_publishing_components/components/heading", {
@@ -77,7 +77,7 @@
77
77
  None
78
78
  <% end %>
79
79
  <% end %>
80
- <%
80
+ <%
81
81
  items << {
82
82
  field: "#{item[:name]} (#{item[:value].length})",
83
83
  value: content
@@ -134,7 +134,7 @@
134
134
  } %>
135
135
  <p class="govuk-body">This is a list of components found in this application. Note that some components may appear to be missing files due to inconsistencies in directory structure and naming conventions.</p>
136
136
  <%= render "component_contents", passed_components: application_components, show_application_name: false %>
137
- <% end %>
137
+ <% end %>
138
138
  <% else %>
139
139
  <p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
140
140
  <% end %>
@@ -42,7 +42,7 @@
42
42
  <% contents.each.with_index(1) do |contents_item, position| %>
43
43
  <li class="<%= cl_helper.list_item_classes(contents_item, false) %>" <%= "aria-current=true" if contents_item[:active] %>>
44
44
  <span aria-hidden="true"></span>
45
- <% link_text = format_numbers ? cl_helper.wrap_numbers_with_spans(contents_item[:text]) : contents_item[:text]
45
+ <% link_text = format_numbers ? cl_helper.wrap_numbers_with_spans(contents_item[:text]) : cl_helper.clean_string(contents_item[:text])
46
46
  unless disable_ga4
47
47
  ga4_data[:event_name] = cl_helper.get_ga4_event_name(contents_item[:href]) if contents_item[:href]
48
48
  ga4_data[:index_link] = index_link
@@ -88,7 +88,7 @@ examples:
88
88
  format_numbers: true
89
89
  contents:
90
90
  - href: "#first-thing"
91
- text: 1. First thing
91
+ text: 1.&nbsp;First thing
92
92
  - href: "#two"
93
93
  active: true
94
94
  text: 2. Second thing
@@ -22,24 +22,31 @@ module GovukPublishingComponents
22
22
  list_item_classes
23
23
  end
24
24
 
25
- def wrap_numbers_with_spans(content_item_link)
26
- content_item_text = strip_tags(content_item_link) # just the text of the link
27
- content_item_text_stripped = content_item_text.strip # strip trailing spaces for the regex. Keep original content_item_text for the string replacement.
25
+ def wrap_numbers_with_spans(link_text)
26
+ output = clean_string(link_text)
28
27
  # Must start with a number
29
28
  # Number must be between 1 and 999 (ie not 2014)
30
29
  # Must be followed by a space
31
30
  # May contain a period `1.`
32
31
  # May be a decimal `1.2`
33
- number = /^\d{1,3}(\.?|\.\d{1,2})(?=\s)/.match(content_item_text_stripped)
32
+ number = /^\d{1,3}(\.?|\.\d{1,2})(?=\s)/.match(output)
34
33
 
35
34
  if number
36
- words = content_item_text.sub(number.to_s, "").strip # remove the number from the text
37
- content_item_link.sub(content_item_text, "<span class=\"gem-c-contents-list__number\">#{number} </span><span class=\"gem-c-contents-list__numbered-text\">#{words}</span>").squish.html_safe
35
+ words = output.sub(number.to_s, "").strip # remove the number from the text
36
+ # the space in the first span is needed for screen readers
37
+ "<span class=\"gem-c-contents-list__number\">#{number} </span><span class=\"gem-c-contents-list__numbered-text\">#{words}</span>".squish.html_safe
38
38
  else
39
- content_item_link
39
+ output
40
40
  end
41
41
  end
42
42
 
43
+ def clean_string(text)
44
+ text = text.gsub(/&nbsp;/, " ")
45
+ text = text.gsub("/\u00a0/", " ")
46
+ text = text.gsub(160.chr("UTF-8"), " ")
47
+ strip_tags(text.tr("\n", "")).strip
48
+ end
49
+
43
50
  def get_index_total
44
51
  total = @contents.length
45
52
  @contents.each do |parent|
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "39.2.0".freeze
2
+ VERSION = "39.2.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 39.2.0
4
+ version: 39.2.2
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: 2024-07-01 00:00:00.000000000 Z
11
+ date: 2024-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config