iqvoc 4.0.6 → 4.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/CHANGELOG.md +6 -0
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/javascripts/iqvoc/manifest.js +0 -1
  4. data/app/assets/javascripts/iqvoc/onebox.js.erb +81 -0
  5. data/app/assets/javascripts/iqvoc/quicksearch.js +19 -1
  6. data/app/assets/stylesheets/iqvoc/components.css.scss +26 -3
  7. data/app/controllers/concepts/alphabetical_controller.rb +5 -1
  8. data/app/controllers/triplestore_sync_controller.rb +8 -2
  9. data/app/views/concepts/alphabetical/_pref_labeling.html.erb +17 -4
  10. data/app/views/concepts/alphabetical/index.html.erb +2 -2
  11. data/app/views/frontpage/index.html.erb +7 -8
  12. data/config/boot.rb +3 -10
  13. data/config/engine.rb +5 -0
  14. data/db/migrate/20110510162719_use_mono_hierarchy_instead_of_poly_hierarchy.rb +2 -2
  15. data/db/migrate/20110525103100_separate_note_annotation_predicates.rb +10 -23
  16. data/db/migrate/20110615134040_change_umt_note_annotations_to_dct.rb +2 -2
  17. data/lib/engine_tasks/db.rake +0 -21
  18. data/lib/iqvoc/rdf_sync.rb +22 -14
  19. data/lib/iqvoc/version.rb +1 -1
  20. data/public/assets/ajax-loader-dada1fbb71d7fb80d8dde7a031ae6cd0.gif +0 -0
  21. data/public/assets/ajax-loader.gif +0 -0
  22. data/public/assets/arrow_down-07c5dea12928d65fcc31c08279366170.gif +0 -0
  23. data/public/assets/arrow_down.gif +0 -0
  24. data/public/assets/arrow_up-51ede92c113b9a870e7a306907360ba8.gif +0 -0
  25. data/public/assets/arrow_up.gif +0 -0
  26. data/public/assets/bootstrap/bootstrap-2012a68e8267282c0a2c177d7005ae6d.css +9 -0
  27. data/public/assets/bootstrap/bootstrap-2012a68e8267282c0a2c177d7005ae6d.css.gz +0 -0
  28. data/public/assets/bootstrap/bootstrap-35fd77cdf54a8cb63a39d8d0cea7a746.js +19 -0
  29. data/public/assets/bootstrap/bootstrap-35fd77cdf54a8cb63a39d8d0cea7a746.js.gz +0 -0
  30. data/public/assets/bootstrap/bootstrap-responsive-609b376f4bb032588c054b563d4bca1f.css +9 -0
  31. data/public/assets/bootstrap/bootstrap-responsive-609b376f4bb032588c054b563d4bca1f.css.gz +0 -0
  32. data/public/assets/bootstrap/bootstrap-responsive.css +9 -0
  33. data/public/assets/bootstrap/bootstrap-responsive.css.gz +0 -0
  34. data/public/assets/bootstrap/bootstrap.css +9 -0
  35. data/public/assets/bootstrap/bootstrap.css.gz +0 -0
  36. data/public/assets/bootstrap/bootstrap.js +19 -0
  37. data/public/assets/bootstrap/bootstrap.js.gz +0 -0
  38. data/public/assets/bootstrap/glyphicons-halflings-0e7ff93d8f48fe1f5f762e4312e78da7.png +0 -0
  39. data/public/assets/bootstrap/glyphicons-halflings-white-ef3d5b8d6a297804352b4a46fdb5466d.png +0 -0
  40. data/public/assets/bootstrap/glyphicons-halflings-white.png +0 -0
  41. data/public/assets/bootstrap/glyphicons-halflings.png +0 -0
  42. data/public/assets/file-58ce0b58f19dfe871b25270e98cff66c.gif +0 -0
  43. data/public/assets/file.gif +0 -0
  44. data/public/assets/folder-5c5b1fd2f1ece710f9159f05cc2aaaa8.gif +0 -0
  45. data/public/assets/folder-closed-8b61fc55011d534f0216c1150994f229.gif +0 -0
  46. data/public/assets/folder-closed.gif +0 -0
  47. data/public/assets/folder.gif +0 -0
  48. data/public/assets/html5-05e1be9157c8366db72fb7a1bcc8daff.js +3 -0
  49. data/public/assets/html5-05e1be9157c8366db72fb7a1bcc8daff.js.gz +0 -0
  50. data/public/assets/html5.js +3 -0
  51. data/public/assets/html5.js.gz +0 -0
  52. data/public/assets/iqvoc/ie_fixes-6a106c21d979ccdd1f6bf1cb129a0e69.css +1 -0
  53. data/public/assets/iqvoc/ie_fixes-6a106c21d979ccdd1f6bf1cb129a0e69.css.gz +0 -0
  54. data/public/assets/iqvoc/ie_fixes.css +1 -0
  55. data/public/assets/iqvoc/ie_fixes.css.gz +0 -0
  56. data/public/assets/iqvoc_logo-316859a511c646918fe75e92fa0bf6ac.png +0 -0
  57. data/public/assets/iqvoc_logo.png +0 -0
  58. data/public/assets/jquery-ui/ui-bg_flat_0_aaaaaa_40x100-a1eb3e0764573ed4b261ca742ed96ac3.png +0 -0
  59. data/public/assets/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  60. data/public/assets/jquery-ui/ui-bg_flat_55_fbec88_40x100-439ee8e6c8ce855f43ed4d7b90684720.png +0 -0
  61. data/public/assets/jquery-ui/ui-bg_flat_55_fbec88_40x100.png +0 -0
  62. data/public/assets/jquery-ui/ui-bg_glass_75_d0e5f5_1x400-9357836db77954d0d8c5feb259635223.png +0 -0
  63. data/public/assets/jquery-ui/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  64. data/public/assets/jquery-ui/ui-bg_glass_85_dfeffc_1x400-7beb11d1590fb2fb1ef5c754100a078a.png +0 -0
  65. data/public/assets/jquery-ui/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  66. data/public/assets/jquery-ui/ui-bg_glass_95_fef1ec_1x400-c723e9a2b50006c6054836a10b76bb84.png +0 -0
  67. data/public/assets/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  68. data/public/assets/jquery-ui/ui-bg_gloss-wave_55_5c9ccc_500x100-cb26f48ac4912c23ce301c69c474d306.png +0 -0
  69. data/public/assets/jquery-ui/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  70. data/public/assets/jquery-ui/ui-bg_inset-hard_100_f5f8f9_1x100-519299e2aa31bffdd4fed34b4fac603d.png +0 -0
  71. data/public/assets/jquery-ui/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  72. data/public/assets/jquery-ui/ui-bg_inset-hard_100_fcfdfd_1x100-27e08524d3d56bb59e354435b663c3ac.png +0 -0
  73. data/public/assets/jquery-ui/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  74. data/public/assets/jquery-ui/ui-icons_217bc0_256x240-ed26778199d8722ae064038a1e841bc8.png +0 -0
  75. data/public/assets/jquery-ui/ui-icons_217bc0_256x240.png +0 -0
  76. data/public/assets/jquery-ui/ui-icons_2e83ff_256x240-94086d0ce953eb0887ab1b8140903af9.png +0 -0
  77. data/public/assets/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
  78. data/public/assets/jquery-ui/ui-icons_469bdd_256x240-1c055f2d65517ef8faf1d1999c8ac2fa.png +0 -0
  79. data/public/assets/jquery-ui/ui-icons_469bdd_256x240.png +0 -0
  80. data/public/assets/jquery-ui/ui-icons_6da8d5_256x240-8f5b417c5604f1b7b5965c98754c33b9.png +0 -0
  81. data/public/assets/jquery-ui/ui-icons_6da8d5_256x240.png +0 -0
  82. data/public/assets/jquery-ui/ui-icons_cd0a0a_256x240-8b44e266bdc1f57f1393579591f89222.png +0 -0
  83. data/public/assets/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  84. data/public/assets/jquery-ui/ui-icons_d8e7f3_256x240-1b415e411069df902e6f417cc014172c.png +0 -0
  85. data/public/assets/jquery-ui/ui-icons_d8e7f3_256x240.png +0 -0
  86. data/public/assets/jquery-ui/ui-icons_f9bd01_256x240-4553d0576c0498ca4c776aa77aa80833.png +0 -0
  87. data/public/assets/jquery-ui/ui-icons_f9bd01_256x240.png +0 -0
  88. data/public/assets/json2-b08b7b9af3e715f42c088ac728f62a2b.js +157 -0
  89. data/public/assets/json2-b08b7b9af3e715f42c088ac728f62a2b.js.gz +0 -0
  90. data/public/assets/json2.js +157 -0
  91. data/public/assets/json2.js.gz +0 -0
  92. data/public/assets/manifest-3ce8edde69d5d291841ef7c49daaa9cb.js +21 -0
  93. data/public/assets/manifest-3ce8edde69d5d291841ef7c49daaa9cb.js.gz +0 -0
  94. data/public/assets/manifest-c0eca563fd9f16907d302af9a2dcae6b.css +51 -0
  95. data/public/assets/manifest-c0eca563fd9f16907d302af9a2dcae6b.css.gz +0 -0
  96. data/public/assets/manifest.css +51 -0
  97. data/public/assets/manifest.css.gz +0 -0
  98. data/public/assets/manifest.js +21 -0
  99. data/public/assets/manifest.js.gz +0 -0
  100. data/public/assets/manifest.yml +47 -0
  101. data/public/assets/minus-1d0fae0720bab52bd98598218e8345c0.gif +0 -0
  102. data/public/assets/minus.gif +0 -0
  103. data/public/assets/plus-1a29e46532f839ed9c977ef4613d079f.gif +0 -0
  104. data/public/assets/plus.gif +0 -0
  105. data/public/assets/spinner_16x16-17dcf941457ae4e702f4600e714b21c1.gif +0 -0
  106. data/public/assets/spinner_16x16.gif +0 -0
  107. data/public/assets/spinner_24x24-78c707c1921b93962ea5edd7f4a74134.gif +0 -0
  108. data/public/assets/spinner_24x24.gif +0 -0
  109. data/public/assets/treeview-black-c46d96020e5d79c652af0fb0c6656384.gif +0 -0
  110. data/public/assets/treeview-black-line-0903c58efd34c3203d132e6f873049f6.gif +0 -0
  111. data/public/assets/treeview-black-line.gif +0 -0
  112. data/public/assets/treeview-black.gif +0 -0
  113. data/public/assets/treeview-default-ee6298d311205d21dc57c01c0696df70.gif +0 -0
  114. data/public/assets/treeview-default-line-2c4106cfd4d322c6e6565f80702c27cb.gif +0 -0
  115. data/public/assets/treeview-default-line.gif +0 -0
  116. data/public/assets/treeview-default.gif +0 -0
  117. data/public/assets/treeview-famfamfam-20dfef13cd5fd1e08fb61ee68eb9d3fa.gif +0 -0
  118. data/public/assets/treeview-famfamfam-line-a02cce2b80977e066df83137aae71fa8.gif +0 -0
  119. data/public/assets/treeview-famfamfam-line.gif +0 -0
  120. data/public/assets/treeview-famfamfam.gif +0 -0
  121. data/public/assets/treeview-gray-01bfdcd116e081e23daf13024fd3e4e0.gif +0 -0
  122. data/public/assets/treeview-gray-line-029b3a7b92ed10ea6c4b6289cb9fa0e3.gif +0 -0
  123. data/public/assets/treeview-gray-line.gif +0 -0
  124. data/public/assets/treeview-gray.gif +0 -0
  125. data/public/assets/treeview-red-2a5abbce598d05c864d845998381eef6.gif +0 -0
  126. data/public/assets/treeview-red-line-f51e6c30aa3b0ff856900ba85d769f1c.gif +0 -0
  127. data/public/assets/treeview-red-line.gif +0 -0
  128. data/public/assets/treeview-red.gif +0 -0
  129. data/test/integration/alphabetical_test.rb +5 -7
  130. data/test/unit/hygiene_test.rb +0 -4
  131. data/test/unit/rdf_sync_test.rb +9 -12
  132. metadata +112 -4
  133. data/app/assets/javascripts/iqvoc/extract_concepts.js +0 -19
  134. data/app/assets/javascripts/iqvoc/onebox.js +0 -44
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [4.0.7]
2
+
3
+ * Added support for Sesame as triplestore synchronization target
4
+ * Ditched Ruby 1.8 API compatibility; iQvoc now requires Ruby 1.9+
5
+ * Improved instant search on front page
6
+
1
7
  ## 4.0.6
