Class: TextFilterPlugin
- Inherits:
-
Object
show all
- Extended by:
- ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, PublifyPlugins
- Defined in:
- lib/text_filter_plugin.rb
Defined Under Namespace
Modules: MacroMethods
Classes: MacroPost, MacroPre, Markup, PostProcess
Constant Summary
collapse
- @@filter_map =
{}
Class Method Summary
collapse
plugin_description, plugin_display_name, plugin_public_action, plugin_public_actions
Class Method Details
.abstract_filter! ⇒ Object
118
119
120
|
# File 'lib/text_filter_plugin.rb', line 118
def self.abstract_filter!
@@filter_map.delete short_name
end
|
.available_filter_types ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/text_filter_plugin.rb', line 28
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_filters ⇒ Object
24
25
26
|
# File 'lib/text_filter_plugin.rb', line 24
def self.available_filters
filter_map.values
end
|
.component_name ⇒ Object
The name that needs to be used when refering to the plugin’s controller in render statements
77
78
79
80
81
82
83
|
# File 'lib/text_filter_plugin.rb', line 77
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.
110
111
112
|
# File 'lib/text_filter_plugin.rb', line 110
def self.config_value(params, name)
params[:filterparams][name] || default_config[name][:default]
end
|
.default_config ⇒ Object
95
96
97
|
# File 'lib/text_filter_plugin.rb', line 95
def self.default_config
{}
end
|
.default_helper_module! ⇒ Object
107
|
# File 'lib/text_filter_plugin.rb', line 107
def self.default_helper_module!; end
|
.expand_filter_list(filter_list) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/text_filter_plugin.rb', line 55
def self.expand_filter_list(filter_list)
filter_list.flat_map do |key|
case key
when :macropost
macro_post_filters
when :macropre
macro_pre_filters
else
filter_map[key.to_s]
end
end.compact
end
|
.filter_map ⇒ Object
20
21
22
|
# File 'lib/text_filter_plugin.rb', line 20
def self.filter_map
@@filter_map
end
|
.filter_type ⇒ Object
91
92
93
|
# File 'lib/text_filter_plugin.rb', line 91
def self.filter_type
"other"
end
|
.help_text ⇒ Object
99
100
101
|
# File 'lib/text_filter_plugin.rb', line 99
def self.help_text
""
end
|
.inherited(sub) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/text_filter_plugin.rb', line 13
def self.inherited(sub)
super
name = sub.short_name
@@filter_map[name] = sub
end
|
.logger ⇒ Object
114
115
116
|
# File 'lib/text_filter_plugin.rb', line 114
def self.logger
@logger ||= ::Rails.logger || Logger.new($stdout)
end
|
.macro_filters ⇒ Object
43
44
45
|
# File 'lib/text_filter_plugin.rb', line 43
def self.macro_filters
macro_pre_filters + macro_post_filters
end
|
.macro_post_filters ⇒ Object
51
52
53
|
# File 'lib/text_filter_plugin.rb', line 51
def self.macro_post_filters
available_filter_types["macropost"]
end
|
.macro_pre_filters ⇒ Object
47
48
49
|
# File 'lib/text_filter_plugin.rb', line 47
def self.macro_pre_filters
available_filter_types["macropre"]
end
|
.reloadable? ⇒ Boolean
71
72
73
|
# File 'lib/text_filter_plugin.rb', line 71
def self.reloadable?
false
end
|
.sanitize(*args) ⇒ Object
103
104
105
|
# File 'lib/text_filter_plugin.rb', line 103
def self.sanitize(*args)
(@sanitizer ||= Rails::Html::WhiteListSanitizer.new).sanitize(*args)
end
|
.short_name ⇒ Object
The name that’s stored in the DB. This is the final chunk of the controller name, like ‘markdown’ or ‘smartypants’.
87
88
89
|
# File 'lib/text_filter_plugin.rb', line 87
def self.short_name
component_name.split(%r{/}).last
end
|