metadata_presenter 0.27.3 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 027ea2efffbb85068abc14cb2ba4ff016aa92f7d32052a29689e1e5a0f38e315
4
- data.tar.gz: 77b4685de4e43230b2c42b716f318d19e0352dea1b9ffa7e13f36f3a55501b54
3
+ metadata.gz: 710ee25690f8d4c33cd436f03553399076b6a43b9db5146a25ca865deec4a861
4
+ data.tar.gz: 9241c9c780ce678cbb8d83cdcf6c61bece75447709ab568e180ea0eeddc3fb70
5
5
  SHA512:
6
- metadata.gz: d19d3e0d29083c44dc3efda1c631b0e949d78e865b112c97601acf71590e6e376b0f9324d92d35dd39dcf0866a9552fd0609025ce344570f344926c0aa4a4ea4
7
- data.tar.gz: 18426551b21ebca783e364ad645bfef4b9dcf1a94a868e35d73c549535efbf30e77d571f8ac94919fae4c34804be16c84fe8642f6a6e5fa7514140979845070c
6
+ metadata.gz: c192cf21be0ef86dd737a7fda0d313b8861c6ee02cc12d649627d56ab3e09c3fc714a3da71009236a980d068eb6147e0559b324087298b050f225f15b1da1d3e
7
+ data.tar.gz: 5ce185225d8a00da09b1937aba2f8b398e2822f60182c4fb4624e3847f4d608a1a5ee2d1581c3c129c560b6cefed6e7782e82cab59449701c33bc63e458f0232
@@ -8,7 +8,10 @@ module MetadataPresenter
8
8
  def back_link
9
9
  return if @page.blank?
10
10
 
11
- previous_page = service.previous_page(current_page: @page)&.url
11
+ previous_page = service.previous_page(
12
+ current_page: @page,
13
+ referrer: request.referer
14
+ )&.url
12
15
 
13
16
  @back_link ||= File.join(request.script_name, previous_page) if previous_page
14
17
  end
@@ -18,5 +18,9 @@ module MetadataPresenter
18
18
  def default_text(property)
19
19
  MetadataPresenter::DefaultText[property]
20
20
  end
21
+
22
+ def meta_items
23
+ service.meta.items
24
+ end
21
25
  end
22
26
  end
@@ -0,0 +1,7 @@
1
+ class MetadataPresenter::Meta < MetadataPresenter::Metadata
2
+ def items
3
+ metadata.items.map do |item|
4
+ MetadataPresenter::MetaItem.new(item)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ class MetadataPresenter::MetaItem < MetadataPresenter::Metadata
2
+ end
@@ -5,6 +5,12 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
5
5
  end
6
6
  end
7
7
 
8
+ def standalone_pages
9
+ @standalone_pages ||= metadata.standalone_pages.map do |page|
10
+ MetadataPresenter::Page.new(page, editor: editor?)
11
+ end
12
+ end
13
+
8
14
  def start_page
9
15
  pages.first
10
16
  end
@@ -14,11 +20,11 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
14
20
  end
15
21
 
16
22
  def find_page_by_url(url)
17
- pages.find { |page| strip_slash(page.url) == strip_slash(url) }
23
+ all_pages.find { |page| strip_slash(page.url) == strip_slash(url) }
18
24
  end
19
25
 
20
26
  def find_page_by_uuid(uuid)
21
- pages.find { |page| page.uuid == uuid }
27
+ all_pages.find { |page| page.uuid == uuid }
22
28
  end
23
29
 
24
30
  def next_page(from:)
@@ -26,8 +32,10 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
26
32
  pages[pages.index(current_page) + 1] if current_page.present?
27
33
  end
28
34
 
29
- def previous_page(current_page:)
30
- pages[pages.index(current_page) - 1] unless current_page == start_page
35
+ def previous_page(current_page:, referrer:)
36
+ unless no_back_link?(current_page)
37
+ flow_page(current_page) || referrer_page(referrer)
38
+ end
31
39
  end
