From e86f4f109986169a4d3ba3f96ad58843cae557e2 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 21 Aug 2024 14:19:56 +0100 Subject: [PATCH 1/9] build: Updated Makefile reorganised targets alphabetically as well as mirrored other improvements from the other applications in the suite --- Makefile | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 84b16fa..56a6fd7 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,6 @@ GEM=${NAME}-${VERSION}.gem GPR=https://rubygems.pkg.github.com/${OWNER} SPEC=${NAME}.gemspec -all: publish - -auth: ${AUTH} - -build: gem - ${AUTH}: @mkdir -p ${HOME}/.gem @echo '---' > ${AUTH} @@ -25,23 +19,37 @@ ${AUTH}: ${GEM}: ${SPEC} ./lib/${NAME}/version.rb gem build ${SPEC} +all: publish + +auth: ${AUTH} + +build: gem + +clean: + @rm -rf ${GEM} + gem: ${GEM} @echo ${GEM} -test: gem - @bundle install - @rake test - publish: ${AUTH} ${GEM} @echo Publishing package ${NAME}:${VERSION} to ${OWNER} ... @gem push --key github --host ${GPR} ${GEM} @echo Done. -clean: - @rm -rf ${GEM} - realclean: clean - @rm -rf ${AUTH} - + @rm -rf ${AUTH} + tags: @echo version=${VERSION} + +test: gem + @bundle install + @rake test + +vars: + @echo "GEM" = ${GEM} + @echo "GPR" = ${GPR} + @echo "NAME = ${NAME}" + @echo "OWNER = ${OWNER}" + @echo "SPEC = ${SPEC}" + @echo "VERSION = ${VERSION}" From f5af01761be2532f05175e4ffebdc0dcb07d1439 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 21 Aug 2024 14:34:19 +0100 Subject: [PATCH 2/9] refactor: updates to main menu - adjusted the LrCommonStyles.app_link method to include the root path for the suite of apps - converted the shared header template to use the non-ukhpi centric approach for linking - adjusted the application template to use said shared header to allow a single source of truth in future --- app/models/lr_common_config.rb | 31 ++++++++++++----- app/views/layouts/application.html.haml | 25 +------------- app/views/shared/_header.html.haml | 45 ++++++------------------- 3 files changed, 34 insertions(+), 67 deletions(-) diff --git a/app/models/lr_common_config.rb b/app/models/lr_common_config.rb index 2510ff8..4e42d09 100644 --- a/app/models/lr_common_config.rb +++ b/app/models/lr_common_config.rb @@ -6,19 +6,20 @@ class LrCommonConfig class << self include ActionView::Helpers::UrlHelper - def app_link(app_name, request) - # Set the css classes for the link - css_classes = ['lr-header--header-proposition--a'] - # If the current url contains the app name, set the active class - if request.original_url =~ /#{app_name}/ - css_classes << 'lr-header--header-proposition--a__active' - end + def app_link(app_name, request, css_classes) + root = app_name == '/' + # Set the css classes for the link if they are not set + link_classes = set_link_classes(app_name, css_classes, root, request.original_url) # Sub replaces just the first instance of the app name in the relative_url_root - path = relative_url_root.sub(%r{[^/]*\Z}, app_name) + path = root ? relative_url_root : relative_url_root.sub(%r{[^/]*\Z}, app_name) # Add the lang param if it exists path += "?lang=#{request.params[:lang]}" if request.params.key?(:lang) + # if the app name is the same as the current app, set the path to the root + t_name = root ? 'common.header.app_title' : "common.app.#{app_name}" + # Set the link id if an id is required + link_id = root ? 'proposition-name' : nil # Return the link with the css classes and path set accordingly - link_to(I18n.t("common.app.#{app_name}"), path, class: css_classes.join(' ')) + link_to(I18n.t(t_name), path, class: link_classes, id: link_id) end # Returns the relative url root for the app if running in a subdirectory @@ -32,5 +33,17 @@ def relative_url_root root_url = "/app#{root_url}" if root_url.exclude?('app') && Rails.env.production? root_url end + + # Returns a space separated string of css classes for the link + # If the classes are not set, the default class is set + # If the app name is the same as the current url, the active class is set + def set_link_classes(name, classes, root, current_url) + classes = Array.wrap(classes) if classes.present? + # If the current url contains the app name, set the active class + if root == false && current_url =~ /#{name}/ + classes << 'lr-header--header-proposition--a__active' + end + classes.join(' ') + end end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7b4857d..9feb1d5 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -36,30 +36,7 @@ %body{ class: "government website lr lr-app" } = render partial: "shared/cookie_banner" = render partial: 'shared/skip_to_main_content' - - %header#global-header.with-proposition.lr-header{ role: "banner" } - .header-wrapper - .header-global - .header-logo - %a.content{ href: 'https://www.gov.uk/government/organisations/land-registry/', title: I18n.t('common.header.home_link') } - = image_tag('hm_lr_logo.png', srcset: image_path('hm_lr_logo.svg'), alt: "HM Land Registry logo") - .header-proposition.lr-header--header-proposition - .content - %a.js-header-toggle.menu{ href: "#proposition-links"} - Menu - %nav#proposition-menu - %a#proposition-name.lr-header--proposition-name{ href: '/' } - = I18n.t('common.header.site_title') - %ul#proposition-links - %li - = LrCommonConfig.app_link( "ukhpi", request ) - %li - = LrCommonConfig.app_link( "ppd", request ) - %li - = LrCommonConfig.app_link( "standard-reports", request ) - %li - = LrCommonConfig.app_link( "qonsole", request ) - + = render partial: "shared/header" .o-lr-top-bar diff --git a/app/views/shared/_header.html.haml b/app/views/shared/_header.html.haml index e6b8906..d7af395 100644 --- a/app/views/shared/_header.html.haml +++ b/app/views/shared/_header.html.haml @@ -1,44 +1,21 @@ -%header.with-proposition.c-hmlr-header#global-header +%header#global-header.with-proposition.lr-header{ role: "banner" } .header-wrapper .header-global .header-logo - %a.content{ href: '/app/ukhpi', title: t('common.header.home_link') } - = image_tag('ukhpi-icon.png', srcset: image_path('ukhpi-icon.svg'), alt: '') + %a.content{ href: 'https://www.gov.uk/government/organisations/land-registry/', title: I18n.t('common.header.home_link') } + = image_tag('hm_lr_logo.png', srcset: image_path('hm_lr_logo.svg'), alt: "HM Land Registry logo") - - .header-proposition + .header-proposition.lr-header--header-proposition .content - %a.js-header-toggle.menu{ href: '#proposition-links' } Menu - %nav#proposition-menu{ 'aria-label' => 'application menu' } - %a#proposition-name{ href: '/app/ukhpi' } - = t('common.header.app_title') - + = link_to(t('common.header.menu_text'), '#proposition-links', class: 'js-header-toggle menu') + %nav#proposition-menu + = LrCommonConfig.app_link( "/", request, 'lr-header--proposition-name' ) %ul#proposition-links %li - = link_to(t('action.browse'), browse_path(lang: I18n.locale), class: active_class(browse_path)) - %li - = link_to(t('action.compare_locations'), compare_path(lang: I18n.locale), class: active_class(compare_path)) + = LrCommonConfig.app_link( "ukhpi", request, 'lr-header--header-proposition--a' ) %li - = link_to(t('action.sparql'), '/app/qonsole') + = LrCommonConfig.app_link( "ppd", request, 'lr-header--header-proposition--a' ) %li - = link_to(t('action.user_guide'), doc_ukhpi_user_guide_path(lang: I18n.locale)) + = LrCommonConfig.app_link( "standard-reports", request, 'lr-header--header-proposition--a' ) %li - = link_to(t('action.about'), doc_index_path(lang: I18n.locale), class: active_class(doc_index_path)) - %li - = link_to(t('action.changelog'), changelog_index_path(lang: I18n.locale), class: active_class(changelog_index_path)) - -.o-lr-top-bar - -.container.o-container - .o-secondary-banner - - if Rails.application.config.welsh_language_enabled - %nav.o-secondary-banner__lang-select{ 'aria-label' => 'language selector' } - - if @view_state.user_selections.english? - English - - else - = link_to('English', @view_state.user_selections.alternative_language_params.params) - | - - if @view_state.user_selections.welsh? - Cymraeg - - else - = link_to('Cymraeg', @view_state.user_selections.alternative_language_params.params) + = LrCommonConfig.app_link( "qonsole", request, 'lr-header--header-proposition--a' ) From 4baf61fad863758e628fdbfa815f0f09fa83421a Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 21 Aug 2024 14:35:11 +0100 Subject: [PATCH 3/9] feat: added `puma.stats` to footer template Only displayed in Rails development environment --- app/views/shared/_footer.html.haml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml index caa125b..970b374 100644 --- a/app/views/shared/_footer.html.haml +++ b/app/views/shared/_footer.html.haml @@ -32,3 +32,8 @@ = succeed(':') do = I18n.t('common.footer.application_release') = Version::VERSION + - if Rails.env.development? + %pre + [puma stats: + = JSON.pretty_generate(JSON.parse(Puma.stats)) + , time: #{Time.now}] From b8d60362c9a230c1c0a469185f2d178e320e0cec Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Tue, 27 Aug 2024 16:03:12 +0100 Subject: [PATCH 4/9] fix: converted `a` tags to `link_to` helpers also includes only appending the `lang` parameter to the url if it exists for "internal" links --- app/views/shared/_footer.html.haml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml index 970b374..d64889c 100644 --- a/app/views/shared/_footer.html.haml +++ b/app/views/shared/_footer.html.haml @@ -5,20 +5,18 @@ %h2.o-footer--h2.hidden Support links %ul.list-inline %li - %a{:href => "http://www.nationalarchives.gov.uk/information-management/our-services/crown-copyright.htm"} - © - = t('common.footer.crown_copyright') - = Time.now.year + = link_to("© #{I18n.t('common.footer.crown_copyright')} #{Time.now.year}".html_safe, "http://www.nationalarchives.gov.uk/information-management/our-services/crown-copyright.htm") + %li - %a{:href => "https://www.gov.uk/government/organisations/land-registry/about/personal-information-charter"} - = t('common.footer.personal_info') + = link_to(I18n.t('common.footer.personal_info'), "https://www.gov.uk/government/organisations/land-registry/about/personal-information-charter") + %li - %a{:href => "https://www.gov.uk/land-registry-public-data"} - = t('common.footer.public_data') + = link_to(I18n.t('common.footer.public_data'), "https://www.gov.uk/land-registry-public-data") + %li - = link_to(I18n.t('common.footer.accessibility'), "#{Rails.application.config.accessibility_document_path}?lang=#{I18n.locale}") + = link_to(I18n.t('common.footer.accessibility'), "#{Rails.application.config.accessibility_document_path}#{"?lang=#{I18n.locale}" if params[:lang].present?}") %li - = link_to(I18n.t('common.footer.privacy'), "#{Rails.application.config.privacy_document_path}?lang=#{I18n.locale}") + = link_to(I18n.t('common.footer.privacy'), "#{Rails.application.config.privacy_document_path}#{"?lang=#{I18n.locale}" if params[:lang].present?}") .ogl.open-government-licence %p.logo %a{:href => "http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3", rel:"license"} From 3b3c47e277d9f10783b57aa38e1da90db6e17e39 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Tue, 27 Aug 2024 16:03:48 +0100 Subject: [PATCH 5/9] refactor: adds `symbolize_names` param to puma stats output --- app/views/shared/_footer.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml index d64889c..02ee434 100644 --- a/app/views/shared/_footer.html.haml +++ b/app/views/shared/_footer.html.haml @@ -33,5 +33,5 @@ - if Rails.env.development? %pre [puma stats: - = JSON.pretty_generate(JSON.parse(Puma.stats)) + = JSON.pretty_generate(JSON.parse(Puma.stats, symbolize_names: true)) , time: #{Time.now}] From ba9039e6a8158be8e0981020885ec87bf7a73f1a Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Tue, 27 Aug 2024 16:04:49 +0100 Subject: [PATCH 6/9] a11y: adds selection label to language selection menu --- app/views/shared/_lang_switch.html.haml | 2 ++ config/locales/cy.yml | 4 +++- config/locales/en.yml | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_lang_switch.html.haml b/app/views/shared/_lang_switch.html.haml index d4c0f7e..5a56eea 100644 --- a/app/views/shared/_lang_switch.html.haml +++ b/app/views/shared/_lang_switch.html.haml @@ -1,6 +1,8 @@ .o-secondary-banner - if Rails.application.config.welsh_language_enabled %nav.pull-right.o-secondary-banner__lang-select{ 'aria-label' => 'language selector' } + .visuallyhidden + = "#{I18n.t('common.header.language_selection')}: " - if I18n.locale == :en English - else diff --git a/config/locales/cy.yml b/config/locales/cy.yml index 79b45a8..db73d5d 100644 --- a/config/locales/cy.yml +++ b/config/locales/cy.yml @@ -1,10 +1,12 @@ cy: common: header: + menu_text: "Dewislen" home_link: "Ewch i hafan Mynegai Prisiau Tai y DU" site_title: "Data Agored Cofrestrfa Tir EM" app_title: "Data Agored Cofrestrfa Tir EM" feedback_request: "Problem neu awgrym? Bydd eich adborth yn ein helpu i wella’r gwasanaeth hwn." + language_selection: "Dewiswch eich dewis iaith" cookie_banner: heading: "Mae’r wefan hon yn defnyddio cwcis" details: "Ffeiliau sy’n cael eu storio ar eich cyfrifiadur, ffôn neu lechen yw cwcis. Maen nhw’n ein helpu i ddeall sut rydych yn defnyddio’r wefan hon, er enghraifft pa dudalennau rydych yn ymweld â nhw. Am ragor o wybodaeth, edrychwch ar ein" @@ -28,4 +30,4 @@ cy: application_release: "Cyhoeddiad ap" accessibility: "Hygyrchedd" privacy: "Preifatrwydd" - additional_terms: "Mae rhai telerau trwyddedu ychwanegol yn gymwys wrth ailgyhoeddi data cyfeiriadau." \ No newline at end of file + additional_terms: "Mae rhai telerau trwyddedu ychwanegol yn gymwys wrth ailgyhoeddi data cyfeiriadau." diff --git a/config/locales/en.yml b/config/locales/en.yml index 42b3564..f528399 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,10 +1,12 @@ en: common: header: + menu_text: "Menu" home_link: "Go to the UK HPI homepage" app_title: "HM Land Registry Open Data" site_title: "HM Land Registry Open Data" feedback_request: "Found a problem or have a suggestion? Your feedback will help us to improve this service." + language_selection: "Choose your preferred language" cookie_banner: heading: "This site uses cookies" details: "Cookies are files stored on your computer, phone, or tablet. They help us understand how you use this site, such as which pages you visit. For more information please read our" From 59539c95c0c76b75cdf4feb79335e15265f67f35 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Tue, 27 Aug 2024 16:22:32 +0100 Subject: [PATCH 7/9] docs: Updated CHANGELOG --- CHANGELOG.md | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c04500a..66bfa9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,21 +5,34 @@ applications. ## Changes +## 1.9.6 - 2024-08 + +- (Jon) Additional improvements for the suite of apps that use this gem to + ensure the menu links are built correctly alongside including the appropriate + classes and/or attributes for accessibility and usability + ## 1.9.5 - 2024-08 -- (Dan) Updates page title tag so we can update the page titles in various repos to improve accessibility [116](https://github.com/epimorphics/standard-reports-ui/issues/116), [220](https://github.com/epimorphics/ppd-explorer/issues/220) and [409](https://github.com/epimorphics/ukhpi/issues/409) +- (Dan) Updates page title tag so we can update the page titles in various repos + to improve accessibility + [116](https://github.com/epimorphics/standard-reports-ui/issues/116), + [220](https://github.com/epimorphics/ppd-explorer/issues/220) and + [409](https://github.com/epimorphics/ukhpi/issues/409) ## 1.9.4 - 2024-08 -- (Dan) Adds underline to link text for the feedback section to meet accessibility requirments [114](https://github.com/epimorphics/standard-reports-ui/issues/114) -- (Dan) Adds underline to link text in the cookie banner to meet accessibility requirments [126](https://github.com/epimorphics/lr-landing/issues/126) +- (Dan) Adds underline to link text for the feedback section to meet + accessibility requirments + [114](https://github.com/epimorphics/standard-reports-ui/issues/114) +- (Dan) Adds underline to link text in the cookie banner to meet accessibility + requirments [126](https://github.com/epimorphics/lr-landing/issues/126) ## 1.9.3 - 2023-11-27 -- (Jon) If the app is running in production, and the `relative_url_root` excludes - `/app`, then the app name is appended to the relative_url_root of `/app` - This resolves the urls paths for the apps from the landing page, but not - for the apps themselves +- (Jon) If the app is running in production, and the `relative_url_root` + excludes `/app`, then the app name is appended to the relative_url_root of + `/app` This resolves the urls paths for the apps from the landing page, but + not for the apps themselves ## 1.9.2 - 2023-11-23 @@ -47,8 +60,8 @@ applications. - (Jon) Updated the gemspec to ensure the dependency versions are locked to specific base versions to avoid any potential issues with the gem being used -- (Jon) Minor text changes to the .gemspec file to update the summary - field to mirror the common fields set in other gems. +- (Jon) Minor text changes to the .gemspec file to update the summary field to + mirror the common fields set in other gems. - (Jon) Refactored the version cadence creation to include a SUFFIX value if provided; otherwise no SUFFIX is included in the version number. From f62a170198f797322215522a589f905f0f571ab2 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Tue, 27 Aug 2024 16:23:02 +0100 Subject: [PATCH 8/9] build: updated version patch cadence v1.9.5 ~> 1.9.6 --- lib/lr_common_styles/version.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/lr_common_styles/version.rb b/lib/lr_common_styles/version.rb index 7818dd8..7258cd7 100644 --- a/lib/lr_common_styles/version.rb +++ b/lib/lr_common_styles/version.rb @@ -3,7 +3,7 @@ module LrCommonStyles MAJOR = 1 MINOR = 9 - PATCH = 5 - SUFFIX = nil - VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && ".#{SUFFIX}"}" + PATCH = 6 + SUFFIX = nil # nil or 'rc' or 'beta' or 'alpha' for pre-release versions + VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && "-#{SUFFIX}"}" end From cc9be81e42c18c0edc5e1dc2715b8c71435e4499 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Tue, 27 Aug 2024 17:04:27 +0100 Subject: [PATCH 9/9] build: resolves `open-ended dependency` warning on test gem build --- lr_common_styles.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lr_common_styles.gemspec b/lr_common_styles.gemspec index 2587524..4c34d18 100644 --- a/lr_common_styles.gemspec +++ b/lr_common_styles.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |s| s.add_dependency 'rails', '~> 5.2.4' s.add_dependency 'sass-rails', '~> 5.0.4' - s.add_development_dependency 'minitest-rails' - s.add_development_dependency 'mocha' - s.add_development_dependency 'rails_real_favicon' + s.add_development_dependency 'minitest-rails', '~> 5.2.0' + s.add_development_dependency 'mocha', '~> 2.0.0' + s.add_development_dependency 'rails_real_favicon', '~> 0.1.0' end