diff --git a/Gemfile b/Gemfile index 9ce05d2b5..442986219 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,8 @@ gem "bootsnap", ">= 1.4.4", require: false gem "govuk-components" # GOV UK component form builder DSL gem "govuk_design_system_formbuilder" +# Convert Markdown into GOV.UK frontend-styled HTML +gem "govuk_markdown" # GOV UK Notify gem "notifications-ruby-client" # Turbo and Stimulus diff --git a/Gemfile.lock b/Gemfile.lock index 1c5f83389..512665f41 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -181,6 +181,9 @@ GEM activemodel (>= 6.1) activesupport (>= 6.1) deep_merge (~> 1.2.1) + govuk_markdown (1.0.0) + activesupport + redcarpet has_scope (0.8.0) actionpack (>= 5.2) activesupport (>= 5.2) @@ -328,6 +331,7 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) + redcarpet (3.5.1) redis (4.6.0) regexp_parser (2.2.1) request_store (1.5.1) @@ -476,6 +480,7 @@ DEPENDENCIES factory_bot_rails govuk-components govuk_design_system_formbuilder + govuk_markdown hotwire-rails json-schema listen (~> 3.3) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb new file mode 100644 index 000000000..ecac6ee5a --- /dev/null +++ b/app/controllers/content_controller.rb @@ -0,0 +1,24 @@ +class ContentController < ApplicationController + def accessibility_statement + render_content_page :accessibility_statement + end + + def privacy_notice + render_content_page :privacy_notice, page_title: "Privacy notice for tenants and buyers of new social housing" + end + +private + + def render_content_page(page_name, page_title: nil, locals: {}) + raw_content = File.read("app/views/content/#{page_name}.md") + content_with_erb_tags_replaced = ApplicationController.renderer.render( + inline: raw_content, + locals:, + ) + + @page_title = page_title || page_name.to_s.humanize + @page_content = GovukMarkdown.render(content_with_erb_tags_replaced).html_safe + + render "content/page" + end +end diff --git a/app/views/content/accessibility_statement.md b/app/views/content/accessibility_statement.md new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/content/page.html.erb b/app/views/content/page.html.erb new file mode 100644 index 000000000..39acc46f9 --- /dev/null +++ b/app/views/content/page.html.erb @@ -0,0 +1,9 @@ +<%= content_for :title, @page_title %> + +