32
40
 
33
41
  def confirmation_page
@@ -36,8 +44,29 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
36
44
  end
37
45
  end
38
46
 
47
+ def meta
48
+ MetadataPresenter::Meta.new(configuration['meta'])
49
+ end
50
+
39
51
  private
40
52
 
53
+ def all_pages
54
+ @all_pages ||= pages + standalone_pages
55
+ end
56
+
57
+ def no_back_link?(current_page)
58
+ current_page == start_page || current_page == confirmation_page
59
+ end
60
+
61
+ def flow_page(current_page)
62
+ page_index = pages.index(current_page)
63
+ pages[page_index - 1] if page_index.present?
64
+ end
65
+
66
+ def referrer_page(referrer)
67
+ find_page_by_url(URI(referrer).path) if referrer
68
+ end
69
+
41
70
  def strip_slash(url)
42
71
  return url if url == '/'
43
72
 
@@ -9,9 +9,8 @@ class MetadataPresenter::ValidateSchema
9
9
  validate(controller.request.params, 'request.service')
10
10
 
11
11
  metadata = controller.request.params['metadata']
12
- Array(metadata['pages']).each do |page|
13
- validate(page, page['_type'])
14
- end
12
+ validate_pages(metadata['pages'])
13
+ validate_pages(metadata['standalone_pages'])
15
14
  rescue JSON::Schema::ValidationError, JSON::Schema::SchemaError, SchemaNotFoundError => e
16
15
  controller.render(
17
16
  json: ErrorsSerializer.new(message: e.message).attributes,
@@ -39,5 +38,11 @@ class MetadataPresenter::ValidateSchema
39
38
  rescue Errno::ENOENT
40
39
  raise SchemaNotFoundError, "Schema not found => #{schema_name}"
41
40
  end
41
+
42
+ def validate_pages(pages)
43
+ Array(pages).each do |page|
44
+ validate(page, page['_type'])
45
+ end
46
+ end
42
47
  end
43
48
  end
@@ -0,0 +1,9 @@
1
+ <h2 class="govuk-visually-hidden">Support links</h2>
2
+
3
+ <ul class="govuk-footer__inline-list">
4
+ <% meta_items.each do |item| %>
5
+ <li class="govuk-footer__inline-list-item">
6
+ <a class="govuk-footer__link" href=<%= item.href %>><%= item.text %></a>
7
+ </li>
8
+ <% end %>
9
+ </ul>
@@ -3,6 +3,10 @@
3
3
  <div class="govuk-footer__meta">
4
4
  <div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
5
5
 
6
+ <%= render partial: 'metadata_presenter/footer/meta' %>
7
+
8
+ <hr class="govuk-footer__section-break govuk-!-margin-top-7">
9
+
6
10
  <svg aria-hidden="true" focusable="false" class="govuk-footer__licence-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 483.2 195.7" height="17" width="41">
7
11
  <path fill="currentColor" d="M421.5 142.8V.1l-50.7 32.3v161.1h112.4v-50.7zm-122.3-9.6A47.12 47.12 0 0 1 221 97.8c0-26 21.1-47.1 47.1-47.1 16.7 0 31.4 8.7 39.7 21.8l42.7-27.2A97.63 97.63 0 0 0 268.1 0c-36.5 0-68.3 20.1-85.1 49.7A98 98 0 0 0 97.8 0C43.9 0 0 43.9 0 97.8s43.9 97.8 97.8 97.8c36.5 0 68.3-20.1 85.1-49.7a97.76 97.76 0 0 0 149.6 25.4l19.4 22.2h3v-87.8h-80l24.3 27.5zM97.8 145c-26 0-47.1-21.1-47.1-47.1s21.1-47.1 47.1-47.1 47.2 21 47.2 47S123.8 145 97.8 145" />
8
12
  </svg>
@@ -9,7 +9,7 @@
9
9
  data-fb-content-type="element">
10
10
  <%= @page.heading %>
11
11
  </h1>
12
-
12
+
13
13
  <%= render 'metadata_presenter/attribute/lede' %>
14
14
  <%= render 'metadata_presenter/attribute/body' %>
15
15
 
@@ -0,0 +1,17 @@
1
+ <div class="fb-main-grid-wrapper" data-fb-pagetype="<%= @page.type %>">
2
+ <div class="govuk-grid-row">
3
+ <div class="govuk-grid-column-two-thirds">
4
+
5
+ <% if @page.heading %>
6
+ <h1 class="fb-editable govuk-heading-xl"
7
+ data-fb-content-id="page[heading]"
8
+ data-fb-content-type="element">
9
+ <%= @page.heading %>
10
+ </h1>
11
+ <% end %>
12
+
13
+ <%= render 'metadata_presenter/attribute/body' %>
14
+
15
+ </div>
16
+ </div>
17
+ </div>
@@ -0,0 +1,8 @@
1
+ {
2
+ "_id": "page.standalone",
3
+ "_type": "page.standalone",
4
+ "heading": "Title",
5
+ "body": "[Optional content]",
6
+ "components": [],
7
+ "url": ""
8
+ }
@@ -4,5 +4,6 @@
4
4
  "service_name": "Service name",
5
5
  "configuration": {},
6
6
  "pages": [],
7
+ "standalone_pages": [],
7
8
  "locale": "en"
8
9
  }
