Skip to content

Commit

Permalink
Add the print variant route, action and view.
Browse files Browse the repository at this point in the history
  • Loading branch information
leenagupte committed Sep 11, 2024
1 parent 080f43e commit ebc9fbb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/travel_advice_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def index
def show
@content_item.set_current_part(params[:slug])

request.variant = :print if params[:variant] == "print"

respond_to do |format|
format.html
format.atom
Expand Down
45 changes: 45 additions & 0 deletions app/views/travel_advice/show.html+print.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<% add_view_stylesheet("travel-advice") %>
<%
content_for :title, "Print #{@content_item.page_title}"
content_for :simple_header, true
content_for :extra_head_content do %>
<meta name="robots" content="noindex, nofollow">
<% end %>

<div class="govuk-grid-row" id="travel-advice-print">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-!-margin-bottom-6">
<%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %>
</div>

<div class="govuk-!-display-none-print">
<%= render 'govuk_publishing_components/components/lead_paragraph', {
margin_bottom: 6,
text: t("multi_page.printable_version"),
} %>
</div>

<%= render 'govuk_publishing_components/components/print_link', {
margin_bottom: 8,
text: t("components.print_link.text"),
} %>
<% @content_item.parts.each_with_index do |part, i| %>
<section>
<h1 class="part-title">
<%= part['title'] %>
</h1>

<%= render 'shared/travel_advice_first_part', content_item: @content_item if i == 0 %>
<%= render 'govuk_publishing_components/components/govspeak',
content: part['body'].html_safe,
direction: page_text_direction %>
</section>
<% end %>
<%= render 'govuk_publishing_components/components/print_link', {
text: t("components.print_link.text")
} %>
</div>
</div>
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
get "/find-local-council/:authority_slug" => "find_local_council#result"

get "/foreign-travel-advice", to: "travel_advice#index", as: :travel_advice
get "/foreign-travel-advice/:country/*slug", to: "travel_advice#show"
get "/foreign-travel-advice/:country/*slug/:variant",
to: "travel_advice#show",
constraints: {
variant: /print/,
}

# Accounts
get "/sign-in", to: "help#sign_in"
Expand Down

0 comments on commit ebc9fbb

Please sign in to comment.