profile.rb
922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
ActionView::Base.sanitized_allowed_attributes += ['data-macro']
class VariablesPlugin::Profile < Noosfero::Plugin::Macro
def self.configuration
{
:title => _('Variables'),
:skip_dialog => false,
:generator => method(:macro_default_generator),
:params => [
{
:name => 'variable',
:label => _('Select the desired variable'),
:type => 'select',
:values => ['{profile}', '{name}']
}
],
}
end
def self.macro_default_generator(macro)
"
'<div class=\"macro mceNonEditable\" data-macro=\"#{macro.identifier}\">'
+ jQuery('*[name=variable]', dialog).val()
+ '</div>';
"
end
def parse(params, inner_html, source)
if context.profile
inner_html.gsub!(/\{profile\}/, context.profile.identifier)
inner_html.gsub!(/\{name\}/, context.profile.name)
end
inner_html
end
end