iqvoc 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/CHANGELOG.md +6 -0
  2. data/Gemfile.lock +43 -47
  3. data/app/assets/javascripts/framework.js +1 -1
  4. data/app/assets/javascripts/iqvoc/extract_concepts.js +19 -0
  5. data/app/assets/javascripts/iqvoc/iqvoc.js +8 -12
  6. data/app/assets/javascripts/iqvoc/manifest.js +3 -0
  7. data/app/assets/javascripts/iqvoc/onebox.js +44 -0
  8. data/app/assets/javascripts/iqvoc/quicksearch.js +41 -0
  9. data/app/assets/stylesheets/framework.css +1 -1
  10. data/app/assets/stylesheets/iqvoc/bootstrap_extensions.css.scss +0 -7
  11. data/app/assets/stylesheets/iqvoc/components.css.scss +27 -1
  12. data/app/assets/stylesheets/iqvoc/manifest.css +0 -1
  13. data/app/controllers/application_controller.rb +1 -1
  14. data/app/controllers/concepts/alphabetical_controller.rb +5 -1
  15. data/app/controllers/concepts/untranslated_controller.rb +1 -1
  16. data/app/controllers/concepts_controller.rb +2 -0
  17. data/app/controllers/frontpage_controller.rb +23 -0
  18. data/app/controllers/instance_configuration_controller.rb +10 -2
  19. data/app/controllers/pages_controller.rb +21 -0
  20. data/app/controllers/rdf_controller.rb +0 -21
  21. data/app/helpers/concepts_helper.rb +1 -1
  22. data/app/helpers/navigation_helper.rb +0 -10
  23. data/app/helpers/rdf_helper.rb +1 -1
  24. data/app/models/concept/base.rb +2 -2
  25. data/app/models/concept/skos/base.rb +1 -1
  26. data/app/models/label/base.rb +5 -2
  27. data/app/models/labeling/base.rb +2 -2
  28. data/app/models/labeling/skos/base.rb +1 -1
  29. data/app/models/note/base.rb +0 -6
  30. data/app/models/note/skos/base.rb +20 -8
  31. data/app/views/concepts/alphabetical/index.html.erb +2 -2
  32. data/app/views/{rdf/show_concept.iqrdf → concepts/show.iqrdf} +1 -1
  33. data/app/views/concepts/show_published.html.erb +0 -1
  34. data/app/views/concepts/show_unpublished.html.erb +0 -1
  35. data/app/views/concepts/sidebars/_plural.html.erb +3 -3
  36. data/app/views/concepts/sidebars/_singular.html.erb +4 -5
  37. data/app/views/concepts/untranslated/index.html.erb +1 -1
  38. data/app/views/frontpage/index.html.erb +8 -0
  39. data/app/views/instance_configuration/index.html.erb +8 -5
  40. data/app/views/layouts/_navigation.html.erb +10 -8
  41. data/app/views/layouts/application.html.erb +3 -1
  42. data/app/views/pages/help.html.erb +75 -0
  43. data/app/views/partials/labeling/skos/_base.html.erb +2 -1
  44. data/config/initializers/language.rb +1 -1
  45. data/config/locales/de.yml +8 -0
  46. data/config/locales/en.yml +8 -0
  47. data/config/routes.rb +8 -6
  48. data/lib/generators/app/template.rb +1 -1
  49. data/lib/iqvoc/ability.rb +3 -0
  50. data/lib/iqvoc/configuration/collection.rb +2 -2
  51. data/lib/iqvoc/configuration/concept.rb +1 -1
  52. data/lib/iqvoc/configuration/core.rb +6 -4
  53. data/lib/iqvoc/configuration/label.rb +2 -2
  54. data/lib/iqvoc/controller_extensions.rb +1 -1
  55. data/lib/iqvoc/environments/development.rb +6 -0
  56. data/lib/iqvoc/environments/production.rb +6 -0
  57. data/lib/iqvoc/environments/test.rb +6 -0
  58. data/lib/iqvoc/instance_configuration.rb +3 -2
  59. data/lib/iqvoc/skos_importer.rb +23 -0
  60. data/lib/iqvoc/version.rb +1 -1
  61. data/lib/tasks/importer.rake +2 -2
  62. data/test/integration/alphabetical_test.rb +2 -2
  63. data/test/integration/browse_concepts_and_labels_test.rb +4 -4
  64. data/test/integration/untranslated_test.rb +3 -3
  65. data/test/unit/hygiene_test.rb +4 -0
  66. data/test/unit/instance_configuration_test.rb +17 -1
  67. data/test/unit/skos_import_test.rb +19 -0
  68. data/vendor/assets/images/jquery-ui/ui-icons_469bdd_256x240.png +0 -0
  69. data/vendor/assets/javascripts/{jquery-ui-1.8.20.custom.js → jquery-ui-1.8.23.custom.js} +124 -69
  70. data/vendor/assets/stylesheets/{jquery-ui-1.8.20.custom.css → jquery-ui-1.8.23.custom.css} +5 -7
  71. metadata +34 -31
  72. data/app/assets/javascripts/iqvoc/visualization.js +0 -321
  73. data/app/views/concepts/_visualization.html.erb +0 -11
  74. data/vendor/assets/javascripts/excanvas.js +0 -35
  75. data/vendor/assets/javascripts/jit_rgraph.js +0 -153
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iqvoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-21 00:00:00.000000000 Z
14
+ date: 2012-11-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- requirement: &70337016512600 !ruby/object:Gem::Requirement
18
+ requirement: &70342874186600 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 3.2.1
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70337016512600
26
+ version_requirements: *70342874186600
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
- requirement: &70337016512200 !ruby/object:Gem::Requirement
29
+ requirement: &70342874186200 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70337016512200
37
+ version_requirements: *70342874186200
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: kaminari
40
- requirement: &70337016511740 !ruby/object:Gem::Requirement
40
+ requirement: &70342874185740 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *70337016511740
48
+ version_requirements: *70342874185740
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: authlogic
51
- requirement: &70337016511320 !ruby/object:Gem::Requirement
51
+ requirement: &70342874185320 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *70337016511320
59
+ version_requirements: *70342874185320
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: cancan
62
- requirement: &70337016510900 !ruby/object:Gem::Requirement
62
+ requirement: &70342874184900 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *70337016510900
70
+ version_requirements: *70342874184900
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: iq_rdf
73
- requirement: &70337016510400 !ruby/object:Gem::Requirement
73
+ requirement: &70342874184400 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: 0.1.2
79
79
  type: :runtime
