From e5524ffefb13024ee82c2a182b2a6a05a5f293c9 Mon Sep 17 00:00:00 2001
From: sarahcrack <73823091+sarahcrack@users.noreply.github.com>
Date: Thu, 9 Jan 2025 10:34:46 +0000
Subject: [PATCH] Remove blog tech debt (#4455)
* removed blog structured data from structured data helper
* deleted views/blog folder and contents
* removed blog_structured_data from rspec test and deleted views/layouts/blog folder and contents
* deleted BlogHelper and spec file
* removed BlogController
* removed controllers/blog folder which included tag_controller
* removed config for blog structured data from prod and dev files
* removed models/pages/blog.rb and spec file
* removed references to blog in content_pages_spec file
* removed blog from sitemap controller
* removed blog_posting from structured data spec
* removed references to blog in routes.rb
* removed blog scss file and import to git
* renamed images/content/blog to how-to-apply-for-teacher-training to house notepad image. Edited paths
* removed references to blog in images.yml file
* re-instated 2 external link redirects to routes.rb as per review comments
* renamed folder containing notepad image and edited paths
* removed spec/support/views/content/blog/post_invalid_tag.md and blog folder
---
app/controllers/blog/tag_controller.rb | 20 --
app/controllers/blog_controller.rb | 35 ----
app/controllers/sitemap_controller.rb | 1 -
app/helpers/blog_helper.rb | 15 --
app/helpers/structured_data_helper.rb | 20 --
app/models/pages/blog.rb | 55 -----
app/views/blog/_date_and_author.html.erb | 7 -
app/views/blog/_header.html.erb | 5 -
app/views/blog/_highlights.erb | 3 -
app/views/blog/_post_preview.html.erb | 17 --
app/views/blog/_tag_list.html.erb | 5 -
...riching-the-lives-of-young-people.html.erb | 3 -
app/views/blog/index.html.erb | 24 ---
app/views/blog/tag/show.html.erb | 10 -
.../how-to-apply-for-teacher-training.md | 2 +-
app/views/layouts/blog/index.html.erb | 23 ---
app/views/layouts/blog/post.html.erb | 60 ------
.../content/{blog => application}/notepad.jpg | Bin
app/webpacker/styles/blog.scss | 194 ------------------
app/webpacker/styles/git.scss | 1 -
config/environments/development.rb | 1 -
config/environments/production.rb | 1 -
config/images.yml | 77 +------
config/routes.rb | 6 -
spec/features/content_pages_spec.rb | 3 +-
spec/helpers/blog_helper_spec.rb | 41 ----
spec/helpers/structured_data_helper_spec.rb | 59 ------
spec/models/pages/blog_spec.rb | 114 ----------
spec/requests/structured_data_spec.rb | 2 +-
.../views/content/blog/post_invalid_tag.md | 9 -
30 files changed, 7 insertions(+), 806 deletions(-)
delete mode 100644 app/controllers/blog/tag_controller.rb
delete mode 100644 app/controllers/blog_controller.rb
delete mode 100644 app/helpers/blog_helper.rb
delete mode 100644 app/models/pages/blog.rb
delete mode 100644 app/views/blog/_date_and_author.html.erb
delete mode 100644 app/views/blog/_header.html.erb
delete mode 100644 app/views/blog/_highlights.erb
delete mode 100644 app/views/blog/_post_preview.html.erb
delete mode 100644 app/views/blog/_tag_list.html.erb
delete mode 100644 app/views/blog/closing-paragraphs/_enriching-the-lives-of-young-people.html.erb
delete mode 100644 app/views/blog/index.html.erb
delete mode 100644 app/views/blog/tag/show.html.erb
delete mode 100644 app/views/layouts/blog/index.html.erb
delete mode 100644 app/views/layouts/blog/post.html.erb
rename app/webpacker/images/content/{blog => application}/notepad.jpg (100%)
delete mode 100644 app/webpacker/styles/blog.scss
delete mode 100644 spec/helpers/blog_helper_spec.rb
delete mode 100644 spec/models/pages/blog_spec.rb
delete mode 100644 spec/support/views/content/blog/post_invalid_tag.md
diff --git a/app/controllers/blog/tag_controller.rb b/app/controllers/blog/tag_controller.rb
deleted file mode 100644
index 6704f1ce89..0000000000
--- a/app/controllers/blog/tag_controller.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class Blog::TagController < ApplicationController
- include PaginatablePosts
-
- layout "layouts/blog/index"
-
- POSTS_PER_PAGE = 10
-
- def show
- @front_matter = {
- "title" => "Blog posts about #{params[:id].tr('-', ' ')}",
- "noindex" => true,
- }
-
- breadcrumb "Blog", blog_index_path
- breadcrumb @front_matter["title"], request.path
-
- @tag = params[:id]
- @posts = paginate_posts(::Pages::Blog.posts(@tag))
- end
-end
diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb
deleted file mode 100644
index 76d0a06b78..0000000000
--- a/app/controllers/blog_controller.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-class BlogController < ApplicationController
- include PaginatablePosts
-
- caches_page :show
-
- layout "layouts/blog/index"
-
- def index
- @front_matter = {
- "title" => "Get Into Teaching Blog",
- "description" => "Read about the real life experiences of teachers and teachers in training, as well as tips on how to start your journey into the classroom.",
- }
-
- breadcrumb "Blog", blog_index_path
-
- @posts = paginate_posts(::Pages::Blog.posts)
- end
-
- def show
- @post = ::Pages::Blog.find(request.path)
-
- begin
- @post.validate!
- rescue ::Pages::ContentError => e
- raise e unless helpers.display_content_errors?
-
- add_content_error(e)
- end
-
- breadcrumb "Blog", blog_index_path
- breadcrumb @post.title, request.path
-
- render template: @post.template, layout: "layouts/blog/post"
- end
-end
diff --git a/app/controllers/sitemap_controller.rb b/app/controllers/sitemap_controller.rb
index c58a00a79c..59fabb950e 100644
--- a/app/controllers/sitemap_controller.rb
+++ b/app/controllers/sitemap_controller.rb
@@ -11,7 +11,6 @@ class SitemapController < ApplicationController
# This will keep it consistent with how canonical-rails behaves and ensure search engines are happy.
OTHER_PATHS = %w[
/events
- /blog
/events/about-get-into-teaching-events
/mailinglist/signup/name
].freeze
diff --git a/app/helpers/blog_helper.rb b/app/helpers/blog_helper.rb
deleted file mode 100644
index dc4341f7fa..0000000000
--- a/app/helpers/blog_helper.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module BlogHelper
- def format_blog_date(date_string)
- Date.parse(date_string).to_formatted_s(:govuk_zero_pad)
- end
-
- def thumbnail_image_from_post(images)
- first_image_params = images.values.first.symbolize_keys
-
- if first_image_params.key?(:thumbnail_path)
- first_image_params[:path] = first_image_params[:thumbnail_path]
- end
-
- render Content::ImageComponent.new(**first_image_params.slice(:path))
- end
-end
diff --git a/app/helpers/structured_data_helper.rb b/app/helpers/structured_data_helper.rb
index 8fada1df46..1e5f984fe8 100644
--- a/app/helpers/structured_data_helper.rb
+++ b/app/helpers/structured_data_helper.rb
@@ -18,26 +18,6 @@ def structured_data(type, data)
end
end
- def blog_structured_data(page)
- frontmatter = page.frontmatter
- author_name = frontmatter[:author]
-
- data = {
- headline: frontmatter[:title],
- image: frontmatter[:images]&.values&.map { |h| asset_pack_url(h["path"]) },
- datePublished: frontmatter[:date],
- keywords: frontmatter[:keywords],
- author: [
- {
- "@type": author_name.present? ? "Person" : "Organization",
- name: author_name || "Get Into Teaching",
- },
- ],
- }.compact
-
- structured_data("BlogPosting", data)
- end
-
def government_organization_structured_data
data = {
"@context": "https://schema.org",
diff --git a/app/models/pages/blog.rb b/app/models/pages/blog.rb
deleted file mode 100644
index bc11fa46d3..0000000000
--- a/app/models/pages/blog.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-module Pages
- class Blog
- class InvalidTagError < RuntimeError; end
-
- class << self
- delegate :posts, :popular_tags, :similar_posts, to: :instance
-
- def find(path)
- ::Pages::Post.find(path)
- end
-
- private
-
- def instance
- new
- end
- end
-
- def initialize(pages = Pages::Frontmatter.select_by_path("/blog"))
- @posts = pages
- .select { |_path, fm| fm[:date] <= Time.zone.today.iso8601 }
- .sort_by { |_path, fm| fm[:date] }
- .reverse
- .to_h
- end
-
- def posts(tag = nil)
- return @posts unless tag
-
- @posts.select { |_path, fm| tag.in?(fm[:tags].map(&:parameterize)) }
- end
-
- # return the most-frequently used tags, ordered by frequency then
- # alphabetically if there are ties
- def popular_tags(limit = 5)
- posts
- .flat_map { |_path, fm| fm[:tags] }
- .compact
- .tally
- .sort_by { |tag, count| [-count, tag] }
- .map { |tag, _count| tag }
- .first(limit)
- end
-
- def similar_posts(post, limit = 3)
- tags = post.frontmatter.tags
-
- posts
- .reject { |path, _fm| path == post.path }
- .sort_by { |_path, fm| -(tags & fm[:tags]).size }
- .first(limit)
- .to_h
- end
- end
-end
diff --git a/app/views/blog/_date_and_author.html.erb b/app/views/blog/_date_and_author.html.erb
deleted file mode 100644
index 21e4472fd5..0000000000
--- a/app/views/blog/_date_and_author.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-
- Published <%= format_blog_date(front_matter["date"]) %>
-
-
-
- By <%= front_matter["author"] || "Get Into Teaching" %>
-
diff --git a/app/views/blog/_header.html.erb b/app/views/blog/_header.html.erb
deleted file mode 100644
index 1bf3962c95..0000000000
--- a/app/views/blog/_header.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/app/views/blog/_highlights.erb b/app/views/blog/_highlights.erb
deleted file mode 100644
index 4d278e1118..0000000000
--- a/app/views/blog/_highlights.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-
- - <%= link_to("Applying for teacher training", blog_tag_path("applications")) %>
-
diff --git a/app/views/blog/_post_preview.html.erb b/app/views/blog/_post_preview.html.erb
deleted file mode 100644
index 7baa4216fc..0000000000
--- a/app/views/blog/_post_preview.html.erb
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- <%= link_to fm[:title], path %>
- <% if fm[:subtitle].present? %>
- <%= fm[:subtitle] %>
- <% end %>
-
- <%= render partial: "blog/date_and_author", locals: { front_matter: fm.with_indifferent_access } %>
-
- <% if fm[:images].present? %>
-
<%= thumbnail_image_from_post(fm[:images]) %>
- <% end %>
-
- <%= fm[:description] %>
- <%= render partial: "blog/tag_list", locals: { tags: fm[:tags] } %>
-
diff --git a/app/views/blog/_tag_list.html.erb b/app/views/blog/_tag_list.html.erb
deleted file mode 100644
index b98fe864bf..0000000000
--- a/app/views/blog/_tag_list.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-
- <% tags.each do |tag| %>
- - <%= link_to(tag, blog_tag_path(tag.parameterize)) %>
- <% end %>
-
diff --git a/app/views/blog/closing-paragraphs/_enriching-the-lives-of-young-people.html.erb b/app/views/blog/closing-paragraphs/_enriching-the-lives-of-young-people.html.erb
deleted file mode 100644
index 622da08fb8..0000000000
--- a/app/views/blog/closing-paragraphs/_enriching-the-lives-of-young-people.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-
- If you're interested in enriching the lives of young people, find out more about how you can become a teacher.
-
diff --git a/app/views/blog/index.html.erb b/app/views/blog/index.html.erb
deleted file mode 100644
index 3b1053a04c..0000000000
--- a/app/views/blog/index.html.erb
+++ /dev/null
@@ -1,24 +0,0 @@
-<%= content_for :aside do %>
-
-
Popular tags
- <%= render partial: "blog/tag_list", locals: { tags: Pages::Blog.popular_tags } %>
-
-
-
-
Highlights
- <%= render partial: "blog/highlights" %>
-
-
-
-<% end %>
-
-
- <% @posts.each do |post| %>
- -
- <%= render partial: "blog/post_preview", locals: { path: post[:path], fm: post[:fm] } %>
-
-
- <% end %>
-
-
-<%= paginate @posts, window: 2 %>
diff --git a/app/views/blog/tag/show.html.erb b/app/views/blog/tag/show.html.erb
deleted file mode 100644
index fb2cf0809f..0000000000
--- a/app/views/blog/tag/show.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-
- <% @posts.each do |post| %>
- -
- <%= render partial: "blog/post_preview", locals: { path: post[:path], fm: post[:fm] } %>
-
-
- <% end %>
-
-
-<%= paginate @posts, window: 2 %>
diff --git a/app/views/content/how-to-apply-for-teacher-training.md b/app/views/content/how-to-apply-for-teacher-training.md
index b55ab380f4..60318f7374 100644
--- a/app/views/content/how-to-apply-for-teacher-training.md
+++ b/app/views/content/how-to-apply-for-teacher-training.md
@@ -15,5 +15,5 @@ layout: "layouts/category"
content:
- content/how-to-apply-for-teacher-training/questions
- content/how-to-apply-for-teacher-training/why-teach
-image: "static/images/content/blog/notepad.jpg"
+image: "static/images/content/application/notepad.jpg"
---
diff --git a/app/views/layouts/blog/index.html.erb b/app/views/layouts/blog/index.html.erb
deleted file mode 100644
index 754a40aaba..0000000000
--- a/app/views/layouts/blog/index.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- <%= render "sections/head" %>
- <%= body_tag do %>
- <%= render "sections/govuk_javascript" %>
- <%= render HeaderComponent.new(@front_matter) %>
-
- <%= main_tag do %>
-
- <%= render(partial: "blog/header", locals: { mobile: true }) %>
- ">
- <%= render(partial: "blog/header", locals: { mobile: false }) %>
- <%= yield %>
-
-
-
- <% end %>
-
- <%= render FooterComponent.new %>
- <% end %>
-
diff --git a/app/views/layouts/blog/post.html.erb b/app/views/layouts/blog/post.html.erb
deleted file mode 100644
index 9856f2e360..0000000000
--- a/app/views/layouts/blog/post.html.erb
+++ /dev/null
@@ -1,60 +0,0 @@
-<% content_for(:head) do %>
- <%= blog_structured_data(@post) %>
-<% end %>
-
-
-
- <%= render "sections/head" %>
- <%= body_tag do %>
- <%= render "sections/govuk_javascript" %>
- <%= render HeaderComponent.new(@front_matter) %>
-
- <%= main_tag do %>
-
- <%= render(partial: "sections/content_errors") %>
-
-
-
- <%= tag.h1(@front_matter["title"], class: "heading-l heading--margin-bottom-0") %>
- <% if @front_matter.key?("subtitle") %>
- <%= tag.div(@front_matter["subtitle"], role: 'doc-subtitle') %>
- <% end %>
-
- <%= render partial: "blog/date_and_author", locals: { front_matter: @front_matter } %>
-
-
- <%= yield %>
-
- <% if @front_matter.key?("closing_paragraph") %>
- <%= render(partial: %(blog/closing-paragraphs/#{@front_matter['closing_paragraph']})) %>
- <% end %>
-
-
-
-
-
-
-
- <% if @front_matter.key?("promo_content") %>
- <% @front_matter["promo_content"]&.each do |partial| %>
- <%= render(partial) %>
- <% end %>
- <% end %>
- <% end %>
-
- <%= render FooterComponent.new %>
- <% end %>
-
diff --git a/app/webpacker/images/content/blog/notepad.jpg b/app/webpacker/images/content/application/notepad.jpg
similarity index 100%
rename from app/webpacker/images/content/blog/notepad.jpg
rename to app/webpacker/images/content/application/notepad.jpg
diff --git a/app/webpacker/styles/blog.scss b/app/webpacker/styles/blog.scss
deleted file mode 100644
index 978e8732b8..0000000000
--- a/app/webpacker/styles/blog.scss
+++ /dev/null
@@ -1,194 +0,0 @@
-@mixin blog-article {
- @include mq($from: tablet) {
- > div {
- display: flex;
- gap: $indent-amount;
-
- header {
- flex-grow: 1;
- }
- }
- }
-
- header {
- .published-date {
- margin-top: $indent-amount;
- }
- }
-}
-
-.blog {
- hr,
- header p {
- margin-top: 2 * $indent-amount;
- }
-
- header + p {
- margin-top: 3em;
- }
-
- ol {
- padding-left: 0;
- }
-
- aside {
- padding: 0 $indent-amount;
-
- @include mq($from: tablet) {
- padding: 0;
-
- hr {
- display: none;
- }
- }
-
- > div {
- margin-bottom: $indent-amount;
- }
-
- .blog-highlights {
- list-style: none;
-
- li {
- margin-top: .4em;
- }
- }
- }
-
- .blog-tags {
- display: flex;
- flex-wrap: wrap;
- grid-gap: .8em;
- gap: .8em;
- margin: 0;
- list-style: none;
-
- li {
- background-color: $grey;
- margin-bottom: 0;
-
- &:last-child {
- margin-bottom: 0;
- }
-
- a {
- display: block;
- padding: .4em .8em;
- @extend .link--dark;
- }
- }
- }
-
- .blog-index {
- margin-top: 0;
- list-style: none;
-
- li > .blog-article {
- @include blog-article;
-
- img {
- width: 170px;
- height: 120px;
- object-fit: cover;
- object-position: center;
- }
- }
-
- li:last-child hr {
- display: none;
- }
- }
-
- > .blog-article {
- @include blog-article;
-
- > p:last-of-type {
- border-left: .4em solid $grey-mid;
- padding: .5em 0 .5em 1em;
- margin-top: 2.5em;
- }
-
- img {
- width: 100%;
- height: 300px;
- object-position: center;
- object-fit: cover;
-
- @include mq($from: mobile) {
- height: 450px;
- }
-
- @include mq($from: desktop) {
- height: 550px;
- }
- }
- }
-
- blockquote {
- margin: 2em 1.5rem;
-
- @include quote($white);
-
- border-left: 5px solid $pink;
-
- p {
- margin: 0;
- padding: 0 1em 1em 1.5em;
- font-weight: normal;
-
- span {
- white-space: nowrap;
- font-weight: normal;
- }
-
- // some extra rules to make the quotes a bit nicer. this 'smart' css
- // unfortunately has the side affect of requiring attribution for
- // multi-paragraph quotes; to get around it we'll need to implement
- // something more powerful like the regular quote module that wraps
- // the in a