2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-03 10:31:16 -05:00
|
|
|
# we can not guess what to do if customization already started, so skip it
|
|
|
|
if !Theme.exists?
|
2020-10-14 09:18:02 -05:00
|
|
|
STDERR.puts "> Seeding theme and color schemes"
|
2017-05-03 10:31:16 -05:00
|
|
|
|
2020-10-15 13:05:48 -05:00
|
|
|
color_schemes = [
|
|
|
|
{ name: I18n.t("color_schemes.dark"), base_scheme_id: "Dark" },
|
|
|
|
{ name: I18n.t("color_schemes.wcag"), base_scheme_id: "WCAG" },
|
2022-07-08 16:46:32 -05:00
|
|
|
{ name: I18n.t("color_schemes.wcag_dark"), base_scheme_id: "WCAG Dark" },
|
|
|
|
{ name: I18n.t("color_schemes.dracula"), base_scheme_id: "Dracula" },
|
|
|
|
{ name: I18n.t("color_schemes.solarized_light"), base_scheme_id: "Solarized Light" },
|
2023-01-09 05:59:41 -06:00
|
|
|
{ name: I18n.t("color_schemes.solarized_dark"), base_scheme_id: "Solarized Dark" },
|
2020-10-15 13:05:48 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
color_schemes.each do |cs|
|
|
|
|
scheme = ColorScheme.find_by(base_scheme_id: cs[:base_scheme_id])
|
2023-01-09 05:59:41 -06:00
|
|
|
scheme ||=
|
|
|
|
ColorScheme.create_from_base(
|
|
|
|
name: cs[:name],
|
|
|
|
via_wizard: true,
|
|
|
|
base_scheme_id: cs[:base_scheme_id],
|
|
|
|
user_selectable: true,
|
|
|
|
)
|
2020-10-15 13:05:48 -05:00
|
|
|
end
|
2017-05-03 10:31:16 -05:00
|
|
|
|
2023-01-09 05:59:41 -06:00
|
|
|
name = I18n.t("color_schemes.default_theme_name")
|
2020-10-14 09:18:02 -05:00
|
|
|
default_theme = Theme.create!(name: name, user_id: -1)
|
2017-05-03 10:31:16 -05:00
|
|
|
default_theme.set_default!
|
2021-09-02 13:55:38 -05:00
|
|
|
|
2023-01-09 05:59:41 -06:00
|
|
|
if SiteSetting.default_dark_mode_color_scheme_id ==
|
|
|
|
SiteSetting.defaults[:default_dark_mode_color_scheme_id]
|
2023-02-12 22:39:45 -06:00
|
|
|
dark_scheme_id = ColorScheme.where(base_scheme_id: "Dark").pick(:id)
|
2021-09-02 13:55:38 -05:00
|
|
|
|
2023-01-09 05:59:41 -06:00
|
|
|
SiteSetting.default_dark_mode_color_scheme_id = dark_scheme_id if dark_scheme_id.present?
|
2021-09-02 13:55:38 -05:00
|
|
|
end
|
2017-05-03 10:31:16 -05:00
|
|
|
end
|