-
Notifications
You must be signed in to change notification settings - Fork 21
Move speech document #4573
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
Merged
Merged
Move speech document #4573
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c8f4e1a
Update README.md and govuk_examples.yml
sairamya93 e899fa0
Add Speech route and controller
sairamya93 bd61ee6
Add Speech model and presenter
sairamya93 baf380f
Add News image concern and tests
sairamya93 eeebe9f
Add political concern and tests
sairamya93 cbcec15
Modify method in updatable concern
sairamya93 43cf78f
Add history_notice partial
sairamya93 3b27d11
Add locales for shared.historically_political
sairamya93 ee2c69b
Add Views for Speeches
sairamya93 f64fd48
Add locales for written_statement
sairamya93 5b986f1
Add formats.oral_statement translations
sairamya93 2eef571
Add request and system tests for speeches
sairamya93 01fb79e
Add locales for authored_article
sairamya93 255b8b7
Add locales for Speech to handle pluralization
sairamya93 4395a8d
Update locales for Speech
sairamya93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class SpeechController < ContentItemsController | ||
def show | ||
@presenter = SpeechPresenter.new(content_item) | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module NewsImage | ||
sairamya93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extend ActiveSupport::Concern | ||
|
||
def image | ||
content_store_response.dig("details", "image") || default_news_image || placeholder_image | ||
end | ||
|
||
private | ||
|
||
def default_news_image | ||
organisation = content_store_response.dig("links", "primary_publishing_organisation") | ||
organisation[0].dig("details", "default_news_image") if organisation.present? | ||
end | ||
|
||
def placeholder_image | ||
# this image has been uploaded to asset-manager | ||
return { "url" => "https://assets.publishing.service.gov.uk/media/5e985599d3bf7f3fc943bbd8/UK_government_logo.jpg" } if content_store_response["document_type"] == "world_news_story" | ||
|
||
{ "url" => "https://assets.publishing.service.gov.uk/media/5e59279b86650c53b2cefbfe/placeholder.jpg" } | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module People | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
def people | ||
linked("people") | ||
end | ||
end | ||
end |
leenagupte marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Political | ||
sairamya93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extend ActiveSupport::Concern | ||
|
||
included do | ||
def historically_political? | ||
political? && historical? | ||
end | ||
|
||
def publishing_government | ||
content_store_response.dig( | ||
"links", "government", 0, "title" | ||
) | ||
end | ||
end | ||
|
||
private | ||
|
||
def political? | ||
KludgeKML marked this conversation as resolved.
Show resolved
Hide resolved
|
||
content_store_response.dig("details", "political") | ||
end | ||
|
||
def historical? | ||
government_current = content_store_response.dig( | ||
"links", "government", 0, "details", "current" | ||
) | ||
|
||
# Treat no government as not historical | ||
return false if government_current.nil? | ||
|
||
!government_current | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class Speech < ContentItem | ||
include EmphasisedOrganisations | ||
include NewsImage | ||
leenagupte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
include People | ||
include Political | ||
include Updatable | ||
|
||
def contributors | ||
sairamya93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(organisations_ordered_by_emphasis + people + speaker).compact.uniq(&:content_id) | ||
end | ||
|
||
def speaker | ||
linked("speaker") | ||
end | ||
|
||
def speaker_without_profile | ||
content_store_response.dig("details", "speaker_without_profile") | ||
end | ||
|
||
def location | ||
content_store_response.dig("details", "location") | ||
end | ||
|
||
def delivered_on_date | ||
content_store_response.dig("details", "delivered_on") | ||
end | ||
|
||
def speech_type_explanation | ||
sairamya93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
explanation = content_store_response.dig("details", "speech_type_explanation") | ||
" (#{explanation})" if explanation | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class SpeechPresenter < ContentItemPresenter | ||
def speech_contributor_links | ||
return contributor_links unless content_item.speaker_without_profile | ||
|
||
contributor_links + [{ text: content_item.speaker_without_profile }] | ||
end | ||
|
||
def delivery_type | ||
sairamya93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return I18n.t("formats.speech.written_on") if content_item.document_type == "authored_article" | ||
|
||
I18n.t("formats.speech.delivered_on") | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% if content_item.historically_political? %> | ||
sairamya93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<%= render "govuk_publishing_components/components/notice", { | ||
title: sanitize( | ||
t("shared.historically_political", government: "<span lang='en' dir='ltr'>#{content_item.publishing_government}</span>"), | ||
attributes: %w(lang dir), | ||
), | ||
} %> | ||
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<% content_for :title do %> | ||
sairamya93 marked this conversation as resolved.
Show resolved
Hide resolved
KludgeKML marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<%= content_item.title %> - GOV.UK | ||
<% end %> | ||
|
||
<% content_for :extra_headers do %> | ||
<%= render "govuk_publishing_components/components/machine_readable_metadata", { content_item: content_item.to_h, schema: :news_article } %> | ||
<meta name="description" content="<%= strip_tags(content_item.description) %>"> | ||
<% end %> | ||
|
||
deborahchua marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div class="govuk-grid-row gem-print-columns-none"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= render "govuk_publishing_components/components/heading", { | ||
text: content_item.title, | ||
context: I18n.t("formats.#{content_item.document_type}", count: 1), | ||
context_locale: t_locale_fallback("formats.#{content_item.document_type}", count: 1), | ||
average_title_length: "long", | ||
heading_level: 1, | ||
font_size: "l", | ||
margin_bottom: 8, | ||
} %> | ||
</div> | ||
<%= render "shared/translations" %> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= render "govuk_publishing_components/components/lead_paragraph", text: content_item.description %> | ||
</div> | ||
</div> | ||
|
||
<%= render "shared/publisher_metadata", locals: { | ||
from: govuk_styled_links_list(@presenter.speech_contributor_links), | ||
first_published: display_date(content_item.initial_publication_date), | ||
last_updated: display_date(content_item.updated), | ||
see_updates_link: true, | ||
} %> | ||
<%= render "shared/history_notice", content_item: content_item %> | ||
<% if content_item.withdrawn? %> | ||
<% withdrawn_time_tag = tag.time(display_date(content_item.withdrawn_at), datetime: content_item.withdrawn_at) %> | ||
|
||
<%= render "govuk_publishing_components/components/notice", { | ||
title: I18n.t("withdrawn_notice.title", schema_name: I18n.t("formats.#{content_item.schema_name}", count: 1, locale: :en).downcase, withdrawn_time: withdrawn_time_tag).html_safe, | ||
description_govspeak: content_item.withdrawn_explanation&.html_safe, | ||
time: withdrawn_time_tag, | ||
lang: "en", | ||
} %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row gem-print-columns-none"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<div class="content-bottom-margin"> | ||
<div class="responsive-bottom-margin"> | ||
<%= content_tag :div, class: "important-metadata inverse-background responsive-bottom-margin" do %> | ||
<% delivered_on = tag.time(display_date(content_item.delivered_on_date), datetime: content_item.delivered_on_date) %> | ||
<% speech_type_explanation = content_item.speech_type_explanation %> | ||
<%= render "govuk_publishing_components/components/metadata", { | ||
inverse: true, | ||
other: { I18n.t("formats.speech.location") => content_item.location , @presenter.delivery_type => "#{delivered_on}#{speech_type_explanation}" }, | ||
margin_bottom: 0, | ||
} %> | ||
<% end %> | ||
|
||
<%= render "components/figure", | ||
src: content_item.image["url"], | ||
alt: content_item.image["alt_text"], | ||
credit: content_item.image["credit"], | ||
caption: content_item.image["caption"] if content_item.image %> | ||
|
||
<%= render "govuk_publishing_components/components/govspeak", { | ||
direction: page_text_direction, | ||
} do %> | ||
<%= raw(content_item.body) %> | ||
<% end %> | ||
</div> | ||
|
||
<%= render "components/published_dates", { | ||
published: display_date(content_item.initial_publication_date), | ||
last_updated: display_date(content_item.updated), | ||
history: content_item.history, | ||
} %> | ||
</div> | ||
</div> | ||
|
||
<%= render "shared/sidebar_navigation" %> | ||
</div> | ||
|
||
<%= render "shared/footer_navigation" %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.