2
8
 
3
9
  * Bugfixes for Triplestore Sync and configuration
data/Gemfile.lock CHANGED
@@ -87,7 +87,7 @@ GEM
87
87
  iq_rdf (0.1.8)
88
88
  builder
89
89
  bundler
90
- iq_triplestorage (0.1.4)
90
+ iq_triplestorage (0.2.2)
91
91
  jdbc-mysql (5.1.13)
92
92
  jdbc-sqlite3 (3.7.2)
93
93
  journey (1.0.4)
@@ -1,5 +1,4 @@
1
1
  //= require iqvoc/iqvoc
2
- //= require iqvoc/extract_concepts
3
2
  //= require iqvoc/quicksearch
4
3
  //= require iqvoc/onebox
5
4
  //= require iqvoc/langselect
@@ -0,0 +1,81 @@
1
+ /*jslint vars: true, browser: true, white: true */
2
+ /*global jQuery, IQVOC */
3
+
4
+ IQVOC.onebox = (function($) {
5
+
6
+ "use strict";
7
+
8
+ function OneBox(form) {
9
+ this.form = form.jquery ? form : $(form);
10
+ this.input = $(".onebox-input", this.form); // TODO: document
11
+ this.container = this.form.removeClass("onebox").
12
+ wrap('<div class="onebox" />').parent(); // TODO: document
13
+ this.results = $('<ol class="results concepts unstyled" />');
14
+ this.spinner = $("<img />").
15
+ attr("src", "<%= asset_path('spinner_24x24.gif') %>").
16
+ appendTo(this.container).hide();
17
+
18
+ this.form.on("submit", $.proxy(this, "onSubmit"));
19
+ this.input.on("keyup", debounce($.proxy(this, "onInput"), 300));
20
+ }
21
+ OneBox.prototype.reset = function() {
22
+ this.container.children().not(this.form).not(this.spinner).remove();
23
+ };
24
+ OneBox.prototype.renderResults = function(html) {
25
+ var doc = $("<div />").append(html);
26
+ var items = $(".concepts > li", doc);
27
+ var pagination = $(".pagination", doc);
28
+
29
+ this.reset();
30
+ this.results.empty().append(items).appendTo(this.container);
31
+ pagination.appendTo(this.container);
32
+ };
33
+ OneBox.prototype.onSubmit = function(ev) {
34
+ ev.preventDefault(); // handled by #onInput
35
+ };
36
+ OneBox.prototype.onInput = function(ev) {
37
+ var val = this.input.val();
38
+ this.reset();
39
+ if(val.length > 0 && val !== this.initialValue) {
40
+ this.getConcepts();
41
+ }
42
+ };
43
+ OneBox.prototype.getConcepts = function() {
44
+ this.spinner.show();
45
+ $.ajax({
46
+ type: this.form.attr("method"),
47
+ url: this.form.attr("action"),
48
+ data: this.form.serialize(),
49
+ success: $.proxy(this, "onResults")
50
+ });
51
+ };
52
+ OneBox.prototype.onResults = function(html, status, xhr) {
53
+ // disable scripts (adapted from jQuery#load)
54
+ var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
55
+ html = html.replace(rscript, "");
56
+
57
+ this.spinner.hide();
58
+ this.renderResults(html);
59
+ };
60
+
61
+ return function(selector) {
62
+ return new OneBox(selector); // XXX: returning an instance of a private class seems weird
63
+ };
64
+
65
+ function debounce(fn, delay) { // TODO: move elsewhere
66
+ var timer;
67
+ return function() {
68
+ var self = this;
69
+ var args = arguments;
70
+ if(timer) {
71
+ clearTimeout(timer);
72
+ timer = null;
73
+ }
74
+ timer = setTimeout(function() {
75
+ fn.apply(self, args);
76
+ timer = null;
77
+ }, delay);
78
+ };
79
+ }
80
+
81
+ }(jQuery));
@@ -28,11 +28,29 @@ function getConcepts(req, callback) {
28
28
  url: form.attr("action"),
29
29
  data: form.serialize(),
30
30
  success: function(data, status, xhr) {
31
- callback(IQVOC.extractConcepts(data));
31
+ callback(extractConcepts(data));
32
32
  }
33
33
  });