@@ -68,5 +68,6 @@
68
68
  "url": "how-many-lights"
69
69
  }
70
70
  ],
71
+ "standalone_pages": [],
71
72
  "locale": "en"
72
73
  }
@@ -56,5 +56,6 @@
56
56
  "components": []
57
57
  }
58
58
  ],
59
+ "standalone_pages": [],
59
60
  "locale": "en"
60
61
  }
@@ -116,5 +116,6 @@
116
116
  "url": "/parent-name"
117
117
  }
118
118
  ],
119
+ "standalone_pages": [],
119
120
  "locale": "en"
120
121
  }
@@ -46,5 +46,6 @@
46
46
  "url": "/"
47
47
  }
48
48
  ],
49
+ "standalone_pages": [],
49
50
  "locale": "en"
50
51
  }
@@ -370,5 +370,34 @@
370
370
  ]
371
371
  }
372
372
  ],
373
+ "standalone_pages": [
374
+ {
375
+ "_uuid": "8239d280-4cb2-4cf8-b5d7-713f148a82f7",
376
+ "_id": "page.cookies",
377
+ "_type": "page.standalone",
378
+ "heading": "Cookies",
379
+ "body": "This online form puts small files (known as ‘cookies’) onto your computer to collect information about how you browse the site.\r\n\r\nCookies are used to:\r\n\r\n- remember your progress\r\n- measure how you use the website so it can be updated and improved based on your needs\r\n\r\nThis online form's cookies aren't used to identify you personally.\r\n\r\nYou'll normally see a message on the site before we store a cookie on your computer.\r\n\r\nFind out more about [how to manage cookies](https://www.aboutcookies.org/).\r\n\r\n##How cookies are used on this online form\r\n\r\nWe will store a cookie to remember your progress on this computer and to expire your session after 60 minutes of inactivity or when you close your browser.\r\n\r\n| Name | Purpose | Expires |\r\n|---|---|---|\r\n| _fb_runner_session | Saves your current progress in this computer and tracks inactivity periods | After 20 minutes of inactivity or when you close your browser |",
380
+ "components": [],
381
+ "url": "cookies"
382
+ },
383
+ {
384
+ "_uuid": "67c91f95-805e-4731-969e-648c7d3d172f",
385
+ "_id": "page.accessibility",
386
+ "_type": "page.standalone",
387
+ "heading": "Accessibility Statement",
388
+ "body": "This accessibility statement applies to [describe your form here - for example, the general enquiries form for the CICA]. There is a separate [accessibility statement for the main GOV.UK website](https://www.gov.uk/help/accessibility-statement).\r\n\r\n###Using this online form\r\n\r\nThis form was built using a tool developed by the Ministry of Justice and uses components from the [GOV.UK Design System](https://design-system.service.gov.uk/).\r\n\r\n[insert your organisation here] is responsible for the content of this online form. The Ministry of Justice is responsible for its technical aspects.\r\n\r\nWe want as many people as possible to be able to use this online form. For example, that means you should be able to:\r\n\r\n- change colours, contrast levels and fonts\r\n- zoom in up to 300% without the text spilling off the screen\r\n- navigate the form using just a keyboard\r\n- navigate the form using speech recognition software\r\n- listen to the form using a screen reader (including recent versions of JAWS, NVDA and VoiceOver)\r\n\r\nWe’ve also made the text as simple as possible to understand.\r\n\r\n[AbilityNet](https://mcmw.abilitynet.org.uk/) has advice on making your device easier to use if you have a disability.\r\n\r\n###What to do if you can’t access part of this form\r\n\r\nIf you need information on this website in a different format:\r\n\r\n[insert your contact details for user requests here - add other channels, such as text phones or Relay UK, as required]\r\n\r\nEmail: [your email address]\r\nTelephone: [your telephone number]\r\n[Hours - e.g. Monday to Friday, 9am to 5pm]\r\n[Find out about call charges](https://www.gov.uk/call-charges)\r\n\r\nWe'll consider your request and get back to you in [add your SLA - e.g. a week or 5 working days].\r\n\r\n###Reporting accessibility problems\r\n\r\nWe’re always looking to improve the accessibility of this online form.\r\n\r\nIf you find any problems that aren’t listed on this page or think we’re not meeting accessibility requirements:\r\n\r\n[insert your contact details for user feedback here - add other channels, such as text phones or Relay UK, as required]\r\n\r\nEmail: [your email address]\nTelephone: [your telephone number]\n[Hours - e.g. Monday to Friday, 9am to 5pm]\n[Find out about call charges](https://www.gov.uk/call-charges)\r\n\r\n###Enforcement procedure\r\n\r\nThe Equality and Human Rights Commission (EHRC) is responsible for enforcing the accessibility regulations. If you’re not happy with how we respond to your complaint, contact the [Equality Advisory and Support Service (EASS)](https://www.equalityadvisoryservice.com/).\r\n\r\n###Technical information about this online form’s accessibility\r\n\r\nWe are committed to making our online forms and services accessible, in accordance with the Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018.\r\n\r\nThis online form is fully compliant with the [Web Content Accessibility Guidelines version 2.1 AA standard](https://www.w3.org/TR/WCAG21/).\r\n\r\n###How we tested this online form\r\n\r\nThis online form was last tested in February 2021. The test was carried out by the Ministry of Justice. It was tested using the [WAVE Web Accessibility Evaluation Tool](https://wave.webaim.org/) following guidance from the Government Digital Service (GDS). We tested all the form’s pages.\r\n\r\n###What we’re doing to improve accessibility\r\n\r\nWe will monitor the accessibility of this website on an ongoing basis and fix any accessibility issues reported to us.\r\n\r\nThis statement was prepared on [insert current date].",
389
+ "components": [],
390
+ "url": "accessibility"
391
+ },
392
+ {
393
+ "_uuid": "d658f790-0ceb-4507-b8ac-ae30ece6bc8d",
394
+ "_id": "page.privacy",
395
+ "_type": "page.standalone",
396
+ "heading": "Privacy notice",
397
+ "body": "This privacy notice explains what [insert your organisation name] means when we talk about personal data, why we ask for this information about you and what we do with it when you use this form.\r\n\r\nIt also explains how we store your data, how you can get a copy of the information we’ve collected about you and how you can complain if you think we’ve done something wrong.\r\n\r\n###Who manages this service\r\n\r\nThis form is managed by [your organisation].\r\n\r\nThe information you submit will be processed by [insert who will be processing the information and, if it’s a separate organisation, what their relationship is to you].\r\n\r\n[Insert name of organisation that acts as data controller for your form] is the data controller for the personal data collected by this form.\r\n\r\n###When we ask for personal data\r\n\r\nWhenever we ask for information about you, we promise to:\r\n\r\n- always let you know why we need it\r\n- ask for relevant personal information only\r\n- make sure we do not keep it longer than needed\r\n- keep your information safe and make sure nobody can access it unless authorised to do so\r\n- only share your data with other organisations for legitimate purposes\r\n- consider any request you make to correct or delete your personal data\r\n\r\nWe also promise to make it easy for you to:\r\n\r\n- tell us at any time if you want us to stop storing your personal data\r\n- make a complaint to the supervisory authority\r\n\r\n###The personal data we collect\r\n\r\nWe only collect personal data that you directly provide with your application.\r\n\r\nWe only collect the information we need to deliver this service to you. The personal data collected includes:\r\n\r\n[list the types of personal information requested by your form]\r\n\r\nWe [use cookies](http://www.aboutcookies.org.uk/managing-cookies) to collect data that tells us about how the servicermation we ask for, we may not be able to process your [insert the purpose of your form, such as claim, application or request].\r\n\r\nPlease note that transmitting information over the internet is generally not completely secure, and [your organisation] can’t guarantee the security of your data. Any data you transmit is at your own risk. [your organisation, and any other organisations involved in processing the data] have procedures and security features in place to keep your data secure once we receive it.\r\n\r\n###Sharing your personal data\r\n\r\nThe information you provide will be shared with… [name any organisations that you might share the data with and provide an explanation of why the information may be shared and what it will be used for]\r\n\r\nWe may also use your contact information to ask for feedback on using the service, but only when you have given your consent for us to do so. [delete this paragraph if not applicable]\r\n\r\nWe’ll never share your information with other organisations for marketing, market researcer organisation will receive the information for processing] take data security very seriously and take every step to ensure that your data remains private and secure. All data collected by this service is stored in a secure database kept entirely within the European Economic Area (EEA). [change this statement if date leaves the EEA]\r\n\r\nYour application will only be accessible to [your organisation, and any other organisations involved in processing the data] staff who require access to process applications.\r\n\r\n###Your rights\r\n\r\nYou can ask:\r\n\r\n- to see the personal data that we hold on you\r\n- to have the personal data corrected\r\n- to have the personal data removed or deleted (this will depend on the circumstances, for example if you decide not to continue your [insert the purpose of your form, such as claim, application or request])\r\n\r\nIf you want to see the personal data that we hold on you, you can make a [subject access request](https://www.gov.uk/government/organisations/ministry-of-justice/about/personal-information).\r\n\r\nWrite to us at:\r\n\r\n[insert your postal and email addresses]\r\n\r\n###Getting more information\r\n\r\nYou can get more details on:\r\n\r\n- agreements we have with other organisations for sharing information\r\n- when we can pass on personal information without telling you, for example, to help with the prevention or - detection of crime or to produce anonymised statistics\r\n- instructions we give to staff on how to collect, use or delete your personal information\r\n- how we check that the information we have is accurate and up-to-date\r\n- how to make a complaint\r\n\r\nFor more information, please contact the [your organisation] data protection officer at:\r\n\r\n[insert the postal and email addresses of your data protection officer - for the MoJ, this is:\r\n\r\n102 Petty France\r\nLondon\r\nSW1H 9AJ\r\ndata.compliance@justice.gov.uk]\r\n\r\n###Making a complaint\r\n\r\nWhen we ask you for information, we will keep to the law. If you think that your information has not been handled correctly, you can contact the [Information Commissioner](https://ico.org.uk/) for independent advice about data protection on the address below:\r\n\r\nInformation Commissioner's Office\r\nWycliffe House\r\nWater Lane\r\nWilmslow\r\nCheshire\r\nSK9 5AF\r\n\r\nTelephone: 0303 123 1113",
398
+ "components": [],
399
+ "url": "privacy"
400
+ }
401
+ ],
373
402
  "locale": "en"
