omf_web 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. data/bin/omf_web_server +18 -0
  2. data/example/bridge/README.md +7 -0
  3. data/example/bridge/data_sources/sensor-sqlite.rb +15 -15
  4. data/example/bridge/htdocs/graph/js/bridge.js +35 -45
  5. data/example/bridge/htdocs/graph/js/event_line_chart.js +20 -18
  6. data/example/bridge/htdocs/graph/js/event_table.js +26 -28
  7. data/example/bridge/viz_server.rb +5 -9
  8. data/example/demo/demo_viz_server.rb +2 -2
  9. data/example/demo/widgets/linked_graphs_tab.yaml +9 -32
  10. data/example/openflow-gec15/code_tab.yaml +7 -12
  11. data/example/openflow-gec15/dashboard_tab.yaml +11 -12
  12. data/example/openflow-gec15/exp_source.rb +26 -26
  13. data/example/openflow-gec15/of_viz_server.rb +7 -7
  14. data/example/simple/simple.yaml +2 -1
  15. data/example/simple/simple_dynamic.yaml +1 -1
  16. data/example/web_rtc/web_rtc.yaml +54 -0
  17. data/example/web_rtc/webrtc-exp_1381786573.sq3 +0 -0
  18. data/lib/omf-web/config.ru +1 -1
  19. data/lib/omf-web/content/content_proxy.rb +2 -2
  20. data/lib/omf-web/content/file_repository.rb +11 -53
  21. data/lib/omf-web/content/git_repository.rb +1 -1
  22. data/lib/omf-web/content/irods_repository.rb +1 -1
  23. data/lib/omf-web/content/repository.rb +5 -3
  24. data/lib/omf-web/content/static_repository.rb +25 -11
  25. data/lib/omf-web/data_source_proxy.rb +3 -3
  26. data/lib/omf-web/rack/content_handler.rb +2 -2
  27. data/lib/omf-web/rack/session_authenticator.rb +3 -3
  28. data/lib/omf-web/rack/tab_mapper.rb +2 -2
  29. data/lib/omf-web/rack/update_handler.rb +2 -2
  30. data/lib/omf-web/rack/websocket_handler.rb +3 -3
  31. data/lib/omf-web/rack/widget_mapper.rb +2 -2
  32. data/lib/omf-web/session_store.rb +2 -2
  33. data/lib/omf-web/theme/abstract_page.rb +15 -24
  34. data/lib/omf-web/theme/bright/code_renderer.rb +24 -30
  35. data/lib/omf-web/theme/bright/data_renderer.rb +7 -5
  36. data/lib/omf-web/theme/bright/page.rb +2 -1
  37. data/lib/omf-web/theme/bright/widget_chrome.rb +16 -14
  38. data/lib/omf-web/theme.rb +1 -1
  39. data/lib/omf-web/thin/logging.rb +18 -13
  40. data/lib/omf-web/thin/runner.rb +2 -2
  41. data/lib/omf-web/thin/server.rb +105 -27
  42. data/lib/omf-web/version.rb +1 -1
  43. data/lib/omf-web/widget/abstract_widget.rb +3 -3
  44. data/lib/omf-web/widget/data_widget.rb +1 -0
  45. data/lib/omf-web/widget/text/maruku.rb +1 -1
  46. data/lib/omf-web/widget.rb +22 -22
  47. data/lib/omf_web.rb +1 -1
  48. data/omf_web.gemspec +18 -15
  49. data/share/htdocs/graph/js/abstract_chart.js +69 -68
  50. data/share/htdocs/graph/js/abstract_nv_chart.js +35 -33
  51. data/share/htdocs/graph/js/abstract_widget.js +61 -62
  52. data/share/htdocs/graph/js/axis.js +30 -25
  53. data/share/htdocs/graph/js/barchart_brush.js +23 -21
  54. data/share/htdocs/graph/js/code_mirror.js +35 -33
  55. data/share/htdocs/graph/js/discrete_bar_chart.js +27 -30
  56. data/share/htdocs/graph/js/histogram2.js +37 -47
  57. data/share/htdocs/graph/js/line_chart3.js +36 -30
  58. data/share/htdocs/graph/js/line_chart_with_focus.js +10 -9
  59. data/share/htdocs/graph/js/multi_barchart.js +33 -30
  60. data/share/htdocs/graph/js/network2.js +98 -97
  61. data/share/htdocs/graph/js/pie_chart2.js +25 -23
  62. data/share/htdocs/graph/js/scatter_plot.js +38 -36
  63. data/share/htdocs/graph/js/table2.js +60 -54
  64. data/share/htdocs/js/app.js +43 -0
  65. data/share/htdocs/js/{data_source2.js → data_source3.js} +44 -73
  66. data/share/htdocs/js/data_source_repo.js +42 -0
  67. data/share/htdocs/require/nv_d3.js +2 -0
  68. data/share/htdocs/theme/abstract/abstract.js +4 -4
  69. data/share/htdocs/vendor/VERSION_MAP.yaml +2 -0
  70. data/share/htdocs/vendor/require-2.1.8/require.js +2053 -0
  71. data/share/htdocs/vendor/require-2.1.8/require.min.js +36 -0
  72. data/share/htdocs/vendor/require-css-0.0.7/.gitignore +1 -0
  73. data/share/htdocs/vendor/require-css-0.0.7/LICENSE +10 -0
  74. data/share/htdocs/vendor/require-css-0.0.7/README.md +231 -0
  75. data/share/htdocs/vendor/require-css-0.0.7/bower.json +5 -0
  76. data/share/htdocs/vendor/require-css-0.0.7/css-builder.js +251 -0
  77. data/share/htdocs/vendor/require-css-0.0.7/css.js +436 -0
  78. data/share/htdocs/vendor/require-css-0.0.7/normalize.js +138 -0
  79. data/share/htdocs/vendor/require-css-0.0.7/package.json +5 -0
  80. data/share/htdocs/vendor/spin/jquery.spin.js +6 -4
  81. metadata +100 -74
  82. checksums.yaml +0 -7
  83. data/bin/omf_web_demo +0 -3
  84. data/bin/omf_web_demo.sh +0 -7
  85. data/bin/omf_web_server.rb +0 -157
  86. data/lib/omf_common/lobject.rb +0 -187
  87. data/lib/omf_common/log4r_outputter.rb +0 -69
  88. data/sample.sq3 +0 -0
  89. data/share/htdocs/js/data_source.js +0 -173
  90. data/share/htdocs/js/require3.js +0 -292
