Class: TextFilterPlugin

Inherits:
Object
  • Object
show all
Extended by:
ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, PublifyPlugins
Defined in:
lib/text_filter_plugin.rb

Defined Under Namespace

Classes: Macro, MacroPost, MacroPre, Markup, PostProcess

Constant Summary collapse

@@filter_map =
{}

Class Method Summary collapse

Methods included from PublifyPlugins

plugin_description, plugin_display_name, plugin_public_action, plugin_public_actions

Class Method Details

.available_filter_typesObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/text_filter_plugin.rb', line 26

def self.available_filter_types
  unless @cached_filter_types
    types = { 'macropre' => [],
              'macropost' => [],
              'markup' => [],
              'postprocess' => [],
              'other' => [] }

    available_filters.each { |filter| types[filter.filter_type].push(filter) }

    @cached_filter_types = types
  end
  @cached_filter_types
end

.available_filtersObject



22
23
24
# File 'lib/text_filter_plugin.rb', line 22

def self.available_filters
  filter_map.values
end

.component_nameObject

The name that needs to be used when refering to the plugin’s controller in render statements



54
55
56
57
58
59
60
# File 'lib/text_filter_plugin.rb', line 54

def self.component_name
  if to_s =~ /::([a-zA-Z]+)$/
    "plugins/textfilters/#{Regexp.last_match[1]}".downcase
  else
    raise "I don't know who I am: #{self}"
  end
end

.config_value(params, name) ⇒ Object

Look up a config paramater, falling back to the default as needed.



87
88
89
# File 'lib/text_filter_plugin.rb', line 87

def self.config_value(params, name)
  params[:filterparams][name] || default_config[name][:default]
end

.default_configObject



72
73
74
# File 'lib/text_filter_plugin.rb', line 72

def self.default_config
  {}
end

.default_helper_module!Object



84
# File 'lib/text_filter_plugin.rb', line 84

def self.default_helper_module!; end

.filter_mapObject



18
19
20
# File 'lib/text_filter_plugin.rb', line 18

def self.filter_map
  @@filter_map
end

.filter_typeObject



68
69
70
# File 'lib/text_filter_plugin.rb', line 68

def self.filter_type
  'other'
end

.help_textObject



76
77
78
# File 'lib/text_filter_plugin.rb', line 76

def self.help_text
  ''
end

.inherited(sub) ⇒ Object



11
12
13
14
15
16
# File 'lib/text_filter_plugin.rb', line 11

def self.inherited(sub)
  if sub.to_s =~ /^Plugin/ || sub.to_s =~ /^PublifyApp::Textfilter/
    name = sub.short_name
    @@filter_map[name] = sub
  end
end

.loggerObject



91
92
93
# File 'lib/text_filter_plugin.rb', line 91

def self.logger
  @logger ||= ::Rails.logger || Logger.new(STDOUT)
end

.macro_filtersObject



41
42
43
# File 'lib/text_filter_plugin.rb', line 41

def self.macro_filters
  available_filters.select { |filter| TextFilterPlugin::Macro > filter }
end

.reloadable?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/text_filter_plugin.rb', line 48

def self.reloadable?
  false
end

.sanitize(*args) ⇒ Object



80
81
82
# File 'lib/text_filter_plugin.rb', line 80

def self.sanitize(*args)
  (@sanitizer ||= Rails::Html::WhiteListSanitizer.new).sanitize(*args)
end

.short_nameObject

The name that’s stored in the DB. This is the final chunk of the controller name, like ‘markdown’ or ‘smartypants’.



64
65
66
# File 'lib/text_filter_plugin.rb', line 64

def self.short_name
  component_name.split(%r{/}).last
end