Module: Locomotive::Plugin

Includes:
ClassTracker, ConfigUI, JS3, Liquid, LoadInitialization, RackAppHelpers
Defined in:
lib/locomotive/plugin.rb,
lib/locomotive/plugin/js3.rb,
lib/locomotive/plugin/liquid.rb,
lib/locomotive/plugin/config_ui.rb,
lib/locomotive/plugin/exceptions.rb,
lib/locomotive/plugin/class_tracker.rb,
lib/locomotive/plugin/rack_app_helpers.rb,
lib/locomotive/plugin/load_initialization.rb,
lib/locomotive/plugin/liquid/drop_extension.rb,
lib/locomotive/plugin/liquid/context_helpers.rb,
lib/locomotive/plugin/liquid/tag_subclass_methods.rb,
lib/locomotive/plugin/liquid/prefixed_filter_module.rb

Overview

Include this module in a class which should be registered as a Locomotive plugin. See the documentation for the various methods which can be called or overridden to describe the plugin.

Defined Under Namespace

Modules: ClassMethods, ClassTracker, ConfigUI, JS3, Liquid, LoadInitialization, RackAppHelpers Classes: Error, InitializationError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JS3

#js3_context

Methods included from RackAppHelpers

#mounted_rack_app, #mountpoint, #mountpoint=, #rack_app_full_path, #rack_app_full_url

Methods included from Liquid

#setup_liquid_context

Instance Attribute Details

#configObject

This variable is set by LocomotiveCMS. It contains the current configuration hash for the plugin.



130
131
132
# File 'lib/locomotive/plugin.rb', line 130

def config
  @config
end

#controllerObject

This variable is set by LocomotiveCMS. It contains the controller which is handling the current request.



126
127
128
# File 'lib/locomotive/plugin.rb', line 126

def controller
  @controller
end

Class Method Details

.included(base) ⇒ Object

Set up the plugin class with some class methods, callbacks, and plugin class tracking.

Parameters:

  • base

    the plugin class



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/locomotive/plugin.rb', line 26

def self.included(base)
  self.add_load_initialization_class_methods(base)
  self.add_liquid_class_methods(base)

  base.extend RackAppHelpers::ClassMethods

  base.class_eval do
    extend ActiveModel::Callbacks
    define_model_callbacks :page_render
    define_model_callbacks :rack_app_request
    define_model_callbacks :plugin_setup

    around_rack_app_request :set_plugin_object_on_rack_app
  end

  base.extend ClassMethods

  self.track_plugin_class(base)
end

Instance Method Details

#config_template_fileObject

Override this method to supply a path to the config UI template file. This file should be an HTML or HAML file using the Handlebars.js templating language.



141
142
143
# File 'lib/locomotive/plugin.rb', line 141

def config_template_file
  nil
end

#config_template_stringObject

This method may be overridden to supply the raw HTML string to be used for the config UI. The HTML string may be a Handlebars.js template. By default, this method will use the file supplied by the config_template_file method to construct the string (see #config_template_file).

Returns:

  • by default, the contents of config_template_file, parsed by HAML if needed



153
154
155
# File 'lib/locomotive/plugin.rb', line 153

def config_template_string
  self.default_config_template_string(self.config_template_file)
end

#to_liquidObject

Override this method to provide a liquid drop which should be available in the CMS.



134
135
136
# File 'lib/locomotive/plugin.rb', line 134

def to_liquid
  nil
end