374
403
  }
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '0.27.3'.freeze
2
+ VERSION = '0.28.0'.freeze
3
3
  end
@@ -0,0 +1,23 @@
1
+ {
2
+ "$id": "http://gov.uk/schema/v1.0.0/page/standalone",
3
+ "_name": "page.standalone",
4
+ "title": "Standalone",
5
+ "description": "Pages which are not part of any flow",
6
+ "type": "object",
7
+ "properties": {
8
+ "_type": {
9
+ "const": "page.standalone"
10
+ }
11
+ },
12
+ "allOf": [
13
+ {
14
+ "$ref": "definition.page.content"
15
+ }
16
+ ],
17
+ "uiCategory": {
18
+ "main": [
19
+ "lede",
20
+ "body"
21
+ ]
22
+ }
23
+ }
@@ -56,6 +56,16 @@
56
56
  }
57
57
  ]
58
58
  }
59
+ },
60
+ "standalone_pages": {
61
+ "type": "array",
62
+ "items": {
63
+ "anyOf": [
64
+ {
65
+ "$ref": "page.standalone"
66
+ }
67
+ ]
68
+ }
59
69
  }
60
70
  },
61
71
  "required": [
@@ -65,7 +75,8 @@
65
75
  "created_by",
66
76
  "locale",
67
77
  "configuration",
68
- "pages"
78
+ "pages",
79
+ "standalone_pages"
69
80
  ],
