This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: load custom site settings from yaml file.
- Loading branch information
1 parent
662f2f1
commit 4116077
Showing
6 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails' | ||
|
||
module DiscourseDev | ||
class Config | ||
attr_reader :config, :default_config | ||
|
||
def initialize | ||
@default_config = YAML.load_file(File.join(File.expand_path(__dir__), "config.yml")) | ||
file_path = File.join(Rails.root, "config", "dev.yml") | ||
|
||
if File.exists?(file_path) | ||
@config = YAML.load_file(file_path) | ||
else | ||
@config = {} | ||
end | ||
end | ||
|
||
def update! | ||
update_site_settings | ||
end | ||
|
||
def update_site_settings | ||
puts "Updating site settings..." | ||
|
||
site_settings = config["site_settings"] || {} | ||
|
||
site_settings.each do |key, value| | ||
puts "#{key} = #{value}" | ||
SiteSetting.set(key, value) | ||
end | ||
|
||
keys = site_settings.keys | ||
|
||
default_config["site_settings"].each do |key, value| | ||
next if keys.include?(key) | ||
|
||
puts "#{key} = #{value}" | ||
SiteSetting.set(key, value) | ||
end | ||
|
||
SiteSetting.refresh! | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
site_settings: | ||
tagging_enabled: false | ||
verbose_discourse_connect_logging: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters