From 633da602211dc3ed84077b5a1573a2a81adea3ed Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Tue, 6 Aug 2024 09:42:15 +0100 Subject: [PATCH 01/31] adds underline to links --- app/assets/stylesheets/application.scss | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 579491b..f43fc7e 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -5,3 +5,12 @@ "bootstrap", "qonsole_rails/application", "lr_common_styles/lr-common"; + +.row { + li,p,dl>dt, dl>dd { + a { + text-decoration: underline; + } + } +} + \ No newline at end of file From 7e42ef79f5c1ea27b0227145a0b361fc52cbb6c3 Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Tue, 6 Aug 2024 10:17:44 +0100 Subject: [PATCH 02/31] updates version cadence --- CHANGELOG.md | 4 ++++ app/lib/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5dca82..0e2724d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ This app presents the landing page experience for landregistry.data.gov.uk, including the SPARQL Qonsole +## 1.7.7 - 2024-08 + +- (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibiliy requirments[GH-126](https://github.com/epimorphics/lr-landing/issues/126) + ## 1.7.6 - 2024-03-12 - (Jon) Reconfigured the `detailed documentation` links, both english and welsh, diff --git a/app/lib/version.rb b/app/lib/version.rb index 4b828a8..4c52ee3 100644 --- a/app/lib/version.rb +++ b/app/lib/version.rb @@ -3,7 +3,7 @@ module Version MAJOR = 1 MINOR = 7 - REVISION = 6 + REVISION = 7 SUFFIX = nil VERSION = "#{MAJOR}.#{MINOR}.#{REVISION}#{SUFFIX && ".#{SUFFIX}"}" end From 0aaf0d6e509ee13a01d7a383af6ebe10194721ad Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Tue, 6 Aug 2024 10:24:01 +0100 Subject: [PATCH 03/31] Updates readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index fee63ae..8bb578e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,14 @@ cd lr-landing && bundle install ``` +#### Trouble shooting bundle install + +If bundle install does not work add a .bundle directory and create a config +file. So you now have .bundle/config. +Add the following line to the config file. +BUNDLE_RUBYGEMS__PKG__GITHUB__COM: "your-username:your-personal-access-token" +Then run bundle install again and eveything should work. + Start the app locally for development: ```sh From 7743b5db74c4cfc1e1539803192148b8156cc58b Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Tue, 6 Aug 2024 11:10:52 +0100 Subject: [PATCH 04/31] updates scss format --- app/assets/stylesheets/application.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f43fc7e..88fe7b5 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -7,7 +7,7 @@ "lr_common_styles/lr-common"; .row { - li,p,dl>dt, dl>dd { + li,p,dl>dt,dl>dd { a { text-decoration: underline; } From 17ba4debd205681cc4e89e31f0008719dd4b0b26 Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Mon, 19 Aug 2024 11:28:30 +0100 Subject: [PATCH 05/31] updates gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f34a12f..c7ec5a6 100644 --- a/Gemfile +++ b/Gemfile @@ -46,5 +46,5 @@ gem 'qonsole-rails', git: 'https://github.com/epimorphics/qonsole-rails' # TODO: In production you want to set this to the gem from the epimorphics package repo source 'https://rubygems.pkg.github.com/epimorphics' do gem 'json_rails_logger', '~> 1.0.0' - gem 'lr_common_styles', '~> 1.9.3' + gem 'lr_common_styles', '~> 1.9', '>= 1.9.5' end From 13aae401a33a3ba55ceae8cbdf721c1698be111d Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Mon, 19 Aug 2024 11:40:36 +0100 Subject: [PATCH 06/31] updates changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e2724d..902f524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ including the SPARQL Qonsole ## 1.7.7 - 2024-08 +- (Dan) Updates gemfile to use v1.9.5 lr_common_styles - (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibiliy requirments[GH-126](https://github.com/epimorphics/lr-landing/issues/126) ## 1.7.6 - 2024-03-12 From 86865ff922af38c2916400979811b12cb788ffe7 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 21 Aug 2024 13:59:04 +0100 Subject: [PATCH 07/31] build: updated .gitignore added additional rulesets as well as reorganised and grouped rules to allow easier reading and updating in the future --- .gitignore | 53 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 4717b47..5c1b39b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,26 +4,51 @@ # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' -!/log/.keep -.byebug_history -.github-token -.npmrc -.tags +# Ignore vscode config .vscode -.yarn-integrity + +## Ignore bundler configuration: /.bundle +/vendor/bundle +/lib/bundler/man/ + +# Ignore all logfiles and tempfiles. /log/* -/node_modules +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore Byebug command history file. +.byebug_history + +# Ignore node_modules +node_modules/ + +# Ignore precompiled javascript packs /public/packs /public/packs-test -/tmp -coverage -fc_simple.json +/public/assets + +# Ignore uploaded files in development +/storage/* +!/storage/.keep +/public/uploads + +### Rails specific ### +.byebug_history +/public/system +/coverage/ +tmp + +# Ignore files specific to the development environment fc.json +fc_simple.json index-names.txt index.json -node_modules/ -public/assets tags -yarn-debug.log* -yarn-error.log + +# Ignore dot files used by environment or IDE tools +.tags +.tool-versions +.github-token +.npmrc From 906f8aa3ab9b7dd712afb36edd0ef26756bafd11 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 21 Aug 2024 14:05:02 +0100 Subject: [PATCH 08/31] build: updated makefile reorganised targets alphabetically as well as mirrored other improvements from the other applications in the suite --- Makefile | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index eb3bfe3..b043fd1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: assets clean image lint publish realclean run tag test vars +.PHONY: assets auth check clean image lint local publish realclean run tag test vars ACCOUNT?=$(shell aws sts get-caller-identity | jq -r .Account) ALPINE_VERSION?=3.13 @@ -27,23 +27,27 @@ REPO?=${ECR}/${IMAGE} GITHUB_TOKEN=.github-token BUNDLE_CFG=.bundle/config -all: image - ${BUNDLE_CFG}: ${GITHUB_TOKEN} @./bin/bundle config set --local rubygems.pkg.github.com ${GPR_OWNER}:`cat ${GITHUB_TOKEN}` ${GITHUB_TOKEN}: @echo ${PAT} > ${GITHUB_TOKEN} +all: image + assets: - @./bin/bundle config set --local without 'development' + @./bin/bundle config set --local without 'development test' @./bin/bundle install @./bin/rails assets:clean assets:precompile auth: ${GITHUB_TOKEN} ${BUNDLE_CFG} +check: lint test + @echo "All checks passed." + clean: @[ -d public/assets ] && ./bin/rails assets:clobber || : + @@ rm -rf bundle coverage log node_modules image: auth @echo Building ${REPO}:${TAG} ... @@ -63,6 +67,12 @@ image: auth lint: assets @./bin/bundle exec rubocop +local: + @echo "Installing all packages ..." + @./bin/bundle install + @echo "Starting local server ..." + @./bin/rails server -p ${PORT} + publish: image @echo Publishing image: ${REPO}:${TAG} ... @docker push ${REPO}:${TAG} 2>&1 @@ -71,16 +81,23 @@ publish: image realclean: clean @rm -f ${GITHUB_TOKEN} ${BUNDLE_CFG} -run: +run: start @if docker network inspect dnet > /dev/null 2>&1; then echo "Using docker network dnet"; else echo "Create docker network dnet"; docker network create dnet; sleep 2; fi + @docker run -p ${PORT}:3000 -e API_SERVICE_URL=${API_SERVICE_URL} --network dnet --rm --name ${SHORTNAME} ${REPO}:${TAG} + +server: assets start + @export SECRET_KEY_BASE=$(./bin/rails secret) + @API_SERVICE_URL=${API_SERVICE_URL} ./bin/rails server -p ${PORT} + +start: @docker stop ${SHORTNAME} > /dev/null 2>&1 || : @echo "Starting ${SHORTNAME} ..." - @docker run -p ${PORT}:3000 --network dnet --rm --name ${SHORTNAME} ${REPO}:${TAG} tag: @echo ${TAG} test: assets + @echo "Running unit tests ..." @./bin/rails test vars: From a3a774ebff9d3794715c40b201b5d9f9bfdbca81 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 21 Aug 2024 14:06:34 +0100 Subject: [PATCH 09/31] feat: addition of metrics to landing app Implements improved boilerplate metrics integration --- .../action_dispatch_prometheus_subscriber.rb | 28 ++++++++ app/subscribers/api_prometheus_subscriber.rb | 64 +++++++++++++++++++ .../application_prometheus_subscriber.rb | 13 ++++ config.ru | 11 ++-- config/initializers/prometheus.rb | 58 +++++++++++++++++ 5 files changed, 169 insertions(+), 5 deletions(-) create mode 100644 app/subscribers/action_dispatch_prometheus_subscriber.rb create mode 100644 app/subscribers/api_prometheus_subscriber.rb create mode 100644 app/subscribers/application_prometheus_subscriber.rb create mode 100644 config/initializers/prometheus.rb diff --git a/app/subscribers/action_dispatch_prometheus_subscriber.rb b/app/subscribers/action_dispatch_prometheus_subscriber.rb new file mode 100644 index 0000000..4128c26 --- /dev/null +++ b/app/subscribers/action_dispatch_prometheus_subscriber.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Subscribe to `*.action_controller`` events +# +# Note: This is Rails 5 specific. In Rails 6, we'd subscribe to +# `request.action_dispatch` +class ActionDispatchPrometheusSubscriber < ActiveSupport::Subscriber + attach_to :action_controller + + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength + def process_action(_event) + mem = GetProcessMem.new + Prometheus::Client.registry + .get(:memory_used_mb) + .set(mem.mb) + + Prometheus::Client.registry + .get(:thread_count) + .set(Thread.list.select do |thread| + %w[run sleep].include?(thread.status) + end.count) + + Prometheus::Client.registry + .get(:process_threads) + .set(Thread.list.select { |thread| thread.status == 'run' }.count) + end + # rubocop:enable Metrics/AbcSize, Metrics/MethodLength +end diff --git a/app/subscribers/api_prometheus_subscriber.rb b/app/subscribers/api_prometheus_subscriber.rb new file mode 100644 index 0000000..0760c41 --- /dev/null +++ b/app/subscribers/api_prometheus_subscriber.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +# Subscribe to :data_api events +class ApiPrometheusSubscriber < ActiveSupport::Subscriber + attach_to :api + + def response(event) + response = event.payload[:response] + duration = event.payload[:duration] + + Prometheus::Client.registry + .get(:api_status) + .increment(labels: { status: response.status.to_s }) + + Prometheus::Client.registry + .get(:api_requests) + .increment(labels: { result: 'success' }) + + Prometheus::Client.registry + .get(:api_response_times) + .observe(duration) + end + + def connection_failure(event) + exception = event.payload[:exception] + message = exception.message || exception.to_s + + Prometheus::Client.registry + .get(:api_requests) + .increment(labels: { result: 'failure' }) + + Prometheus::Client.registry + .get(:api_connection_failure) + .increment(labels: { message: }) + end + + def service_exception(event) + exception = event.payload[:exception] + status = exception_status(exception) + + return if status == 404 + + Prometheus::Client.registry + .get(:api_service_exception) + .increment(labels: { status: }) + end + + private + + def exception_status(exception) + status = 500 + + begin + json = JSON.parse(exception.message) + status = json['status'] if json&.key?('status') + rescue JSON::ParserError + # was not JSON after all + end + + status = exception.status if exception.respond_to?(:status) + + status + end +end diff --git a/app/subscribers/application_prometheus_subscriber.rb b/app/subscribers/application_prometheus_subscriber.rb new file mode 100644 index 0000000..245a6fd --- /dev/null +++ b/app/subscribers/application_prometheus_subscriber.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Subscribe to :application events +class ApplicationPrometheusSubscriber < ActiveSupport::Subscriber + attach_to :application + + def internal_error(event) + message = event.payload[:exception] + Prometheus::Client.registry + .get(:internal_application_error) + .increment(labels: { message: message.to_s }) + end +end diff --git a/config.ru b/config.ru index 4cb621b..7b7256b 100644 --- a/config.ru +++ b/config.ru @@ -1,14 +1,15 @@ # frozen_string_literal: true # This file is used by Rack-based servers to start the application. - require_relative 'config/environment' -require 'prometheus/middleware/collector' -require 'prometheus/middleware/exporter' +unless Rails.env.test? + require 'prometheus/middleware/collector' + require 'prometheus/middleware/exporter' -use Prometheus::Middleware::Collector -use Prometheus::Middleware::Exporter + use Prometheus::Middleware::Collector + use Prometheus::Middleware::Exporter +end require ::File.expand_path('config/environment', __dir__) diff --git a/config/initializers/prometheus.rb b/config/initializers/prometheus.rb new file mode 100644 index 0000000..5c6afe9 --- /dev/null +++ b/config/initializers/prometheus.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +prometheus = Prometheus::Client.registry + +# Prometheus counters +prometheus.counter( + :api_status, + docstring: 'Count of API responses, labelled by status', + labels: [:status] +) + +prometheus.counter( + :api_requests, + docstring: 'Count of API responses, labelled by succeeded true/false', + labels: [:result] +) + +prometheus.counter( + :api_connection_failure, + docstring: 'Total of failures to connect to API, labelled by reason', + labels: [:message] +) + +prometheus.counter( + :api_service_exception, + docstring: 'Total of other errors when processing API responses', + labels: [:status] +) + +prometheus.counter( + :internal_application_error, + docstring: 'Unexpected events and internal error count', + labels: [:message] +) + +# Prometheus gauges +prometheus.gauge( + :memory_used_mb, + docstring: 'Process memory usage in mb' +) + +prometheus.gauge( + :thread_count, + docstring: 'The number of threads currently alive' +) + +prometheus.gauge( + :process_threads, + docstring: 'The number of currently running threads' +) + +# Histograms + +prometheus.histogram( + :api_response_times, + docstring: 'Histogram of back-end API response times', + buckets: Prometheus::Client::Histogram.exponential_buckets(start: 0.0005, count: 16) +) From b26f50bf9458e68c7e2118da7f42e733478e2eb5 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 21 Aug 2024 14:12:24 +0100 Subject: [PATCH 10/31] refactor: additional a11y improvements implemented the dynamic page title approach used in the other suite apps to the accessibility and privacy translation templates, as well as converted the privacy templates to match the same haml formatting language used everywhere else, alongside tweaking the application controller to improve selected language option to be applied --- app/controllers/application_controller.rb | 33 ++++---- app/views/doc/_accessibility_cy.html.haml | 5 +- app/views/doc/_accessibility_en.html.haml | 6 +- ...vacy_cy.html.erb => _privacy_cy.html.haml} | 76 +++++++++++-------- ...vacy_en.html.erb => _privacy_en.html.haml} | 66 +++++++++------- app/views/doc/hpi.html.haml | 5 +- app/views/doc/ppd.html.haml | 4 +- app/views/doc/privacy.html.erb | 2 - app/views/doc/privacy.html.haml | 2 + app/views/landing/_index_cy.html.haml | 4 +- app/views/landing/_index_en.html.haml | 3 +- app/views/landing/hpi.html.haml | 4 +- config/application.rb | 6 +- 13 files changed, 131 insertions(+), 85 deletions(-) rename app/views/doc/{_privacy_cy.html.erb => _privacy_cy.html.haml} (64%) rename app/views/doc/{_privacy_en.html.erb => _privacy_en.html.haml} (52%) delete mode 100644 app/views/doc/privacy.html.erb create mode 100644 app/views/doc/privacy.html.haml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9df9271..d70049b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,30 +2,37 @@ # :nodoc: class ApplicationController < ActionController::Base - # Prevent CSRF attacks by raising an exception. - # For APIs, you may want to use :null_session instead. + # Prevent CSRF attacks by raising an exception. For APIs, you may want to use + # :null_session instead. protect_from_forgery with: :exception - - before_action :set_locale, :change_default_caching_policy + before_action :change_default_caching_policy + before_action :set_locale private - # Set the user's preferred locale. An explicit locale set via - # the URL param `lang` is preeminent, otherwise we look to the - # user's preferred language specified via browser headers + # Set the user's preferred locale. An explicit locale set via the URL param + # `lang` is preeminent, otherwise we look to the user's preferred language + # specified via browser headers def set_locale - user_locale = - params['lang'] || - http_accept_language.compatible_language_from(I18n.available_locales) + user_locale = params['lang'] + user_locale ||= http_accept_language.compatible_language_from(I18n.available_locales) I18n.locale = user_locale if Rails.application.config.welsh_language_enabled end # * Set cache control headers for HMLR apps to be public and cacheable - # * Landing Page uses a time limit of 5 minutes (300 seconds) - # Sets the default `Cache-Control` header for all requests, - # unless overridden in the action + # * Landing Page uses a time limit of 5 minutes (300 seconds) Sets the default + # `Cache-Control` header for all requests, unless overridden in the action def change_default_caching_policy expires_in 5.minutes, public: true, must_revalidate: true if Rails.env.production? end + + # Notify subscriber(s) of an internal error event with the payload of the + # exception once done + # @param [Exception] exp the exception that caused the error + # @return [ActiveSupport::Notifications::Event] provides an object-oriented + # interface to the event + def instrument_internal_error(exp) + ActiveSupport::Notifications.instrument('internal_error.application', exception: exp) + end end diff --git a/app/views/doc/_accessibility_cy.html.haml b/app/views/doc/_accessibility_cy.html.haml index 41bbe2b..cf855ee 100644 --- a/app/views/doc/_accessibility_cy.html.haml +++ b/app/views/doc/_accessibility_cy.html.haml @@ -1,7 +1,8 @@ +- content_for(:title, 'Datganiad hygyrchedd') +- content_for(:description, 'Datganiad hygyrchedd ar gyfer cymwysiadau data agored: archwiliwr Data Pris a Dalwyd, adeiladwr adroddiadau safonol a Mynegai Prisiau Tai y DU') %article %h1.heading-large - Datganiad hygyrchedd ar gyfer cymwysiadau data agored: archwiliwr Data Pris a - Dalwyd, adeiladwr adroddiadau safonol a Mynegai Prisiau Tai y DU + = yield(:description) %p Cofrestrfa Tir EM sy’n rhedeg y wefan hon. Rydym am i gynifer o bobl â diff --git a/app/views/doc/_accessibility_en.html.haml b/app/views/doc/_accessibility_en.html.haml index 707be84..df9d8ba 100644 --- a/app/views/doc/_accessibility_en.html.haml +++ b/app/views/doc/_accessibility_en.html.haml @@ -1,8 +1,8 @@ +- content_for(:title, 'Accessibility statement') +- content_for(:description, 'Accessibility statement for open data applications: Price Paid Data (PPD) explorer, standard reports builder and UK House Price Index (UKHPI)') %article %h1.heading-large - Accessibility statement for open data applications: Price Paid - Data (PPD) explorer, standard reports builder and UK House - Price Index (UKHPI) + = yield(:description) %p This website is run by HM Land Registry. We want as many people as diff --git a/app/views/doc/_privacy_cy.html.erb b/app/views/doc/_privacy_cy.html.haml similarity index 64% rename from app/views/doc/_privacy_cy.html.erb rename to app/views/doc/_privacy_cy.html.haml index d74c0ff..5f8b6e7 100644 --- a/app/views/doc/_privacy_cy.html.erb +++ b/app/views/doc/_privacy_cy.html.haml @@ -1,37 +1,53 @@ -
-

