Module: GovukPersonalisation::Urls
- Defined in:
- lib/govuk_personalisation/urls.rb
Class Method Summary collapse
-
.digital_identity_domain ⇒ String
Gets the Digital Identity domain for the current environment.
-
.feedback ⇒ String
Find the external URL for the “feedback” page.
-
.find_external_url(var:, url:) ⇒ String
Finds a URL outside www.gov.uk.
-
.find_govuk_url(var:, application:, path:) ⇒ String
Finds a URL on www.gov.uk.
-
.manage ⇒ String
Find the external URL for the “manage” page.
-
.manage_email ⇒ String
Find the GOV.UK URL for the “email manager” page.
-
.security ⇒ String
Find the external URL for the “security” page.
-
.sign_in ⇒ String
Find the GOV.UK URL for the “sign in” page.
-
.sign_out ⇒ String
Find the GOV.UK URL for the “sign out” page.
-
.your_account ⇒ String
Find the external URL for the “your account” page.
Class Method Details
.digital_identity_domain ⇒ String
Gets the Digital Identity domain for the current environment
97 98 99 100 101 102 103 104 |
# File 'lib/govuk_personalisation/urls.rb', line 97 def self.digital_identity_domain environment = ENV["DIGITAL_IDENTITY_ENVIRONMENT"] if environment "#{environment}.account.gov.uk" else "account.gov.uk" end end |
.feedback ⇒ String
Find the external URL for the “feedback” page
49 50 51 |
# File 'lib/govuk_personalisation/urls.rb', line 49 def self.feedback find_external_url(var: "FEEDBACK", url: "https://signin.account.gov.uk/support") end |
.find_external_url(var:, url:) ⇒ String
Finds a URL outside www.gov.uk
If ‘GOVUK_PERSONALISATION_#var_URI` is in the environment, that will be returned.
Otherwise, an application URL generated by Plek will be returned.
90 91 92 |
# File 'lib/govuk_personalisation/urls.rb', line 90 def self.find_external_url(var:, url:) ENV.fetch("GOVUK_PERSONALISATION_#{var}_URI", url) end |
.find_govuk_url(var:, application:, path:) ⇒ String
Finds a URL on www.gov.uk. This method is used so we can have links which work both in production (where the website root is returned) and in local development (where an application URL is returned).
If ‘GOVUK_PERSONALISATION_#var_URI` is in the environment, that will be returned.
Otherwise, a ‘www.gov.uk` URL will be returned (a `dev.gov.uk` domain in development mode)
69 70 71 72 73 74 75 76 77 |
# File 'lib/govuk_personalisation/urls.rb', line 69 def self.find_govuk_url(var:, application:, path:) value_from_env_var = ENV["GOVUK_PERSONALISATION_#{var}_URI"] if value_from_env_var value_from_env_var else plek_application_uri = Rails.env.development? ? Plek.find(application) : Plek.new.website_root "#{plek_application_uri}#{path}" end end |
.manage ⇒ String
Find the external URL for the “manage” page
35 36 37 |
# File 'lib/govuk_personalisation/urls.rb', line 35 def self.manage find_external_url(var: "MANAGE", url: "https://#{digital_identity_domain}?link=manage-account") end |
.manage_email ⇒ String
Find the GOV.UK URL for the “email manager” page
21 22 23 |
# File 'lib/govuk_personalisation/urls.rb', line 21 def self.manage_email find_govuk_url(var: "SIGN_OUT", application: "email-alert-frontend", path: "/email/manage") end |
.security ⇒ String
Find the external URL for the “security” page
42 43 44 |
# File 'lib/govuk_personalisation/urls.rb', line 42 def self.security find_external_url(var: "SECURITY", url: "https://#{digital_identity_domain}?link=security-privacy") end |
.sign_in ⇒ String
Find the GOV.UK URL for the “sign in” page
7 8 9 |
# File 'lib/govuk_personalisation/urls.rb', line 7 def self.sign_in find_govuk_url(var: "SIGN_IN", application: "frontend", path: "/account") end |
.sign_out ⇒ String
Find the GOV.UK URL for the “sign out” page
14 15 16 |
# File 'lib/govuk_personalisation/urls.rb', line 14 def self.sign_out find_govuk_url(var: "SIGN_OUT", application: "frontend", path: "/sign-out") end |
.your_account ⇒ String
Find the external URL for the “your account” page
28 29 30 |
# File 'lib/govuk_personalisation/urls.rb', line 28 def self.your_account find_external_url(var: "YOUR_ACCOUNT", url: "https://#{digital_identity_domain}") end |