Skip to content

Commit

Permalink
Remove ContentBlock related functionality
Browse files Browse the repository at this point in the history
Because of a degree of complexity in how Govspeak is rendered in the
Publishing Platform, we can’t always fetch embedded content at the
point where Govspeak is rendered (this is particuarly the case in
Whitehall). With this in mind, and after some discussion with the team,
we’ve decided that, for now, it’s better to handle embeds in the
Publishing API.

With this in mind, rather than letting this functionality die on the
vine within Govspeak, we should remove the functionality altogether. As
this is pretty new code (and the content modelling team are the only
people aware of it and likely to use it), we should remove it from the
codebase entirely.
  • Loading branch information
pezholio committed Oct 30, 2024
1 parent 18ca993 commit 4717d84
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 263 deletions.
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,34 +608,6 @@ will output
</div>
```

### Content blocks

Authors can embed different types of [supported content](https://github.com/alphagov/govspeak/blob/main/lib/govspeak/content_block.rb#L3) created by the Content Block Manager

```
{{embed:content_block_email_address:d308f561-e5ee-45b5-90b2-3ac36a23fad9}}
```

with options provided

```
{
content_blocks: [
{
content_id: "d308f561-e5ee-45b5-90b2-3ac36a23fad9",
title: "Government Digital Service",
details: { email_address: "[email protected]" },
}
]
}
```

will output

```html
<span class="embed_content_block_email_address" id="embed_d308f561-e5ee-45b5-90b2-3ac36a23fad9">[email protected]</span>
```

### Button

An accessible way to add button links into content, that can also allow cross domain tracking with [Google Analytics](https://support.google.com/analytics/answer/7372977?hl=en)
Expand Down
15 changes: 1 addition & 14 deletions lib/govspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
require "govspeak/html_validator"
require "govspeak/html_sanitizer"
require "govspeak/blockquote_extra_quote_remover"
require "govspeak/content_block_extractor"
require "govspeak/content_block"
require "govspeak/post_processor"
require "govspeak/link_extractor"
require "govspeak/template_renderer"
require "govspeak/presenters/attachment_presenter"
require "govspeak/presenters/contact_presenter"
require "govspeak/presenters/content_block_presenter"
require "govspeak/presenters/h_card_presenter"
require "govspeak/presenters/image_presenter"
require "govspeak/presenters/attachment_image_presenter"
Expand All @@ -40,7 +37,7 @@ class Document
@extensions = []

attr_accessor :images
attr_reader :attachments, :contacts, :links, :locale, :content_blocks
attr_reader :attachments, :contacts, :links, :locale

def self.to_html(source, options = {})
new(source, options).to_html
Expand All @@ -60,7 +57,6 @@ def initialize(source, options = {})
@attachments = Array.wrap(options.delete(:attachments))
@links = Array.wrap(options.delete(:links))
@contacts = Array.wrap(options.delete(:contacts))
@content_blocks = Array.wrap(options.delete(:content_blocks))
@locale = options.fetch(:locale, "en")
@options = { input: PARSER_CLASS_NAME,
sanitize: true,
Expand Down Expand Up @@ -259,15 +255,6 @@ def insert_strong_inside_p(body, parser = Govspeak::Document)
render_image(AttachmentImagePresenter.new(attachment))
end

extension("content blocks", Govspeak::ContentBlock::EMBED_REGEX) do |embed_code, _document_type, content_id|
next embed_code if content_blocks.empty?

embed = content_blocks.detect { |e| e[:content_id] == content_id }
next "" unless embed

ContentBlockPresenter.new(embed).render
end

# As of version 1.12.0 of Kramdown the block elements (div & figcaption)
# inside this html block will have it's < > converted into HTML Entities
# when ever this code is used inside block level elements.
Expand Down
15 changes: 0 additions & 15 deletions lib/govspeak/content_block.rb

This file was deleted.

17 changes: 0 additions & 17 deletions lib/govspeak/content_block_extractor.rb

This file was deleted.

32 changes: 0 additions & 32 deletions lib/govspeak/presenters/content_block_presenter.rb

This file was deleted.

59 changes: 0 additions & 59 deletions test/content_block_extractor_test.rb

This file was deleted.

98 changes: 0 additions & 98 deletions test/govspeak_content_blocks_test.rb

This file was deleted.

0 comments on commit 4717d84

Please sign in to comment.