80
80
  prerelease: false
81
- version_requirements: *70337016510400
81
+ version_requirements: *70342874184400
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: json
84
- requirement: &70337016509980 !ruby/object:Gem::Requirement
84
+ requirement: &70342874183980 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
- version_requirements: *70337016509980
92
+ version_requirements: *70342874183980
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rails_autolink
95
- requirement: &70337016509520 !ruby/object:Gem::Requirement
95
+ requirement: &70342891454560 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: '0'
101
101
  type: :runtime
102
102
  prerelease: false
103
- version_requirements: *70337016509520
103
+ version_requirements: *70342891454560
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: fastercsv
106
- requirement: &70337016539800 !ruby/object:Gem::Requirement
106
+ requirement: &70342891454100 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,10 +111,10 @@ dependencies:
111
111
  version: '0'
112
112
  type: :runtime
113
113
  prerelease: false
114
- version_requirements: *70337016539800
114
+ version_requirements: *70342891454100
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: simple_form
117
- requirement: &70337016539380 !ruby/object:Gem::Requirement
117
+ requirement: &70342891453680 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ! '>='
@@ -122,10 +122,10 @@ dependencies:
122
122
  version: '0'
123
123
  type: :runtime
124
124
  prerelease: false
125
- version_requirements: *70337016539380
125
+ version_requirements: *70342891453680
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: sass-rails
128
- requirement: &70337016538880 !ruby/object:Gem::Requirement
128
+ requirement: &70342891453180 !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
131
131
  - - ~>
@@ -133,7 +133,7 @@ dependencies:
133
133
  version: 3.2.5
134
134
  type: :runtime
135
135
  prerelease: false
136
- version_requirements: *70337016538880
136
+ version_requirements: *70342891453180
137
137
  description: iQvoc - a SKOS(-XL) vocabulary management system built on the Semantic
138
138
  Web
139
139
  email:
@@ -159,10 +159,12 @@ files:
159
159
  - app/assets/javascripts/framework.js
160
160
  - app/assets/javascripts/iqvoc/entityselect.js.erb
161
161
  - app/assets/javascripts/iqvoc/entityselect_qualified.js.erb
162
+ - app/assets/javascripts/iqvoc/extract_concepts.js
162
163
  - app/assets/javascripts/iqvoc/iqvoc.js
163
164
  - app/assets/javascripts/iqvoc/langselect.js
164
165
  - app/assets/javascripts/iqvoc/manifest.js
165
- - app/assets/javascripts/iqvoc/visualization.js
166
+ - app/assets/javascripts/iqvoc/onebox.js
167
+ - app/assets/javascripts/iqvoc/quicksearch.js
166
168
  - app/assets/javascripts/manifest.js
167
169
  - app/assets/stylesheets/framework.css
168
170
  - app/assets/stylesheets/iqvoc/bootstrap_extensions.css.scss
@@ -188,8 +190,10 @@ files:
188
190
  - app/controllers/concepts/versions_controller.rb
189
191
  - app/controllers/concepts_controller.rb
190
192
  - app/controllers/dashboard_controller.rb
193
+ - app/controllers/frontpage_controller.rb
191
194
  - app/controllers/import_controller.rb
192
195
  - app/controllers/instance_configuration_controller.rb
196
+ - app/controllers/pages_controller.rb
193
197
  - app/controllers/rdf_controller.rb
194
198
  - app/controllers/search_results_controller.rb
195
199
  - app/controllers/triple_store_syncs_controller.rb
@@ -261,7 +265,6 @@ files:
261
265
  - app/views/collections/show.iqrdf
262
266
  - app/views/concepts/_form.html.erb
263
267
  - app/views/concepts/_header.html.erb
264
- - app/views/concepts/_visualization.html.erb
265
268
  - app/views/concepts/alphabetical/_pref_labeling.html.erb
266
269
  - app/views/concepts/alphabetical/index.html.erb
