Add config option for Forem collective noun (#11107)

Not everyone will want to use "Community" to describe their Forem, so
now they have some flexibility there.
This commit is contained in:
Jacob Herrington 2020-10-27 11:45:52 -05:00 committed by GitHub
parent 7f08ff2b93
commit c91c07920f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 69 additions and 25 deletions

View file

@ -14,6 +14,8 @@ module Admin
COMMUNITY_PARAMS =
%i[
community_name
collective_noun
collective_noun_disabled
community_description
community_member_label
community_copyright_start_year

View file

@ -185,7 +185,9 @@ module ApplicationHelper
end
def community_qualified_name
"#{community_name} Community"
return "#{community_name} #{SiteConfig.collective_noun}" unless SiteConfig.collective_noun_disabled
community_name
end
def release_adjusted_cache_key(path)

View file

@ -3,19 +3,27 @@ import { Controller } from 'stimulus';
const recaptchaFields = document.querySelector('#recaptchaContainer');
export default class ConfigController extends Controller {
static targets = ['inviteOnlyMode', 'authenticationProviders', 'requireCaptchaForEmailPasswordRegistration'];
static targets = [
'authenticationProviders',
'collectiveNoun',
'requireCaptchaForEmailPasswordRegistration',
];
disableAuthenticationOptions() {
if (this.inviteOnlyModeTarget.checked) {
this.authenticationProvidersTarget.disabled = true;
disableTargetField(event) {
const targetElementName = event.target.dataset.disableTarget;
const targetElement = this[`${targetElementName}Target`];
const newValue = event.target.checked;
targetElement.disabled = newValue;
// Disable the button generated by ERB for select tags
if (targetElement.nodeName === 'SELECT') {
const snakeCaseName = targetElementName.replace(
/[A-Z]/g,
(letter) => `_${letter.toLowerCase()}`,
);
document.querySelector(
'button[data-id=site_config_authentication_providers]',
).disabled = true;
} else {
this.authenticationProvidersTarget.disabled = false;
document.querySelector(
'button[data-id=site_config_authentication_providers]',
).disabled = false;
`button[data-id=site_config_${snakeCaseName}]`,
).disabled = newValue;
}
}

View file

@ -49,6 +49,10 @@ module Constants
description: "https://url.com/lander",
placeholder: "URL campaign sidebar image will link to"
},
collective_noun: {
description: "Used to describe your collective identity.",
placeholder: "Herd"
},
community_copyright_start_year: {
description: "Used to mark the year this forem was started.",
placeholder: Time.zone.today.year.to_s

View file

@ -2,7 +2,8 @@ class DeviseMailer < Devise::Mailer
before_action :use_site_config_values
def use_site_config_values
Devise.mailer_sender = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>"
Devise.mailer_sender =
"#{SiteConfig.community_name} #{SiteConfig.collective_noun} <#{SiteConfig.email_addresses[:default]}>"
ActionMailer::Base.default_url_options[:host] = SiteConfig.app_domain
end
end

View file

@ -48,6 +48,8 @@ class SiteConfig < RailsSettings::Base
# Community Content
field :community_name, type: :string, default: ApplicationConfig["COMMUNITY_NAME"] || "New Forem"
field :collective_noun, type: :string, default: "Community"
field :collective_noun_disabled, type: :boolean, default: false
field :community_description, type: :string
field :community_member_label, type: :string, default: "user"
field :tagline, type: :string

View file

@ -141,7 +141,7 @@
</h3>
<div class="form-group">
<div class="crayons-field--checkbox">
<%= f.check_box :invite_only_mode, checked: SiteConfig.invite_only_mode, data: { action: "config#disableAuthenticationOptions", target: "config.inviteOnlyMode" }, class: "crayons-checkbox" %>
<%= f.check_box :invite_only_mode, checked: SiteConfig.invite_only_mode, data: { action: "config#disableTargetField", disable_target: "authenticationProviders" }, class: "crayons-checkbox" %>
<div class="mt-0">
<%= admin_config_label :invite_only_mode %>
<%= admin_config_description Constants::SiteConfig::DETAILS[:invite_only_mode][:description] %>
@ -463,6 +463,19 @@
placeholder: Constants::SiteConfig::DETAILS[:community_name][:placeholder] %>
</div>
<div class="crayons-field">
<%= admin_config_label :collective_noun %>
<%= admin_config_description Constants::SiteConfig::DETAILS[:collective_noun][:description] %>
<%= f.text_field :collective_noun,
class: "crayons-textfield",
value: SiteConfig.collective_noun,
placeholder: Constants::SiteConfig::DETAILS[:collective_noun][:placeholder],
disabled: SiteConfig.collective_noun_disabled,
data: { target: "config.collectiveNoun" } %>
<%= admin_config_label :collective_noun_disabled %>
<%= f.check_box :collective_noun_disabled, checked: SiteConfig.collective_noun_disabled, data: { action: "config#disableTargetField", disable_target: "collectiveNoun" }, class: "crayons-checkbox" %>
</div>
<div class="crayons-field">
<%= admin_config_label :tagline %>
<%= admin_config_description Constants::SiteConfig::DETAILS[:tagline][:description] %>

View file

@ -12,7 +12,7 @@
</style>
<div id="onboarding-container"
data-community-name="<%= community_name %>"
data-community-name="<%= community_qualified_name %>"
data-community-description="<%= SiteConfig.community_description %>"
data-community-logo="<%= optimized_image_url(safe_logo_url(SiteConfig.onboarding_logo_image)) %>"
data-community-background="<%= optimized_image_url(SiteConfig.onboarding_background_image, width: 1680, quality: 75, random_fallback: false) %>">

View file

@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title><%= community_name %> Community ❤️</title>
<title><%= community_qualified_name %> ❤️</title>
</head>
<body>
<%= @html_variant.html.html_safe %>

View file

@ -1,7 +1,7 @@
<h1>Bronze Sponsorship</h1>
<p>
Thank you for supporting the <%= community_name %> Community! Heres what to expect with a Bronze Sponsorship:
Thank you for supporting the <%= community_qualified_name %>! Heres what to expect with a Bronze Sponsorship:
</p>
<h3>
@ -20,7 +20,7 @@
🏆 Special flair on your organization profile page
</h3>
<p>
As a Bronze sponsor, you will receive special flair that lives on your organization page. This visual cue will show the <%= community_name %> Community and broader ecosystem that you are an important community supporter, providing a natural draw for increased engagement on the platform. And, of course, youll have bragging rights and company pride knowing that youre supporting a wonderful community.
As a Bronze sponsor, you will receive special flair that lives on your organization page. This visual cue will show the <%= community_qualified_name %> and broader ecosystem that you are an important community supporter, providing a natural draw for increased engagement on the platform. And, of course, youll have bragging rights and company pride knowing that youre supporting a wonderful community.
</p>
<% if user_signed_in? %>
<h3>Bronze sponsorship costs 100 credits/mo ($250 when purchased in bulk)</h3>

View file

@ -37,7 +37,7 @@ It will also include a call-to-action to follow your organization directly in th
🏆 Special flair on your organization profile page
</h3>
<p>
As a Gold sponsor, you will receive special flair that lives on your organization page. This visual cue will show the <%= community_name %> Community and broader ecosystem that you are an important community supporter, providing a natural draw for increased engagement on the platform. And, of course, youll have bragging rights and company pride knowing that youre supporting a wonderful community.
As a Gold sponsor, you will receive special flair that lives on your organization page. This visual cue will show the <%= community_qualified_name %> and broader ecosystem that you are an important community supporter, providing a natural draw for increased engagement on the platform. And, of course, youll have bragging rights and company pride knowing that youre supporting a wonderful community.
</p>
<% unless user_signed_in? %>
<h2>Email <%= email_link(:business) %> for pricing information</h2>

View file

@ -19,7 +19,7 @@
🏆 Special flair on your organization profile page
</h3>
<p>
As a Silver sponsor, you will receive special flair that lives on your organization page. This visual cue will show the <%= community_name %> Community and broader ecosystem that you are an important community supporter, providing a natural draw for increased engagement on the platform. And, of course, youll have bragging rights and company pride knowing that youre supporting a wonderful community.
As a Silver sponsor, you will receive special flair that lives on your organization page. This visual cue will show the <%= community_qualified_name %> and broader ecosystem that you are an important community supporter, providing a natural draw for increased engagement on the platform. And, of course, youll have bragging rights and company pride knowing that youre supporting a wonderful community.
</p>
<% if user_signed_in? %>
<h3>Silver sponsorship costs 500 credits/mo ($1,250 when purchased in bulk)</h3>

View file

@ -15,7 +15,7 @@ Target your messaging with a tag sponsorship. This is a great way to increase y
Placement on our tag overview page
</h3>
<p>
Members of the <%= community_name %> Community head to the dedicated tags page to explore new areas of the site, and to manage which tags they follow. Your company will be listed as a sponsor directly alongside the tag you support. This placement provides visibility to all members, even if they dont directly engage within your tag.
Members of the <%= community_qualified_name %> head to the dedicated tags page to explore new areas of the site, and to manage which tags they follow. Your company will be listed as a sponsor directly alongside the tag you support. This placement provides visibility to all members, even if they dont directly engage within your tag.
</p>
<h3>
Special flair on your organization profile page

View file

@ -12,7 +12,13 @@ RSpec.describe ApplicationHelper, type: :helper do
describe "#community_qualified_name" do
it "equals to the full qualified community name" do
expected_name = "#{SiteConfig.community_name} Community"
allow(SiteConfig).to receive(:collective_noun_disabled).and_return(true)
expected_name = SiteConfig.community_name.to_s
expect(helper.community_qualified_name).to eq(expected_name)
allow(SiteConfig).to receive(:collective_noun).and_return("Flock")
allow(SiteConfig).to receive(:collective_noun_disabled).and_return(false)
expected_name = "#{SiteConfig.community_name} #{SiteConfig.collective_noun}"
expect(helper.community_qualified_name).to eq(expected_name)
end
end

View file

@ -105,6 +105,13 @@ RSpec.describe "/admin/config", type: :request do
expect(SiteConfig.community_name).to eq(name_magoo)
end
it "updates the collective_noun" do
collective_noun = "Rhumba"
post "/admin/config", params: { site_config: { collective_noun: collective_noun },
confirmation: confirmation_message }
expect(SiteConfig.collective_noun).to eq(collective_noun)
end
it "updates the community_member_label" do
name = "developer"
post "/admin/config", params: { site_config: { community_member_label: name },
@ -664,7 +671,6 @@ RSpec.describe "/admin/config", type: :request do
expect(SiteConfig.home_feed_minimum_score).to eq(home_feed_minimum_score)
end
it "updates the brand color if proper hex" do
hex = "#0a0a0a" # dark enough
post "/admin/config", params: { site_config: { primary_brand_color_hex: hex },

View file

@ -36,7 +36,7 @@ RSpec.describe "ArticlesShow", type: :request do
"publisher" => {
"@context" => "http://schema.org",
"@type" => "Organization",
"name" => "#{SiteConfig.community_name} Community",
"name" => "#{SiteConfig.community_name} #{SiteConfig.collective_noun}",
"logo" => {
"@context" => "http://schema.org",
"@type" => "ImageObject",

View file

@ -21,7 +21,7 @@ RSpec.describe "ServiceWorker", type: :request do
describe "GET /manifest.json" do
it "renders file with proper text" do
get "/manifest.json"
expect(response.body).to include("\"name\": \"#{SiteConfig.community_name} Community\"")
expect(response.body).to include("\"name\": \"#{SiteConfig.community_name} #{SiteConfig.collective_noun}\"")
end
it "renders json file" do