70
81
  "additionalProperties": false
71
82
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metadata_presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.3
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MoJ Online
@@ -264,6 +264,8 @@ files:
264
264
  - app/models/metadata_presenter/component.rb
265
265
  - app/models/metadata_presenter/date_field.rb
266
266
  - app/models/metadata_presenter/item.rb
267
+ - app/models/metadata_presenter/meta.rb
268
+ - app/models/metadata_presenter/meta_item.rb
267
269
  - app/models/metadata_presenter/metadata.rb
268
270
  - app/models/metadata_presenter/next_page.rb
269
271
  - app/models/metadata_presenter/page.rb
@@ -292,6 +294,7 @@ files:
292
294
  - app/views/metadata_presenter/component/_radios.html.erb
293
295
  - app/views/metadata_presenter/component/_text.html.erb
294
296
  - app/views/metadata_presenter/component/_textarea.html.erb
297
+ - app/views/metadata_presenter/footer/_meta.html.erb
295
298
  - app/views/metadata_presenter/footer/footer.html.erb
296
299
  - app/views/metadata_presenter/header/show.html.erb
297
300
  - app/views/metadata_presenter/page/checkanswers.html.erb
@@ -300,6 +303,7 @@ files:
300
303
  - app/views/metadata_presenter/page/form.html.erb
301
304
  - app/views/metadata_presenter/page/multiplequestions.html.erb
302
305
  - app/views/metadata_presenter/page/singlequestion.html.erb
306
+ - app/views/metadata_presenter/page/standalone.html.erb
303
307
  - app/views/metadata_presenter/page/start.html.erb
304
308
  - config/initializers/default_metadata.rb
305
309
  - config/initializers/default_text.rb
@@ -322,6 +326,7 @@ files:
322
326
  - default_metadata/page/content.json
323
327
  - default_metadata/page/multiplequestions.json
324
328
  - default_metadata/page/singlequestion.json
329
+ - default_metadata/page/standalone.json
325
330
  - default_metadata/page/start.json
326
331
  - default_metadata/service/base.json
327
332
  - default_metadata/string/error.date.json
@@ -392,6 +397,7 @@ files:
392
397
  - schemas/page/content.json
393
398
  - schemas/page/multiplequestions.json
394
399
  - schemas/page/singlequestion.json
400
+ - schemas/page/standalone.json
395
401
  - schemas/page/start.json
396
402
  - schemas/request/service.json
397
403
  - schemas/service/base.json