-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detailed guides migration #134
Changes from all commits
0de760e
0a71801
742688c
8d0b4d0
b668451
75a9d02
3df261e
53e5b02
f73f188
2461688
bc1b21c
73ff914
40ff668
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.detailed-guide { | ||
@include description; | ||
@include sidebar-with-body; | ||
|
||
.offset-one-third { | ||
margin-left: percentage(1 / 3); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module CommonSections | ||
def from | ||
links("lead_organisations") + links("supporting_organisations") + links("worldwide_organisations") | ||
end | ||
|
||
def published | ||
display_time(content_item["details"]["first_public_at"]) | ||
end | ||
|
||
def updated | ||
display_time(content_item["public_updated_at"]) if any_updates? | ||
end | ||
|
||
def short_history | ||
if any_updates? | ||
"#{I18n.t('content_item.metadata.updated')} #{updated}" | ||
else | ||
"#{I18n.t('content_item.metadata.published')} #{published}" | ||
end | ||
end | ||
|
||
def history | ||
return [] unless any_updates? | ||
content_item["details"]["change_history"].map do |item| | ||
{ | ||
display_time: display_time(item["public_timestamp"]), | ||
note: item["note"], | ||
timestamp: item["public_timestamp"] | ||
} | ||
end | ||
end | ||
|
||
private | ||
|
||
def any_updates? | ||
if (first_public_at = content_item["details"]["first_public_at"]).present? | ||
DateTime.parse(content_item["public_updated_at"]) != DateTime.parse(first_public_at) | ||
else | ||
false | ||
end | ||
end | ||
|
||
def links(type) | ||
return [] unless content_item["links"][type] | ||
content_item["links"][type].map do |link| | ||
link_to(link["title"], link["base_path"]) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class DetailedGuidePresenter < ContentItemPresenter | ||
include ExtractsHeadings | ||
include ActionView::Helpers::UrlHelper | ||
include CommonSections | ||
|
||
def body | ||
content_item["details"]["body"] | ||
end | ||
|
||
def breadcrumbs | ||
e = parent | ||
res = [] | ||
|
||
while e | ||
res << { title: e["title"], url: e["base_path"] } | ||
e = e["parent"] && e["parent"].first | ||
end | ||
|
||
res << { title: "Home", url: "/" } | ||
res.reverse | ||
end | ||
|
||
def contents | ||
extract_headings_with_ids(body).map do |heading| | ||
link_to(heading[:text], "##{heading[:id]}") | ||
end | ||
end | ||
|
||
def context | ||
parent["title"] | ||
end | ||
|
||
def part_of | ||
links("document_collections") + links("related_policies") + links("worldwide_priorities") + links("world_locations") + links("topics") | ||
end | ||
|
||
private | ||
|
||
def parent | ||
content_item["links"]["parent"][0] | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<%= content_for :page_class, @content_item.format.dasherize %> | ||
<%= content_for :title, @content_item.title %> | ||
|
||
<%= render 'govuk_component/breadcrumbs', breadcrumbs: @content_item.breadcrumbs %> | ||
|
||
<div class="grid-row"> | ||
<div class="column-two-thirds"> | ||
<%= render 'govuk_component/title', | ||
context: t("content_item.format.#{@content_item.format}", count: 1), | ||
title: @content_item.title %> | ||
</div> | ||
</div> | ||
|
||
<div class="grid-row"> | ||
<div class="column-two-thirds"> | ||
<%= render 'govuk_component/metadata', | ||
from: @content_item.from, | ||
other: { | ||
"First published" => @content_item.published, | ||
"Last updated" => [@content_item.updated,"<a href=\"#history\">see all updates</a>"].join(", "), | ||
"Part of" => @content_item.part_of #doing this to preserve the ordering but if part_of, at the same level as from and other | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if the ordering needs to be preserved. |
||
} | ||
%> | ||
</div> | ||
</div> | ||
|
||
<%= render 'shared/description', description: @content_item.description %> | ||
|
||
<div class="grid-row sidebar-with-body"> | ||
<% if @content_item.contents.any? %> | ||
<div class="column-third"> | ||
<%= render 'shared/sidebar_contents', contents: @content_item.contents %> | ||
</div> | ||
<% end %> | ||
<div class="column-two-thirds <% unless @content_item.contents.any? %>offset-one-third<% end %>"> | ||
<%= render 'govuk_component/govspeak', | ||
content: @content_item.body, | ||
direction: page_text_direction %> | ||
</div> | ||
</div> | ||
|
||
<%= render 'govuk_component/document_footer', | ||
from: @content_item.from, | ||
updated: @content_item.updated, | ||
history: @content_item.history, | ||
published: @content_item.published, | ||
direction: page_text_direction | ||
%> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,7 @@ ar: | |
few: | ||
many: | ||
other: | ||
detailed_guidance: | ||
detailed_guide: | ||
zero: | ||
one: "توجيه مفصل" | ||
two: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ be: | |
few: | ||
many: | ||
other: | ||
detailed_guidance: | ||
detailed_guide: | ||
one: "Падрабязнае кіраўніцтва" | ||
few: | ||
many: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ bn: | |
decision: | ||
one: | ||
other: | ||
detailed_guidance: | ||
detailed_guide: | ||
one: | ||
other: | ||
document_collection: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ cy: | |
few: | ||
many: | ||
other: | ||
detailed_guidance: | ||
detailed_guide: | ||
zero: | ||
one: Cyfarwyddyd manwl | ||
two: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ en: | |
correspondence: | ||
one: Correspondence | ||
other: Correspondences | ||
detailed_guidance: | ||
detailed_guide: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably all the other language keys also need updating? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you're right. I quickly substituted them, we can go back eventually. In Whitehall I found both terms used, although "detailed_guide" seems to be used more. |
||
one: Guidance | ||
other: Guidance | ||
document_collection: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ he: | |
two: | ||
many: | ||
other: | ||
detailed_guidance: | ||
detailed_guide: | ||
one: "מדריך מפורט" | ||
two: | ||
many: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually adding the "Home" link as this is not present in the parent hierarchy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot 👍