omf_web 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
metadata CHANGED
@@ -1,228 +1,244 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - NICTA
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-11-05 00:00:00.000000000 Z
12
+ date: 2013-12-12 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: omf_oml
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
19
- version: '1.0'
21
+ version: '1'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
26
- version: '1.0'
29
+ version: '1'
27
30
  - !ruby/object:Gem::Dependency
28
- name: erector
31
+ name: omf_base
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ~>
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
- version: 0.8.3
37
+ version: '0'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ~>
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
- version: 0.8.3
45
+ version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
- name: activesupport
47
+ name: erector
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
47
- version: 3.0.0
53
+ version: '0.9'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
54
- version: 3.0.0
61
+ version: '0.9'
55
62
  - !ruby/object:Gem::Dependency
56
- name: rack
63
+ name: activesupport
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
61
- version: 1.3.5
69
+ version: '3.0'
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
68
- version: 1.3.5
77
+ version: '3.0'
69
78
  - !ruby/object:Gem::Dependency
70
- name: thin
79
+ name: rack
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
75
- version: 1.3.1
85
+ version: '1'
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
82
- version: 1.3.1
93
+ version: '1'
83
94
  - !ruby/object:Gem::Dependency
84
- name: coderay
95
+ name: thin
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ~>
88
100
  - !ruby/object:Gem::Version
89
- version: 1.0.6
101
+ version: '1'
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ~>
95
108
  - !ruby/object:Gem::Version
96
- version: 1.0.6
109
+ version: '1'
97
110
  - !ruby/object:Gem::Dependency
98
- name: log4r
111
+ name: coderay
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ~>
102
116
  - !ruby/object:Gem::Version
103
- version: 1.1.10
117
+ version: '1'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ~>
109
124
  - !ruby/object:Gem::Version
110
- version: 1.1.10
125
+ version: '1'
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: maruku
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ~>
116
132
  - !ruby/object:Gem::Version
117
- version: 0.6.0
133
+ version: '0.6'
118
134
  type: :runtime
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ~>
123
140
  - !ruby/object:Gem::Version
124
- version: 0.6.0
141
+ version: '0.6'
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: ritex
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ~>
130
148
  - !ruby/object:Gem::Version
131
- version: 1.0.1
149
+ version: '1.0'
132
150
  type: :runtime
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ~>
137
156
  - !ruby/object:Gem::Version
138
- version: 1.0.1
157
+ version: '1.0'
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: json
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
163
  - - ~>
144
164
  - !ruby/object:Gem::Version
145
- version: 1.7.3
165
+ version: '1.7'
146
166
  type: :runtime
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
171
  - - ~>
151
172
  - !ruby/object:Gem::Version
152
- version: 1.7.3
173
+ version: '1.7'
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: grit
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
179
  - - ~>
158
180
  - !ruby/object:Gem::Version
159
- version: 2.5.0
181
+ version: '2.5'
160
182
  type: :runtime
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
187
  - - ~>
165
188
  - !ruby/object:Gem::Version
166
- version: 2.5.0
189
+ version: '2.5'
167
190
  - !ruby/object:Gem::Dependency
168
- name: sqlite3
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ~>
172
- - !ruby/object:Gem::Version
173
- version: 1.3.6
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ~>
179
- - !ruby/object:Gem::Version
180
- version: 1.3.6
181
- - !ruby/object:Gem::Dependency
182
- name: postgres-pr
191
+ name: websocket-rack
183
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
184
194
  requirements:
185
195
  - - ~>
186
196
  - !ruby/object:Gem::Version
187
- version: 0.6.3
197
+ version: '0.4'
188
198
  type: :runtime
189
199
  prerelease: false
190
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
191
202
  requirements:
192
203
  - - ~>
193
204
  - !ruby/object:Gem::Version
194
- version: 0.6.3
205
+ version: '0.4'
195
206
  - !ruby/object:Gem::Dependency
196
- name: websocket-rack
207
+ name: rack-accept
197
208
  requirement: !ruby/object:Gem::Requirement
209
+ none: false
198
210
  requirements:
199
211
  - - ~>
200
212
  - !ruby/object:Gem::Version
201
- version: 0.4.0
213
+ version: '0.4'
202
214
  type: :runtime
203
215
  prerelease: false
204
216
  version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
205
218
  requirements:
206
219
  - - ~>
