Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-26 02:50:28 +01:00
DEV: Keep plugin.rb format
Dieser Commit ist enthalten in:
Ursprung
9ff9844420
Commit
af064dc655
1 geänderte Dateien mit 10 neuen und 9 gelöschten Zeilen
19
plugin.rb
19
plugin.rb
|
@ -7,9 +7,9 @@
|
||||||
# contact_emails: development@pavilion.tech
|
# contact_emails: development@pavilion.tech
|
||||||
# subscription_url: https://coop.pavilion.tech
|
# subscription_url: https://coop.pavilion.tech
|
||||||
|
|
||||||
gem "liquid", "5.0.1", require: true
|
gem 'liquid', '5.0.1', require: true
|
||||||
register_asset "stylesheets/common/admin.scss"
|
register_asset 'stylesheets/common/admin.scss'
|
||||||
register_asset "stylesheets/common/wizard.scss"
|
register_asset 'stylesheets/common/wizard.scss'
|
||||||
|
|
||||||
enabled_site_setting :custom_wizard_enabled
|
enabled_site_setting :custom_wizard_enabled
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ after_initialize do
|
||||||
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
|
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
|
||||||
|
|
||||||
add_to_class(:topic, :wizard_submission_id) do
|
add_to_class(:topic, :wizard_submission_id) do
|
||||||
custom_fields["wizard_submission_id"]
|
custom_fields['wizard_submission_id']
|
||||||
end
|
end
|
||||||
|
|
||||||
add_class_method(:wizard, :user_requires_completion?) do |user|
|
add_class_method(:wizard, :user_requires_completion?) do |user|
|
||||||
|
@ -123,6 +123,7 @@ after_initialize do
|
||||||
if user &&
|
if user &&
|
||||||
user.first_seen_at.blank? &&
|
user.first_seen_at.blank? &&
|
||||||
wizard = CustomWizard::Wizard.after_signup(user)
|
wizard = CustomWizard::Wizard.after_signup(user)
|
||||||
|
|
||||||
if !wizard.completed?
|
if !wizard.completed?
|
||||||
custom_redirect = true
|
custom_redirect = true
|
||||||
CustomWizard::Wizard.set_user_redirect(wizard.id, user)
|
CustomWizard::Wizard.set_user_redirect(wizard.id, user)
|
||||||
|
@ -133,8 +134,8 @@ after_initialize do
|
||||||
end
|
end
|
||||||
|
|
||||||
add_to_class(:user, :redirect_to_wizard) do
|
add_to_class(:user, :redirect_to_wizard) do
|
||||||
if custom_fields["redirect_to_wizard"].present?
|
if custom_fields['redirect_to_wizard'].present?
|
||||||
custom_fields["redirect_to_wizard"]
|
custom_fields['redirect_to_wizard']
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
@ -159,10 +160,10 @@ after_initialize do
|
||||||
end
|
end
|
||||||
|
|
||||||
add_to_class(:application_controller, :redirect_to_wizard_if_required) do
|
add_to_class(:application_controller, :redirect_to_wizard_if_required) do
|
||||||
@excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split("|") + ["/w/"]
|
@excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/']
|
||||||
url = request.referer || request.original_url
|
url = request.referer || request.original_url
|
||||||
excluded_route = @excluded_routes.any? { |str| /#{str}/ =~ url }
|
excluded_route = @excluded_routes.any? { |str| /#{str}/ =~ url }
|
||||||
not_api = request.format === "text/html"
|
not_api = request.format === 'text/html'
|
||||||
|
|
||||||
if not_api && !excluded_route
|
if not_api && !excluded_route
|
||||||
wizard_id = current_user.redirect_to_wizard
|
wizard_id = current_user.redirect_to_wizard
|
||||||
|
@ -202,7 +203,7 @@ after_initialize do
|
||||||
|
|
||||||
full_path = "#{Rails.root}/plugins/discourse-custom-wizard/assets/stylesheets/wizard/wizard_custom.scss"
|
full_path = "#{Rails.root}/plugins/discourse-custom-wizard/assets/stylesheets/wizard/wizard_custom.scss"
|
||||||
if Stylesheet::Importer.respond_to?(:plugin_assets)
|
if Stylesheet::Importer.respond_to?(:plugin_assets)
|
||||||
Stylesheet::Importer.plugin_assets["wizard_custom"] = Set[full_path]
|
Stylesheet::Importer.plugin_assets['wizard_custom'] = Set[full_path]
|
||||||
else
|
else
|
||||||
# legacy method, Discourse 2.7.0.beta5 and below
|
# legacy method, Discourse 2.7.0.beta5 and below
|
||||||
DiscoursePluginRegistry.register_asset(full_path, {}, "wizard_custom")
|
DiscoursePluginRegistry.register_asset(full_path, {}, "wizard_custom")
|
||||||
|
|
Laden …
In neuem Issue referenzieren