* feat: define the different social media handles * feat: dynamically render all the social media fields * feat: ensure that the social media handles are permitter and dealt in a separate path from the rest * test: update social_networks_handle to social_media_handles * feat: update the sidebar to use different social media * feat: update the twitter:site meta handle to be SiteConfig.social_media_handles["twitter"] * feat: update the a links to tweets * feat: make the links dynamic and only show those that there is a value for * refactor: make @ThePracticalDev dynamic * refactor: make @ThePracticalDev dynamic * feat: add dynamic social media handles * chore: rename values * chore: remove extra social handles * chore: some spacing * chore: remove lines * rafector: user rails-settings-cached type: :hash to set the type and the defaults * feat: use nil and blank instead of "" and empty * chore: move the social media handles into the right box * refactor: rearrange model placement based on the UI * chore: code climate * refactor: comments from PR * chore: rename the ff * chore: amended twitter username * chore: add a temporary rake task * feat: update names * chore: why am i using the old syntax :( * chore: revert dynamic erb variable in offline.html
59 lines
2.5 KiB
Ruby
59 lines
2.5 KiB
Ruby
class Internal::ConfigsController < Internal::ApplicationController
|
|
layout "internal"
|
|
|
|
before_action :extra_authorization_and_confirmation, only: [:create]
|
|
|
|
def show
|
|
@logo_svg = SiteConfig.logo_svg.html_safe # rubocop:disable Rails/OutputSafety
|
|
end
|
|
|
|
def create
|
|
clean_up_params
|
|
config_params.keys.each do |key|
|
|
if config_params[key].respond_to?(:to_h)
|
|
SiteConfig.public_send("#{key}=", config_params[key].to_h) unless config_params[key].empty?
|
|
else
|
|
SiteConfig.public_send("#{key}=", config_params[key].strip) unless config_params[key].nil?
|
|
end
|
|
end
|
|
bust_relevant_caches
|
|
redirect_to internal_config_path, notice: "Site configuration was successfully updated."
|
|
end
|
|
|
|
private
|
|
|
|
def config_params
|
|
allowed_params = %i[
|
|
default_site_email mascot_user_id
|
|
campaign_hero_html_variant_name campaign_sidebar_enabled campaign_featured_tags
|
|
campaign_sidebar_image
|
|
main_social_image favicon_url logo_svg logo_png primary_sticker_image_url
|
|
mascot_image_url mascot_image_description
|
|
rate_limit_follow_count_daily
|
|
ga_view_id ga_fetch_rate community_description authentication_providers
|
|
community_member_description tagline
|
|
mailchimp_newsletter_id mailchimp_sustaining_members_id
|
|
mailchimp_tag_moderators_id mailchimp_community_moderators_id
|
|
periodic_email_digest_max periodic_email_digest_min suggested_tags
|
|
rate_limit_comment_creation rate_limit_published_article_creation
|
|
rate_limit_image_upload rate_limit_email_recipient sidebar_tags
|
|
]
|
|
params.require(:site_config).permit(allowed_params, social_media_handles: SiteConfig.social_media_handles.keys)
|
|
end
|
|
|
|
def extra_authorization_and_confirmation
|
|
not_authorized unless current_user.has_role?(:single_resource_admin, Config) # Special additional permission
|
|
not_authorized if params[:confirmation] != "My username is @#{current_user.username} and this action is 100% safe and appropriate."
|
|
end
|
|
|
|
def clean_up_params
|
|
config = params[:site_config]
|
|
config[:suggested_tags] = config[:suggested_tags].downcase.delete(" ") if config[:suggested_tags]
|
|
config[:authentication_providers] = config[:authentication_providers].downcase.delete(" ") if config[:authentication_providers]
|
|
config[:sidebar_tags] = config[:sidebar_tags].downcase.delete(" ") if config[:sidebar_tags]
|
|
end
|
|
|
|
def bust_relevant_caches
|
|
CacheBuster.bust("/tags/onboarding") # Needs to change when suggested_tags is edited
|
|
end
|
|
end
|