A platform for community discussion. Free, open, simple.
FIX: Add helpers for title and content for `application.html.erb` and `crawler.html.erb` (#32290)
Gabriel Grubba12f05181c797
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex 13f82d96eab..72a22ec0806 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -270,7 +270,7 @@ module ApplicationHelper(request ? I18n.locale.to_s : SiteSetting.default_locale).sub("_", "-")end- def crawlable_title_content+ def title_contentDiscoursePluginRegistry.apply_modifier(:meta_data_content,content_for(:title) || SiteSetting.title,@@ -279,7 +279,7 @@ module ApplicationHelper)end- def crawlable_description_content+ def description_contentDiscoursePluginRegistry.apply_modifier(:meta_data_content,@description_meta || SiteSetting.site_description,diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erbindex 0412f3e85b0..9b4524d7928 100644--- a/app/views/layouts/application.html.erb+++ b/app/views/layouts/application.html.erb@@ -2,8 +2,8 @@<html lang="<%= html_lang %>" class="<%= html_classes %>"><head><meta charset="utf-8">- <title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title>- <meta name="description" content="<%= @description_meta || SiteSetting.site_description %>">+ <title><%= title_content %></title>+ <meta name="description" content="<%= description_content %>"><meta name="discourse_theme_id" content="<%= theme_id %>"><meta name="discourse_current_homepage" content="<%= current_homepage %>">diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erbindex dad9d4f7fd6..954a67d9332 100644--- a/app/views/layouts/crawler.html.erb+++ b/app/views/layouts/crawler.html.erb@@ -2,8 +2,8 @@<html lang="<%= html_lang %>"><head><meta charset="utf-8">- <title><%= crawlable_title_content %></title>- <meta name="description" content="<%= crawlable_description_content %>">+ <title><%= title_content %></title>+ <meta name="description" content="<%= description_content %>"><%= render partial: "layouts/head" %><%= render partial: "common/discourse_stylesheet" %><%= theme_lookup("head_tag") %>diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rbindex 2fe556380ea..8058f3ea977 100644--- a/spec/helpers/application_helper_spec.rb+++ b/spec/helpers/application_helper_spec.rb@@ -745,10 +745,10 @@ RSpec.describe ApplicationHelper doendend- describe "#crawlable_title_content" do+ describe "#title_content" doit "returns the correct title" doSiteSetting.title = "Test Title"- result = helper.crawlable_title_content+ result = helper.title_contentexpect(result).to include("Test Title")end@@ -757,16 +757,16 @@ RSpec.describe ApplicationHelper dohelper.stubs(:content_for?).with(:title).returns(true)helper.stubs(:content_for).with(:title).returns("Custom Title")- result = helper.crawlable_title_content+ result = helper.title_contentexpect(result).to include("Custom Title")endend- describe "#crawlable_description_content" do+ describe "#description_content" doit "returns the correct description" doSiteSetting.site_description = "Test Description"- result = helper.crawlable_description_content+ result = helper.description_contentexpect(result).to include("Test Description")end@@ -774,7 +774,7 @@ RSpec.describe ApplicationHelper doit "accepts a content argument" do@description_meta = "Custom Description"- result = helper.crawlable_description_content+ result = helper.description_contentexpect(result).to include("Custom Description")end@@ -810,7 +810,7 @@ RSpec.describe ApplicationHelper doit "modifies the title tag" doplugin.register_modifier(:meta_data_content, &block)- title = helper.crawlable_title_content+ title = helper.title_contentexpect(title).to include("BIG TITLE")end@@ -818,7 +818,7 @@ RSpec.describe ApplicationHelper doit "modifies the description tag" doplugin.register_modifier(:meta_data_content, &block)- description = helper.crawlable_description_content+ description = helper.description_contentexpect(description).to include(" - modified by plugin")end