34
34
  }
35
35
 
36
+ function extractConcepts(html) {
37
+ // disable scripts (adapted from jQuery's `load`)
38
+ var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
39
+ var html = html.replace(rscript, "");
40
+
41
+ var concepts = $("<div />").append(html).find("ol.concepts li");
42
+ concepts = concepts.map(function(i, node) {
43
+ var el = $("a", node);
44
+ return {
45
+ value: el.attr("href"),
46
+ label: $.trim(el.parent().text()).replace(/\s+/, " ")
47
+ };
48
+ });
49
+
50
+ return concepts.length ? Array.prototype.slice.call(concepts, 0) :
51
+ [{ value: null, label: "no matches" }]; // TODO: i18n
52
+ }
53
+
36
54
  return function(selector, options) {
37
55
  options = options ? $.extend(defaults, options) : defaults;
38
56
  $(selector).autocomplete(options);
@@ -18,11 +18,15 @@
18
18
  min-width: 60%;
19
19
  }
20
20
 
21
- ul {
21
+ ol {
22
22
  margin-left: 0;
23
23
  list-style: none;
24
24
  text-align: left;
25
25
  }
26
+
27
+ .pagination {
28
+ text-align: left;
29
+ }
26
30
  }
27
31
 
28
32
  tr.highlightable {
@@ -61,8 +65,10 @@ img.spinner {
61
65
  margin-top: 2px;
62
66
  }
63
67
 
64
- dt {
65
- margin-top: 10px;
68
+ dl {
69
+ dt {
70
+ margin-top: 10px;
71
+ }
66
72
  }
67
73
 
68
74
  .letter-selector {
@@ -106,3 +112,20 @@ dt {
106
112
  }
107
113
  }
108
114
  }
115
+
116
+ ol.concepts {
117
+ li {
118
+ margin-bottom: 15px;
119
+ p {
120
+ margin: 0;
121
+ }
122
+ p.term {
123
+ a {
124
+ font-weight: bold;
125
+ }
126
+ }
127
+ p.uri {
128
+ color: green;
129
+ }
130
+ }
131
+ }
@@ -35,7 +35,11 @@ class Concepts::AlphabeticalController < ConceptsController
35
35
 
36
36
  # When in single query mode, AR handles ALL includes to be loaded by that
37
37
  # one query. We don't want that! So let's do it manually :-)
38
- ActiveRecord::Associations::Preloader.new(@pref_labelings, :owner => Iqvoc::Concept.base_class.default_includes).run
38
+ includes = Iqvoc::Concept.base_class.default_includes
39
+ if Iqvoc::Concept.note_classes.include?(Note::SKOS::Definition)
40
+ includes << Note::SKOS::Definition.name.to_relation_name
41
+ end
42
+ ActiveRecord::Associations::Preloader.new(@pref_labelings, :owner => includes).run
39
43
  end
40
44
 
41
45
  end
@@ -50,12 +50,18 @@ class TriplestoreSyncController < ApplicationController
50
50
  def sync
51
51
  authorize! :use, :dashboard
52
52
 
53
- success = triplestore_syncer.all # XXX: long-running
53
+ flash[:error] = []
54
+ begin
55
+ success = triplestore_syncer.all # XXX: long-running
56
+ rescue => exc
57
+ success = false
58
+ flash[:error] << exc.message
59
+ end
54
60
 
55
61
  if success
56
62
  flash[:success] = I18n.t("txt.controllers.triplestore_sync.success")
57
63
  else
58
- flash[:error] = I18n.t("txt.controllers.triplestore_sync.error")
64
+ flash[:error] << I18n.t("txt.controllers.triplestore_sync.error")
59
65
  end
60
66
 
61
67
  redirect_to :action => "index"
@@ -1,6 +1,19 @@
1
1
  <li>
2
- <%= link_to pref_labeling.target.to_s, concept_path(:id => pref_labeling.owner), :alt => pref_labeling.owner.origin %>
3
- <%- if pref_labeling.owner.additional_info.present? -%>
4
- (<%= pref_labeling.owner.additional_info %>)
5
- <%- end -%>
2
+ <p class="term">
3
+ <%= link_to pref_labeling.target.to_s, concept_path(:id => pref_labeling.owner), :alt => pref_labeling.owner.origin %>
4
+ <% if pref_labeling.owner.additional_info.present? %>
5
+ (<%= pref_labeling.owner.additional_info %>)
6
+ <% end %>
7
+ </p>
8
+
9
+ <p class="uri"><%= rdf_url(:id => pref_labeling.owner.origin, :lang => nil, :format => nil) %></p>
10
+ <% if pref_labeling.owner.respond_to?(Note::SKOS::Definition.name.to_relation_name) &&
11
+ pref_labeling.owner.send(Note::SKOS::Definition.name.to_relation_name).any? %>
12
+ <% pref_labeling.owner.send(Note::SKOS::Definition.name.to_relation_name).each do |definition| %>
13
+ <p class="definition" lang="<%= definition.language %>">
14
+ <%= pref_labeling.owner.send(Note::SKOS::Definition.name.to_relation_name).first.value %>
15
+ </p>
16
+ <% end %>
17
+ <% end %>
18
+
6
19
  </li>
@@ -8,9 +8,9 @@
8
8
  <% alphabetical_concepts_path(:prefix => letter.to_s.downcase) %>
9
9
  <% end %>
10
10
  </div>
11
- <ul class="concepts">
11
+ <ol class="concepts unstyled">
12
12
  <%= render :partial => 'pref_labeling', :collection => @pref_labelings %>
13
- </ul>
13
+ </dl>
14
14
  </div>
15
15
 
16
16
  <%= paginate @pref_labelings %>
@@ -1,8 +1,7 @@
1
- <div class="onebox">
2
- <%= form_tag alphabetical_concepts_path(:prefix => nil), :method => :get do %>
3
- <%= search_field_tag "prefix", nil, :id => nil,
4
- :class => "onebox-input",
5
- :autofocus => true,
6
- :placeholder => t("txt.views.frontpage.type_to_browse") %>
7
- <% end %>
8
- </div>
1
+ <%= form_tag alphabetical_concepts_path(:prefix => nil), :method => :get,
2
+ :class => "onebox" do %>
3
+ <%= search_field_tag "prefix", nil, :id => nil,
4
+ :class => "onebox-input",
5
+ :autofocus => true,
6
+ :placeholder => t("txt.views.frontpage.type_to_browse") %>
7
+ <% end %>
data/config/boot.rb CHANGED
@@ -17,13 +17,6 @@
17
17
  require 'rubygems'
18
18
 
19
19
  # Set up gems listed in the Gemfile.
20
- gemfile = File.expand_path('../../Gemfile', __FILE__)
21
- begin
22
- ENV['BUNDLE_GEMFILE'] = gemfile
23
- require 'bundler'
24
- Bundler.setup
25
- rescue Bundler::GemNotFound => e
26
- STDERR.puts e.message
27
- STDERR.puts "Try running `bundle install`."
28
- exit!
29
- end if File.exist?(gemfile)
20
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
21
+
22
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
data/config/engine.rb CHANGED
@@ -29,6 +29,11 @@ module Iqvoc
29
29
  initializer "iqvoc.add_assets_to_precompilation" do |app|
30
30
  app.config.assets.precompile += Iqvoc.core_assets
31
31
  end
32
+
33
+ initializer "iqvoc.load_migrations" do |app|
34
+ # Pull in all the migrations to the application embedding iqvoc
35
+ app.config.paths['db/migrate'] += Iqvoc::Engine.paths['db/migrate'].existent
36
+ end
32
37
  end
33
38
 
34
39
  end
@@ -1,13 +1,13 @@
1
1
  class UseMonoHierarchyInsteadOfPolyHierarchy < ActiveRecord::Migration
2
2
  def self.up
3
3
  ActiveRecord::Base.transaction do
4
- Concept::Relation::Base.update_all("type = 'Concept::Relation::SKOS::Broader::Mono'", :type => 'Concept::Relation::SKOS::Broader::Poly')
4
+ execute "UPDATE concept_relations SET type = 'Concept::Relation::SKOS::Broader::Mono' WHERE type = 'Concept::Relation::SKOS::Broader::Poly'"
5
5
  end
6
6
  end
7
7
 
8
8
  def self.down
9
9
  ActiveRecord::Base.transaction do
10
- Concept::Relation::Base.update_all("type = 'Concept::Relation::SKOS::Broader::Poly'", :type => 'Concept::Relation::SKOS::Broader::Mono')
10
+ execute "UPDATE concept_relations SET type = 'Concept::Relation::SKOS::Broader::Poly' WHERE type = 'Concept::Relation::SKOS::Broader::Mono'"
11
11
  end
12
12
  end
13
13
  end
@@ -3,35 +3,22 @@ class SeparateNoteAnnotationPredicates < ActiveRecord::Migration
3
3
  rename_column :note_annotations, :identifier, :predicate
4
4
  add_column :note_annotations, :namespace, :string, :limit => 50
5
5
 
6
- total = Note::Annotated::Base.count
7
- i = 0
6
+ annotations = select_rows("SELECT id, predicate FROM note_annotations")
8
7
 
9
- puts "starting #{total} note annotation conversions..."
10
- reset = "\r" + "\e[0K" # adapted from http://snippets.dzone.com/posts/show/3760
11
-
12
- Note::Annotated::Base.find_each do |annotation|
13
- print "#{reset}#{i += 1} / #{total}"
14
-
15
- old_identifier = annotation.predicate
16
- namespace, predicate = old_identifier.split(":", 2)
17
- annotation.predicate = predicate
18
- annotation.namespace = namespace
19
- annotation.save!
20
-
21
- $stdout.flush
8
+ annotations.each do |annotation|
9
+ namespace, predicate = annotation[1].split(":", 2)
10
+ execute "UPDATE note_annotations SET namespace = '#{namespace}', predicate = '#{predicate}' WHERE id = #{annotation[0]}"
22
11
  end
23
-
24
- print "#{reset}"
25
- $stdout.flush
26
- puts "note annotation conversion complete"
27
12
  end
28
13
 
29
14
  def self.down
30
- Note::Annotated::Base.find_each do |annotation|
31
- identifier = [annotation.namespace, annotation.predicate].join(":")
32
- annotation.predicate = identifier
33
- annotation.save!
15
+ annotations = select_rows("SELECT id, predicate, namespace FROM note_annotations")
16
+
17
+ annotations.each do |annotation|
18
+ identifier = [annotation[2], annotation[1]].join(":")
19
+ execute "UPDATE note_annotations SET predicate = '#{identifier}' WHERE id = #{annotation[0]}"
34
20
  end
21
+
35
22
  rename_column :note_annotations, :predicate, :identifier
36
23
  remove_column :note_annotations, :namespace
37
24
  end
@@ -1,9 +1,9 @@
1
1
  class ChangeUmtNoteAnnotationsToDct < ActiveRecord::Migration
2
2
  def self.up
3
- Note::Annotated::Base.update_all({:namespace => "dct", :predicate => "creator"}, {:namespace => "umt", :predicate => "editor"})
3
+ execute "UPDATE note_annotations SET namespace = 'dct', predicate = 'creator' WHERE namespace = 'umt' AND predicate = 'editor'"
4
4
  end
5
5
 
6
6
  def self.down
7
- Note::Annotated::Base.update_all({:namespace => "umt", :predicate => "editor"}, {:namespace => "dct", :predicate => "creator"})
7
+ execute "UPDATE note_annotations SET namespace = 'umt', predicate = 'editor' WHERE namespace = 'dct' AND predicate = 'creator'"
8
8
  end
9
9
  end
@@ -1,27 +1,6 @@
1
1
  namespace :iqvoc do
2
2
  namespace :db do
3
3
 
4
- desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
5
- task :migrate => :environment do
6
- ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
7
- ActiveRecord::Migrator.migrate(Iqvoc::Engine.find_root_with_flag("db").join("db/migrate"), ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
8
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
9
- end
10
-
11
-
12
- desc "Migrate the database through all scripts in db/migrate of every engine and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
13
- task :migrate_all => :environment do
14
- ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
15
- paths = Rails.application.config.paths["db/migrate"].existent +
16
- Rails.application.railties.engines.
17
- map { |e| e.config.paths["db/migrate"] && e.config.paths["db/migrate"].existent }.
18
- flatten.compact
19
-
20
- puts "Migrating from: " + paths.join(", ")
21
- ActiveRecord::Migrator.migrate(paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
22
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
23
- end
24
-
25
4
  desc "Load seeds (task is idempotent)"
26
5
  task :seed => :environment do
27
6
  Iqvoc::Engine.load_seed
@@ -1,15 +1,27 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'iq_triplestorage/virtuoso_adaptor'
4
-
5
3
  class Iqvoc::RDFSync
6
4
  delegate :url_helpers, :to => "Rails.application.routes"
7
5
 
8
- def initialize(base_url, target_host, *args)
6
+ ADAPTORS = { # XXX: inappropriate?
7
+ "virtuoso" => lambda do |host_url, options|
8
+ require 'iq_triplestorage/virtuoso_adaptor'
9
+ return IqTriplestorage::VirtuosoAdaptor.new(host_url, options)
10
+ end,
11
+ "sesame" => lambda do |host_url, options|
12
+ require 'iq_triplestorage/sesame_adaptor'
13
+ host_url, _, repo = host_url.rpartition("/repositories/")
14
+ if host_url.blank? || repo.blank?
15
+ raise ArgumentError, "missing repository in Sesame URL"
16
+ end
17
+ options[:repository] = repo
18
+ return IqTriplestorage::SesameAdaptor.new(host_url, options)
19
+ end
20
+ }
21
+
22
+ def initialize(base_url, target_url, options)
9
23
  @base_url = base_url
10
- @target_host = target_host
11
- options = args.extract_options!
12
- @target_port = options[:port]
24
+ @target_url = target_url
13
25
  @username = options[:username]
14
26
  @password = options[:password]
15
27
  @batch_size = options[:batch_size] || 100
@@ -50,8 +62,9 @@ class Iqvoc::RDFSync
50
62
  memo
51
63
  end
52
64
 
53
- adaptor = IqTriplestorage::VirtuosoAdaptor.new(@target_host, @target_port,
54
- @username, @password)
65
+ adaptor_type = "sesame" # XXX: hard-coded
66
+ adaptor = ADAPTORS[adaptor_type].call(@target_url, :username => @username,
67
+ :password => @password)
55
68
  return adaptor.batch_update(data)
56
69
  end
57
70
 
@@ -97,12 +110,7 @@ module Iqvoc::RDFSync::Helper # TODO: rename -- XXX: does not belong here!?
97
110
  def triplestore_syncer
98
111
  base_url = root_url(:lang => nil) # XXX: brittle in the face of future changes?
99
112
 
100
- host = URI.parse(Iqvoc.config["triplestore.url"])
101
- port = host.port
102
- host.port = 80 # XXX: hack to remove port from serialization
103
- host = host.to_s
104
-
105
- return Iqvoc::RDFSync.new(base_url, host, :port => port,
113
+ return Iqvoc::RDFSync.new(base_url, Iqvoc.config["triplestore.url"],
106
114
  :username => Iqvoc.config["triplestore.username"].presence,
107
115
  :password => Iqvoc.config["triplestore.password"].presence,
108
116
  :view_context => view_context) # fugly, but necessary; cf. RDFSync#serialize
data/lib/iqvoc/version.rb CHANGED
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module Iqvoc
18
- VERSION = "4.0.6"
18
+ VERSION = "4.0.7"
19
19
  end
Binary file
Binary file
Binary file