Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2e1aa6a
Add HTML publication document examples
andysellick Aug 6, 2025
9802731
Add placeholder routes and methods
andysellick Aug 12, 2025
11b3383
Add request tests
andysellick Aug 12, 2025
9359951
Add html publication CSS
andysellick Aug 12, 2025
cc6d836
Copy html publication view from government-frontend
andysellick Aug 12, 2025
93f19f8
Fix lint errors in html publication document show template
andysellick Aug 12, 2025
735ef87
Update headers in html publication template
andysellick Aug 12, 2025
3edef9c
Replace @content_item with content_item
andysellick Aug 12, 2025
2107c56
Create HtmlPublication model
andysellick Aug 12, 2025
153b158
Add HtmlPublicationPresenter
andysellick Aug 12, 2025
d7c28b9
Basic HTML publication controller
andysellick Aug 12, 2025
e670463
Add hide_from_search_engines method
andysellick Aug 12, 2025
f16b7b8
Add organisation logos
andysellick Aug 14, 2025
78ad9a0
Add translations
andysellick Oct 23, 2025
7fe7d54
Add HTML publication header
andysellick Aug 29, 2025
a00b64c
Add shared history notice
andysellick Sep 4, 2025
8dd6805
Add withdrawn section
andysellick Sep 4, 2025
c0a801a
Add notice of national applicability
andysellick Sep 5, 2025
c4f1711
Add contents list
andysellick Sep 17, 2025
f76c7cf
Add print copyright statement
andysellick Sep 19, 2025
e07a017
Add govspeak body content
andysellick Sep 22, 2025
9f38114
Add integration test
andysellick Sep 23, 2025
ba42084
Restore breadcrumbs
andysellick Oct 8, 2025
13b6833
Add guidance translations
andysellick Oct 23, 2025
fb400ee
Add corporate report translations
andysellick Oct 23, 2025
d810862
Add form translations
andysellick Oct 23, 2025
906cda4
Add foi_release translations
andysellick Oct 23, 2025
7a5bb89
Add promotional translations
andysellick Oct 23, 2025
f8d8f43
Add notice translations
andysellick Oct 23, 2025
73db000
Add correspondence translations
andysellick Oct 23, 2025
6223b2f
Add research translations
andysellick Oct 23, 2025
f7e5f56
Add official_statistics translations
andysellick Oct 23, 2025
f340ece
Add transparency translations
andysellick Oct 23, 2025
0c82395
Add standard translations
andysellick Oct 23, 2025
ad952b5
Add statutory_guidance translations
andysellick Oct 23, 2025
7faddd7
Add independent_report translations
andysellick Oct 23, 2025
246cc58
Add national_statistics translations
andysellick Oct 23, 2025
20ab3f1
Add policy_paper translations
andysellick Oct 23, 2025
5cea6f0
Add decision translations
andysellick Oct 23, 2025
ea4d276
Add map translations
andysellick Oct 23, 2025
2b37953
Add regulation translations
andysellick Oct 23, 2025
cde51c6
Add international_treaty translations
andysellick Oct 23, 2025
2d289ec
Add impact_assessment translations
andysellick Oct 23, 2025
1b6156b
Fix right to left language display
andysellick Oct 23, 2025
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ some hard-coded routes.
|Help |[help_page](https://docs.publishing.service.gov.uk/content-schemas/help_page.html)|https://www.gov.uk/help/browsers|
|History |[history](https://docs.publishing.service.gov.uk/content-schemas/history.html)|https://www.gov.uk/government/history/10-downing-street|
|Homepage |[homepage](https://docs.publishing.service.gov.uk/content-schemas/homepage.html)|https://www.gov.uk/|
|HTML Publication |[html_publication](https://docs.publishing.service.gov.uk/content-schemas/html_publication.html)|https://www.gov.uk/government/publications/car-show-me-tell-me-vehicle-safety-questions/car-show-me-tell-me-vehicle-safety-questions|
| ||https://www.gov.uk/government/publications/skilled-worker-visa-temporary-shortage-list/skilled-worker-visa-temporary-shortage-list|
| ||https://www.gov.uk/government/publications/usa-apply-for-a-uk-visa/apply-for-a-uk-visa-in-the-usa|
|Get involved |[get_involved](https://docs.publishing.service.gov.uk/content-schemas/get_involved.html)|https://www.gov.uk/government/get-involved|
|Gone |[gone](https://docs.publishing.service.gov.uk/content-schemas/gone.html)|https://www.gov.uk/government/collections/greenhouse-gas-conversion-factors-for-company-reporting|
|Licence finder |schema: [specialist_document](https://docs.publishing.service.gov.uk/content-schemas/specialist_document.html)|https://www.gov.uk/find-licences/premises-licence|
Expand Down
Binary file added app/assets/images/open-government-licence-min.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $govuk-include-default-font-face: true;
@import "govuk_publishing_components/components/feedback";
@import "govuk_publishing_components/components/figure";
@import "govuk_publishing_components/components/govspeak";
@import "govuk_publishing_components/components/govspeak-html-publication";
@import "govuk_publishing_components/components/heading";
@import "govuk_publishing_components/components/hint";
@import "govuk_publishing_components/components/image-card";
Expand Down
64 changes: 64 additions & 0 deletions app/assets/stylesheets/views/_html-publication.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@import "govuk_publishing_components/individual_component_support";

.publication-external {
margin-bottom: govuk-spacing(4);
position: relative;

// design calls for the logos at the top to always be left aligned
.direction-rtl & {
direction: ltr;
}

.organisation-logos {
margin: 0;
}
}

.offset-empty-contents-list {
@include govuk-media-query($from: desktop) {
float: right;

.direction-rtl & {
float: left;
}
}
}

.contents-list-container {
@include govuk-media-query($from: desktop) {
position: sticky;
top: govuk-spacing(2);
max-height: 100vh;
overflow-y: auto;
margin-bottom: govuk-spacing(4);
}

.direction-rtl & {
float: right;
}
}

.print-metadata {
display: none;
}

.print-metadata__licence {
width: 78px;
height: auto;
margin-top: 60px;
margin-bottom: 40px;
}

.direction-rtl .back-to-top-wrapper {
direction: rtl;
text-align: start;
}

// Required to display a separate meta data page when printing
@include govuk-media-query($media-type: print) {
.print-metadata {
page-break-before: always;
page-break-after: always;
display: block;
}
}
7 changes: 7 additions & 0 deletions app/controllers/html_publication_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class HtmlPublicationController < ContentItemsController
include Cacheable

def show
@presenter = HtmlPublicationPresenter.new(content_item)
end
end
28 changes: 28 additions & 0 deletions app/models/html_publication.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class HtmlPublication < ContentItem
include Political
include NationalApplicability

def parent
linked("parent").first
end

def public_timestamp
content_store_response["details"]["public_timestamp"]
end

def first_published_version
content_store_response.dig("details", "first_published_version")
end

def headers
content_store_response.dig("details", "headers") || []
end

def copyright_year
content_store_response.dig("details", "public_timestamp").to_date.year if public_timestamp.present?
end

def isbn
content_store_response.dig("details", "isbn")
end
end
45 changes: 45 additions & 0 deletions app/presenters/html_publication_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class HtmlPublicationPresenter < ContentItemPresenter
include ContentsList
include DateHelper

def hide_from_search_engines?
return false unless content_item.parent

PublicationPresenter::PATHS_TO_HIDE.include? content_item.parent.base_path
end

def organisation_logos
content_item.organisations.map do |organisation|
{
name: organisation.logo.formatted_title.html_safe,
url: organisation.base_path,
brand: organisation.brand,
crest: organisation.logo.crest,
image: content_item.organisations.count == 1 ? organisation.logo.image : nil,
}
end
end

def last_changed
timestamp = display_date(content_item.public_timestamp)

# This assumes that a translation doesn't need the date to come beforehand.
if content_item.first_published_version
"#{I18n.t('common.metadata.published')} #{timestamp}"
else
"#{I18n.t('common.metadata.updated')} #{timestamp}"
end
end

def format_sub_type
if content_item.parent && content_item.parent.document_type.present?
content_item.parent.document_type
else
"publication"
end
end

def full_path(request)
request.base_url + request.path
end
end
20 changes: 20 additions & 0 deletions app/views/html_publication/_print_meta_data.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<p>
<%= image_tag "open-government-licence-min.png", class: "print-metadata__licence" %>
</p>
<p>
<%= t("formats.html_publication.print_meta_data.copyright", year: content_item.copyright_year) %>
</p>
<p>
<%= t("formats.html_publication.print_meta_data.licence_html") %>
</p>
<p>
<%= t("formats.html_publication.print_meta_data.third_party") %>
</p>
<p>
<%= t("formats.html_publication.print_meta_data.available_at", url: @presenter.full_path(request)) %>
</p>
<% unless content_item.isbn.blank? %>
<p>
<%= t("formats.html_publication.print_meta_data.isbn") %> <%= content_item.isbn %>
</p>
<% end %>
92 changes: 92 additions & 0 deletions app/views/html_publication/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<% content_for :head do %>
<%= render "govuk_publishing_components/components/machine_readable_metadata",
schema: :html_publication,
content_item: content_item.to_h %>

<% if @presenter.hide_from_search_engines? %>
<meta name="robots" content="noindex">
<% end %>
<%= stylesheet_link_tag "views/_html-publication" %>
<%= stylesheet_link_tag "views/_csv_preview" %>
<% end %>

<% if content_item.organisations %>
<div class="publication-external">
<ul class="organisation-logos">
<% @presenter.organisation_logos.each do |organisation| %>
<li class="organisation-logos__logo">
<%= render "govuk_publishing_components/components/organisation_logo", {
organisation:,
} %>
</li>
<% end %>
</ul>
</div>
<% end %>

<%= render "govuk_publishing_components/components/inverse_header", {
padding_top: 6,
padding_bottom: 6,
subtext: @presenter.last_changed,
dir: page_text_direction,
} do %>
<%= render "govuk_publishing_components/components/heading", {
text: content_item.title,
context: I18n.t("formats.#{@presenter.format_sub_type}.name", count: 1),
inverse: true,
margin_bottom: 0,
font_size: "xl",
heading_level: 1,
} %>
<% end %>

<%= 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.#{@presenter.format_sub_type}.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",
dir: page_text_direction,
} %>
<% end %>

<% if content_item.national_applicability.present? %>
<%= render "govuk_publishing_components/components/devolved_nations", {
national_applicability: content_item.national_applicability,
content_type: content_item.schema_name,
} %>
<% end %>

<div id="contents">
<div class="govuk-grid-row gem-print-columns-none">
<% if content_item.headers.any? %>
<div class="govuk-grid-column-one-quarter-from-desktop contents-list-container">
<%= render "govuk_publishing_components/components/contents_list", contents: @presenter.headers_for_contents_list_component, format_numbers: true %>

<%= render "govuk_publishing_components/components/print_link", {
margin_bottom: 6,
} %>
</div>
<% end %>

<div class="print-metadata">
<%= render partial: "print_meta_data" %>
</div>

<div class="govuk-grid-column-three-quarters-from-desktop contents-container<% unless content_item.headers.any? %> offset-empty-contents-list<% end %>">
<%= render "govuk_publishing_components/components/govspeak_html_publication", {
direction: page_text_direction,
} do %>
<%= raw(content_item.body.html_safe) %>
<% end %>
</div>
</div>

<div class="govuk-grid-row back-to-top-wrapper">
<%= render "govuk_publishing_components/components/back_to_top_link", href: "#contents", text: "Back to top" %>
</div>
</div>
1 change: 1 addition & 0 deletions app/views/shared/_history_notice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
t("shared.historically_political", government: "<span lang='en' dir='ltr'>#{content_item.publishing_government}</span>"),
attributes: %w(lang dir),
),
dir: page_text_direction,
} %>
<% end %>
1 change: 1 addition & 0 deletions config/govuk_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gone: /government/collections/greenhouse-gas-conversion-factors-for-company-repo
guide: /log-in-register-hmrc-online-services
help_page: /help/browsers
history: /government/history/10-downing-street
html_publication: /government/publications/car-show-me-tell-me-vehicle-safety-questions/car-show-me-tell-me-vehicle-safety-questions
homepage: /
licence_transaction: /find-licences/tv-licence
local_transaction: /contact-electoral-registration-office
Expand Down
1 change: 1 addition & 0 deletions config/initializers/dartsass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"views/_csv_preview.scss" => "views/_csv_preview.css",
"views/_guide.scss" => "views/_guide.css",
"views/_homepage.scss" => "views/_homepage.css",
"views/_html-publication.scss" => "views/_html-publication.css",
"views/_local-transaction.scss" => "views/_local-transaction.css",
"views/_location_form.scss" => "views/_location_form.css",
"views/_place-list.scss" => "views/_place-list.css",
Expand Down
Loading