Module: Decidim::DecidimAwesome::AwesomeHelpers
- Defined in:
- lib/decidim/decidim_awesome/awesome_helpers.rb
Instance Method Summary collapse
- #awesome_config ⇒ Object
-
#awesome_config_instance ⇒ Object
Returns the normalized config for an Organization and the current url.
-
#awesome_custom_styles ⇒ Object
Collects all CSS that is applied in the current URL context.
- #awesome_version ⇒ Object
- #javascript_config_vars ⇒ Object
- #organization_awesome_config ⇒ Object
- #show_public_intergram? ⇒ Boolean
- #tenant_stylesheets ⇒ Object
- #unfiltered_awesome_config ⇒ Object
- #version_prefix ⇒ Object
Instance Method Details
#awesome_config ⇒ Object
18 19 20 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 18 def awesome_config @awesome_config ||= awesome_config_instance.config end |
#awesome_config_instance ⇒ Object
Returns the normalized config for an Organization and the current url
10 11 12 13 14 15 16 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 10 def awesome_config_instance return @awesome_config_instance if @awesome_config_instance @awesome_config_instance = Config.new request.env["decidim.current_organization"] @awesome_config_instance.context_from_request request @awesome_config_instance end |
#awesome_custom_styles ⇒ Object
Collects all CSS that is applied in the current URL context
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 53 def awesome_custom_styles return unless awesome_config[:scoped_styles] return @awesome_custom_styles if @awesome_custom_styles styles = awesome_config[:scoped_styles]&.filter do |key, _value| config = AwesomeConfig.find_by(var: "scoped_style_#{key}", organization: current_organization) @awesome_config_instance.valid_in_context?(config&.constraints) end @awesome_custom_styles = styles.values.join("\n") end |
#awesome_version ⇒ Object
41 42 43 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 41 def awesome_version ::Decidim::DecidimAwesome::VERSION end |
#javascript_config_vars ⇒ Object
22 23 24 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 22 def javascript_config_vars awesome_config.except(:scoped_styles).to_json.html_safe end |
#organization_awesome_config ⇒ Object
37 38 39 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 37 def organization_awesome_config @organization_awesome_config ||= awesome_config_instance.organization_config end |
#show_public_intergram? ⇒ Boolean
26 27 28 29 30 31 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 26 def show_public_intergram? return unless awesome_config[:intergram_for_public] return true unless awesome_config[:intergram_for_public_settings][:require_login] user_signed_in? end |
#tenant_stylesheets ⇒ Object
45 46 47 48 49 50 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 45 def tenant_stylesheets return @tenant_stylesheets if @tenant_stylesheets prefix = Rails.root.join("app", "assets", "themes", current_organization.host) return @tenant_stylesheets = current_organization.host.to_s if File.exist?("#{prefix}.css") || File.exist?("#{prefix}.scss") || File.exist?("#{prefix}.scss.erb") end |
#unfiltered_awesome_config ⇒ Object
33 34 35 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 33 def unfiltered_awesome_config @unfiltered_awesome_config ||= awesome_config_instance.unfiltered_config end |
#version_prefix ⇒ Object
64 65 66 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 64 def version_prefix "v#{Decidim.version[0..3]}" end |