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.
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}"
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/_footer.html.haml b/app/views/shared/_footer.html.haml
index caa125b..02ee434 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"}
@@ -32,3 +30,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, symbolize_names: true))
+ , time: #{Time.now}]
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' )
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"
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
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