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
Classes: Macro, 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
.available_filter_types ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/text_filter_plugin.rb', line 30
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
26
27
28
|
# File 'lib/text_filter_plugin.rb', line 26
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
58
59
60
61
62
63
64
|
# File 'lib/text_filter_plugin.rb', line 58
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.
91
92
93
|
# File 'lib/text_filter_plugin.rb', line 91
def self.config_value(params, name)
params[:filterparams][name] || default_config[name][:default]
end
|
.default_config ⇒ Object
76
77
78
|
# File 'lib/text_filter_plugin.rb', line 76
def self.default_config
{}
end
|
.default_helper_module! ⇒ Object
88
|
# File 'lib/text_filter_plugin.rb', line 88
def self.default_helper_module!; end
|
.filter_map ⇒ Object
22
23
24
|
# File 'lib/text_filter_plugin.rb', line 22
def self.filter_map
@@filter_map
end
|
.filter_type ⇒ Object
72
73
74
|
# File 'lib/text_filter_plugin.rb', line 72
def self.filter_type
"other"
end
|
.help_text ⇒ Object
80
81
82
|
# File 'lib/text_filter_plugin.rb', line 80
def self.help_text
""
end
|
.inherited(sub) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/text_filter_plugin.rb', line 13
def self.inherited(sub)
super
if sub.to_s.start_with?("Plugin", "PublifyApp::Textfilter")
name = sub.short_name
@@filter_map[name] = sub
end
end
|
.logger ⇒ Object
95
96
97
|
# File 'lib/text_filter_plugin.rb', line 95
def self.logger
@logger ||= ::Rails.logger || Logger.new($stdout)
end
|
.macro_filters ⇒ Object
45
46
47
|
# File 'lib/text_filter_plugin.rb', line 45
def self.macro_filters
available_filters.select { |filter| TextFilterPlugin::Macro > filter }
end
|
.reloadable? ⇒ Boolean
52
53
54
|
# File 'lib/text_filter_plugin.rb', line 52
def self.reloadable?
false
end
|
.sanitize(*args) ⇒ Object
84
85
86
|
# File 'lib/text_filter_plugin.rb', line 84
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’.
68
69
70
|
# File 'lib/text_filter_plugin.rb', line 68
def self.short_name
component_name.split(%r{/}).last
end
|