A platform for community discussion. Free, open, simple.
FEATURE: add short_site_description setting to be included in title tag on homepage
Maja Komeldbbadb5c357b
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rbindex b51882fe8dc..c1bb2dda9ec 100644--- a/app/controllers/categories_controller.rb+++ b/app/controllers/categories_controller.rb@@ -33,7 +33,11 @@ class CategoriesController < ApplicationController)@category_list.draft = Draft.get(current_user, Draft::NEW_TOPIC, @category_list.draft_sequence) if current_user- @title = "#{I18n.t('js.filters.categories.title')} - #{SiteSetting.title}" unless category_options[:is_homepage]+ if category_options[:is_homepage] && SiteSetting.short_site_description.present?+ @title = "#{SiteSetting.title} - #{SiteSetting.short_site_description}"+ elsif !category_options[:is_homepage]+ @title = "#{I18n.t('js.filters.categories.title')} - #{SiteSetting.title}"+ endrespond_to do |format|format.html dodiff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rbindex a5f297e6b1c..d52f1ee4bea 100644--- a/app/controllers/list_controller.rb+++ b/app/controllers/list_controller.rb@@ -107,6 +107,8 @@ class ListController < ApplicationController@title = I18n.t('js.filters.with_topics', filter: filter_title)end@title << " - #{SiteSetting.title}"+ elsif (filter.to_s == current_homepage) && SiteSetting.short_site_description.present?+ @title = "#{SiteSetting.title} - #{SiteSetting.short_site_description}"endenddiff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex a75b9d48963..53dbf4945ad 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -1193,6 +1193,7 @@ en:educate_until_posts: "When the user starts typing their first (n) new posts, show the pop-up new user education panel in the composer."title: "The name of this site, as used in the title tag."site_description: "Describe this site in one sentence, as used in the meta description tag."+ short_site_description: "Short description, as used in the title tag on homepage."contact_email: "Email address of key contact responsible for this site. Used for critical notifications, as well as on the <a href='%{base_path}/about' target='_blank'>/about</a> contact form for urgent matters."contact_url: "Contact URL for this site. Used on the <a href='%{base_path}/about' target='_blank'>/about</a> contact form for urgent matters."crawl_images: "Retrieve images from remote URLs to insert the correct width and height dimensions."@@ -4047,6 +4048,9 @@ en:site_description:label: "Describe your community in one short sentence"placeholder: "A place for Jane and her friends to discuss cool stuff"+ short_site_description:+ label: "Describe your community in few words"+ placeholder: "Best community ever"introduction:title: "Introduction"diff --git a/config/site_settings.yml b/config/site_settings.ymlindex ace129d4518..9fb257110db 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -31,6 +31,8 @@ required:default: 'Discourse'site_description:default: ''+ short_site_description:+ default: ''contact_email:client: truedefault: ''diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rbindex 92c6aa90353..02214c7f95f 100644--- a/lib/wizard/builder.rb+++ b/lib/wizard/builder.rb@@ -33,12 +33,13 @@ class Wizard@wizard.append_step('forum-title') do |step|step.add_field(id: 'title', type: 'text', required: true, value: SiteSetting.title)step.add_field(id: 'site_description', type: 'text', required: true, value: SiteSetting.site_description)+ step.add_field(id: 'short_site_description', type: 'text', required: false, value: SiteSetting.short_site_description)step.on_update do |updater|updater.ensure_changed(:title)if updater.errors.blank?- updater.apply_settings(:title, :site_description)+ updater.apply_settings(:title, :site_description, :short_site_description)endendenddiff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rbindex 80c7622f9ca..428b876b3e4 100644--- a/spec/requests/categories_controller_spec.rb+++ b/spec/requests/categories_controller_spec.rb@@ -37,6 +37,18 @@ describe CategoriesController doexpect(json['topic_list_latest']).to include(%{"more_topics_url":"/latest"})endend++ it "Shows correct title if category list is set for homepage" do+ SiteSetting.top_menu = "categories|latest"+ get "/"++ expect(response.body).to have_tag "title", text: "Discourse"++ SiteSetting.short_site_description = "Official community"+ get "/"++ expect(response.body).to have_tag "title", text: "Discourse - Official community"+ endendcontext 'extensibility event' dodiff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rbindex d7b0ea2dacb..e15ca638d92 100644--- a/spec/requests/list_controller_spec.rb+++ b/spec/requests/list_controller_spec.rb@@ -5,8 +5,10 @@ RSpec.describe ListController dolet(:group) { Fabricate(:group) }let(:user) { Fabricate(:user) }let(:post) { Fabricate(:post, user: user) }+ let(:admin) { Fabricate(:admin) }before do+ admin # to skip welcome wizard at home page `/`SiteSetting.top_menu = 'latest|new|unread|categories'end@@ -77,6 +79,17 @@ RSpec.describe ListController doparsed = JSON.parse(response.body)expect(parsed["topic_list"]["topics"].length).to eq(1)end++ it "shows correct title if topic list is set for homepage" do+ get "/"++ expect(response.body).to have_tag "title", text: "Discourse"++ SiteSetting.short_site_description = "Best community"+ get "/"++ expect(response.body).to have_tag "title", text: "Discourse - Best community"+ endenddescribe "categories and X" do