207
220
  - !ruby/object:Gem::Version
208
- version: 0.4.0
221
+ version: '0.4'
209
222
  - !ruby/object:Gem::Dependency
210
- name: rack-accept
223
+ name: i18n
211
224
  requirement: !ruby/object:Gem::Requirement
225
+ none: false
212
226
  requirements:
213
- - - ~>
227
+ - - ! '>='
214
228
  - !ruby/object:Gem::Version
215
- version: 0.4.5
229
+ version: '0'
216
230
  type: :runtime
217
231
  prerelease: false
218
232
  version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
219
234
  requirements:
220
- - - ~>
235
+ - - ! '>='
221
236
  - !ruby/object:Gem::Version
222
- version: 0.4.5
237
+ version: '0'
223
238
  - !ruby/object:Gem::Dependency
224
239
  name: ruby-openid
225
240
  requirement: !ruby/object:Gem::Requirement
241
+ none: false
226
242
  requirements:
227
243
  - - ~>
228
244
  - !ruby/object:Gem::Version
@@ -230,6 +246,7 @@ dependencies:
230
246
  type: :runtime
231
247
  prerelease: false
232
248
  version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
233
250
  requirements:
234
251
  - - ~>
235
252
  - !ruby/object:Gem::Version
@@ -238,9 +255,7 @@ description: OMF's Web based control and visualization framework.
238
255
  email:
239
256
  - omf-user@lists.nicta.com.au
240
257
  executables:
241
- - omf_web_demo
242
- - omf_web_demo.sh
243
- - omf_web_server.rb
258
+ - omf_web_server
244
259
  extensions: []
245
260
  extra_rdoc_files: []
246
261
  files:
@@ -248,9 +263,7 @@ files:
248
263
  - Gemfile
249
264
  - README.md
250
265
  - Rakefile
251
- - bin/omf_web_demo
252
- - bin/omf_web_demo.sh
253
- - bin/omf_web_server.rb
266
+ - bin/omf_web_server
254
267
  - debug/README
255
268
  - debug/brooklyn.dat
256
269
  - debug/ca.crt
@@ -313,6 +326,7 @@ files:
313
326
  - example/NOT_WORKING/wimax/test.rb
314
327
  - example/NOT_WORKING/wimax/uplink.yaml
315
328
  - example/NOT_WORKING/wimax/viz_server.rb
329
+ - example/bridge/README.md
316
330
  - example/bridge/auth_basic.rb
317
331
  - example/bridge/bridge_ctl.sh
318
332
  - example/bridge/bridge_log4r.yaml
@@ -381,6 +395,8 @@ files:
381
395
  - example/simple/sample.sql
382
396
  - example/simple/simple.yaml
383
397
  - example/simple/simple_dynamic.yaml
398
+ - example/web_rtc/web_rtc.yaml
399
+ - example/web_rtc/webrtc-exp_1381786573.sq3
384
400
  - lib/irods4r.rb
385
401
  - lib/irods4r/directory.rb
386
402
  - lib/irods4r/file.rb
@@ -459,11 +475,8 @@ files:
459
475
  - lib/omf-web/widget/text/maruku/output/to_html.rb
460
476
  - lib/omf-web/widget/text/text_widget.rb
461
477
  - lib/omf-web/xmpp_adapter.rb
462
- - lib/omf_common/lobject.rb
463
- - lib/omf_common/log4r_outputter.rb
464
478
  - lib/omf_web.rb
465
479
  - omf_web.gemspec
466
- - sample.sq3
467
480
  - share/htdocs/UNUSED/log/table.js
468
481
  - share/htdocs/graph/css/graph.css
469
482
  - share/htdocs/graph/img/bar_chart.png
@@ -498,11 +511,12 @@ files:
498
511
  - share/htdocs/graph/js/pie_chart2.js
499
512
  - share/htdocs/graph/js/scatter_plot.js
500
513
  - share/htdocs/graph/js/table2.js
501
- - share/htdocs/js/data_source.js
502
- - share/htdocs/js/data_source2.js
514
+ - share/htdocs/js/app.js
515
+ - share/htdocs/js/data_source3.js
516
+ - share/htdocs/js/data_source_repo.js
503
517
  - share/htdocs/js/mustache.js
504
- - share/htdocs/js/require3.js
505
518
  - share/htdocs/js/stacktrace.js