Hysbysiad preifatrwydd

-

+- content_for(:title, 'Hysbysiad preifatrwydd') + +%article + %h1 + = yield(:title) + + %p Mae’r hysbysiad preifatrwydd hwn yn egluro beth rydym yn ei wneud gyda’r wybodaeth a gawn oddi wrthych pan fyddwch yn defnyddio’n gwasanaeth. -

-

Cwcis

-

+ + %h2 + Cwcis + %p Ffeiliau bach sy’n cael eu harbed ar eich ffôn, llechen neu gyfrifiadur pan fyddwch yn ymweld â gwefan yw cwcis. Rydym yn defnyddio cwcis i wneud i’r wefan weithio ac i ddeall sut rydych yn defnyddio’n gwasanaeth, er enghraifft y tudalennau rydych yn ymweld â nhw. -

-

Cwcis hanfodol

-

+ + %h3 + Cwcis hanfodol + %p Mae cwcis hanfodol yn cadw’ch gwybodaeth yn ddiogel wrth ichi ddefnyddio’r gwasanaeth hwn. Nid oes angen eich caniatâd arnom i’w defnyddio. -

-
    -
  • Dynodydd sesiwn unigryw
  • -
-

Cwcis dadansoddol (dewisol)

-

+ + %ul.list.list-bullet + %li + Dynodydd sesiwn unigryw + + + %h3 + Cwcis dadansoddol (dewisol) + %p Gyda’ch caniatâd, rydym yn defnyddio Google Analytics i gasglu data am sut rydych yn defnyddio’r gwasanaeth. Rydym yn defnyddio’r wybodaeth hon i’n helpu i wella’r gwasanaeth ar sail anghenion defnyddwyr. -

