Class: OMF::Web::Widget::CodeWidget
Overview
Maintains the context for a particular code rendering within a specific session.
Instance Attribute Summary collapse
#name, #opts, #widget_id, #widget_type
Class Method Summary
collapse
Instance Method Summary
collapse
#layout?, #tools_menu, #widget_info
Constructor Details
Returns a new instance of CodeWidget.
17
18
19
20
21
22
23
|
# File 'lib/omf-web/widget/code_widget.rb', line 17
def initialize(opts)
super opts
unless (content_descr = opts[:content])
raise "Missing 'content' option in '#{opts.describe}'"
end
@content_proxy = OMF::Web::ContentRepository.create_content_proxy_for(content_descr, opts)
end
|
Instance Attribute Details
#content_proxy ⇒ Object
Returns the value of attribute content_proxy.
15
16
17
|
# File 'lib/omf-web/widget/code_widget.rb', line 15
def content_proxy
@content_proxy
end
|
Class Method Details
11
12
13
|
# File 'lib/omf-web/widget/code_widget.rb', line 11
def self.create_code_widget(type, wdescr)
return self.new(wdescr)
end
|
Instance Method Details
#code_type(source) ⇒ Object
Return the language the code is written in
81
82
83
84
85
86
87
88
89
|
# File 'lib/omf-web/widget/code_widget.rb', line 81
def code_type(source)
if source.end_with? '.rb'
:ruby
elsif source.end_with? '.xml'
:xml
else
:text
end
end
|
#collect_data_sources(ds_set) ⇒ Object
48
49
50
|
# File 'lib/omf-web/widget/code_widget.rb', line 48
def collect_data_sources(ds_set)
ds_set
end
|
#content ⇒ Object
42
43
44
45
46
|
# File 'lib/omf-web/widget/code_widget.rb', line 42
def content()
OMF::Web::Theme.require 'code_renderer'
mode = @content_proxy.mime_type.split('/')[-1]
OMF::Web::Theme::CodeRenderer.new(self, @content_proxy.content, mode, @opts)
end
|
#content_id ⇒ Object
37
38
39
40
|
# File 'lib/omf-web/widget/code_widget.rb', line 37
def content_id
@content_proxy.content_url
end
|
#mime_type ⇒ Object
29
30
31
|
# File 'lib/omf-web/widget/code_widget.rb', line 29
def mime_type
@content_proxy.mime_type
end
|
#title ⇒ Object
25
26
27
|
# File 'lib/omf-web/widget/code_widget.rb', line 25
def title
@content_proxy.name
end
|
#update_url ⇒ Object
33
34
35
|
# File 'lib/omf-web/widget/code_widget.rb', line 33
def update_url
@content_proxy.content_url
end
|