diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb index 2488ece75..20209cdac 100644 --- a/app/controllers/content_items_controller.rb +++ b/app/controllers/content_items_controller.rb @@ -83,6 +83,8 @@ def format_banner_links(links, type) end def content_item_template + return "guide_single" if @content_item.render_guide_as_single_page? + @content_item.schema_name end diff --git a/app/presenters/content_item/parts.rb b/app/presenters/content_item/parts.rb index da0f12f7c..e44bc4c6b 100644 --- a/app/presenters/content_item/parts.rb +++ b/app/presenters/content_item/parts.rb @@ -61,7 +61,9 @@ def previous_and_next_navigation def part_link_elements parts.map do |part| - if part["slug"] != current_part["slug"] + if render_guide_as_single_page? + { href: "##{part['slug']}", text: part["title"] } + elsif part["slug"] != current_part["slug"] { href: part["full_path"], text: part["title"] } else { href: part["full_path"], text: part["title"], active: true } diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index fdd20948e..6b32ba825 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -78,6 +78,11 @@ def cache_control_public? !content_item.cache_control.private? end + def render_guide_as_single_page? + # /voting-in-the-uk + content_id == "9315bc67-33e7-42e9-8dea-e022f56dabfa" + end + private def display_date(timestamp, format = "%-d %B %Y") diff --git a/app/views/content_items/guide_single.html.erb b/app/views/content_items/guide_single.html.erb new file mode 100644 index 000000000..e0030c800 --- /dev/null +++ b/app/views/content_items/guide_single.html.erb @@ -0,0 +1,51 @@ +<% content_for :extra_head_content do %> + <%= machine_readable_metadata( + schema: :article, + canonical_url: @content_item.canonical_url, + body: @content_item.current_part_body + ) %> +<% end %> + + + +<% content_for :simple_header, true %> + +
+
+ <%= render 'govuk_publishing_components/components/title', { title: @content_item.content_title } %> + + <% if @content_item.show_guide_navigation? %> + + <% end %> +
+ +
+ <% if @content_item.has_parts? %> + + <% @content_item.parts.each_with_index do |part, index| %> +
"> + <%= render "govuk_publishing_components/components/heading", { + text: part["title"], + id: part["slug"], + heading_level: 1, + border_top: index.zero? ? 0 : 2, + padding: true + } %> + + <%= render 'govuk_publishing_components/components/govspeak', + content: part["body"].html_safe, + direction: page_text_direction, + disable_youtube_expansions: true %> +
+ <% end %> + <% end %> +
+ + <%= render 'shared/sidebar_navigation' %> +
+ +<%= render 'shared/footer_navigation' %> diff --git a/config/routes.rb b/config/routes.rb index 0eca6af76..fcfcacce2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,9 @@ get "healthcheck", to: proc { [200, {}, [""]] } + # Testing guides as a single page so we redirect parts to the default page + get "/voting-in-the-uk/:chapter", to: redirect("/voting-in-the-uk#%{chapter}") + get "*path/:variant" => "content_items#show", constraints: { variant: /print/,