@@ -1,187 +0,0 @@
1
- #
2
- # Copyright (c) 2006-2009 National ICT Australia (NICTA), Australia
3
- #
4
- # Copyright (c) 2004-2009 WINLAB, Rutgers University, USA
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- #
24
- #
25
- #
26
- require 'rubygems'
27
- require 'date'
28
- require 'log4r'
29
- require 'log4r/configurator'
30
- require 'log4r/yamlconfigurator'
31
- require 'log4r/outputter/datefileoutputter'
32
- require 'omf_common/log4r_outputter'
33
-
34
- #include Log4r
35
-
36
- module OMF; module Common; end end
37
-
38
- #
39
- # An extended object class with support for logging
40
- #
41
- module OMF::Common
42
- module Loggable
43
- @@logger = nil
44
- @@rootLoggerName = nil
45
-
46
-
47
- #
48
- # Initialize the logger. The 'appName' is used to build some of the defaults.
49
- # The 'environment' is the name of the root
50
- # logger. 'AppInstance' and 'appName' are available as parameters
51
- # in the log configuration file. The 'opts' hash can optionally
52
- # contain information on how to find a configuration file. The
53
- # following keys are used:
54
- #
55
- # * :environment - Name used for root logger name ['development']
56
- # * :env - Name of environment variable holding dominant config file
57
- # * :fileName - Name of config file [#{appName}_log.xml]
58
- # * :searchPath - Array of directories to look for 'fileName'
59
- #
60
- def self.init_log(appName, opts = {})
61
-
62
- #@@logger = ::Log4r::Logger.new(appName)
63
- set_environment(opts[:environment] || 'development')
64
- @@logger = ::Log4r::Logger.new(@@rootLoggerName)
65
-
66
- configFile = opts[:configFile]
67
- if (configFile == nil && logEnv = opts[:env])
68
- configFile = ENV[logEnv]
69
- end
70
- if (configFile != nil)
71
- # Make sure log exists ...
72
- configFile = File.exists?(configFile) ? configFile : nil
73
- else
74
- name = opts[:fileName] || "#{appName}_log4r.yaml"
75
- if ((searchPath = opts[:searchPath]) != nil)
76
- searchPath = searchPath.is_a?(Enumerable) ? searchPath : [searchPath]
77
- logDir = searchPath.find {|dir|
78
- File.exists?("#{dir}/#{name}")
79
- }
80
- #puts "logDir '#{logDir}:#{logDir.class}'"
81
- configFile = "#{logDir}/#{name}" if logDir != nil
82
- end
83
- end
84
- #puts "config file '#{configFile}'"
85
- if !(configFile || '').empty?
86
- ::Log4r::Configurator['appName'] = appName
87
- begin
88
- ycfg = YAML.load_file(configFile)
89
- ::Log4r::YamlConfigurator.decode_yaml(ycfg['log4r'])
90
- #::Log4r::Configurator.load_xml_file(configFile)
91
- # rescue ::Log4r::ConfigError => ex
92
- # @@logger.outputters = ::Log4r::Outputter.stdout
93
- # # TODO: FIX ME
94
- # puts("ERROR: Log::Config: #{ex}")
95
- end
96
- else
97
- # set default behavior
98
- ::Log4r::Logger.global.level = ::Log4r::ALL
99
- formatter = ::Log4r::PatternFormatter.new(:pattern => "%l %c: %m")
100
- ::Log4r::StdoutOutputter.new('console', :formatter => formatter)
101
- @@logger.add 'console'
102
- #@@logger.outputters = ::Log4r::StdoutOutputter.new('console') #Outputter.stdout
103
- ##@@logger.outputters = ::Log4r::Outputter.stdout
104
- end
105
- end
106
-
107
- def self.set_environment(root_logger_name)
108
- if root_logger_name.nil? || root_logger_name.empty?
109
- # TODO: FIX ME
110
- puts("ERROR: LObject: Ignoring empty root logger")
111
- return
112
- end
113
- @@rootLoggerName = root_logger_name
114
- end
115
-
116
- def self.logger(category)
117
- raise "Logger not initialized" unless @@logger
118
-
119
- name = "#{@@rootLoggerName}::#{category}"
120
- logger = Log4r::Logger[name]
121
- if logger == nil
122
- logger = Log4r::Logger.new(name)
123
- end
124
- return logger
125
- end
126
-
127
- def debug(*message)
128
- logger = _logger()
129
- logger.debug(message.join('')) if logger.debug?
130
- end
131
-
132
- def info(*message)
133
- logger = _logger()
134
- logger.info(message.join('')) if logger.info?
135
- end
136
-
137
- def warn(*message)
138
- logger = _logger()
139
- logger.warn(message.join('')) if logger.warn?
140
- end
141
-
142
- def error(*message)
143
- logger = _logger()
144
- logger.error(message.join('')) if logger.error?
145
- end
146
-
147
- def fatal(*message)
148
- logger = _logger()
149
- logger.fatal(message.join('')) if logger.fatal?
150
- end
151
-
152
- def _logger(category = nil)
153
- unless @logger #&& category.nil?
154
- cat = self.class.to_s
155
- if category
156
- cat = "#{cat}-#{category}"
157
- end
158
- @logger = OMF::Common::Loggable.logger(cat)
159
- end
160
- return @logger
161
- end
162
-
163
- end
164
-
165
- class LObject
166
- include Loggable
167
- extend Loggable
168
-
169
- def initialize(logCategory = nil)
170
- _logger(logCategory)
171
- end
172
- end
173
-
174
- end
175
-
176
- if $0 == __FILE__
177
- OMF::Common::Loggable.init_log 'foo'
178
- #puts OMF::Common::Loggable.logger('test').inspect
179
- o = OMF::Common::LObject.new
180
- #puts (o.methods - Object.new.methods).sort
181
- o.debug 'Something happened'
182
-
183
- o2 = OMF::Common::LObject.new('fancy')
184
- o2.debug 'Something happened'
185
-
186
- end
187
-
@@ -1,69 +0,0 @@
1
-
2
-
3
- require 'log4r/outputter/fileoutputter'
4
-
5
- module Log4r
6
- # When daemonizing, the file handler gets closed and we fall over here.
7
- # The following monkey patch retries once to open the file and write again
8
- #
9
- class FileOutputter
10
-
11
- # def initialize(_name, hash={})
12
- # raise "#{_name}::#{hash.inspect}"
13
- # end
14
-
15
- def write(data)
16
- #puts ">>> #{data}"
17
- begin
18
- @out.print data
19
- @out.flush
20
- rescue IOError => ioe # recover from this instead of crash
21
- # retry once
22
- unless @retrying
23
- @retrying = true
24
- @out = File.new(@filename, (@trunc ? "w" : "a"))
25
- return write(data)
26
- end
27
- Logger.log_internal {"IOError in Outputter '#{@name}'!"}
28
- Logger.log_internal {ioe}
29
- close
30
- rescue NameError => ne
31
- Logger.log_internal {"Outputter '#{@name}' IO is #{@out.class}!"}
32
- Logger.log_internal {ne}
33
- close
34
- end
35
- @retrying = false
36
- end
37
- end
38
- end
39
-
40
- # module OMF; module Common; end end
41
- #
42
- # #
43
- # # An extended object class with support for logging
44
- # #
45
- # module OMF::Common
46
- # module Log4r
47
- #
48
- # class DateFileOutputter < ::Log4r::DateFileOutputter
49
- #
50
- # def write(data)
51
- # puts ">>> #{data}"
52
- # begin
53
- # @out.print data
54
- # @out.flush
55
- # rescue IOError => ioe # recover from this instead of crash
56
- # Logger.log_internal {"IOError in Outputter '#{@name}'!"}
57
- # Logger.log_internal {ioe}
58
- # close
59
- # rescue NameError => ne
60
- # Logger.log_internal {"Outputter '#{@name}' IO is #{@out.class}!"}
61
- # Logger.log_internal {ne}
62
- # close
63
- # end
64
- # end
65
- # end
66
- # end
67
- # end
68
- #
69
- # puts "REQUIRE #{OMF::Common::Log4r::DateFileOutputter}"
data/sample.sq3 DELETED
File without changes
@@ -1,173 +0,0 @@
1
-
2
-
3
- OML.data_sources = function() {
4
- var sources = {};
5
-
6
- function context() {};
7
-
8
- context.register = function(name, updateURL, schema, events) {
9
- return sources[name] = new OML.data_source(name, updateURL, schema, events);
10
- //return context;
11
- };
12
-
13
- context.lookup = function(ds_descr) {
14
- var name;
15
- var dynamic = false;
16
-
17
- if (typeof(ds_descr) == 'object') {
18
- name = ds_descr.name;
19
- dynamic = ds_descr.dynamic;
20
- } else {
21
- name = ds_descr;
22
- }
23
- var source = sources[name];
24
- if (! source) {
25
- throw("Unknown data source '" + name + "'.");
26
- }
27
- if (dynamic) {
28
- source.is_dynamic(dynamic);
29
- }
30
- return source;
31
- };
32
-
33
- return context;
34
- }();
35
-
36
- OML['data_source'] = function(name, updateURL, schema, events) {
37
- this.version = "0.1";
38
-
39
- this.init = function() {
40
- this.event_name = "data_source." + this.name + ".changed";
41
- this.indexes = [];
42
- //this.is_dynamic = false;
43
- };
44
-
45
- this.name = name;
46
- if (! updateURL) {
47
- updateURL = '/_update/' + name + '?sid=' + OML.session_id;
48
- }
49
- this.update_url = updateURL;
50
- this.update_interval = -1;
51
- this.schema = schema;
52
- this.events = events; // array of events
53
- this.init();
54
-
55
- this.create_index = function(index) {
56
- var idx = this.indexes[index];
57
- if (idx) return;
58
-
59
- this._create_index(index);
60
- };
61
-
62
- this._create_index = function(index) {
63
- idx = this.indexes[index] = {};
64
- // index ignores rows with identical index
65
- _.map(this.events, function(r) {
66
- idx[r[index]] = r;
67
- });
68
- };
69
-
70
- this.get_indexed_row = function(index, key) {
71
- var idx = this.indexes[index];
72
- if (idx == undefined) {
73
- throw "Need to create index first";
74
- }
75
- return idx[key];
76
- }
77
-
78
- this.update_indexes = function() {
79
- var self = this;
80
- _.each(this.indexes, function(value, key) {
81
- var i = 0;
82
- self._create_index(key);
83
- });
84
-
85
- }
86
-
87
- this.is_dynamic = function(_) {
88
- if (!arguments.length) {
89
- return this.update_interval > 0 || this.ws;
90
- }
91
-
92
- var opts = _;
93
- var interval = -1;
94
- if (typeof(opts) == 'number') {
95
- interval = opts
96
- } else if (opts == true) {
97
- interval = 3;
98
- }
99
- if (interval < 0) return false;
100
-
101
-
102
- //if (window.WebSocket) {
103
- if (false) { // web sockets don't work right now
104
- if (this.ws) return; // already running
105
-
106
- var url = 'ws://' + window.location.host + '/_ws';
107
- var ws = this.ws = new WebSocket(url);
108
- var self = this;
109
- ws.onopen = function() {
110
- ws.send('id:' + this.name);
111
- };
112
- ws.onmessage = function(evt) {
113
- // evt.data contains received string.
114
- var msg = jQuery.parseJSON(evt.data);
115
- var data = msg;
116
- this.events.append(data);
117
- };
118
- ws.onclose = function() {
119
- var status = "onclose";
120
- };
121
- ws.onerror = function(evt) {
122
- var status = "onerror";
123
- };
124
- } else {
125
- var first_time = this.update_interval < 0;
126
-
127
- if (this.update_interval < 0 || this.update_interval > interval) {
128
- this.update_interval = interval;
129
- }
130
-
131
- if (first_time) {
132
- var self = this;
133
- var check1 = $('.widget-title-icon');
134
- // L.require([], function() {
135
- // var check2 = $('.widget-title-icon');
136
- // var i = 0;
137
- // });
138
- L.require(['/resource/vendor/jquery/jquery.js', '/resource/vendor/jquery/jquery.periodicalupdater.js'], function() {
139
- var check3 = $('.widget-title-icon');
140
-
141
- var update_interval = self.update_interval * 1000;
142
- if (update_interval < 1000) update_interval = 3000;
143
- var opts = {
144
- method: 'get', // method; get or post
145
- data: '', // array of values to be passed to the page - e.g. {name: "John", greeting: "hello"}
146
- minTimeout: update_interval, // starting value for the timeout in milliseconds
147
- maxTimeout: 4 * update_interval, // maximum length of time between requests
148
- multiplier: 2, // if set to 2, timerInterval will double each time the response hasn't changed (up to maxTimeout)
149
- type: 'json', // response type - text, xml, json, etc. See $.ajax config options
150
- maxCalls: 0, // maximum number of calls. 0 = no limit.
151
- autoStop: 0 // automatically stop requests after this many returns of the same data. 0 = disabled.
152
- };
153
- $.PeriodicalUpdater(self.update_url, opts, function(reply) {
154
- self.events = reply.events;
155
- self.update_indexes();
156
- reply.data_source = self;
157
- OHUB.trigger(self.event_name, reply);
158
- });
159
- });
160
- } else {
161
- // TODO: Don't know how to change updater to decrease interval - hope web sockets start working again soon
162
- }
163
- }
164
- return true;
165
- }
166
-
167
- this.on_changed = function(update_f) {
168
- OHUB.bind(this.event_name, update_f);
169
- }
170
-
171
- return this;
172
- }
173
-