omf_web 0.9.9 → 1.0.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.
- checksums.yaml +7 -0
- data/README.md +31 -0
- data/bin/omf_web_server.rb +157 -0
- data/doc/screenshot2.png +0 -0
- data/doc/widget_detail.png +0 -0
- data/example/demo/data_sources/downloads.rb +2 -1
- data/example/simple/README.md +12 -13
- data/example/simple/create_waveform.rb +29 -0
- data/example/simple/introduction.md +17 -0
- data/example/simple/sample.sq3 +0 -0
- data/example/simple/sample.sql +1008 -0
- data/example/simple/simple.yaml +62 -0
- data/example/simple/simple_dynamic.yaml +66 -0
- data/lib/irods4r/file.rb +15 -14
- data/lib/irods4r/icommands.rb +18 -18
- data/lib/irods4r.rb +9 -9
- data/lib/omf-web/config.ru +41 -16
- data/lib/omf-web/content/git_repository.rb +32 -31
- data/lib/omf-web/content/irods_repository.rb +34 -33
- data/lib/omf-web/content/repository.rb +48 -44
- data/lib/omf-web/data_source_proxy.rb +33 -22
- data/lib/omf-web/rack/session_authenticator.rb +48 -12
- data/lib/omf-web/rack/tab_mapper.rb +30 -36
- data/lib/omf-web/rack/websocket_handler.rb +26 -25
- data/lib/omf-web/session_store.rb +16 -13
- data/lib/omf-web/theme/abstract_page.rb +26 -22
- data/lib/omf-web/theme/bright/page.rb +84 -34
- data/lib/omf-web/theme/bright/stacked_renderer.rb +20 -19
- data/lib/omf-web/theme.rb +14 -9
- data/lib/omf-web/thin/runner.rb +38 -36
- data/lib/omf-web/thin/server.rb +255 -0
- data/lib/omf-web/version.rb +1 -1
- data/lib/omf-web/widget/data_widget.rb +6 -6
- data/lib/omf-web/widget/text/maruku/helpers.rb +33 -30
- data/lib/omf-web/widget/text/maruku/input/parse_block.rb +117 -117
- data/lib/omf-web/widget/text/maruku/output/to_html.rb +155 -154
- data/lib/omf-web/widget/text/maruku.rb +17 -16
- data/omf_web.gemspec +6 -2
- data/sample.sq3 +0 -0
- data/share/htdocs/graph/js/gauge.js +524 -0
- data/share/htdocs/vendor/VERSION_MAP.yaml +3 -3
- data/share/htdocs/vendor/backbone-1.0.0/backbone.js +1571 -0
- data/share/htdocs/vendor/d3-3.0/LICENSE.brewer.txt +38 -0
- data/share/htdocs/vendor/d3-3.0/colorbrewer.js +1 -0
- data/share/htdocs/vendor/d3-3.0/d3.js +8810 -0
- data/share/htdocs/vendor/d3-3.0/d3.min.js +5 -0
- data/share/htdocs/vendor/geo_json/Readme.txt +71 -0
- data/share/htdocs/vendor/geo_json/regions.json +41 -0
- data/share/htdocs/vendor/geo_json/switzerland.json +24 -0
- data/share/htdocs/vendor/geo_json/world.json +497 -0
- data/share/htdocs/vendor/nv_d3/js/nv.d3.js +8801 -4447
- data/share/htdocs/vendor/spin/jquery.spin.js +46 -0
- data/share/htdocs/vendor/spin/spin.js +349 -0
- data/share/htdocs/vendor/spin/spin.min.js +1 -0
- data/share/htdocs/vendor/underscore-1.4.4/underscore.js +1227 -0
- metadata +63 -48
- data/example/simple/data_sources/gimi31.sq3 +0 -0
- data/example/simple/data_sources/ping_source.rb +0 -56
- data/example/simple/simple_viz_server.rb +0 -39
- data/example/simple/widgets/charts_tab.yaml +0 -38
- data/share/.DS_Store +0 -0
- data/share/htdocs/.DS_Store +0 -0
- data/share/htdocs/vendor/backbone-0.5.3/backbone.js +0 -1158
- data/share/htdocs/vendor/underscore-1.2.1/underscore.js +0 -958
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a076091a3915e52b1dddc6ed1f2f65b4a28c6905
|
4
|
+
data.tar.gz: b861770697dad3299f6f9a8e1c0b800b9c32058a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5d66a617e076f8960fe39656f1fe6ce77b82d5df76bcf6f12fc6f61822d57b5d8aef43b3a6df72a46a09b60a44f29c18301ab3a2a383c7e579bd1aae44d6497
|
7
|
+
data.tar.gz: ab162397635d906b9d0ded7117723d75dd81ce53bacb8f64e5f6b5547ccbf4bac985964785e946663140e0a7b093919fae6e1ed1b3a253ff8c60901b07607129
|
data/README.md
CHANGED
@@ -4,6 +4,37 @@ This Ruby 1.9 gem provides the components for building a web-based data visualiz
|
|
4
4
|
The typical use case is to allow a user to investigate a data set stored in one or more databases
|
5
5
|
as well as life data streams.
|
6
6
|
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
|
10
|
+
At this stage the best course of action is to clone the repository
|
11
|
+
|
12
|
+
% git clone https://github.com/mytestbed/omf_web.git
|
13
|
+
% cd omf_web
|
14
|
+
% export OMF_WEB=`pwd`
|
15
|
+
% bundle install
|
16
|
+
|
17
|
+
|
18
|
+
Getting Started
|
19
|
+
---------------
|
20
|
+
|
21
|
+
There are a few example sites in the 'example' directory. They have been developed in the context of various demos and
|
22
|
+
may not always be kept up to date. The one which should always work is 'example/simple'. Try it out.
|
23
|
+
|
24
|
+
% $OMF_WEB/bin/omf_web_server.rb --config $OMF_WEB/example/simple/simple.yaml start
|
25
|
+
|
26
|
+
This starts a webserver which can be accessed locally via 'http:localhost:4050'. Connecting to it through your favorite
|
27
|
+
web browser should display a web page approx. looking like:
|
28
|
+
|
29
|
+