-

+ + %p Ni chaniateir i Google ddefnyddio neu rannu ein data dadansoddol gydag unrhyw un. -

-

+ + %p Mae Google Analytics yn gosod cwcis sy’n storio gwybodaeth ddienw am y canlynol: -

-
    -
  • y tudalennau rydych yn ymweld â nhw
  • -
  • pa mor hir rydych yn ei dreulio ar bob tudalen
  • -
  • sut y cyrhaeddwyd y gwasanaeth
  • -
  • ar beth rydych yn clicio wrth ymweld â’r gwasanaeth
  • -
-

Cwcis sy’n cofio’ch gosodiadau

-

+ + %ul.list.list-bullet + %li + y tudalennau rydych yn ymweld â nhw + + %li + pa mor hir rydych yn ei dreulio ar bob tudalen + + %li + sut y cyrhaeddwyd y gwasanaeth + + %li + ar beth rydych yn clicio wrth ymweld â’r gwasanaeth + + + %h3 + Cwcis sy’n cofio’ch gosodiadau + %p Mae’r cwcis hyn yn gwneud pethau fel cofio eich ffafriaeth a’r dewisiadau a wnewch i bersonoli’ch profiad o ddefnyddio’r wefan. -

-
diff --git a/app/views/doc/_privacy_en.html.erb b/app/views/doc/_privacy_en.html.haml similarity index 52% rename from app/views/doc/_privacy_en.html.erb rename to app/views/doc/_privacy_en.html.haml index bc83b70..231b52f 100644 --- a/app/views/doc/_privacy_en.html.erb +++ b/app/views/doc/_privacy_en.html.haml @@ -1,40 +1,50 @@ -
-

Privacy notice

-

+- content_for(:title, 'Privacy notice') + +%article + %h1 + = yield(:title) + %p This privacy notice tells you what we do with the information we collect from you when you use our service. -

-

Cookies

-

+ %h2 + Cookies + %p Cookies are small files saved on your phone, tablet or computer when you visit a website. We use cookies to make the site work and understand how you use our service, such as the pages you visit. -

