Module: Plugins::CamaleonGoogleAnalytic::MainHelper

Included in:
AdminController
Defined in:
app/helpers/plugins/camaleon_google_analytic/main_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



2
3
4
# File 'app/helpers/plugins/camaleon_google_analytic/main_helper.rb', line 2

def self.included(klass)
  # klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
end

Instance Method Details

#camaleon_google_analytic_on_active(plugin) ⇒ Object

here all actions on going to active you can run sql commands like this: results = ActiveRecord::Base.connection.execute(query); plugin: plugin model



10
11
12
13
14
# File 'app/helpers/plugins/camaleon_google_analytic/main_helper.rb', line 10

def camaleon_google_analytic_on_active(plugin)
  current_site.set_meta('camaleon_google_analytic_config',
                        {google_analytics_code: 'UA-XXXXXX-X'
                        })
end

#camaleon_google_analytic_on_inactive(plugin) ⇒ Object

here all actions on going to inactive plugin: plugin model



18
19
20
# File 'app/helpers/plugins/camaleon_google_analytic/main_helper.rb', line 18

def camaleon_google_analytic_on_inactive(plugin)
  current_site.camaleon_google_analytic.destroy_all
end

#camaleon_google_analytic_on_upgrade(plugin) ⇒ Object

here all actions to upgrade for a new version plugin: plugin model



24
25
# File 'app/helpers/plugins/camaleon_google_analytic/main_helper.rb', line 24

def camaleon_google_analytic_on_upgrade(plugin)
end

#google_analytic_front_before_loadObject



27
28
29
30
31
32
33
34
# File 'app/helpers/plugins/camaleon_google_analytic/main_helper.rb', line 27

def google_analytic_front_before_load
  cameleon_google_analytics_meta = current_site.get_meta('camaleon_google_analytic_config')
  if cameleon_google_analytics_meta.has_key? :code
    camaleon_google_analytics_code = cameleon_google_analytics_meta[:code]
    append_asset_content("<script>window.GAID='#{camaleon_google_analytics_code}';</script>")
    append_asset_libraries({camaleon_google_analytic: {js: [plugin_gem_asset('google_analytics')]}})
  end
end

#google_analytic_plugin_options(arg) ⇒ Object



36
37
38
# File 'app/helpers/plugins/camaleon_google_analytic/main_helper.rb', line 36

def google_analytic_plugin_options(arg)
  arg[:links] << link_to(t('plugin.camaleon_google_analytic.settings.link_name'), admin_plugins_camaleon_google_analytic_settings_path)
end