267
270
  - app/views/concepts/edit.html.erb
@@ -270,6 +273,7 @@ files:
270
273
  - app/views/concepts/index.iqrdf
271
274
  - app/views/concepts/new.html.erb
272
275
  - app/views/concepts/notifications/_referenced_concepts.html.erb
276
+ - app/views/concepts/show.iqrdf
273
277
  - app/views/concepts/show_published.html.erb
274
278
  - app/views/concepts/show_unpublished.html.erb
275
279
  - app/views/concepts/sidebars/_plural.html.erb
@@ -279,6 +283,7 @@ files:
279
283
  - app/views/dashboard/index.html.erb
280
284
  - app/views/errors/access_denied.html.erb
281
285
  - app/views/errors/not_found.html.erb
286
+ - app/views/frontpage/index.html.erb
282
287
  - app/views/import/import.html.erb
283
288
  - app/views/import/index.html.erb
284
289
  - app/views/instance_configuration/index.html.erb
@@ -294,6 +299,7 @@ files:
294
299
  - app/views/layouts/_navigation.html.erb
295
300
  - app/views/layouts/_sections.html.erb
296
301
  - app/views/layouts/application.html.erb
302
+ - app/views/pages/help.html.erb
297
303
  - app/views/partials/collection/_member.html.erb
298
304
  - app/views/partials/concept/_edit_link_base.html.erb
299
305
  - app/views/partials/concept/_inline_base.html.erb
@@ -318,7 +324,6 @@ files:
318
324
  - app/views/partials/note/skos/change_note/_search_result.html.erb
319
325
  - app/views/partials/note/skos/definition/_search_result.html.erb
320
326
  - app/views/rdf/scheme.iqrdf
321
- - app/views/rdf/show_concept.iqrdf
322
327
  - app/views/search_results/_header.html.erb
323
328
  - app/views/search_results/_sidebar.html.erb
324
329
  - app/views/search_results/index.html.erb
@@ -482,11 +487,9 @@ files:
482
487
  - vendor/assets/images/treeview-red-line.gif
483
488
  - vendor/assets/images/treeview-red.gif
484
489
  - vendor/assets/javascripts/bootstrap/bootstrap.js
485
- - vendor/assets/javascripts/excanvas.js
486
490
  - vendor/assets/javascripts/html5.js
487
- - vendor/assets/javascripts/jit_rgraph.js
488
491
  - vendor/assets/javascripts/jquery-1.7.1.js
489
- - vendor/assets/javascripts/jquery-ui-1.8.20.custom.js
492
+ - vendor/assets/javascripts/jquery-ui-1.8.23.custom.js
490
493
  - vendor/assets/javascripts/jquery-ui.datepicker-de.js
491
494
  - vendor/assets/javascripts/jquery.treeview.async.js
492
495
  - vendor/assets/javascripts/jquery.treeview.js
@@ -495,7 +498,7 @@ files:
495
498
  - vendor/assets/javascripts/storage.js
496
499
  - vendor/assets/stylesheets/bootstrap/bootstrap-responsive.css
497
500
  - vendor/assets/stylesheets/bootstrap/bootstrap.css
498
- - vendor/assets/stylesheets/jquery-ui-1.8.20.custom.css
501
+ - vendor/assets/stylesheets/jquery-ui-1.8.23.custom.css
499
502
  - vendor/assets/stylesheets/jquery.treeview.css.erb
500
503
  homepage: http://github.com/innoq/iqvoc
501
504
  licenses: []