-

Essential cookies

-

+ %h3 + Essential cookies + %p Essential cookies keep your information secure while you use this service. We do not need your permission to use them. -

-
    -
  • Unique session ID
  • -
-

Analytics cookies (optional)

-

+ %ul.list.list-bullet + %li + Unique session ID + + %h3 + Analytics cookies (optional) + %p With your permission, we use Google Analytics to collect data about how you use the service. We use this information to help us improve the service based on user needs. -

-

Google is not allowed to use or share our analytics data with anyone.

-

Google analytics sets cookies that store anonymised information about:

-
    -
  • the pages you visit
  • -
  • how long you spend on each page
  • -
  • how you got to the service
  • -
  • what you click on while you're visiting the service
  • -
-

Cookies that remember your settings

-

+ + %p + Google is not allowed to use or share our analytics data with anyone. + %p + Google analytics sets cookies that store anonymised information about: + %ul.list.list-bullet + %li + the pages you visit + %li + how long you spend on each page + %li + how you got to the service + %li + what you click on while you're visiting the service + + %h3 + Cookies that remember your settings + %p These cookies do things like remember your preferences and the choices you make to personalise your experience of using the site. -

-
+ diff --git a/app/views/doc/hpi.html.haml b/app/views/doc/hpi.html.haml index f49beac..e2aa049 100644 --- a/app/views/doc/hpi.html.haml +++ b/app/views/doc/hpi.html.haml @@ -1,4 +1,7 @@ -%h2 House Price Index Linked Data +- content_for(:title, 'House Price Index Linked Data') + +%h2 + = yield(:title) %h3 What does the House Price Index Dataset consist of? %p diff --git a/app/views/doc/ppd.html.haml b/app/views/doc/ppd.html.haml index e3a3125..9e6485a 100644 --- a/app/views/doc/ppd.html.haml +++ b/app/views/doc/ppd.html.haml @@ -1,4 +1,6 @@ -%h1 Price Paid Linked Data +- content_for(:title, 'Price Paid Linked Data') +%h1 + = yield(:title) %h2 What does the Price Paid Dataset consist of? %p HM Land Registry publish Price Paid Data for England and Wales on a monthly basis. New transactions are added diff --git a/app/views/doc/privacy.html.erb b/app/views/doc/privacy.html.erb deleted file mode 100644 index 4507eed..0000000 --- a/app/views/doc/privacy.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= render partial: 'shared/lang_switch' %> -<%= render partial: "privacy_#{I18n.locale}"%> diff --git a/app/views/doc/privacy.html.haml b/app/views/doc/privacy.html.haml new file mode 100644 index 0000000..38fa68c --- /dev/null +++ b/app/views/doc/privacy.html.haml @@ -0,0 +1,2 @@ += render partial: 'shared/lang_switch' += render partial: "privacy_#{I18n.locale}" diff --git a/app/views/landing/_index_cy.html.haml b/app/views/landing/_index_cy.html.haml index bcdadcb..e4fe374 100644 --- a/app/views/landing/_index_cy.html.haml +++ b/app/views/landing/_index_cy.html.haml @@ -1,7 +1,9 @@ +- content_for(:title, 'Data Agored') .row .col-md-12 %h1.heading-large - Data Agored + = yield(:title) + %p Mae Cofrestrfa Tir EM yn cyhoeddi’r setiau data cyhoeddus canlynol fel rhan o’n hymrwymiad i flaenoriaethau’r Llywodraeth i dwf economaidd diff --git a/app/views/landing/_index_en.html.haml b/app/views/landing/_index_en.html.haml index bd47045..1d3426c 100644 --- a/app/views/landing/_index_en.html.haml +++ b/app/views/landing/_index_en.html.haml @@ -1,7 +1,8 @@ +- content_for(:title, 'Open Data') .row .col-md-12 %h1.heading-large - Open Data + = yield(:title) %p HM Land Registry publishes the following public datasets on GOV.UK as part of our commitment to the Government’s priorities diff --git a/app/views/landing/hpi.html.haml b/app/views/landing/hpi.html.haml index 738d774..2928bb7 100644 --- a/app/views/landing/hpi.html.haml +++ b/app/views/landing/hpi.html.haml @@ -1,4 +1,6 @@ -%h1 Change to House Price Index data +- content_for(:title, "Change to House Price Index data" ) +%h1 + = yield(:title) %p From 14 June 2016 the HM Land Registry House Price Index was replaced by the %strong UK House Price Index, diff --git a/config/application.rb b/config/application.rb index 87174fe..6c75e48 100644 --- a/config/application.rb +++ b/config/application.rb @@ -35,7 +35,7 @@ def print_boot_information message: "Starting #{server} Rails #{Rails.version} in #{Rails.env} #{origin}" } - puts(msg.to_json) # rubocop:disable Rails/Output + puts(msg.to_json) end end end @@ -53,6 +53,8 @@ class Application < Rails::Application # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de + config.i18n.enforce_available_locales = true + config.i18n.default_locale = :en + config.i18n.available_locales = %i[en cy] end end From 27af4deaa463ee903e2d58bcf03d5132f8bb1596 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 28 Aug 2024 11:36:42 +0100 Subject: [PATCH 11/31] feat: prometheus metrics Now includes metrics even though the rails server is not reporting much due to content of app are static pages. --- Gemfile | 4 +- Gemfile.lock | 8 +-- .../action_dispatch_prometheus_subscriber.rb | 53 +++++++++++++++---- app/subscribers/api_prometheus_subscriber.rb | 9 ++-- config/initializers/prometheus.rb | 9 ++-- 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/Gemfile b/Gemfile index c7ec5a6..985cff6 100644 --- a/Gemfile +++ b/Gemfile @@ -37,7 +37,7 @@ end # ! These "local" paths do not work with a docker image - use the repo instead # gem 'qonsole-rails', path: '~/Epimorphics/clients/land-registry/projects/qonsole-rails' # gem 'json_rails_logger', '~> 1.0.0', path: '~/Epimorphics/shared/json-rails-logger/' -# gem 'lr_common_styles', '~> 1.9.3', path: '~/Epimorphics/clients/land-registry/projects/lr_common_styles/' +# gem 'lr_common_styles', '~> 1.9', '>= 1.9.6', path: '~/Epimorphics/clients/land-registry/projects/lr_common_styles/' # rubocop:enable Layout/LineLength # TODO: In production you want to set this to the gem from the epimorphics github repo @@ -46,5 +46,5 @@ gem 'qonsole-rails', git: 'https://github.com/epimorphics/qonsole-rails' # TODO: In production you want to set this to the gem from the epimorphics package repo source 'https://rubygems.pkg.github.com/epimorphics' do gem 'json_rails_logger', '~> 1.0.0' - gem 'lr_common_styles', '~> 1.9', '>= 1.9.5' + gem 'lr_common_styles', '~> 1.9', '>= 1.9.6' end diff --git a/Gemfile.lock b/Gemfile.lock index 20b1477..05f86b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,7 +61,7 @@ GEM tzinfo (~> 1.1) arel (9.0.0) ast (2.4.2) - autoprefixer-rails (10.4.16.0) + autoprefixer-rails (10.4.19.0) execjs (~> 2) bindex (0.8.1) bootstrap-sass (3.4.1) @@ -155,7 +155,7 @@ GEM parser (3.1.1.0) ast (~> 2.4.1) prometheus-client (4.0.0) - puma (5.6.7) + puma (6.4.2) nio4r (~> 2.0) racc (1.6.2) rack (2.2.8) @@ -263,7 +263,7 @@ GEM json lograge railties - lr_common_styles (1.9.3) + lr_common_styles (1.9.6) bootstrap-sass (~> 3.4.0) font-awesome-rails (~> 4.7.0.1) govuk_elements_rails (~> 2.0.0) @@ -290,7 +290,7 @@ DEPENDENCIES jbuilder (~> 2.0) jquery-rails json_rails_logger (~> 1.0.0)! - lr_common_styles (~> 1.9.3)! + lr_common_styles (~> 1.9, >= 1.9.6)! prometheus-client (~> 4.0) puma qonsole-rails! diff --git a/app/subscribers/action_dispatch_prometheus_subscriber.rb b/app/subscribers/action_dispatch_prometheus_subscriber.rb index 4128c26..217f87e 100644 --- a/app/subscribers/action_dispatch_prometheus_subscriber.rb +++ b/app/subscribers/action_dispatch_prometheus_subscriber.rb @@ -7,22 +7,57 @@ class ActionDispatchPrometheusSubscriber < ActiveSupport::Subscriber attach_to :action_controller - # rubocop:disable Metrics/AbcSize, Metrics/MethodLength + # rubocop:disable Metrics/AbcSize def process_action(_event) mem = GetProcessMem.new Prometheus::Client.registry .get(:memory_used_mb) .set(mem.mb) - + # description: 'Thread is aborting' Prometheus::Client.registry - .get(:thread_count) - .set(Thread.list.select do |thread| - %w[run sleep].include?(thread.status) - end.count) - + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status == 'aborting' }.count, + labels: { + status: 'aborting' + } + ) + # description: 'Thread is sleeping or waiting on I/O' + Prometheus::Client.registry + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status == 'sleep' }.count, + labels: { + status: 'sleep' + } + ) + # description: 'Thread is executing' + Prometheus::Client.registry + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status == 'run' }.count, + labels: { + status: 'run' + } + ) + # description: 'Thread is terminated normally' + Prometheus::Client.registry + .get(:process_threads) + .set( + Thread.list.select { |thread| thread.status == false }.count, + labels: { + status: 'false' + } + ) + # description: 'Thread is terminated with an exception' Prometheus::Client.registry .get(:process_threads) - .set(Thread.list.select { |thread| thread.status == 'run' }.count) + .set( + Thread.list.select { |thread| thread.status.nil? }.count, + labels: { + status: 'nil' + } + ) end - # rubocop:enable Metrics/AbcSize, Metrics/MethodLength + # rubocop:enable Metrics/AbcSize end diff --git a/app/subscribers/api_prometheus_subscriber.rb b/app/subscribers/api_prometheus_subscriber.rb index 0760c41..ab4ab17 100644 --- a/app/subscribers/api_prometheus_subscriber.rb +++ b/app/subscribers/api_prometheus_subscriber.rb @@ -4,13 +4,15 @@ class ApiPrometheusSubscriber < ActiveSupport::Subscriber attach_to :api + # rubocop:disable Metrics/MethodLength def response(event) response = event.payload[:response] duration = event.payload[:duration] + status = response.status.to_s Prometheus::Client.registry .get(:api_status) - .increment(labels: { status: response.status.to_s }) + .increment(labels: { status: status }) Prometheus::Client.registry .get(:api_requests) @@ -20,6 +22,7 @@ def response(event) .get(:api_response_times) .observe(duration) end + # rubocop:enable Metrics/MethodLength def connection_failure(event) exception = event.payload[:exception] @@ -31,7 +34,7 @@ def connection_failure(event) Prometheus::Client.registry .get(:api_connection_failure) - .increment(labels: { message: }) + .increment(labels: { message: message }) end def service_exception(event) @@ -42,7 +45,7 @@ def service_exception(event) Prometheus::Client.registry .get(:api_service_exception) - .increment(labels: { status: }) + .increment(labels: { status: status }) end private diff --git a/config/initializers/prometheus.rb b/config/initializers/prometheus.rb index 5c6afe9..df1d07b 100644 --- a/config/initializers/prometheus.rb +++ b/config/initializers/prometheus.rb @@ -39,14 +39,11 @@ docstring: 'Process memory usage in mb' ) -prometheus.gauge( - :thread_count, - docstring: 'The number of threads currently alive' -) - prometheus.gauge( :process_threads, - docstring: 'The number of currently running threads' + docstring: 'The number of process threads, labelled by status', + labels: [:status], + preset_labels: { status: 'total' } ) # Histograms From ccf39add3c72d4429c25d4ca50c4bb618c273e7c Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 28 Aug 2024 11:39:41 +0100 Subject: [PATCH 12/31] style: rubocop linting fixes primarily comment changes --- app/controllers/application_controller.rb | 14 +++++++------- config/application.rb | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d70049b..cfc2891 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,13 +2,12 @@ # :nodoc: class ApplicationController < ActionController::Base - # Prevent CSRF attacks by raising an exception. For APIs, you may want to use - # :null_session instead. + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception - before_action :change_default_caching_policy before_action :set_locale - - private + before_action :change_default_caching_policy # Set the user's preferred locale. An explicit locale set via the URL param # `lang` is preeminent, otherwise we look to the user's preferred language @@ -21,8 +20,9 @@ def set_locale end # * Set cache control headers for HMLR apps to be public and cacheable - # * Landing Page uses a time limit of 5 minutes (300 seconds) Sets the default - # `Cache-Control` header for all requests, unless overridden in the action + # * Landing Page uses a time limit of 5 minutes (300 seconds) + # Sets the default `Cache-Control` header for all requests, + # unless overridden in the action def change_default_caching_policy expires_in 5.minutes, public: true, must_revalidate: true if Rails.env.production? end diff --git a/config/application.rb b/config/application.rb index 6c75e48..d4c9e7b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,8 +34,9 @@ def print_boot_information level: 'INFO', message: "Starting #{server} Rails #{Rails.version} in #{Rails.env} #{origin}" } - + # rubocop:disable Rails/Output puts(msg.to_json) + # rubocop:enable Rails/Output end end end From 9b4c5d663c447402ec6e7e75b7d639a41157a878 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 28 Aug 2024 11:40:11 +0100 Subject: [PATCH 13/31] refactor: expand argument name for readability expansion of the `exp` var to `exception` in the `instrument_internal_error` metric subscriber --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cfc2891..aba30ba 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -32,7 +32,7 @@ def change_default_caching_policy # @param [Exception] exp the exception that caused the error # @return [ActiveSupport::Notifications::Event] provides an object-oriented # interface to the event - def instrument_internal_error(exp) - ActiveSupport::Notifications.instrument('internal_error.application', exception: exp) + def instrument_internal_error(exception) + ActiveSupport::Notifications.instrument('internal_error.application', exception: exception) end end From 698a509b22bc952d915ea80528d2a512fc4b303f Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 28 Aug 2024 11:40:57 +0100 Subject: [PATCH 14/31] build: update to assets target Now includes auth when building assets --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b043fd1..a8aa0c4 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ ${GITHUB_TOKEN}: all: image -assets: +assets: auth @./bin/bundle config set --local without 'development test' @./bin/bundle install @./bin/rails assets:clean assets:precompile From 16fcc296de75a4504778944661687bf10557c926 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 28 Aug 2024 11:54:22 +0100 Subject: [PATCH 15/31] build: incremented updated version minor cadence from v.1.7.7 ~> v1.8.0 --- app/lib/version.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/lib/version.rb b/app/lib/version.rb index 4c52ee3..38bc7ca 100644 --- a/app/lib/version.rb +++ b/app/lib/version.rb @@ -2,8 +2,8 @@ module Version MAJOR = 1 - MINOR = 7 - REVISION = 7 + MINOR = 8 + REVISION = 0 SUFFIX = nil VERSION = "#{MAJOR}.#{MINOR}.#{REVISION}#{SUFFIX && ".#{SUFFIX}"}" end From d57662195162a46ec5cd0d7007b4f4aaac89040c Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 28 Aug 2024 11:54:34 +0100 Subject: [PATCH 16/31] docs: Updated CHANGELOG --- CHANGELOG.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 902f524..dd97ccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,26 @@ This app presents the landing page experience for landregistry.data.gov.uk, including the SPARQL Qonsole +## 1.8.0 - 2024-08 + +- (Jon) Implemented improved boilerplate metrics integration to offer analysis of + current application usage stats +- (Jon) Implemented the dynamic page title approach used in the other suite apps + to the accessibility and privacy translation templates +- (Jon) Converted the privacy templates to match the same haml formatting + language used in the app +- (Jon) Tweaked the application controller to improve selected language option + to be applied for the pages +- (Jon) Reorganised makefile targets alphabetically as well as mirrored other + improvements from the other applications in the suite +- (Jon) Updated .gitignore file to mirror the current approach in the other HMLR + apps + ## 1.7.7 - 2024-08 - (Dan) Updates gemfile to use v1.9.5 lr_common_styles -- (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibiliy requirments[GH-126](https://github.com/epimorphics/lr-landing/issues/126) +- (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibiliy + requirments[GH-126](https://github.com/epimorphics/lr-landing/issues/126) ## 1.7.6 - 2024-03-12 @@ -29,7 +45,8 @@ including the SPARQL Qonsole - (Jon) Updated the `app/controllers/application_controller.rb` to include the `before_action` for the `change_default_caching_policy` method to ensure the - default `Cache-Control` header for all requests is set to 5 minutes (300 seconds). + default `Cache-Control` header for all requests is set to 5 minutes (300 + seconds). ## 1.7.3 - 2023-06-07 @@ -58,8 +75,8 @@ including the SPARQL Qonsole - (Jon) Updated and improved the build files for the new infrastructure use. - (Jon) Minor text changes to the `Gemfile` to include instructions for running Epimorphics specific gems locally during the development of those gems. -- (Jon) Updated the production `json_rails_logger` gem version to be at least the - current version `~>0.3.5` (this is to cover out of sync release versions) +- (Jon) Updated the production `json_rails_logger` gem version to be at least + the current version `~>0.3.5` (this is to cover out of sync release versions) - (Jon) Updated the production `lr_common_styles` gem version to be at least the current version `~>1.9.1` (this is to cover out of sync release versions) - (Jon) Refactored the version cadence creation to include a SUFFIX value if From 1116336d4836e3f0b8ef48e73cc767b94eaaf154 Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Tue, 3 Sep 2024 12:48:23 +0100 Subject: [PATCH 17/31] Fixes landing page application error --- Gemfile | 1 + Gemfile.lock | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 985cff6..bb9f5ca 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ gem 'jbuilder', '~> 2.0' gem 'haml-rails', '~> 2.0.0' gem 'http_accept_language' gem 'prometheus-client', '~> 4.0' +gem 'get_process_mem', '~> 0.2.7' gem 'puma' gem 'sentry-rails', '~> 5.2' diff --git a/Gemfile.lock b/Gemfile.lock index 05f86b8..3e74e99 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,6 +85,8 @@ GEM ffi (1.15.5) font-awesome-rails (4.7.0.8) railties (>= 3.2, < 8.0) + get_process_mem (0.2.7) + ffi (~> 1.0) globalid (1.0.1) activesupport (>= 5.0) govuk_elements_rails (2.0.0) @@ -285,6 +287,7 @@ PLATFORMS DEPENDENCIES byebug + get_process_mem (~> 0.2.7) haml-rails (~> 2.0.0) http_accept_language jbuilder (~> 2.0) From b27def70924dddb0698f63a7dc8e1f939d676bc6 Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Tue, 3 Sep 2024 13:40:53 +0100 Subject: [PATCH 18/31] Removed /doc/ from accessibility and privacy routes --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index fa10994..bde123a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,6 +12,6 @@ get 'doc/ppd', to: 'doc#ppd', as: 'ppd_doc' get 'doc/ukhpi-dsd', to: redirect('/app/ukhpi/doc/ukhpi-dsd', status: 302) get 'doc/ukhpi-user-guide', to: redirect('/app/ukhpi/doc/ukhpi-user-guide', status: 302) - get 'doc/accessibility', to: 'doc#accessibility' - get 'doc/privacy', to: 'doc#privacy' + get 'accessibility', to: 'doc#accessibility' + get 'privacy', to: 'doc#privacy' end From 78e2238f9434042914e8f0fd364eca23b8681c94 Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Tue, 3 Sep 2024 13:41:17 +0100 Subject: [PATCH 19/31] Set the correct a11y and privacy statement routes for testing --- config/environments/test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index 5025e19..2867713 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -45,8 +45,8 @@ config.logger = JsonRailsLogger::Logger.new($stdout) # Use default paths for documentation. - config.accessibility_document_path = '/doc/accessibility' - config.privacy_document_path = '/doc/privacy' + config.accessibility_document_path = '/accessibility' + config.privacy_document_path = '/privacy' # feature flag for showing the Welsh language switch affordance config.welsh_language_enabled = true From 27524bea99c100ee2482ec0e2a620d696d14cab8 Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Tue, 3 Sep 2024 13:41:24 +0100 Subject: [PATCH 20/31] Set the correct a11y and privacy statement routes for development --- config/environments/development.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 1141c3b..a19046c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -57,8 +57,8 @@ config.api_service_url = ENV.fetch('API_SERVICE_URL', 'http://localhost:8888') # Use default paths for documentation. - config.accessibility_document_path = '/doc/accessibility' - config.privacy_document_path = '/doc/privacy' + config.accessibility_document_path = '/accessibility' + config.privacy_document_path = '/privacy' # feature flag for showing the Welsh language switch affordance config.welsh_language_enabled = true From 8a0cf8251d434d6fdd2c71d90894aaa056767be8 Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Tue, 3 Sep 2024 13:41:43 +0100 Subject: [PATCH 21/31] Fixed wording and formatting errors in changelog entry --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd97ccf..8a198fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,8 +21,8 @@ including the SPARQL Qonsole ## 1.7.7 - 2024-08 - (Dan) Updates gemfile to use v1.9.5 lr_common_styles -- (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibiliy - requirments[GH-126](https://github.com/epimorphics/lr-landing/issues/126) +- (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibility requirements + [GH-126](https://github.com/epimorphics/lr-landing/issues/126) ## 1.7.6 - 2024-03-12 From 801584ec1a82de8839ccbe098df6e37339e9199c Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Tue, 3 Sep 2024 13:41:51 +0100 Subject: [PATCH 22/31] Added changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a198fa..4d0f64d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ including the SPARQL Qonsole ## 1.8.0 - 2024-08 +- (Bogdan) Fixed a bug where the language switcher was not working correctly when + the user was on the accessibility or privacy pages [GH-130](https://github.com/epimorphics/lr-landing/issues/130) - (Jon) Implemented improved boilerplate metrics integration to offer analysis of current application usage stats - (Jon) Implemented the dynamic page title approach used in the other suite apps From e6dfb89f221e1558ee6a5d3fbcc867399bee1fab Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Tue, 3 Sep 2024 13:43:07 +0100 Subject: [PATCH 23/31] Small typo fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0f64d..9974b16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ including the SPARQL Qonsole ## 1.8.0 - 2024-08 -- (Bogdan) Fixed a bug where the language switcher was not working correctly when +- (Bogdan) Fixed a bug where the language selector was not working correctly when the user was on the accessibility or privacy pages [GH-130](https://github.com/epimorphics/lr-landing/issues/130) - (Jon) Implemented improved boilerplate metrics integration to offer analysis of current application usage stats From 48845ea3140bf025b21cf1c0852f37c1a5a7b191 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Wed, 4 Sep 2024 11:44:31 +0100 Subject: [PATCH 24/31] build: Updated `LR_Common_Styles.gem` to v.1.9.7 --- Gemfile | 6 +++--- Gemfile.lock | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index bb9f5ca..e61a083 100644 --- a/Gemfile +++ b/Gemfile @@ -14,10 +14,10 @@ gem 'jquery-rails' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' +gem 'get_process_mem', '~> 0.2.7' gem 'haml-rails', '~> 2.0.0' gem 'http_accept_language' gem 'prometheus-client', '~> 4.0' -gem 'get_process_mem', '~> 0.2.7' gem 'puma' gem 'sentry-rails', '~> 5.2' @@ -38,7 +38,7 @@ end # ! These "local" paths do not work with a docker image - use the repo instead # gem 'qonsole-rails', path: '~/Epimorphics/clients/land-registry/projects/qonsole-rails' # gem 'json_rails_logger', '~> 1.0.0', path: '~/Epimorphics/shared/json-rails-logger/' -# gem 'lr_common_styles', '~> 1.9', '>= 1.9.6', path: '~/Epimorphics/clients/land-registry/projects/lr_common_styles/' +# gem 'lr_common_styles', '~> 1.9.0', path: '~/Epimorphics/clients/land-registry/projects/lr_common_styles/' # rubocop:enable Layout/LineLength # TODO: In production you want to set this to the gem from the epimorphics github repo @@ -47,5 +47,5 @@ gem 'qonsole-rails', git: 'https://github.com/epimorphics/qonsole-rails' # TODO: In production you want to set this to the gem from the epimorphics package repo source 'https://rubygems.pkg.github.com/epimorphics' do gem 'json_rails_logger', '~> 1.0.0' - gem 'lr_common_styles', '~> 1.9', '>= 1.9.6' + gem 'lr_common_styles', '~> 1.9.0' end diff --git a/Gemfile.lock b/Gemfile.lock index 3e74e99..9a9de4f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -265,7 +265,7 @@ GEM json lograge railties - lr_common_styles (1.9.6) + lr_common_styles (1.9.7) bootstrap-sass (~> 3.4.0) font-awesome-rails (~> 4.7.0.1) govuk_elements_rails (~> 2.0.0) @@ -293,7 +293,7 @@ DEPENDENCIES jbuilder (~> 2.0) jquery-rails json_rails_logger (~> 1.0.0)! - lr_common_styles (~> 1.9, >= 1.9.6)! + lr_common_styles (~> 1.9.0)! prometheus-client (~> 4.0) puma qonsole-rails! From a14e09bcbf1bded9c206ce27ccfa82450daff7ce Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Wed, 4 Sep 2024 17:36:51 +0100 Subject: [PATCH 25/31] Moved all README information into the wiki --- README.md | 189 +----------------------------------------------------- 1 file changed, 1 insertion(+), 188 deletions(-) diff --git a/README.md b/README.md index 8bb578e..f16db37 100644 --- a/README.md +++ b/README.md @@ -1,188 +1 @@ -# HMLR linked-data applications landing site - -This repo provides the landing page experience for visitors to -[landregistry.data.gov.uk](http://landregistry.data.gov.uk). The landing page -provides links to the various open data services, and hosts the qonsole -app, which allows users to run SPARQL queries against the linked-data dataset. - -Please see the other repositories in the [HM Land Registry Open -Data](https://github.com/epimorphics/hmlr-linked-data/) project for more -details. - -## Running the app locally - -### In development mode - -Begin by cloning [the Github repo](https://github.com/epimorphics/lr-landing) -and installing the dependencies: - -```sh -git clone git@github.com:epimorphics/lr-landing.git && -cd lr-landing && -bundle install -``` - -#### Trouble shooting bundle install - -If bundle install does not work add a .bundle directory and create a config -file. So you now have .bundle/config. -Add the following line to the config file. -BUNDLE_RUBYGEMS__PKG__GITHUB__COM: "your-username:your-personal-access-token" -Then run bundle install again and eveything should work. - -Start the app locally for development: - -```sh -rails server -``` - -If you want to be able to test `Qonsole` locally, you will need to run the app -with the `API_SERVICE_URL` environment variable set to the URL of the Data API: - -```sh -API_SERVICE_URL=http://localhost:8888 rails server -``` - -Visit to view the local instance. - -### In production mode - -Unlike other HMLR applications, the Landing application does not run run from a -sub-directory. - -As such **Production** *and* **Development** modes run at the same path. - -If running more than one application locally you need to ensure that each is -listening on a separate port. In the case of running local docker images, the -required configuration is captured in the application's `Makefile` and an image -can be run by using: - -```sh -make image run -``` - -or, if the image is already built, simply - -```sh -make run -``` - -You can start a production mode rails server locally using the following -command: - -```sh -rails server -e production -``` - -N.B Ommitting the `-e` flag will default to `development` mode. - -To test the running application visit in your browser. - -For more information on how to running a proxy to mimic production and run -multple services together see -[simple-web-proxy](https://github.com/epimorphics/simple-web-proxy/) - -With the proxy and Docker container running you can access the application as -[`localhost:8080`](http://localhost:8080) (note the lack of trailing path). - -## Additional Information - -### Updating the code - -This is a pretty standard, and quite small, Rails app. - -Please keep the [changelog](CHANGELOG.md) up-to-date, and increment the -[`/app/lib/version.rb`](https://github.com/epimorphics/lr-landing/app/lib/version.rb) -identifier in line with semver principles. - -### Coding standards - -#### Running code linting - -```sh -rubocop -``` - -Rubocop should always return no errors or warnings. - -```sh -Inspecting 30 files -.............................. - -30 files inspected, no offenses detected -``` - -#### Running integration tests - -```sh -rails test -``` - -Tests should always return as passing: - -```sh -Run options: --seed ##### - -# Running: -[...] - -Finished in 1.050748s, 6.6619 runs/s, 8.5653 assertions/s. -7 runs, 9 assertions, 0 failures, 0 errors, 0 skips -``` - -### Deployment - -The detailed deployment mapping is described in `deployment.yml`. At the time of -writing, using the new infrastructure, the deployment process is as follows: - -- commits to the `dev-infrastructure` branch will deploy the `dev` server -- commits to the `preprod` branch will deploy the `pre-production` server -- any commit on the `prod` branch will deploy the `production` server as a new - release - -If the commit is a "new" release, the deployment should be tagged with the same -version number, e.g. `1.2.3`. as set in the `/app/lib/version.rb` and a short -annotation summarising the updates should be included in the tag. - -Once the production deployment has been completed and verified, please create a -release on the repository using the same latest version number. Utilise the -`Generate release notes from commit log` option to create specific notes on the -contained changes as well as the ability to diff agains the previous version. - -#### `entrypoint.sh` - -- There is a workaround to removing the PID lock of the Rails process in the - event of the application crashing and not releasing the process. -- The rails `SECRET_KEY_BASE` is created here. - -### Runtime Configuration environment variables - -We can use a number of environment variables to determine the runtime behaviour -of the application while developing the codebase locally: - -| name | description | -| -------------------------- | -------------------------------------------------------------------- | -| `SENTRY_API_KEY` | The Sentry DSN client key for the `lr-dgu-landing` Sentry app | - -### Dependent gems - -Most of the local (i.e. Epimorphics) gems that this project depends on are -served via GitHub Package Registry (GPR). Specifically, `lr_common_styles` and -`json-rails-logger`. - -However, `qonsole-rails` is **not** served via GPR at present, mostly because we -are hoping to retire it in favour of a new implementation of Qonsole. Since -`qonsole-rails` is a public repo, this dependency does not require us to lean on -the old pattern of using an ssh key to serve private gems directly from a GitHub -repo. - -Accessing gems from GPR will require a personal access token (PAT). To store -this locally, use `make auth` to set your GitHub Token using the PAT. - -To create a PAT, see [the Epimorphics -wiki](https://github.com/epimorphics/internal/wiki/Ansible-CICD#creating-a-pat-for-gpr-access). - -### Issues - -Please add issues to the [shared issues -list](https://github.com/epimorphics/hmlr-linked-data/issues) +Please see [the wiki](https://github.com/epimorphics/lr-landing/wiki) for more information about the project. From e786512dea91faad710c33744203544dc1083687 Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Thu, 5 Sep 2024 11:54:07 +0100 Subject: [PATCH 26/31] Added short description about the project to the README --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f16db37..27344d4 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ -Please see [the wiki](https://github.com/epimorphics/lr-landing/wiki) for more information about the project. +# HMLR linked-data applications landing site + +This repo provides the landing page experience for visitors to +[landregistry.data.gov.uk](http://landregistry.data.gov.uk). The landing page +provides links to the various open data services, and hosts the qonsole +app, which allows users to run SPARQL queries against the linked-data dataset. + +Please see the other repositories in the [HM Land Registry Open +Data](https://github.com/epimorphics/hmlr-linked-data/) project for more +details. + +For more information about this project check out [the wiki](https://github.com/epimorphics/lr-landing/wiki) From 2dcb574c9923d8ab9fdef1fda7b1308bfd6acb58 Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Thu, 5 Sep 2024 12:04:34 +0100 Subject: [PATCH 27/31] README rewording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 27344d4..cc7f300 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,4 @@ Please see the other repositories in the [HM Land Registry Open Data](https://github.com/epimorphics/hmlr-linked-data/) project for more details. -For more information about this project check out [the wiki](https://github.com/epimorphics/lr-landing/wiki) +For more information about this project visit [the wiki](https://github.com/epimorphics/lr-landing/wiki) From bbacd576ee7857081cfc5d154c1e8b7e3c941157 Mon Sep 17 00:00:00 2001 From: Bogdan Marc Date: Thu, 5 Sep 2024 15:14:03 +0100 Subject: [PATCH 28/31] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc7f300..4846a39 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,4 @@ Please see the other repositories in the [HM Land Registry Open Data](https://github.com/epimorphics/hmlr-linked-data/) project for more details. -For more information about this project visit [the wiki](https://github.com/epimorphics/lr-landing/wiki) +For more information about this project visit [the wiki](https://github.com/epimorphics/lr-landing/wiki). From 3d07c6744a1d0bf00a9098d67be68fa8d9519b8d Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Thu, 5 Sep 2024 16:15:28 +0100 Subject: [PATCH 29/31] build: application configuration unification Moved all mirrored configuration settings from individual environments into the application configuration to reduce the need to manage multiple sources --- config/application.rb | 10 ++++++++++ config/environments/development.rb | 10 ---------- config/environments/production.rb | 10 ---------- config/environments/test.rb | 10 ---------- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/config/application.rb b/config/application.rb index d4c9e7b..47e404f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -48,6 +48,16 @@ class Application < Rails::Application # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + # Use default paths for documentation. + config.accessibility_document_path = '/accessibility' + config.privacy_document_path = '/privacy' + + # feature flag for showing the Welsh language switch affordance + config.welsh_language_enabled = true + + # Set the contact email address to Land Registry supplied address + config.contact_email_address = 'data.services@mail.landregistry.gov.uk' + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' diff --git a/config/environments/development.rb b/config/environments/development.rb index a19046c..8b69f5b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -55,14 +55,4 @@ # API location can be specified in the environment but defaults to the dev service # Here we are still providing the API_SERVICE_URL for qonsole config.api_service_url = ENV.fetch('API_SERVICE_URL', 'http://localhost:8888') - - # Use default paths for documentation. - config.accessibility_document_path = '/accessibility' - config.privacy_document_path = '/privacy' - - # feature flag for showing the Welsh language switch affordance - config.welsh_language_enabled = true - - # Set the contact email address to Land Registry supplied address - config.contact_email_address = 'data.services@mail.landregistry.gov.uk' end diff --git a/config/environments/production.rb b/config/environments/production.rb index b83fc2c..9ead92d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -89,14 +89,4 @@ # API location can be specified in the environment # But defaults to the dev service # API location is not used on the landing page, but is required by all other apps - - # Use default paths for documentation. - config.accessibility_document_path = '/accessibility' - config.privacy_document_path = '/privacy' - - # feature flag for showing the Welsh language switch affordance - config.welsh_language_enabled = true - - # Set the contact email address to Land Registry supplied address - config.contact_email_address = 'data.services@mail.landregistry.gov.uk' end diff --git a/config/environments/test.rb b/config/environments/test.rb index 2867713..ac3449e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -43,14 +43,4 @@ $stdout.sync = true # Log the stdout output to the Epimorphics JSON logging gem config.logger = JsonRailsLogger::Logger.new($stdout) - - # Use default paths for documentation. - config.accessibility_document_path = '/accessibility' - config.privacy_document_path = '/privacy' - - # feature flag for showing the Welsh language switch affordance - config.welsh_language_enabled = true - - # Set the contact email address to Land Registry supplied address - config.contact_email_address = 'data.services@mail.landregistry.gov.uk' end From e689999e387a937782e106a35f976f6d1ea789e5 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Thu, 5 Sep 2024 16:16:19 +0100 Subject: [PATCH 30/31] docs: Updated CHANGELOG --- CHANGELOG.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9974b16..44c6d4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,16 @@ This app presents the landing page experience for landregistry.data.gov.uk, including the SPARQL Qonsole -## 1.8.0 - 2024-08 - -- (Bogdan) Fixed a bug where the language selector was not working correctly when - the user was on the accessibility or privacy pages [GH-130](https://github.com/epimorphics/lr-landing/issues/130) -- (Jon) Implemented improved boilerplate metrics integration to offer analysis of - current application usage stats +## 1.8.0 - 2024-09 + +- (Jon) Moved all mirrored configuration settings from individual environments + into the application configuration to reduce the need to manage multiple + sources of truth +- (Bogdan) Fixed a bug where the language selector was not working correctly + when the user was on the accessibility or privacy pages + [GH-130](https://github.com/epimorphics/lr-landing/issues/130) +- (Jon) Implemented improved boilerplate metrics integration to offer analysis + of current application usage stats - (Jon) Implemented the dynamic page title approach used in the other suite apps to the accessibility and privacy translation templates - (Jon) Converted the privacy templates to match the same haml formatting @@ -23,8 +27,8 @@ including the SPARQL Qonsole ## 1.7.7 - 2024-08 - (Dan) Updates gemfile to use v1.9.5 lr_common_styles -- (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibility requirements - [GH-126](https://github.com/epimorphics/lr-landing/issues/126) +- (Dan) Adds underlines to links in body text to meet WCAG 2.2 accessibility + requirements [GH-126](https://github.com/epimorphics/lr-landing/issues/126) ## 1.7.6 - 2024-03-12 From d3fa71d8219be2d9618cb8e942a0c50d306bfe51 Mon Sep 17 00:00:00 2001 From: "Jon R. Humphrey" Date: Thu, 5 Sep 2024 16:24:23 +0100 Subject: [PATCH 31/31] build: update to `lr_common_styles` gem v1.9.8 --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9a9de4f..43f5b37 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -265,14 +265,14 @@ GEM json lograge railties - lr_common_styles (1.9.7) + lr_common_styles (1.9.8) bootstrap-sass (~> 3.4.0) font-awesome-rails (~> 4.7.0.1) govuk_elements_rails (~> 2.0.0) govuk_frontend_toolkit (~> 4.18.1) govuk_template (~> 0.18.1) haml-rails (~> 2.0.0) - jquery-rails (~> 4.3.5) + jquery-rails (>= 4.3.5, < 4.7.0) lodash-rails (~> 4.17.14) modernizr-rails (~> 2.7.1) modulejs-rails (~> 2.2.0.0)