Skip to content

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 15 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ some hard-coded routes.
|Specialist Document |https://www.gov.uk/cma-cases/veterinary-services-market-for-pets-review|
| |https://www.gov.uk/aaib-reports/aaib-investigation-to-aw189-g-fsar|
| |https://www.gov.uk/protected-food-drink-names/pitahaya-amazonica-de-palora|
|Speech |[speech](https://docs.publishing.service.gov.uk/content-schemas/speech.html)|https://www.gov.uk/government/speeches/motorcycle-testing|
|Take part |[take_part](https://docs.publishing.service.gov.uk/content-schemas/take_part.html)|https://www.gov.uk/government/get-involved/take-part/improve-your-social-housing|
|Transaction start page |[transaction](https://docs.publishing.service.gov.uk/content-schemas/transaction.html)|https://www.gov.uk/register-to-vote|
| ||https://www.gov.uk/vehicle-tax|
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/speech_controller.rb
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
21 changes: 21 additions & 0 deletions app/models/concerns/news_image.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module NewsImage
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
9 changes: 9 additions & 0 deletions app/models/concerns/people.rb
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
32 changes: 32 additions & 0 deletions app/models/concerns/political.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Political
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?
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
8 changes: 3 additions & 5 deletions app/models/concerns/updatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ def initial_publication_date
private

def any_updates?
if public_updated_at && initial_publication_date
Time.zone.parse(public_updated_at) != Time.zone.parse(initial_publication_date)
else
false
end
return false unless public_updated_at && initial_publication_date

Time.zone.parse(public_updated_at) != Time.zone.parse(initial_publication_date)
end

def reverse_chronological_change_history
Expand Down
32 changes: 32 additions & 0 deletions app/models/speech.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class Speech < ContentItem
include EmphasisedOrganisations
include NewsImage
include People
include Political
include Updatable

def contributors
(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
explanation = content_store_response.dig("details", "speech_type_explanation")
" (#{explanation})" if explanation
end
end
13 changes: 13 additions & 0 deletions app/presenters/speech_presenter.rb
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
return I18n.t("formats.speech.written_on") if content_item.document_type == "authored_article"

I18n.t("formats.speech.delivered_on")
end
end
8 changes: 8 additions & 0 deletions app/views/shared/_history_notice.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% if content_item.historically_political? %>
<%= 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 %>
84 changes: 84 additions & 0 deletions app/views/speech/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<% content_for :title do %>
<%= 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 %>

<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" %>
1 change: 1 addition & 0 deletions config/govuk_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ place: /find-regional-passport-office
simple_smart_answer: /sold-bought-vehicle
special-route: /find-local-council
specialist_document: https://content-data.publishing.service.gov.uk/
speeches: /government/speeches/motorcycle-testing
take_part: /government/get-involved/take-part/improve-your-social-housing
transaction: /sign-in-universal-credit
travel_advice_index: /foreign-travel-advice
Expand Down
33 changes: 33 additions & 0 deletions config/locales/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,13 @@ ar:
error:
find:
formats:
authored_article:
few:
many:
one: مقال مؤلَّف
other: مقالات مؤلَّفة
two:
zero:
case_study:
few:
many:
Expand Down Expand Up @@ -782,6 +789,13 @@ ar:
valid_uprn_no_match_sub_html:
website:
what_you_need_to_know:
oral_statement:
few:
many:
one: بيان شفوي للبرلمان
other: بيانات شفوية للبرلمان
two:
zero:
place:
change:
find_results:
Expand All @@ -798,6 +812,16 @@ ar:
pdo_alt_text: شعار المخطط عبارة عن ختم أسود يحمل الكلمات Designated Origin UK Protected
pgi_alt_text: شعار المخطط عبارة عن ختم أسود يحمل الكلمات Geographic Origin UK Protected
tsg_alt_text: شعار المخطط عبارة عن ختم أسود يحمل الكلمات Traditional Speciality UK Protected
speech:
delivered_on: تاريخ التسليم
few:
location: الموقع
many:
one: خطاب
other: خطابات
two:
written_on: تاريخ الكتابة
zero:
start_now:
take_part:
few:
Expand All @@ -824,6 +848,13 @@ ar:
still_current_at: لا يزال ساريًا في
summary: ملخص
updated: تاريخ التحديث
written_statement:
few:
many:
one: بيان خطي للبرلمان
other: بيانات خطية للبرلمان
two:
zero:
help:
index:
about:
Expand Down Expand Up @@ -1009,6 +1040,8 @@ ar:
heading:
invalid:
title:
shared:
historically_political: تم نشره بموجب %{government}
sign_up:
website:
when_do_the_clocks_change:
Expand Down
17 changes: 17 additions & 0 deletions config/locales/az.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ az:
error:
find:
formats:
authored_article:
one: Müəlliflik edilmiş məqalə
other: Müəlliflik edilmiş məqalələr
case_study:
one: Nümunə üzrə araşdırma
other: Nümunə üzrə araşdırmalar
Expand Down Expand Up @@ -486,6 +489,9 @@ az:
valid_uprn_no_match_sub_html:
website:
what_you_need_to_know:
oral_statement:
one: Parlamentə şifahi müraciət
other: Parlamentə şifahi müraciətlər
place:
change:
find_results:
Expand All @@ -502,6 +508,12 @@ az:
pdo_alt_text: Qrafik loqo üzərində "Səlahiyyətli mənbə BK qorunur" sözləri olan qara möhürdür
pgi_alt_text: Qrafik loqo üzərində "Coğrafi mənbə BK qorunur" sözləri olan qara möhürdür
tsg_alt_text: Qrafik loqo üzərində "Ənənəvi məhsul BK qorunur" sözləri olan qara möhürdür
speech:
delivered_on: Çatdırılıb
location: Yer
one: Nitq
other: Nitqlər
written_on: Yazılma tarixi
start_now:
take_part:
one: İştirak edin
Expand All @@ -524,6 +536,9 @@ az:
still_current_at: Hələ də qüvvədədir
summary: İcmal
updated: Yenilənib
written_statement:
one: Parlamentə yazılı müraciət
other: Parlamentə yazılı müraciətlər
help:
index:
about:
Expand Down Expand Up @@ -709,6 +724,8 @@ az:
heading:
invalid:
title:
shared:
historically_political: Bu %{government} əsasən dərc edilmişdir
sign_up:
website:
when_do_the_clocks_change:
Expand Down
Loading