@@ -1,321 +0,0 @@
1
- /*jslint vars: true, unparam: true, nomen: true, browser: true */
2
- /*global jQuery, $jit, IQVOC, HTMLCanvasElement */
3
-
4
- // basic settings -- XXX: cargo-culted from JIT examples
5
- var labelType, nativeTextSupport, useGradients, animate; // XXX: useless globals!?
6
- (function() {
7
- "use strict";
8
-
9
- var ua = navigator.userAgent,
10
- iOS = ua.match(/iPhone/i) || ua.match(/iPad/i),
11
- typeOfCanvas = typeof HTMLCanvasElement,
12
- nativeCanvasSupport = (typeOfCanvas === "object" || typeOfCanvas === "function"),
13
- textSupport = nativeCanvasSupport
14
- && (typeof document.createElement("canvas").getContext("2d").fillText === "function");
15
- // settings based on the fact that ExCanvas provides text support for IE
16
- // and that as of today iPhone/iPad current text support is lame
17
- labelType = (!nativeCanvasSupport || (textSupport && !iOS)) ? "Native" : "HTML";
18
- nativeTextSupport = labelType === "Native";
19
- useGradients = nativeCanvasSupport;
20
- animate = !(iOS || !nativeCanvasSupport);
21
- }());
22
-
23
- IQVOC.visualization = (function($) {
24
-
25
- "use strict";
26
-
27
- var LEVELDISTANCE = 100;
28
- var CONCEPT_URI;
29
- var MAX_CHILDREN = 10; // TODO: rename
30
- var VIZ; // XXX: singleton; hacky - there should be a more elegant way!?
31
-
32
- var spawn, redraw, onFilter, generateGraph, transformData, generateConceptNode,
33
- generateLabelNode, generateDummyConcepts, groupChildNodes,
34
- determineTransparency, htmlEncode;
35
-
36
- var init = function(container, callback) { // TODO: should be a class so multiple instances can be created (should also avoid module-level globals)
37
- CONCEPT_URI = $("head link[type='application/json']").attr("href"); // XXX: should be passed in via argument? (encapsulation)
38
- $.getJSON(CONCEPT_URI, function(data, status, xhr) {
39
- data = transformData(data);
40
- container = spawn(container, data);
41
- VIZ = container.data("widget");
42
- if(callback) {
43
- callback(container);
44
- }
45
- });
46
- };
47
-
48
- // container can be an ID or a DOM element
49
- spawn = function(container, data) {
50
- container = container.nodeType ? container : document.getElementById(container);
51
-
52
- // filter controls
53
- $.each(["label", "relation"], function(i, item) {
54
- var cb = $('<input type="checkbox" name="entities" checked="checked">')
55
- .val(item);
56
- $('<label />').text(item + "s").prepend(cb).appendTo(container);
57
- });
58
- $("input[type=checkbox]", container).live("change", onFilter);
59
- // zoom controls
60
- $.each(["+", "-"], function(i, item) {
61
- $('<input type="button" class="btn btn-small" />').val(item).click(function(ev) {
62
- var d = VIZ.config.Navigation.zooming / 1000;
63
- d = item === "-" ? 1 - d : 1 + d;
64
- VIZ.canvas.scale(d, d);
65
- }).appendTo(container);
66
- });
67
- // resize controls
68
- var toggleSize;
69
- var btns = $.map(["▢", "_"], function(item, i) {
70
- return $('<input type="button" class="btn resize" />').val(item)
71
- .click(function(ev) { toggleSize(i === 0); })
72
- .prependTo(container)[0];
73
- });
74
- btns = $(btns);
75
- btns.eq(1).hide();
76
- toggleSize = (function(container) {
77
- container = $(container);
78
- var width = container.width();
79
- var height = container.height();
80
- return function(enlarge) {
81
- var viz = container.data("widget"),
82
- _width = enlarge ? width * 2 : width,
83
- _height = enlarge ? height * 2 : height;
84
- viz.canvas.resize(_width, _height);
85
- container.css({
86
- width: String(_width) + "px",
87
- height: String(_height) + "px"
88
- });
89
- IQVOC.visualization.redraw(viz);
90
-
91
- btns.toggle();
92
- IQVOC.Storage.setItem("visualization", enlarge ? "enlarged" : "");
93
- };
94
- }(container));
95
-
96
- var viz = generateGraph(container, { levelDistance: LEVELDISTANCE });
97
- viz.filters = []; // TODO: rename? (ambiguous)
98
- viz.data = data;
99
- viz.toggleSize = toggleSize;
100
- redraw(viz);
101
-
102
- return $(container).addClass("infovis").data("widget", viz);
103
- };
104
-
105
- redraw = function(viz) {
106
- viz.graph.empty();
107
- viz.labels.clearLabels();
108
- viz.loadJSON(viz.data);
109
- viz.refresh();
110
- };
111
-
112
- onFilter = function(ev) {
113
- var el = $(this),
114
- checked = el.attr("checked"),
115
- value = el.val();
116
-
117
- if(checked) {
118
- var pos = $.inArray(value, VIZ.filters);
119
- VIZ.filters.splice(pos, 1);
120
- } else {
121
- VIZ.filters.push(value);
122
- }
123
-
124
- el.closest(".infovis").toggleClass("filtered", VIZ.filters.length > 0);
125
-
126
- VIZ.loadJSON(VIZ.data);
127
- VIZ.refresh();
128
- };
129
-
130
- generateGraph = function(container, options) {
131
- options = $.extend(options, {
132
- injectInto: container,
133
-
134
- Navigation: {
135
- enable: true,
136
- panning: "avoid nodes",
137
- zooming: 100
138
- },
139
-
140
- width: container.offsetWidth,
141
- height: container.offsetHeight,
142
-
143
- levelDistance: options.levelDistance || LEVELDISTANCE,
144
-
145
- // concentric circle as background (cargo-culted from RGraph example)
146
- background: {
147
- CanvasStyles: {
148
- strokeStyle: "#AAA",
149
- shadowBlur: 50
150
- //shadowColor: "#EEE" // XXX: fills entire background in Chrome!?
151
- }
152
- },
153
- // styles
154
- Node: {
155
- overridable: true,
156
- dim: 5,
157
- color: "#B0EAA4"
158
- },
159
- Edge: {
160
- overridable: true,
161
- lineWidth: 2,
162
- color: "#888"
163
- },
164
-
165
- // add text and attach event handlers to labels
166
- onCreateLabel: function(domEl, node) {
167
- var name = htmlEncode(node.name);
168
- if(node.data.nodes) { // special-casing placeholder
169
- $(domEl).html(node.name)
170
- .attr("title", String(node.data.nodes.length) + " nodes hidden"); // TODO: i18n
171
- } else if(node.data.etype === "label") {
172
- $(domEl).html(name);
173
- } else { // concept node (link with abbreviated name)
174
- var cue = "/concepts/";
175
- var host = CONCEPT_URI.split(cue)[0]; // XXX: hacky and brittle
176
- var caption = node.name.length <= 5 ? name :
177
- htmlEncode(node.name.substr(0, 5)) + "&hellip;";
178
- $("<a />").attr("href", host + cue + node.id)
179
- .attr("title", name).html(caption)
180
- .appendTo(domEl);
181
- }
182
- },
183
-
184
- // change node styles when labels are placed/moved
185
- onPlaceLabel: function(domEl, node) {
186
- var css = {},
187
- el = $(domEl),
188
- classes = ["level" + String(node._depth),
189
- node.data.etype || "concept"];
190
- // ensure label covers the underlying node
191
- css.height = css.lineHeight = String(node.Node.height) + "px";
192
- el.addClass(classes.join(" ")).css(css);
193
-
194
- // ensure label is centered on the symbol
195
- var style = domEl.style;
196
- var x = parseInt(style.left, 10);
197
- var y = parseInt(style.top, 10);
198
- style.top = String(y - domEl.offsetHeight / 2) + "px";
199
- style.left = String(x - domEl.offsetWidth / 2) + "px";
200
- },
201
-
202
- onBeforePlotLine: function(adj) {
203
- if(adj.nodeTo.data.etype === "label") {
204
- adj.nodeTo.data.$type = "square";
205
- adj.nodeTo.data.$color = "#EEE";
206
- adj.data.$lineWidth = adj.Edge.lineWidth / 2;
207
- adj.data.$color = "#00A";
208
- adj.data.$alpha = 0.5;
209
- } else {
210
- var node = adj.nodeTo; // nodeTo is always the inner node!?
211
- var alpha = determineTransparency(node._depth);
212
- if(alpha) {
213
- node.setData("alpha", alpha);
214
- adj.setData("alpha", alpha);
215
- }
216
- }
217
-
218
- $.each([adj.nodeFrom, adj.nodeTo], function(i, node) { // XXX: inefficient and fugly
219
- var etype = node.data ? node.data.etype : null;
220
- if(VIZ) {
221
- var hideRelations = $.inArray("relation", VIZ.filters) !== -1;
222
- var rootLabel = node._depth === 1 && etype === "label";
223
- if((hideRelations && node._depth > 0 && !rootLabel) ||
224
- (etype && $.inArray(etype, VIZ.filters) !== -1)) {
225
- adj.data.$alpha = 0;
226
- node.data.$alpha = 0;
227
- }
228
- }
229
- });
230
- }
231
- });
232
- return new $jit.RGraph(options);
233
- };
234
-
235
- // create a JIT-compatible JSON tree structure from a concept representation
236
- transformData = function(concept) {
237
- return generateConceptNode(concept);
238
- };
239
-
240
- // generate node from iQvoc concept representation
241
- generateConceptNode = function(concept) {
242
- if(typeof concept.relations === "number") {
243
- concept.relations = generateDummyConcepts(concept.relations);
244
- }
245
- var labels = $.map(concept.labels || [], generateLabelNode);
246
- groupChildNodes(labels, "label");
247
- var relations = $.map(concept.relations || [], generateConceptNode);
248
- groupChildNodes(relations);
249
- // combine labels and relations in alternating order
250
- var children = $.map(labels, function(label, i) {
251
- return relations.length ? [label, relations.pop()] : label;
252
- }).concat(relations);
253
- return {
254
- id: concept.origin,
255
- name: labels.length ? labels[0].name : "", // XXX: should use actual pref label
256
- children: children
257
- };
258
- };
259
-
260
- // generate node from iQvoc label representation
261
- generateLabelNode = function(label) {
262
- return {
263
- id: label.origin || Math.random(),
264
- name: label.value,
265
- data: { etype: "label" }
266
- // TODO: relations to other concepts (XL only)
267
- };
268
- };
269
-
270
- // generate dummy iQvoc label representations
271
- generateDummyConcepts = function(count) {
272
- return $.map(new Array(count), function(item, i) {
273
- return { origin: Math.random() };
274
- });
275
- };
276
-
277
- // combine excessive child nodes in a single placeholder node
278
- groupChildNodes = function(nodes, etype) { // TODO: rename
279
- if(nodes.length > MAX_CHILDREN) {
280
- var excess = nodes.splice(MAX_CHILDREN - 1);
281
- var placeholder = {
282
- id: Math.random(),
283
- name: "&hellip;",
284
- data: { nodes: excess } // XXX: property name ambiguous?
285
- };
286
- if(etype) {
287
- placeholder.data.etype = etype;
288
- }
289
- nodes.push(placeholder);
290
- }
291
- };
292
-
293
- determineTransparency = function(depth) {
294
- if(depth === 2) {
295
- return 0.6;
296
- } else if(depth > 2) {
297
- return 0.3;
298
- }
299
- };
300
-
301
- // hijack setPos method to reduce the relative distance for label nodes -- XXX: modifies all Node instances!
302
- var _setPos = $jit.Graph.Node.prototype.setPos;
303
- $jit.Graph.Node.prototype.setPos = function(value, type) {
304
- if(this.data.etype === "label") {
305
- value.rho = value.rho - (LEVELDISTANCE * 0.5);
306
- }
307
- return _setPos.apply(this, arguments);
308
- };
309
-
310
- // convert &, <, > and " to HTML entities (adapted from TiddlyWiki)
311
- htmlEncode = function(str) {
312
- return str.replace(/&/mg, "&amp;").replace(/</mg, "&lt;")
313
- .replace(/>/mg, "&gt;").replace(/\"/mg, "&quot;");
314
- };
315
-
316
- return {
317
- init: init,
318
- redraw: redraw
319
- };
320
-
321
- }(jQuery));
@@ -1,11 +0,0 @@
1
- <div id="visualization" class="modal hide">
2
- <div id="infovis"></div>
3
- </div>
4
-
5
- <% content_for :scripts do %>
6
- <!--[if IE]>
7
- <%= javascript_include_tag "excanvas.js" %>
8
- <![endif]-->
9
- <%= javascript_include_tag "jit_rgraph.js" %>
10
- <%= javascript_include_tag "iqvoc/visualization.js" %>
11
- <% end %>
@@ -1,35 +0,0 @@
1
- // Copyright 2006 Google Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- document.createElement("canvas").getContext||(function(){var s=Math,j=s.round,F=s.sin,G=s.cos,V=s.abs,W=s.sqrt,k=10,v=k/2;function X(){return this.context_||(this.context_=new H(this))}var L=Array.prototype.slice;function Y(b,a){var c=L.call(arguments,2);return function(){return b.apply(a,c.concat(L.call(arguments)))}}var M={init:function(b){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var a=b||document;a.createElement("canvas");a.attachEvent("onreadystatechange",Y(this.init_,this,a))}},init_:function(b){b.namespaces.g_vml_||
15
- b.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML");b.namespaces.g_o_||b.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML");if(!b.styleSheets.ex_canvas_){var a=b.createStyleSheet();a.owningElement.id="ex_canvas_";a.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"}var c=b.getElementsByTagName("canvas"),d=0;for(;d<c.length;d++)this.initElement(c[d])},
16
- initElement:function(b){if(!b.getContext){b.getContext=X;b.innerHTML="";b.attachEvent("onpropertychange",Z);b.attachEvent("onresize",$);var a=b.attributes;if(a.width&&a.width.specified)b.style.width=a.width.nodeValue+"px";else b.width=b.clientWidth;if(a.height&&a.height.specified)b.style.height=a.height.nodeValue+"px";else b.height=b.clientHeight}return b}};function Z(b){var a=b.srcElement;switch(b.propertyName){case "width":a.style.width=a.attributes.width.nodeValue+"px";a.getContext().clearRect();
17
- break;case "height":a.style.height=a.attributes.height.nodeValue+"px";a.getContext().clearRect();break}}function $(b){var a=b.srcElement;if(a.firstChild){a.firstChild.style.width=a.clientWidth+"px";a.firstChild.style.height=a.clientHeight+"px"}}M.init();var N=[],B=0;for(;B<16;B++){var C=0;for(;C<16;C++)N[B*16+C]=B.toString(16)+C.toString(16)}function I(){return[[1,0,0],[0,1,0],[0,0,1]]}function y(b,a){var c=I(),d=0;for(;d<3;d++){var f=0;for(;f<3;f++){var h=0,g=0;for(;g<3;g++)h+=b[d][g]*a[g][f];c[d][f]=
18
- h}}return c}function O(b,a){a.fillStyle=b.fillStyle;a.lineCap=b.lineCap;a.lineJoin=b.lineJoin;a.lineWidth=b.lineWidth;a.miterLimit=b.miterLimit;a.shadowBlur=b.shadowBlur;a.shadowColor=b.shadowColor;a.shadowOffsetX=b.shadowOffsetX;a.shadowOffsetY=b.shadowOffsetY;a.strokeStyle=b.strokeStyle;a.globalAlpha=b.globalAlpha;a.arcScaleX_=b.arcScaleX_;a.arcScaleY_=b.arcScaleY_;a.lineScale_=b.lineScale_}function P(b){var a,c=1;b=String(b);if(b.substring(0,3)=="rgb"){var d=b.indexOf("(",3),f=b.indexOf(")",d+
19
- 1),h=b.substring(d+1,f).split(",");a="#";var g=0;for(;g<3;g++)a+=N[Number(h[g])];if(h.length==4&&b.substr(3,1)=="a")c=h[3]}else a=b;return{color:a,alpha:c}}function aa(b){switch(b){case "butt":return"flat";case "round":return"round";case "square":default:return"square"}}function H(b){this.m_=I();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.fillStyle=this.strokeStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=k*1;this.globalAlpha=1;this.canvas=b;
20
- var a=b.ownerDocument.createElement("div");a.style.width=b.clientWidth+"px";a.style.height=b.clientHeight+"px";a.style.overflow="hidden";a.style.position="absolute";b.appendChild(a);this.element_=a;this.lineScale_=this.arcScaleY_=this.arcScaleX_=1}var i=H.prototype;i.clearRect=function(){this.element_.innerHTML=""};i.beginPath=function(){this.currentPath_=[]};i.moveTo=function(b,a){var c=this.getCoords_(b,a);this.currentPath_.push({type:"moveTo",x:c.x,y:c.y});this.currentX_=c.x;this.currentY_=c.y};
21
- i.lineTo=function(b,a){var c=this.getCoords_(b,a);this.currentPath_.push({type:"lineTo",x:c.x,y:c.y});this.currentX_=c.x;this.currentY_=c.y};i.bezierCurveTo=function(b,a,c,d,f,h){var g=this.getCoords_(f,h),l=this.getCoords_(b,a),e=this.getCoords_(c,d);Q(this,l,e,g)};function Q(b,a,c,d){b.currentPath_.push({type:"bezierCurveTo",cp1x:a.x,cp1y:a.y,cp2x:c.x,cp2y:c.y,x:d.x,y:d.y});b.currentX_=d.x;b.currentY_=d.y}i.quadraticCurveTo=function(b,a,c,d){var f=this.getCoords_(b,a),h=this.getCoords_(c,d),g={x:this.currentX_+
22
- 0.6666666666666666*(f.x-this.currentX_),y:this.currentY_+0.6666666666666666*(f.y-this.currentY_)};Q(this,g,{x:g.x+(h.x-this.currentX_)/3,y:g.y+(h.y-this.currentY_)/3},h)};i.arc=function(b,a,c,d,f,h){c*=k;var g=h?"at":"wa",l=b+G(d)*c-v,e=a+F(d)*c-v,m=b+G(f)*c-v,r=a+F(f)*c-v;if(l==m&&!h)l+=0.125;var n=this.getCoords_(b,a),o=this.getCoords_(l,e),q=this.getCoords_(m,r);this.currentPath_.push({type:g,x:n.x,y:n.y,radius:c,xStart:o.x,yStart:o.y,xEnd:q.x,yEnd:q.y})};i.rect=function(b,a,c,d){this.moveTo(b,
23
- a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath()};i.strokeRect=function(b,a,c,d){var f=this.currentPath_;this.beginPath();this.moveTo(b,a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath();this.stroke();this.currentPath_=f};i.fillRect=function(b,a,c,d){var f=this.currentPath_;this.beginPath();this.moveTo(b,a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath();this.fill();this.currentPath_=f};i.createLinearGradient=function(b,
24
- a,c,d){var f=new D("gradient");f.x0_=b;f.y0_=a;f.x1_=c;f.y1_=d;return f};i.createRadialGradient=function(b,a,c,d,f,h){var g=new D("gradientradial");g.x0_=b;g.y0_=a;g.r0_=c;g.x1_=d;g.y1_=f;g.r1_=h;return g};i.drawImage=function(b){var a,c,d,f,h,g,l,e,m=b.runtimeStyle.width,r=b.runtimeStyle.height;b.runtimeStyle.width="auto";b.runtimeStyle.height="auto";var n=b.width,o=b.height;b.runtimeStyle.width=m;b.runtimeStyle.height=r;if(arguments.length==3){a=arguments[1];c=arguments[2];h=g=0;l=d=n;e=f=o}else if(arguments.length==
25
- 5){a=arguments[1];c=arguments[2];d=arguments[3];f=arguments[4];h=g=0;l=n;e=o}else if(arguments.length==9){h=arguments[1];g=arguments[2];l=arguments[3];e=arguments[4];a=arguments[5];c=arguments[6];d=arguments[7];f=arguments[8]}else throw Error("Invalid number of arguments");var q=this.getCoords_(a,c),t=[];t.push(" <g_vml_:group",' coordsize="',k*10,",",k*10,'"',' coordorigin="0,0"',' style="width:',10,"px;height:",10,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]){var E=[];E.push("M11=",
26
- this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",j(q.x/k),",","Dy=",j(q.y/k),"");var p=q,z=this.getCoords_(a+d,c),w=this.getCoords_(a,c+f),x=this.getCoords_(a+d,c+f);p.x=s.max(p.x,z.x,w.x,x.x);p.y=s.max(p.y,z.y,w.y,x.y);t.push("padding:0 ",j(p.x/k),"px ",j(p.y/k),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",E.join(""),", sizingmethod='clip');")}else t.push("top:",j(q.y/k),"px;left:",j(q.x/k),"px;");t.push(' ">','<g_vml_:image src="',b.src,
27
- '"',' style="width:',k*d,"px;"," height:",k*f,'px;"',' cropleft="',h/n,'"',' croptop="',g/o,'"',' cropright="',(n-h-l)/n,'"',' cropbottom="',(o-g-e)/o,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",t.join(""))};i.stroke=function(b){var a=[],c=P(b?this.fillStyle:this.strokeStyle),d=c.color,f=c.alpha*this.globalAlpha;a.push("<g_vml_:shape",' filled="',!!b,'"',' style="position:absolute;width:',10,"px;height:",10,'px;"',' coordorigin="0 0" coordsize="',k*10," ",k*10,'"',' stroked="',
28
- !b,'"',' path="');var h={x:null,y:null},g={x:null,y:null},l=0;for(;l<this.currentPath_.length;l++){var e=this.currentPath_[l];switch(e.type){case "moveTo":a.push(" m ",j(e.x),",",j(e.y));break;case "lineTo":a.push(" l ",j(e.x),",",j(e.y));break;case "close":a.push(" x ");e=null;break;case "bezierCurveTo":a.push(" c ",j(e.cp1x),",",j(e.cp1y),",",j(e.cp2x),",",j(e.cp2y),",",j(e.x),",",j(e.y));break;case "at":case "wa":a.push(" ",e.type," ",j(e.x-this.arcScaleX_*e.radius),",",j(e.y-this.arcScaleY_*e.radius),
29
- " ",j(e.x+this.arcScaleX_*e.radius),",",j(e.y+this.arcScaleY_*e.radius)," ",j(e.xStart),",",j(e.yStart)," ",j(e.xEnd),",",j(e.yEnd));break}if(e){if(h.x==null||e.x<h.x)h.x=e.x;if(g.x==null||e.x>g.x)g.x=e.x;if(h.y==null||e.y<h.y)h.y=e.y;if(g.y==null||e.y>g.y)g.y=e.y}}a.push(' ">');if(b)if(typeof this.fillStyle=="object"){var m=this.fillStyle,r=0,n={x:0,y:0},o=0,q=1;if(m.type_=="gradient"){var t=m.x1_/this.arcScaleX_,E=m.y1_/this.arcScaleY_,p=this.getCoords_(m.x0_/this.arcScaleX_,m.y0_/this.arcScaleY_),
30
- z=this.getCoords_(t,E);r=Math.atan2(z.x-p.x,z.y-p.y)*180/Math.PI;if(r<0)r+=360;if(r<1.0E-6)r=0}else{var p=this.getCoords_(m.x0_,m.y0_),w=g.x-h.x,x=g.y-h.y;n={x:(p.x-h.x)/w,y:(p.y-h.y)/x};w/=this.arcScaleX_*k;x/=this.arcScaleY_*k;var R=s.max(w,x);o=2*m.r0_/R;q=2*m.r1_/R-o}var u=m.colors_;u.sort(function(ba,ca){return ba.offset-ca.offset});var J=u.length,da=u[0].color,ea=u[J-1].color,fa=u[0].alpha*this.globalAlpha,ga=u[J-1].alpha*this.globalAlpha,S=[],l=0;for(;l<J;l++){var T=u[l];S.push(T.offset*q+
31
- o+" "+T.color)}a.push('<g_vml_:fill type="',m.type_,'"',' method="none" focus="100%"',' color="',da,'"',' color2="',ea,'"',' colors="',S.join(","),'"',' opacity="',ga,'"',' g_o_:opacity2="',fa,'"',' angle="',r,'"',' focusposition="',n.x,",",n.y,'" />')}else a.push('<g_vml_:fill color="',d,'" opacity="',f,'" />');else{var K=this.lineScale_*this.lineWidth;if(K<1)f*=K;a.push("<g_vml_:stroke",' opacity="',f,'"',' joinstyle="',this.lineJoin,'"',' miterlimit="',this.miterLimit,'"',' endcap="',aa(this.lineCap),
32
- '"',' weight="',K,'px"',' color="',d,'" />')}a.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",a.join(""))};i.fill=function(){this.stroke(true)};i.closePath=function(){this.currentPath_.push({type:"close"})};i.getCoords_=function(b,a){var c=this.m_;return{x:k*(b*c[0][0]+a*c[1][0]+c[2][0])-v,y:k*(b*c[0][1]+a*c[1][1]+c[2][1])-v}};i.save=function(){var b={};O(this,b);this.aStack_.push(b);this.mStack_.push(this.m_);this.m_=y(I(),this.m_)};i.restore=function(){O(this.aStack_.pop(),
33
- this);this.m_=this.mStack_.pop()};function ha(b){var a=0;for(;a<3;a++){var c=0;for(;c<2;c++)if(!isFinite(b[a][c])||isNaN(b[a][c]))return false}return true}function A(b,a,c){if(!!ha(a)){b.m_=a;if(c)b.lineScale_=W(V(a[0][0]*a[1][1]-a[0][1]*a[1][0]))}}i.translate=function(b,a){A(this,y([[1,0,0],[0,1,0],[b,a,1]],this.m_),false)};i.rotate=function(b){var a=G(b),c=F(b);A(this,y([[a,c,0],[-c,a,0],[0,0,1]],this.m_),false)};i.scale=function(b,a){this.arcScaleX_*=b;this.arcScaleY_*=a;A(this,y([[b,0,0],[0,a,
34
- 0],[0,0,1]],this.m_),true)};i.transform=function(b,a,c,d,f,h){A(this,y([[b,a,0],[c,d,0],[f,h,1]],this.m_),true)};i.setTransform=function(b,a,c,d,f,h){A(this,[[b,a,0],[c,d,0],[f,h,1]],true)};i.clip=function(){};i.arcTo=function(){};i.createPattern=function(){return new U};function D(b){this.type_=b;this.r1_=this.y1_=this.x1_=this.r0_=this.y0_=this.x0_=0;this.colors_=[]}D.prototype.addColorStop=function(b,a){a=P(a);this.colors_.push({offset:b,color:a.color,alpha:a.alpha})};function U(){}G_vmlCanvasManager=
35
- M;CanvasRenderingContext2D=H;CanvasGradient=D;CanvasPattern=U})();