omf_web 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +13 -0
- data/README.md +6 -0
- data/example/bridge/README.md +1 -1
- data/example/bridge/bridge.yaml +10 -0
- data/example/bridge/bridge_viz_server +41 -0
- data/example/bridge/data_sources/sensor-sqlite.rb +3 -2
- data/example/bridge/htdocs/graph/js/event_table.js +2 -7
- data/example/bridge/tabs/overview.yaml +82 -0
- data/example/openflow-gec15/dashboard_tab.yaml +1 -0
- data/example/simple/simple.yaml +1 -1
- data/example/simple/simple_dynamic.yaml +5 -3
- data/example/topo_discovery/data_sources/links.csv +3 -0
- data/example/topo_discovery/data_sources/links2.csv +21 -0
- data/example/topo_discovery/data_sources/node_info.csv +10 -0
- data/example/topo_discovery/data_sources/nodes.csv +4 -0
- data/example/topo_discovery/data_sources/nodes2.csv +11 -0
- data/example/topo_discovery/introduction.md +17 -0
- data/example/topo_discovery/topo_discovery_simple.yaml +35 -0
- data/example/topo_discovery/topo_discovery_simple2.yaml +32 -0
- data/example/topo_discovery/widgets/network.yaml +52 -0
- data/example/topo_discovery/widgets/node_info.yaml +23 -0
- data/lib/omf-web/content/file_repository.rb +5 -1
- data/lib/omf-web/content/git_repository.rb +11 -0
- data/lib/omf-web/content/repository.rb +13 -2
- data/lib/omf-web/data_source_proxy.rb +22 -10
- data/lib/omf-web/theme.rb +11 -4
- data/lib/omf-web/theme/abstract_page.rb +5 -0
- data/lib/omf-web/thin/server.rb +62 -16
- data/lib/omf-web/version.rb +1 -1
- data/lib/omf-web/widget/code_widget.rb +24 -23
- data/lib/omf-web/widget/data_widget.rb +14 -5
- data/lib/omf-web/widget/text/maruku.rb +16 -1
- data/lib/omf-web/widget/text/text_widget.rb +1 -1
- data/share/htdocs/graph/js/abstract_chart.js +7 -1
- data/share/htdocs/graph/js/abstract_multiple_datasource_chart.js +21 -3
- data/share/htdocs/graph/js/abstract_nv_chart.js +17 -11
- data/share/htdocs/graph/js/abstract_widget.js +44 -14
- data/share/htdocs/graph/js/line_chart3.js +5 -9
- data/share/htdocs/graph/js/map2.js +122 -79
- data/share/htdocs/graph/js/network2.js +205 -36
- data/share/htdocs/graph/js/table2.js +7 -11
- data/share/htdocs/js/data_source3.js +24 -4
- data/share/htdocs/vendor/VERSION_MAP.yaml +1 -1
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/css/font-awesome.css +251 -23
- data/share/htdocs/vendor/font-awesome-4.1.0/css/font-awesome.min.css +4 -0
- data/share/htdocs/vendor/font-awesome-4.1.0/fonts/FontAwesome.otf +0 -0
- data/share/htdocs/vendor/font-awesome-4.1.0/fonts/fontawesome-webfont.eot +0 -0
- data/share/htdocs/vendor/font-awesome-4.1.0/fonts/fontawesome-webfont.svg +504 -0
- data/share/htdocs/vendor/font-awesome-4.1.0/fonts/fontawesome-webfont.ttf +0 -0
- data/share/htdocs/vendor/font-awesome-4.1.0/fonts/fontawesome-webfont.woff +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/bordered-pulled.less +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/core.less +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/fixed-width.less +0 -0
- data/share/htdocs/vendor/font-awesome-4.1.0/less/font-awesome.less +17 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/icons.less +97 -3
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/larger.less +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/list.less +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/mixins.less +0 -0
- data/share/htdocs/vendor/font-awesome-4.1.0/less/path.less +14 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/rotated-flipped.less +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/spinning.less +8 -6
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/stacked.less +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/less/variables.less +463 -329
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_bordered-pulled.scss +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_core.scss +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_fixed-width.scss +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_icons.scss +97 -3
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_larger.scss +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_list.scss +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_mixins.scss +2 -2
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_path.scss +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_rotated-flipped.scss +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_spinning.scss +8 -6
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_stacked.scss +0 -0
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/_variables.scss +464 -330
- data/share/htdocs/vendor/{font-awesome-4.0.3 → font-awesome-4.1.0}/scss/font-awesome.scss +1 -1
- data/share/htdocs/vendor/jquery-ui-1.8.23/js/jquery-ui.js +125 -0
- data/share/htdocs/vendor/spin/jquery.spin.js +46 -24
- data/share/htdocs/vendor/spin/spin.js +20 -17
- metadata +277 -237
- data/example/bridge/data_sources/test2.oml +0 -1808
- data/example/bridge/data_sources/test2.sq3 +0 -0
- data/example/bridge/data_sources/test31.sq3 +0 -0
- data/example/bridge/viz_server.rb +0 -59
- data/share/htdocs/vendor/font-awesome-4.0.3/css/font-awesome.min.css +0 -4
- data/share/htdocs/vendor/font-awesome-4.0.3/fonts/FontAwesome.otf +0 -0
- data/share/htdocs/vendor/font-awesome-4.0.3/fonts/fontawesome-webfont.eot +0 -0
- data/share/htdocs/vendor/font-awesome-4.0.3/fonts/fontawesome-webfont.svg +0 -414
- data/share/htdocs/vendor/font-awesome-4.0.3/fonts/fontawesome-webfont.ttf +0 -0
- data/share/htdocs/vendor/font-awesome-4.0.3/fonts/fontawesome-webfont.woff +0 -0
- data/share/htdocs/vendor/font-awesome-4.0.3/less/font-awesome.less +0 -17
- data/share/htdocs/vendor/font-awesome-4.0.3/less/path.less +0 -14
- data/share/htdocs/vendor/spin/spin.min.js +0 -1
@@ -0,0 +1,23 @@
|
|
1
|
+
data_sources:
|
2
|
+
- id: node_info
|
3
|
+
file: data_sources/node_info.csv
|
4
|
+
|
5
|
+
widgets:
|
6
|
+
- id: node_info
|
7
|
+
type: data/table2
|
8
|
+
title: Node Info
|
9
|
+
data_source:
|
10
|
+
name: node_info
|
11
|
+
slice:
|
12
|
+
slice_column: nodeID
|
13
|
+
event:
|
14
|
+
name: "graph.network/nodes.selected"
|
15
|
+
key: id
|
16
|
+
columns:
|
17
|
+
- field: property
|
18
|
+
#name: Name
|
19
|
+
- field: value
|
20
|
+
#name: Value
|
21
|
+
|
22
|
+
margin:
|
23
|
+
left: 5
|
@@ -33,7 +33,6 @@ module OMF::Web
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
37
36
|
# Return an array of file names which are in the repository and
|
38
37
|
# match 'search_pattern'
|
39
38
|
#
|
@@ -51,5 +50,10 @@ module OMF::Web
|
|
51
50
|
end.compact
|
52
51
|
end
|
53
52
|
|
53
|
+
protected
|
54
|
+
|
55
|
+
def _create_if_not_exists
|
56
|
+
FileUtils.mkdir_p(@top_dir) unless File.exist?(@top_dir)
|
57
|
+
end
|
54
58
|
end # class
|
55
59
|
end # module
|
@@ -80,5 +80,16 @@ module OMF::Web
|
|
80
80
|
end
|
81
81
|
res
|
82
82
|
end
|
83
|
+
|
84
|
+
protected
|
85
|
+
|
86
|
+
def _create_if_not_exists
|
87
|
+
unless File.exist?("#{@top_dir}/.git")
|
88
|
+
FileUtils.mkdir_p(@top_dir)
|
89
|
+
Dir.chdir(@top_dir) do
|
90
|
+
system "git init"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
83
94
|
end # class
|
84
95
|
end # module
|
@@ -77,7 +77,7 @@ module OMF::Web
|
|
77
77
|
# raise "Unknown repository type '#{type}'"
|
78
78
|
# end
|
79
79
|
|
80
|
-
@@repositories[name] = r = create(opts)
|
80
|
+
@@repositories[name] = r = create(name, opts)
|
81
81
|
@@primary_repository = r if opts[:is_primary]
|
82
82
|
r
|
83
83
|
end
|
@@ -191,11 +191,15 @@ module OMF::Web
|
|
191
191
|
return GitContentRepository.create_url(path, strictly_new)
|
192
192
|
end
|
193
193
|
|
194
|
+
def self.register_mime_type(mapping)
|
195
|
+
MIME_TYPE.merge!(mapping)
|
196
|
+
end
|
194
197
|
|
195
198
|
attr_reader :name, :top_dir
|
196
199
|
|
197
200
|
# params opts [Hash]
|
198
201
|
# opts read_only [Boolean] If true, write will fail
|
202
|
+
# opts create_if_not_exists [Boolean]
|
199
203
|
def initialize(name, opts)
|
200
204
|
@name = name
|
201
205
|
@url_prefix = "#{@name}:"
|
@@ -207,6 +211,8 @@ module OMF::Web
|
|
207
211
|
end
|
208
212
|
@top_dir = File.expand_path(@top_dir)
|
209
213
|
debug "Creating repo '#{name} with top dir: #{@top_dir}"
|
214
|
+
|
215
|
+
_create_if_not_exists if opts[:create_if_not_exists]
|
210
216
|
end
|
211
217
|
end
|
212
218
|
|
@@ -313,7 +319,6 @@ module OMF::Web
|
|
313
319
|
return path
|
314
320
|
end
|
315
321
|
|
316
|
-
#
|
317
322
|
# Return a URL for a path in this repo
|
318
323
|
#
|
319
324
|
def get_url_for_path(path)
|
@@ -325,5 +330,11 @@ module OMF::Web
|
|
325
330
|
#"\#<#{self.class}-#{@name} - #{@top_dir}>"
|
326
331
|
"\#<#{self.class}-#{@name}>"
|
327
332
|
end
|
333
|
+
|
334
|
+
protected
|
335
|
+
|
336
|
+
def _create_if_not_exists
|
337
|
+
raise NotImplementedError, "#{__method__} NOT implementated in #{self.class}"
|
338
|
+
end
|
328
339
|
end # class
|
329
340
|
end # module
|
@@ -67,9 +67,21 @@ module OMF::Web
|
|
67
67
|
unless ds_name = ds_descr[:id] || ds_descr[:stream] || ds_descr[:name]
|
68
68
|
raise "Missing 'name' attribute in datasource description. (#{ds_descr.inspect})"
|
69
69
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
if ds_descr[:sub_sources]
|
71
|
+
res = ds_descr[:sub_sources].inject(true) do |ok, name|
|
72
|
+
#puts ">>>>> #{ok} - #{name}"
|
73
|
+
ok && (@@datasources["#{ds_name}/#{name}".to_sym] != nil)
|
74
|
+
end
|
75
|
+
else
|
76
|
+
ds_name = ds_name.to_sym
|
77
|
+
ds = @@datasources[ds_name]
|
78
|
+
return true if ds
|
79
|
+
|
80
|
+
# Check for automatic sub sources
|
81
|
+
top = "#{ds_name}/"
|
82
|
+
names = @@datasources.keys.find_all { |ds_name| ds_name.to_s.start_with? top }
|
83
|
+
!names.empty?
|
84
|
+
end
|
73
85
|
end
|
74
86
|
|
75
87
|
# Return proxies for 'ds_name'. Note, there can be more then
|
@@ -85,8 +97,8 @@ module OMF::Web
|
|
85
97
|
unless ds_descr.is_a? Hash
|
86
98
|
raise "Expected Hash, but got '#{ds_descr.class}::#{ds_descr.inspect}'"
|
87
99
|
end
|
88
|
-
unless ds_name = ds_descr[:name]
|
89
|
-
raise "Missing 'name' attribute in datasource description. (#{ds_descr.inspect})"
|
100
|
+
unless ds_name = ds_descr[:stream] || ds_descr[:name]
|
101
|
+
raise "Missing 'stream' or 'name' attribute in datasource description. (#{ds_descr.inspect})"
|
90
102
|
end
|
91
103
|
ds_name = ds_name.to_sym
|
92
104
|
ds = @@datasources[ds_name]
|
@@ -104,11 +116,11 @@ module OMF::Web
|
|
104
116
|
end
|
105
117
|
if ds.is_a? Hash
|
106
118
|
raise "Is this actually used anywhere?"
|
107
|
-
proxies = ds.map do |name, ds|
|
108
|
-
id = "#{ds_name}_#{name}".to_sym
|
109
|
-
proxy = OMF::Web::SessionStore[id, :dsp] ||= self.new(id, ds)
|
110
|
-
end
|
111
|
-
return proxies
|
119
|
+
# proxies = ds.map do |name, ds|
|
120
|
+
# id = "#{ds_name}_#{name}".to_sym
|
121
|
+
# proxy = OMF::Web::SessionStore[id, :dsp] ||= self.new(id, ds)
|
122
|
+
# end
|
123
|
+
# return proxies
|
112
124
|
end
|
113
125
|
|
114
126
|
#debug ">>>>> DS: #{ds_descr.inspect} - #{ds}"
|
data/lib/omf-web/theme.rb
CHANGED
@@ -26,7 +26,7 @@ module OMF::Web::Theme
|
|
26
26
|
|
27
27
|
def self.register_renderer(name, klass, theme = DEFAULT_THEME)
|
28
28
|
tr = @@additional_renderers[theme.to_s] ||= {}
|
29
|
-
tr[name] = klass
|
29
|
+
tr[name.to_sym] = klass
|
30
30
|
end
|
31
31
|
|
32
32
|
# Set additional themes to search in the given order for
|
@@ -40,17 +40,24 @@ module OMF::Web::Theme
|
|
40
40
|
|
41
41
|
# Return a named renderer for this theme initialised with 'widget'
|
42
42
|
#
|
43
|
-
def self.create_renderer(name, widget)
|
43
|
+
def self.create_renderer(name, widget, opts = {})
|
44
44
|
name = name.to_sym
|
45
45
|
@@search_order.each do |theme|
|
46
46
|
if tr = @@additional_renderers[theme.to_s]
|
47
47
|
if klass = tr[name]
|
48
48
|
#self.require(name)
|
49
|
-
return klass.new(widget)
|
49
|
+
return klass.new(widget, opts)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
renderers = Set.new
|
54
|
+
@@search_order.each do |theme|
|
55
|
+
if tr = @@additional_renderers[theme.to_s]
|
56
|
+
tr.keys.each {|n| renderers << n}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
#raise "Can't find class implementing renderer '#{name}' in '#{@@search_order.join(', ')}'"
|
60
|
+
raise "Can't find class implementing renderer '#{name}' - #{renderers.to_a.inspect}"
|
54
61
|
end
|
55
62
|
|
56
63
|
def self.require(name)
|
@@ -19,6 +19,11 @@ module OMF::Web::Theme
|
|
19
19
|
depends_on :script, %{
|
20
20
|
// ABSTRACT PAGE
|
21
21
|
if (typeof(OML) == "undefined") OML = {};
|
22
|
+
OML._shim = {}
|
23
|
+
OML.require_dependency = function(target, dependencies) {
|
24
|
+
OML._shim[target] = dependencies
|
25
|
+
require.config({shim: OML._shim});
|
26
|
+
}
|
22
27
|
}
|
23
28
|
|
24
29
|
attr_reader :opts
|
data/lib/omf-web/thin/server.rb
CHANGED
@@ -23,14 +23,17 @@ module OMF::Web
|
|
23
23
|
pre_parse: lambda do |p, runner|
|
24
24
|
p.on("--config CONF_FILE", "File holding description of web site") {|f| runner.options[:omf_config_file] = f}
|
25
25
|
p.on("--top-dir DIR", "Directory to start from for relative data paths [directory of config file]") {|td| @top_dir = td }
|
26
|
-
end
|
27
|
-
post_parse: lambda { |r| load_environment(r.options) },
|
26
|
+
end
|
28
27
|
},
|
29
28
|
authentication: {
|
30
29
|
required: false
|
31
30
|
}
|
32
31
|
}.merge(opts)
|
33
|
-
|
32
|
+
post_parse = opts[:handlers][:post_parse]
|
33
|
+
opts[:handlers][:post_parse] = lambda do |r|
|
34
|
+
post_parse.call(r) if post_parse
|
35
|
+
load_environment(r.options)
|
36
|
+
end
|
34
37
|
@server_name = server_name
|
35
38
|
@top_dir = top_dir
|
36
39
|
@databases = {}
|
@@ -53,6 +56,16 @@ module OMF::Web
|
|
53
56
|
@cfg_dir = File.dirname(cf)
|
54
57
|
opts[:static_dirs].insert(0, File.absolute_path(File.join(@cfg_dir, 'htdocs')))
|
55
58
|
@top_dir ||= @cfg_dir
|
59
|
+
load_config_file(cf, opts)
|
60
|
+
end
|
61
|
+
|
62
|
+
def load_config_file(cf, opts)
|
63
|
+
unless File.readable? cf
|
64
|
+
fatal "Can't read config file '#{cf}'"
|
65
|
+
abort
|
66
|
+
end
|
67
|
+
|
68
|
+
debug "Loading config file '#{cf}'"
|
56
69
|
cfg = _rec_sym_keys(YAML.load_file(cf))
|
57
70
|
|
58
71
|
if log_opts = cfg[:logging]
|
@@ -80,20 +93,54 @@ module OMF::Web
|
|
80
93
|
tabs.each {|t| t[:top_level] = true}
|
81
94
|
widgets += tabs
|
82
95
|
end
|
83
|
-
if widgets.empty?
|
84
|
-
fatal "Can't find 'widgets' or 'tabs' section in config file '#{cf}' - #{cfg.keys}"
|
85
|
-
abort
|
86
|
-
end
|
96
|
+
# if widgets.empty?
|
97
|
+
# fatal "Can't find 'widgets' or 'tabs' section in config file '#{cf}' - #{cfg.keys}"
|
98
|
+
# abort
|
99
|
+
# end
|
87
100
|
widgets.each do |w|
|
88
101
|
register_widget w
|
89
102
|
end
|
90
103
|
|
91
104
|
# Any other file to load before opening shop
|
92
|
-
if
|
93
|
-
unless
|
94
|
-
|
105
|
+
if load = cfg[:load]
|
106
|
+
unless load.is_a? Enumerable
|
107
|
+
load = [load]
|
108
|
+
end
|
109
|
+
load.each do |g| #{|f| load_ruby_file(f) }
|
110
|
+
unless g.start_with? '/'
|
111
|
+
g = File.absolute_path(g, File.dirname(cf))
|
112
|
+
end
|
113
|
+
found_something = false
|
114
|
+
Dir.glob(g).each do |f|
|
115
|
+
found_something = true
|
116
|
+
load_ruby_file(f)
|
117
|
+
end
|
118
|
+
unless found_something
|
119
|
+
fatal "Couldn't find any load file for pattern '#{g}'"
|
120
|
+
abort
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Any other configure to load
|
126
|
+
if include = cfg[:include]
|
127
|
+
unless include.is_a? Enumerable
|
128
|
+
include = [include]
|
129
|
+
end
|
130
|
+
include.each do |g|
|
131
|
+
unless g.start_with? '/'
|
132
|
+
g = File.absolute_path(g, File.dirname(cf))
|
133
|
+
end
|
134
|
+
found_something = false
|
135
|
+
Dir.glob(g).each do |f|
|
136
|
+
found_something = true
|
137
|
+
load_config_file(f, opts)
|
138
|
+
end
|
139
|
+
unless found_something
|
140
|
+
fatal "Couldn't find any config file for pattern '#{g}'"
|
141
|
+
abort
|
142
|
+
end
|
95
143
|
end
|
96
|
-
init.each {|f| load_ruby_file(f) }
|
97
144
|
end
|
98
145
|
|
99
146
|
end
|
@@ -147,7 +194,6 @@ module OMF::Web
|
|
147
194
|
def get_database(config)
|
148
195
|
require 'omf_oml/table'
|
149
196
|
require 'omf_oml/sql_source'
|
150
|
-
|
151
197
|
if config.is_a? String
|
152
198
|
if db = @databases[config]
|
153
199
|
return db
|
@@ -173,8 +219,8 @@ module OMF::Web
|
|
173
219
|
# inject top dir
|
174
220
|
url.insert('sqlite:'.length, '//' + @cfg_dir + '/')
|
175
221
|
end
|
176
|
-
config[:check_interval] ||= 3.0
|
177
|
-
puts "URL: #{url} - #{config}"
|
222
|
+
#config[:check_interval] ||= 3.0
|
223
|
+
#puts "URL: #{url} - #{config}"
|
178
224
|
begin
|
179
225
|
db = OMF::OML::OmlSqlSource.new(url, config)
|
180
226
|
@databases[id] = db if id
|
@@ -195,7 +241,7 @@ module OMF::Web
|
|
195
241
|
abort
|
196
242
|
end
|
197
243
|
unless file.start_with? '/'
|
198
|
-
File.absolute_path(file, @cfg_dir)
|
244
|
+
file = File.absolute_path(file, @cfg_dir)
|
199
245
|
end
|
200
246
|
unless File.readable? file
|
201
247
|
fatal "Can't read file '#{file}'"
|
@@ -298,7 +344,7 @@ module OMF::Web
|
|
298
344
|
require 'digest/md5'
|
299
345
|
w[:id] = Digest::MD5.hexdigest(w[:name] || "tab#{rand(10000)}")[0, 8]
|
300
346
|
end
|
301
|
-
w[:top_level] = true
|
347
|
+
#w[:top_level] = true
|
302
348
|
w[:type] ||= 'layout/one_column'
|
303
349
|
OMF::Web.register_widget w
|
304
350
|
end
|
data/lib/omf-web/version.rb
CHANGED
@@ -3,62 +3,63 @@ require 'omf-web/widget/abstract_widget'
|
|
3
3
|
require 'omf-web/content/repository'
|
4
4
|
|
5
5
|
module OMF::Web::Widget
|
6
|
-
|
6
|
+
|
7
7
|
# Maintains the context for a particular code rendering within a specific session.
|
8
8
|
#
|
9
9
|
class CodeWidget < AbstractWidget
|
10
|
-
|
10
|
+
|
11
11
|
def self.create_code_widget(type, wdescr)
|
12
12
|
return self.new(wdescr)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
attr_accessor :content_proxy
|
16
|
-
|
16
|
+
|
17
17
|
def initialize(opts)
|
18
18
|
super opts
|
19
19
|
unless (content_descr = opts[:content])
|
20
20
|
raise "Missing 'content' option in '#{opts.describe}'"
|
21
|
-
end
|
21
|
+
end
|
22
22
|
@content_proxy = OMF::Web::ContentRepository.create_content_proxy_for(content_descr, opts)
|
23
23
|
end
|
24
|
-
|
25
|
-
def title
|
24
|
+
|
25
|
+
def title
|
26
26
|
@content_proxy.name
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def mime_type
|
30
30
|
@content_proxy.mime_type
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def update_url
|
34
34
|
@content_proxy.content_url
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def content_id
|
38
|
-
@content_proxy.
|
38
|
+
@content_proxy.content_url
|
39
|
+
#@content_proxy.content_id
|
39
40
|
end
|
40
|
-
|
41
|
+
|
41
42
|
def content()
|
42
43
|
OMF::Web::Theme.require 'code_renderer'
|
43
44
|
mode = @content_proxy.mime_type.split('/')[-1]
|
44
45
|
OMF::Web::Theme::CodeRenderer.new(self, @content_proxy.content, mode, @opts)
|
45
46
|
end
|
46
|
-
|
47
|
+
|
47
48
|
def collect_data_sources(ds_set)
|
48
49
|
ds_set
|
49
50
|
end
|
50
|
-
|
51
|
-
|
51
|
+
|
52
|
+
|
52
53
|
# @@codeType2mime = {
|
53
54
|
# :ruby => '/text/ruby',
|
54
55
|
# :xml => '/text/xml'
|
55
56
|
# }
|
56
|
-
|
57
|
+
|
57
58
|
# def render_code(source)
|
58
59
|
# content = load_content(source)
|
59
60
|
# type = code_type(source)
|
60
61
|
# mimeType = @@codeType2mime[type]
|
61
|
-
#
|
62
|
+
#
|
62
63
|
# begin
|
63
64
|
# CodeRay.scan content, type
|
64
65
|
# #tokens.html :line_numbers => :inline, :tab_width => 2, :wrap => :div
|
@@ -67,15 +68,15 @@ module OMF::Web::Widget
|
|
67
68
|
# debug ex.backtrace.join("\n")
|
68
69
|
# end
|
69
70
|
# end
|
70
|
-
|
71
|
+
|
71
72
|
# def load_content(source)
|
72
73
|
# unless File.readable?(source)
|
73
74
|
# raise "Cannot read text file '#{source}'"
|
74
75
|
# end
|
75
76
|
# content = File.open(source).read
|
76
77
|
# end
|
77
|
-
|
78
|
-
# Return the language the code is written in
|
78
|
+
|
79
|
+
# Return the language the code is written in
|
79
80
|
#
|
80
81
|
def code_type(source)
|
81
82
|
if source.end_with? '.rb'
|
@@ -86,8 +87,8 @@ module OMF::Web::Widget
|
|
86
87
|
:text
|
87
88
|
end
|
88
89
|
end
|
89
|
-
|
90
|
-
|
90
|
+
|
91
|
+
|
91
92
|
end # CodeWidget
|
92
|
-
|
93
|
+
|
93
94
|
end
|