mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 13:43:16 +08:00
UX: Remove title and description block if blank (#21861)
If the description is empty then it does not make sense to keep the quote block that contains just the title.
This commit is contained in:
parent
d371f3906e
commit
8e8f733c94
|
@ -683,9 +683,7 @@ en:
|
||||||
body: |
|
body: |
|
||||||
We are so glad you joined us.
|
We are so glad you joined us.
|
||||||
|
|
||||||
> ## %{site_title}
|
%{site_info_quote}
|
||||||
>
|
|
||||||
> %{site_description}
|
|
||||||
|
|
||||||
Here are some things you can do to get started:
|
Here are some things you can do to get started:
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,17 @@ module SeedData
|
||||||
if include_welcome_topics
|
if include_welcome_topics
|
||||||
# Welcome Topic
|
# Welcome Topic
|
||||||
if general_category = Category.find_by(id: SiteSetting.general_category_id)
|
if general_category = Category.find_by(id: SiteSetting.general_category_id)
|
||||||
|
site_info_quote =
|
||||||
|
if SiteSetting.title.present? && SiteSetting.site_description.present?
|
||||||
|
<<~RAW
|
||||||
|
> ## #{SiteSetting.title}
|
||||||
|
>
|
||||||
|
> #{SiteSetting.site_description}
|
||||||
|
RAW
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
|
||||||
topics << {
|
topics << {
|
||||||
site_setting_name: "welcome_topic_id",
|
site_setting_name: "welcome_topic_id",
|
||||||
title: I18n.t("discourse_welcome_topic.title", site_title: SiteSetting.title),
|
title: I18n.t("discourse_welcome_topic.title", site_title: SiteSetting.title),
|
||||||
|
@ -107,6 +118,7 @@ module SeedData
|
||||||
base_path: Discourse.base_path,
|
base_path: Discourse.base_path,
|
||||||
site_title: SiteSetting.title,
|
site_title: SiteSetting.title,
|
||||||
site_description: SiteSetting.site_description,
|
site_description: SiteSetting.site_description,
|
||||||
|
site_info_quote: site_info_quote,
|
||||||
),
|
),
|
||||||
category: general_category,
|
category: general_category,
|
||||||
after_create: proc { |post| post.topic.update_pinned(true, true) },
|
after_create: proc { |post| post.topic.update_pinned(true, true) },
|
||||||
|
|
|
@ -28,6 +28,7 @@ RSpec.describe SeedData::Topics do
|
||||||
base_path: Discourse.base_path,
|
base_path: Discourse.base_path,
|
||||||
site_title: SiteSetting.title,
|
site_title: SiteSetting.title,
|
||||||
site_description: SiteSetting.site_description,
|
site_description: SiteSetting.site_description,
|
||||||
|
site_info_quote: "",
|
||||||
).rstrip,
|
).rstrip,
|
||||||
)
|
)
|
||||||
expect(topic.category_id).to eq(SiteSetting.general_category_id)
|
expect(topic.category_id).to eq(SiteSetting.general_category_id)
|
||||||
|
@ -78,6 +79,27 @@ RSpec.describe SeedData::Topics do
|
||||||
expect(SiteSetting.tos_topic_id).to eq(-1)
|
expect(SiteSetting.tos_topic_id).to eq(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "creates a welcome topic without site title" do
|
||||||
|
SiteSetting.title = "My Awesome Community"
|
||||||
|
SiteSetting.site_description = ""
|
||||||
|
|
||||||
|
create_topic
|
||||||
|
|
||||||
|
post = Post.find_by(topic_id: SiteSetting.welcome_topic_id, post_number: 1)
|
||||||
|
expect(post.raw).not_to include("> ## My Awesome Community")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "creates a welcome topic with site title and description" do
|
||||||
|
SiteSetting.title = "My Awesome Community"
|
||||||
|
SiteSetting.site_description = "The best community"
|
||||||
|
|
||||||
|
create_topic
|
||||||
|
|
||||||
|
post = Post.find_by(topic_id: SiteSetting.welcome_topic_id, post_number: 1)
|
||||||
|
expect(post.raw).to include("> ## My Awesome Community")
|
||||||
|
expect(post.raw).to include("> The best community")
|
||||||
|
end
|
||||||
|
|
||||||
it "creates a legal topic if company_name is set" do
|
it "creates a legal topic if company_name is set" do
|
||||||
SiteSetting.company_name = "Company Name"
|
SiteSetting.company_name = "Company Name"
|
||||||
subject.create(site_setting_names: ["tos_topic_id"])
|
subject.create(site_setting_names: ["tos_topic_id"])
|
||||||
|
@ -110,6 +132,7 @@ RSpec.describe SeedData::Topics do
|
||||||
base_path: Discourse.base_path,
|
base_path: Discourse.base_path,
|
||||||
site_title: SiteSetting.title,
|
site_title: SiteSetting.title,
|
||||||
site_description: SiteSetting.site_description,
|
site_description: SiteSetting.site_description,
|
||||||
|
site_info_quote: "",
|
||||||
).rstrip,
|
).rstrip,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user