|
30
|
+
|
31
|
+
Don't forget to press the icon buttons
|
32
|
+

|
33
|
+
on the left widget header.
|
34
|
+
|
35
|
+
Overview
|
36
|
+
--------
|
37
|
+
|
7
38
|
The core components are:
|
8
39
|
|
9
40
|
* A **DataSource** which holds a specific data set organised as a table. It is defined
|
@@ -0,0 +1,157 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
BIN_DIR = File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__)
|
3
|
+
TOP_DIR = File.join(BIN_DIR, '..')
|
4
|
+
$: << File.join(TOP_DIR, 'lib')
|
5
|
+
|
6
|
+
DESCR = %{
|
7
|
+
Start an OMF WEB site ...
|
8
|
+
}
|
9
|
+
|
10
|
+
require 'omf_common/lobject'
|
11
|
+
require 'omf_oml/table'
|
12
|
+
require 'omf_oml/sql_source'
|
13
|
+
|
14
|
+
|
15
|
+
OMF::Common::Loggable.init_log 'omf_web'
|
16
|
+
|
17
|
+
$config_file_dir = nil
|
18
|
+
|
19
|
+
require 'omf_oml/table'
|
20
|
+
|
21
|
+
def load_environment(opts)
|
22
|
+
unless cf = opts[:omf_config_file]
|
23
|
+
puts "Missing config file"
|
24
|
+
abort
|
25
|
+
end
|
26
|
+
|
27
|
+
unless File.readable? cf
|
28
|
+
puts "Can't read config file '#{cf}'"
|
29
|
+
abort
|
30
|
+
end
|
31
|
+
|
32
|
+
$config_file_dir = File.dirname(cf)
|
33
|
+
cfg = YAML.load_file(cf)
|
34
|
+
(cfg['server'] || {}).each do |k, v|
|
35
|
+
k = k.to_sym
|
36
|
+
case k
|
37
|
+
when :port
|
38
|
+
opts[:port] = v.to_i
|
39
|
+
else
|
40
|
+
opts[k] = v
|
41
|
+
end
|
42
|
+
end
|
43
|
+
databases = {}
|
44
|
+
(cfg['data_sources'] || []).each do |ds|
|
45
|
+
load_datasource(ds, databases)
|
46
|
+
end
|
47
|
+
(cfg['repositories'] || []).each do |repo|
|
48
|
+
load_repository(repo)
|
49
|
+
end
|
50
|
+
|
51
|
+
unless wa = cfg['widgets']
|
52
|
+
puts "Can't find 'widgets' section in config file '#{cf}' - #{cfg.keys}"
|
53
|
+
abort
|
54
|
+
end
|
55
|
+
wa.each do |w|
|
56
|
+
OMF::Web.register_widget w
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_datasource(config, databases)
|
61
|
+
unless id = config['id']
|
62
|
+
puts "Missing id in datasource configuration"
|
63
|
+
abort
|
64
|
+
end
|
65
|
+
unless table_name = config['table']
|
66
|
+
puts "Missing 'table' in datasource configuration '#{id}'"
|
67
|
+
abort
|
68
|
+
end
|
69
|
+
unless db_cfg = config['database']
|
70
|
+
puts "Missing database configuration in datasource '#{id}'"
|
71
|
+
abort
|
72
|
+
end
|
73
|
+
db = get_database(db_cfg, databases)
|
74
|
+
unless table = db.create_table(table_name, :limit => config['limit'], :check_interval => config['dynamic'])
|
75
|
+
puts "Can't find table '#{table_name}' in database '#{db}'"
|
76
|
+
abort
|
77
|
+
end
|
78
|
+
|
79
|
+
OMF::Web.register_datasource table, name: id
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_database(config, databases)
|
83
|
+
if config.is_a? String
|
84
|
+
if db = databases[config]
|
85
|
+
return db
|
86
|
+
end
|
87
|
+
puts "Database '#{config}' not defined - (#{databases.keys})"
|
88
|
+
abort
|
89
|
+
end
|
90
|
+
unless id = config['id']
|
91
|
+
puts "Missing id in database configuration"
|
92
|
+
abort
|
93
|
+
end
|
94
|
+
unless id = config['id']
|
95
|
+
puts "Database '#{config}' not defined - (#{databases.keys})"
|
96
|
+
abort
|
97
|
+
end
|
98
|
+
unless url = config['url']
|
99
|
+
puts "Missing URL for database '#{id}'"
|
100
|
+
abort
|
101
|
+
end
|
102
|
+
if url.start_with?('sqlite://') && ! url.start_with?('sqlite:///')
|
103
|
+
# inject top dir
|
104
|
+
url.insert('sqlite://'.length, $config_file_dir + '/')
|
105
|
+
end
|
106
|
+
puts "URL: #{url}"
|
107
|
+
begin
|
108
|
+
return databases[id] = OMF::OML::OmlSqlSource.new(url, :check_interval => 3.0)
|
109
|
+
rescue Exception => ex
|
110
|
+
puts "Can't connect to database '#{id}' - #{ex}"
|
111
|
+
abort
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def load_repository(config)
|
116
|
+
unless id = config['id']
|
117
|
+
puts "Missing id in respository configuration"
|
118
|
+
abort
|
119
|
+
end
|
120
|
+
unless type = config['type']
|
121
|
+
puts "Missing 'type' in respository configuration '#{id}'"
|
122
|
+
abort
|
123
|
+
end
|
124
|
+
|
125
|
+
require 'omf-web/content/repository'
|
126
|
+
case type
|
127
|
+
when 'file'
|
128
|
+
unless top_dir = config['top_dir']
|
129
|
+
puts "Missing 'top_dir' in respository configuration '#{id}'"
|
130
|
+
abort
|
131
|
+
end
|
132
|
+
unless top_dir.start_with? '/'
|
133
|
+
top_dir = File.join($config_file_dir, top_dir)
|
134
|
+
end
|
135
|
+
OMF::Web::ContentRepository.register_repo(id, type: :file, top_dir: top_dir)
|
136
|
+
else
|
137
|
+
puts "Unknown repository type '#{type}'. Only supporting 'file'."
|
138
|
+
abort
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Configure the web server
|
143
|
+
#
|
144
|
+
opts = {
|
145
|
+
app_name: 'simple',
|
146
|
+
page_title: 'Simple Demo',
|
147
|
+
port: 4000,
|
148
|
+
handlers: {
|
149
|
+
pre_parse: lambda do |p, runner|
|
150
|
+
p.on("--config CONF_FILE", "File holding description of web site") {|f| runner.options[:omf_config_file] = f}
|
151
|
+
end,
|
152
|
+
# delay connecting to databases to AFTER we may run as daemon
|
153
|
+
post_parse: lambda { |r| load_environment(r.options) },
|
154
|
+
}
|
155
|
+
}
|
156
|
+
require 'omf_web'
|
157
|
+
OMF::Web.start(opts)
|
data/doc/screenshot2.png
ADDED
Binary file
|
Binary file
|
@@ -7,7 +7,8 @@ require 'omf_web'
|
|
7
7
|
OMF::Web.register_datasource table
|
8
8
|
|
9
9
|
skip_first_line = true
|
10
|
-
File.open("#{File.dirname(__FILE__)}/downloads.csv", "r").read.gsub
|
10
|
+
#puts File.open("#{File.dirname(__FILE__)}/downloads.csv", "r").read.gsub(/\r\n?/, "\n")
|
11
|
+
File.open("#{File.dirname(__FILE__)}/downloads.csv", "r").read.gsub(/\r\n?/, "\n").each_line do |line|
|
11
12
|
if skip_first_line
|
12
13
|
skip_first_line = false
|
13
14
|
else
|
data/example/simple/README.md
CHANGED
@@ -6,25 +6,24 @@ Essentially the 'Hello World' example of a viz server. Taking data out of a data
|
|
6
6
|
Start the server through:
|
7
7
|
|
8
8
|
ruby -I$OMF_WEB_HOME/lib $OMF_WEB_HOME/example/simple/simple_viz_server.rb start
|
9
|
-
|
9
|
+
ruby --I$OMF_WEB_HOME/lib $OMF_WEB_HOME/bin/omf_web_server.rb --config simple.yaml start
|
10
|
+
|
10
11
|
where $OMF_WEB_HOME points to the directory containing the __omf_web__ code. You will also need to __omf_oml__ package.
|
11
12
|
You may either install the Gem, or download the source code from https://github.com/mytestbed/omf_oml. In the later case you
|
12
|
-
will need to add a '-I$OMF_OML_HOME/lib'
|
13
|
+
will need to add a '-I$OMF_OML_HOME/lib' flag to the above command.
|
13
14
|
|
14
15
|
After all that, the console putput should look like:
|
15
16
|
|
16
|
-
DEBUG OmlSqlSource: Opening DB (sqlite
|
17
|
-
DEBUG OmlSqlSource: DB: #<Sequel::SQLite::Database: "sqlite
|
18
|
-
DEBUG
|
19
|
-
DEBUG
|
20
|
-
|
21
|
-
INFO PingDB: Stream: pingmonitor_myping
|
22
|
-
DEBUG OmlSqlRow-pingmonitor_myping: Read 145/145 rows from 'pingmonitor_myping'
|
23
|
-
INFO Server: >> Thin web server (v1.3.1 codename Triple Espresso)
|
17
|
+
DEBUG OmlSqlSource: Opening DB (sqlite://sample.sq3)
|
18
|
+
DEBUG OmlSqlSource: DB: #<Sequel::SQLite::Database: "sqlite://sample.sq3">
|
19
|
+
DEBUG OmlSchema: schema: '[{:name=>:oml_sender_id, :type=>:integer, :title=>"Oml Sender Id"} ...
|
20
|
+
DEBUG OmlSqlRow-wave: Read 1000 (total 1000) rows from 'wave'
|
21
|
+
INFO Server: >> Thin web server (v1.5.1 codename Straight Razor)
|
24
22
|
DEBUG Server: >> Debugging ON
|
25
23
|
DEBUG Server: >> Tracing ON
|
26
24
|
INFO Server: >> Maximum connections set to 1024
|
27
|
-
INFO Server: >> Listening on 0.0.0.0:
|
25
|
+
INFO Server: >> Listening on 0.0.0.0:4050, CTRL+C to stop
|
26
|
+
|
28
27
|
|
29
|
-
This starts a web server on the local machine listening on port
|
30
|
-
result of a
|
28
|
+
This starts a web server on the local machine listening on port 4050. Now point your browser there and you should see the
|
29
|
+
result of a some experiment.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# File to create a very simple waveform.
|
3
|
+
#
|
4
|
+
|
5
|
+
time_step = 0.001
|
6
|
+
|
7
|
+
amplitude = [0.2, 0.8, 0.6]
|
8
|
+
frequency = [10, 14, 18]
|
9
|
+
|
10
|
+
f = File.open('sample.sql', 'w')
|
11
|
+
f.write %{
|
12
|
+
BEGIN TRANSACTION;
|
13
|
+
CREATE TABLE _senders (name TEXT PRIMARY KEY, id INTEGER UNIQUE);
|
14
|
+
INSERT INTO "_senders" VALUES('ch1',1);
|
15
|
+
CREATE TABLE _experiment_metadata (key TEXT PRIMARY KEY, value TEXT);
|
16
|
+
INSERT INTO "_experiment_metadata" VALUES('start_time','#{Time.now.to_i}');
|
17
|
+
CREATE TABLE "wave" (oml_sender_id INTEGER, oml_seq INTEGER, oml_ts_client REAL, oml_ts_server REAL, "t" REAL, "y" REAL);
|
18
|
+
}
|
19
|
+
|
20
|
+
1000.times do |i|
|
21
|
+
time = i * time_step
|
22
|
+
y = 0
|
23
|
+
3.times do |j|
|
24
|
+
y += amplitude[j] * Math.sin(2 * Math::PI * frequency[j] * time)
|
25
|
+
end
|
26
|
+
f.write "INSERT INTO \"wave\" VALUES(1,#{i},#{time},#{time},#{time},#{y});\n"
|
27
|
+
end
|
28
|
+
f.write "END TRANSACTION;\n"
|
29
|
+
f.close
|
@@ -0,0 +1,17 @@
|
|
1
|
+
title: Introduction
|
2
|
+
|
3
|
+
|
4
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
|
5
|
+
sollicitudin nibh eu ligula lobortis ornare. Sed nibh nibh,
|
6
|
+
ullamcorper at vehicula ac, molestie ac nunc. Duis sodales, nisi vel
|
7
|
+
pellentesque imperdiet, nisi massa accumsan lorem, gravida scelerisque
|
8
|
+
velit est vitae eros. Suspendisse eu lacinia elit.
|
9
|
+
|
10
|
+
|
11
|
+
Suspendisse laoreet, lacus quis dignissim volutpat, dolor augue convallis lectus,
|
12
|
+
ac consectetur yyyy sem iaculis diam. Donec iaculis mattis iaculis.
|
13
|
+
Curabitur ut nisl in sapien semper ullamcorper in id turpis. Vivamus
|
14
|
+
sed sapien justo, ac scelerisque nibh. Sed eget quam velit. Lorem
|
15
|
+
ipsum dolor sit amet, consectetur adipiscing elit.
|
16
|
+
|
17
|
+
|
Binary file
|