519
+ - share/htdocs/require/nv_d3.js
506
520
  - share/htdocs/theme/abstract/abstract.js
507
521
  - share/htdocs/theme/bright/css/bright.css
508
522
  - share/htdocs/theme/bright/css/codemirror.css
@@ -1224,6 +1238,16 @@ files:
1224
1238
  - share/htdocs/vendor/raphael-1.5.2/raphael.primitives.js
1225
1239
  - share/htdocs/vendor/raphael-1.5.2/raphael.shadow.js
1226
1240
  - share/htdocs/vendor/raphael-2.1.0/raphael.js
1241
+ - share/htdocs/vendor/require-2.1.8/require.js
1242
+ - share/htdocs/vendor/require-2.1.8/require.min.js
1243
+ - share/htdocs/vendor/require-css-0.0.7/.gitignore
1244
+ - share/htdocs/vendor/require-css-0.0.7/LICENSE
1245
+ - share/htdocs/vendor/require-css-0.0.7/README.md
1246
+ - share/htdocs/vendor/require-css-0.0.7/bower.json
1247
+ - share/htdocs/vendor/require-css-0.0.7/css-builder.js
1248
+ - share/htdocs/vendor/require-css-0.0.7/css.js
1249
+ - share/htdocs/vendor/require-css-0.0.7/normalize.js
1250
+ - share/htdocs/vendor/require-css-0.0.7/package.json
1227
1251
  - share/htdocs/vendor/silk_icons_v013/icons/accept.png
1228
1252
  - share/htdocs/vendor/silk_icons_v013/icons/add.png
1229
1253
  - share/htdocs/vendor/silk_icons_v013/icons/anchor.png
@@ -2413,25 +2437,27 @@ files:
2413
2437
  - share/htdocs/vendor/valums-file-uploader-cf7bfb1/tests/test-upload-handlers.htm
2414
2438
  homepage: https://www.mytestbed.net
2415
2439
  licenses: []
2416
- metadata: {}
2417
2440
  post_install_message:
2418
2441
  rdoc_options: []
2419
2442
  require_paths:
2420
2443
  - lib
2421
2444
  required_ruby_version: !ruby/object:Gem::Requirement
2445
+ none: false
2422
2446
  requirements:
2423
- - - '>='
2447
+ - - ! '>='
2424
2448
  - !ruby/object:Gem::Version
2425
2449
  version: '0'
2426
2450
  required_rubygems_version: !ruby/object:Gem::Requirement
2451
+ none: false
2427
2452
  requirements:
2428
- - - '>='
2453
+ - - ! '>='
2429
2454
  - !ruby/object:Gem::Version
2430
2455
  version: '0'
2431
2456
  requirements: []
2432
2457
  rubyforge_project: omf_web
2433
- rubygems_version: 2.0.6
2458
+ rubygems_version: 1.8.23
2434
2459
  signing_key:
2435
- specification_version: 4
2460
+ specification_version: 3
2436
2461
  summary: OMF's web frontend.
2437
2462
  test_files: []
2463
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: a076091a3915e52b1dddc6ed1f2f65b4a28c6905
4
- data.tar.gz: b861770697dad3299f6f9a8e1c0b800b9c32058a
5
- SHA512:
6
- metadata.gz: d5d66a617e076f8960fe39656f1fe6ce77b82d5df76bcf6f12fc6f61822d57b5d8aef43b3a6df72a46a09b60a44f29c18301ab3a2a383c7e579bd1aae44d6497
7
- data.tar.gz: ab162397635d906b9d0ded7117723d75dd81ce53bacb8f64e5f6b5547ccbf4bac985964785e946663140e0a7b093919fae6e1ed1b3a253ff8c60901b07607129
data/bin/omf_web_demo DELETED
@@ -1,3 +0,0 @@
1
-
2
- load File.join(File.dirname(__FILE__), '../example/demo/demo_viz_server.rb')
3
- OmfWebDemo.start
data/bin/omf_web_demo.sh DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
-
3
-
4
- TOP_DIR=`ruby -rubygems -e "require 'omf-web/version'; puts OMF::Web::TOP_DIR"`
5
-
6
- cd $TOP_DIR
7
- ruby -rubygems $TOP_DIR/example/demo/demo_viz_server.rb $* start
@@ -1,157 +0,0 @@
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)