iqvoc_skosxl 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/Gemfile +40 -0
  2. data/Gemfile.lock +154 -0
  3. data/README.md +26 -0
  4. data/Rakefile +11 -0
  5. data/app/assets/javascripts/iqvoc_skosxl/manifest.js +0 -0
  6. data/app/assets/javascripts/manifest.js +3 -0
  7. data/app/assets/stylesheets/iqvoc_skosxl/manifest.css +0 -0
  8. data/app/assets/stylesheets/manifest.css +5 -0
  9. data/app/controllers/labels/versions_controller.rb +109 -0
  10. data/app/controllers/labels_controller.rb +130 -0
  11. data/app/controllers/rdf_controller.rb +23 -0
  12. data/app/helpers/iqvoc_skosxl_helper.rb +18 -0
  13. data/app/helpers/labels_helper.rb +68 -0
  14. data/app/models/concept/skosxl/extension.rb +62 -0
  15. data/app/models/label/relation/base.rb +54 -0
  16. data/app/models/label/relation/skosxl/base.rb +12 -0
  17. data/app/models/label/skosxl/base.rb +219 -0
  18. data/app/models/labeling/skosxl/alt_label.rb +8 -0
  19. data/app/models/labeling/skosxl/base.rb +75 -0
  20. data/app/models/labeling/skosxl/hidden_label.rb +12 -0
  21. data/app/models/labeling/skosxl/pref_label.rb +12 -0
  22. data/app/views/labels/_base_data.html.erb +62 -0
  23. data/app/views/labels/_change_note.html.erb +46 -0
  24. data/app/views/labels/_details.html.erb +6 -0
  25. data/app/views/labels/_label_relation.html.erb +7 -0
  26. data/app/views/labels/_labeling.html.erb +3 -0
  27. data/app/views/labels/_note.html.erb +33 -0
  28. data/app/views/labels/_show_head.html.erb +22 -0
  29. data/app/views/labels/_value_and_language.html.erb +9 -0
  30. data/app/views/labels/edit.html.erb +22 -0
  31. data/app/views/labels/new.html.erb +3 -0
  32. data/app/views/labels/show.ttl.erb +1 -0
  33. data/app/views/labels/show_published.html.erb +13 -0
  34. data/app/views/labels/show_unpublished.html.erb +36 -0
  35. data/app/views/partials/label/relation/_base.html.erb +9 -0
  36. data/app/views/partials/label/relation/_edit_base.html.erb +13 -0
  37. data/app/views/partials/label/skosxl/_edit_link_base.html.erb +1 -0
  38. data/app/views/partials/label/skosxl/_new_link_base.html.erb +7 -0
  39. data/app/views/partials/labeling/skosxl/_base.html.erb +19 -0
  40. data/app/views/partials/labeling/skosxl/_edit_base.html.erb +15 -0
  41. data/app/views/partials/labeling/skosxl/_search_result.html.erb +9 -0
  42. data/app/views/rdf/show_label.iqrdf +5 -0
  43. data/config/application.rb +56 -0
  44. data/config/boot.rb +13 -0
  45. data/config/database.template.yml +38 -0
  46. data/config/database.yml +36 -0
  47. data/config/engine.rb +13 -0
  48. data/config/environment.rb +5 -0
  49. data/config/environments/development.rb +55 -0
  50. data/config/environments/production.rb +64 -0
  51. data/config/environments/test.rb +44 -0
  52. data/config/initializers/iqvoc.rb +4 -0
  53. data/config/initializers/iqvoc_skosxl.rb +1 -0
  54. data/config/initializers/secret_token.rb.template +9 -0
  55. data/config/initializers/session_store.rb +8 -0
  56. data/config/locales/activerecord.de.yml +18 -0
  57. data/config/locales/activerecord.en.yml +18 -0
  58. data/config/locales/de.yml +5 -0
  59. data/config/locales/en.yml +5 -0
  60. data/config/routes.rb +15 -0
  61. data/db/migrate/20110408121540_extend_label.rb +37 -0
  62. data/db/migrate/20110408123644_add_label_relations.rb +24 -0
  63. data/db/schema.rb +146 -0
  64. data/db/seeds.rb +0 -0
  65. data/iqvoc_skosxl.gemspec +22 -0
  66. data/lib/engine_tasks/db.rake +19 -0
  67. data/lib/iqvoc/skosxl/version.rb +5 -0
  68. data/lib/iqvoc/xllabel.rb +60 -0
  69. data/lib/iqvoc_skosxl.rb +22 -0
  70. data/test/factories.rb +23 -0
  71. data/test/integration/concept_label_language_test.rb +95 -0
  72. data/test/integration/dashboard_test.rb +29 -0
  73. data/test/integration/edit_labels_test.rb +26 -0
  74. data/test/integration/labels_order_test.rb +27 -0
  75. data/test/integration_test_helper.rb +27 -0
  76. data/test/test_helper.rb +15 -0
  77. data/test/unit/label_test.rb +30 -0
  78. metadata +154 -0
data/Gemfile ADDED
@@ -0,0 +1,40 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rails', '3.1.3'
4
+ gem 'iqvoc', '~> 3.3.2' #, :path => '../iqvoc'
5
+
6
+ group :development do
7
+ gem 'awesome_print'
8
+ end
9
+
10
+ group :assets do
11
+ gem 'uglifier'
12
+ end
13
+
14
+ group :development, :test do
15
+ platforms :ruby do
16
+ gem 'mysql2'
17
+ gem 'sqlite3'
18
+ end
19
+ platforms :jruby do
20
+ gem 'activerecord-jdbcsqlite-adapter'
21
+ gem 'activerecord-jdbcmysql-adapter'
22
+ end
23
+ end
24
+
25
+ group :test do
26
+ gem 'nokogiri', '~> 1.5.0'
27
+ gem 'capybara'
28
+ gem 'database_cleaner'
29
+ gem 'factory_girl_rails'
30
+ end
31
+
32
+ group :production, :production_internal do
33
+ platforms :ruby do
34
+ gem 'sqlite3'
35
+ end
36
+
37
+ platforms :jruby do
38
+ gem 'activerecord-oracle_enhanced-adapter'
39
+ end
40
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,154 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.3)
5
+ actionpack (= 3.1.3)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.3)
8
+ activemodel (= 3.1.3)
9
+ activesupport (= 3.1.3)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.5)
14
+ rack-cache (~> 1.1)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.3)
18
+ activemodel (3.1.3)
19
+ activesupport (= 3.1.3)
20
+ builder (~> 3.0.0)
21
+ i18n (~> 0.6)
22
+ activerecord (3.1.3)
23
+ activemodel (= 3.1.3)
24
+ activesupport (= 3.1.3)
25
+ arel (~> 2.2.1)
26
+ tzinfo (~> 0.3.29)
27
+ activeresource (3.1.3)
28
+ activemodel (= 3.1.3)
29
+ activesupport (= 3.1.3)
30
+ activesupport (3.1.3)
31
+ multi_json (~> 1.0)
32
+ arel (2.2.1)
33
+ authlogic (3.1.0)
34
+ activerecord (>= 3.0.7)
35
+ activerecord (>= 3.0.7)
36
+ awesome_print (1.0.2)
37
+ builder (3.0.0)
38
+ cancan (1.6.7)
39
+ capybara (1.1.2)
40
+ mime-types (>= 1.16)
41
+ nokogiri (>= 1.3.3)
42
+ rack (>= 1.0.0)
43
+ rack-test (>= 0.5.4)
44
+ selenium-webdriver (~> 2.0)
45
+ xpath (~> 0.1.4)
46
+ childprocess (0.2.6)
47
+ ffi (~> 1.0.6)
48
+ database_cleaner (0.7.0)
49
+ erubis (2.7.0)
50
+ execjs (1.2.13)
51
+ multi_json (~> 1.0)
52
+ factory_girl (2.3.2)
53
+ activesupport
54
+ factory_girl_rails (1.4.0)
55
+ factory_girl (~> 2.3.0)
56
+ railties (>= 3.0.0)
57
+ ffi (1.0.11)
58
+ hike (1.2.1)
59
+ i18n (0.6.0)
60
+ iq_rdf (0.1.0)
61
+ builder
62
+ bundler
63
+ iqvoc (3.3.2)
64
+ authlogic
65
+ bundler
66
+ cancan
67
+ iq_rdf (~> 0.1.0)
68
+ json
69
+ kaminari
70
+ rails (~> 3.1.3)
71
+ rails_autolink
72
+ json (1.6.4)
73
+ kaminari (0.13.0)
74
+ actionpack (>= 3.0.0)
75
+ activesupport (>= 3.0.0)
76
+ railties (>= 3.0.0)
77
+ mail (2.3.0)
78
+ i18n (>= 0.4.0)
79
+ mime-types (~> 1.16)
80
+ treetop (~> 1.4.8)
81
+ mime-types (1.17.2)
82
+ multi_json (1.0.4)
83
+ mysql2 (0.3.11)
84
+ nokogiri (1.5.0)
85
+ polyglot (0.3.3)
86
+ rack (1.3.6)
87
+ rack-cache (1.1)
88
+ rack (>= 0.4)
89
+ rack-mount (0.8.3)
90
+ rack (>= 1.0.0)
91
+ rack-ssl (1.3.2)
92
+ rack
93
+ rack-test (0.6.1)
94
+ rack (>= 1.0)
95
+ rails (3.1.3)
96
+ actionmailer (= 3.1.3)
97
+ actionpack (= 3.1.3)
98
+ activerecord (= 3.1.3)
99
+ activeresource (= 3.1.3)
100
+ activesupport (= 3.1.3)
101
+ bundler (~> 1.0)
102
+ railties (= 3.1.3)
103
+ rails_autolink (1.0.4)
104
+ rails (>= 3.1.0)
105
+ railties (3.1.3)
106
+ actionpack (= 3.1.3)
107
+ activesupport (= 3.1.3)
108
+ rack-ssl (~> 1.3.2)
109
+ rake (>= 0.8.7)
110
+ rdoc (~> 3.4)
111
+ thor (~> 0.14.6)
112
+ rake (0.9.2.2)
113
+ rdoc (3.12)
114
+ json (~> 1.4)
115
+ rubyzip (0.9.5)
116
+ selenium-webdriver (2.16.0)
117
+ childprocess (>= 0.2.5)
118
+ ffi (~> 1.0.9)
119
+ multi_json (~> 1.0.4)
120
+ rubyzip
121
+ sprockets (2.0.3)
122
+ hike (~> 1.2)
123
+ rack (~> 1.0)
124
+ tilt (~> 1.1, != 1.3.0)
125
+ sqlite3 (1.3.5)
126
+ thor (0.14.6)
127
+ tilt (1.3.3)
128
+ treetop (1.4.10)
129
+ polyglot
130
+ polyglot (>= 0.3.1)
131
+ tzinfo (0.3.31)
132
+ uglifier (1.2.1)
133
+ execjs (>= 0.3.0)
134
+ multi_json (>= 1.0.2)
135
+ xpath (0.1.4)
136
+ nokogiri (~> 1.3)
137
+
138
+ PLATFORMS
139
+ ruby
140
+
141
+ DEPENDENCIES
142
+ activerecord-jdbcmysql-adapter
143
+ activerecord-jdbcsqlite-adapter
144
+ activerecord-oracle_enhanced-adapter
145
+ awesome_print
146
+ capybara
147
+ database_cleaner
148
+ factory_girl_rails
149
+ iqvoc (~> 3.3.2)
150
+ mysql2
151
+ nokogiri (~> 1.5.0)
152
+ rails (= 3.1.3)
153
+ sqlite3
154
+ uglifier
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Iqvoc::SKOSXL
2
+
3
+ This is the iQvoc SKOS-XL extension. Use this in your Gemfile to add SKOS-XL features to iQvoc.
4
+
5
+ Iqvoc::SKOSXL may run in two different modes: Standalone as Application and embedded into another Application as Engine.
6
+
7
+ ## Standalone Application
8
+
9
+ Operate Iqvoc::SKOSXL like a common iQvoc-based Application.
10
+
11
+ 1. Run database migrations:
12
+ `rake iqvoc:db:migrate_all`
13
+ 2. Populate iQvoc seeds:
14
+ `rake iqvoc:db:seed_all`
15
+ 3. Generate secret token:
16
+ `rake iqvoc:setup:generate_secret_token`
17
+
18
+ ## Engine
19
+
20
+ Operate Iqvoc::SKOSXL and Iqvoc as Engines running in a custom App.
21
+
22
+ 1. Add iqvoc_skosxl to your Gemfile (beneath iqvoc)
23
+ 2. Run Iqvoc migrations:
24
+ `rake iqvoc:db:migrate_all`
25
+ 3. Populate Iqvoc seeds:
26
+ `rake iqvoc:db:seed_all`
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ Iqvoc::SKOSXL::Application.load_tasks
8
+
9
+ require 'bundler'
10
+ Bundler::GemHelper.install_tasks
11
+
File without changes
@@ -0,0 +1,3 @@
1
+ //= require framework
2
+ //= require iqvoc/manifest
3
+ //= require iqvoc_skosxl/manifest
File without changes
@@ -0,0 +1,5 @@
1
+ /*
2
+ *= require framework
3
+ *= require iqvoc/manifest
4
+ *= require iqvoc_skosxl/manifest
5
+ */
@@ -0,0 +1,109 @@
1
+ class Labels::VersionsController < ApplicationController
2
+
3
+ def merge
4
+ current_label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).published.last
5
+ new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
6
+ raise ActiveRecord::RecordNotFound.new("Couldn't find unpublished label with origin '#{params[:origin]}'") unless new_version
7
+ authorize! :merge, new_version
8
+
9
+ ActiveRecord::Base.transaction do
10
+ if current_label.blank? || current_label.destroy
11
+ new_version.publish
12
+ new_version.unlock
13
+ if new_version.valid_with_full_validation?
14
+ new_version.save
15
+ begin
16
+ # TODO if RdfStore.update(new_version.rdf_uri, label_url(:id => new_version, :format => :ttl))
17
+ # new_version.update_attribute(:rdf_updated_at, 1.seconds.since)
18
+ # end
19
+ rescue Exception => e
20
+ handle_virtuoso_exception(e.message)
21
+ end
22
+ if new_version.has_concept_or_label_relations?
23
+ flash[:notice] = t("txt.controllers.versioning.published")
24
+ redirect_to label_path(:id => new_version)
25
+ else
26
+ flash[:error] = t("txt.controllers.versioning.published_with_warning")
27
+ redirect_to label_path(:id => new_version)
28
+ end
29
+ else
30
+ flash[:error] = t("txt.controllers.versioning.merged_publishing_error")
31
+ redirect_to label_path(:published => 0, :id => new_version)
32
+ end
33
+ else
34
+ flash[:error] = t("txt.controllers.versioning.merged_delete_error")
35
+ redirect_to label_path(:published => 0, :id => new_version)
36
+ end
37
+ end
38
+ end
39
+
40
+ def branch
41
+ current_label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).published.last
42
+ raise ActiveRecord::RecordNotFound.new("Couldn't find published Label with origin '#{params[:origin]}'") unless current_label
43
+ raise "There is already an unpublished version for Label '#{params[:origin]}'" if Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
44
+ authorize! :branch, current_label
45
+ new_version = nil
46
+ ActiveRecord::Base.transaction do
47
+ new_version = current_label.branch(current_user)
48
+ new_version.save!
49
+ end
50
+ flash[:notice] = t("txt.controllers.versioning.branched")
51
+ redirect_to edit_label_path(:published => 0, :id => new_version, :check_associations_in_editing_mode => true)
52
+ end
53
+
54
+ def lock
55
+ new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
56
+ raise ActiveRecord::RecordNotFound.new("Couldn't find unpublished Label with origin '#{params[:origin]}'") unless new_version
57
+ raise "Label with origin '#{params[:origin]}' has already been locked." if new_version.locked?
58
+
59
+ authorize! :lock, new_version
60
+
61
+ new_version.lock_by_user(current_user.id)
62
+ new_version.save!
63
+
64
+ flash[:notice] = t("txt.controllers.versioning.locked")
65
+ redirect_to edit_label_path(:published => 0, :id => new_version)
66
+ end
67
+
68
+ def unlock
69
+ new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
70
+ raise ActiveRecord::RecordNotFound.new("Couldn't find unpublished Label with origin '#{params[:origin]}'") unless new_version
71
+ raise "Label with origin '#{params[:origin]}' wasn't locked." unless new_version.locked?
72
+
73
+ authorize! :unlock, new_version
74
+
75
+ new_version.unlock
76
+ new_version.save!
77
+
78
+ flash[:notice] = t("txt.controllers.versioning.unlocked")
79
+ redirect_to label_path(:published => 0, :id => new_version)
80
+ end
81
+
82
+ def consistency_check
83
+ label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
84
+ raise ActiveRecord::RecordNotFound unless label
85
+
86
+ authorize! :check_consistency, label
87
+
88
+ if label.valid_with_full_validation?
89
+ flash[:notice] = t("txt.controllers.versioning.consistency_check_success")
90
+ redirect_to label_path(:published => 0, :id => label)
91
+ else
92
+ flash[:error] = t("txt.controllers.versioning.consistency_check_error")
93
+ redirect_to edit_label_path(:published => 0, :id => label, :full_consistency_check => 1)
94
+ end
95
+ end
96
+
97
+ def to_review
98
+ label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
99
+ raise ActiveRecord::RecordNotFound unless label
100
+
101
+ authorize! :send_to_review, label
102
+
103
+ label.to_review
104
+ label.save!
105
+ flash[:notice] = t("txt.controllers.versioning.to_review_success")
106
+ redirect_to label_path(:published => 0, :id => label)
107
+ end
108
+
109
+ end
@@ -0,0 +1,130 @@
1
+ class LabelsController < ApplicationController
2
+ skip_before_filter :require_user
3
+
4
+ def index
5
+ authorize! :read, Iqvoc::XLLabel.base_class
6
+
7
+ scope = Iqvoc::XLLabel.base_class.by_query_value("#{params[:query]}%")
8
+ if params[:language] # NB: this is not the same as :lang, which is supplied via route
9
+ scope = scope.by_language(params[:language])
10
+ end
11
+ @labels = scope.published.order("LOWER(value)").all
12
+
13
+ respond_to do |format|
14
+ format.html do
15
+ redirect_to :action => "index", :format => "txt"
16
+ end
17
+ format.text do
18
+ render :content_type => "text/plain",
19
+ :text => @labels.map { |label| "#{label.origin}: #{label.value}" }.join("\n")
20
+ end
21
+ format.json do
22
+ response = []
23
+ @labels.each { |label| response << label_widget_data(label) }
24
+
25
+ render :json => response
26
+ end
27
+ end
28
+ end
29
+
30
+ def show
31
+ if params[:published] == '1' || !params[:published]
32
+ published = true
33
+ @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).published.last
34
+ @new_label_version = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
35
+ elsif params[:published] == '0'
36
+ published = false
37
+ @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
38
+ end
39
+
40
+ raise ActiveRecord::RecordNotFound unless @label
41
+ authorize! :read, @label
42
+
43
+ respond_to do |format|
44
+ format.html do
45
+ published ? render('show_published') : render('show_unpublished')
46
+ end
47
+ format.ttl
48
+ end
49
+ end
50
+
51
+ def new
52
+ authorize! :create, Iqvoc::XLLabel.base_class
53
+ raise "You have to specify a language parameter!" if params[:language].blank?
54
+ data = {:language => params[:language]}
55
+ data.merge(:value => params[:value]) if params[:value]
56
+ @label = Iqvoc::XLLabel.base_class.new(data)
57
+ end
58
+
59
+ def create
60
+ authorize! :create, Iqvoc::XLLabel.base_class
61
+ @label = Iqvoc::XLLabel.base_class.new(params[:label])
62
+ @label.origin = OriginMapping.merge(@label.value)
63
+ if @label.valid?
64
+ if @label.save
65
+ flash[:notice] = I18n.t("txt.controllers.versioned_label.success")
66
+ redirect_to label_path(:published => 0, :id => @label.origin)
67
+ else
68
+ flash.now[:error] = I18n.t("txt.controllers.versioned_label.error")
69
+ render :new
70
+ end
71
+ else
72
+ flash.now[:error] = I18n.t("txt.controllers.versioned_label.error")
73
+ render :new
74
+ end
75
+ end
76
+
77
+ def edit
78
+ @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
79
+ raise ActiveRecord::RecordNotFound unless @label
80
+ authorize! :update, @label
81
+
82
+ if params[:check_associations_in_editing_mode]
83
+ @association_objects_in_editing_mode = @label.associated_objects_in_editing_mode
84
+ end
85
+
86
+ # @pref_labelings = PrefLabeling.by_label(@label).all(:include => {:owner => :pref_labels}).sort
87
+ # @alt_labelings = AltLabeling.by_label(@label).all(:include => {:owner => :pref_labels}).sort
88
+
89
+ if params[:full_consistency_check]
90
+ @label.valid_with_full_validation?
91
+ end
92
+
93
+ Iqvoc::XLLabel.note_class_names.each do |note_class_name|
94
+ @label.send(note_class_name.to_relation_name).build if @label.send(note_class_name.to_relation_name).empty?
95
+ end
96
+ end
97
+
98
+ def update
99
+ @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
100
+ raise ActiveRecord::RecordNotFound unless @label
101
+ authorize! :update, @label
102
+
103
+ respond_to do |format|
104
+ format.html do
105
+ raise ActiveRecord::RecordNotFound unless @label
106
+ if @label.update_attributes(params[:label])
107
+ flash[:notice] = I18n.t("txt.controllers.versioned_label.update_success")
108
+ redirect_to label_path(:published => 0, :id => @label)
109
+ else
110
+ flash.now[:error] = I18n.t("txt.controllers.versioned_label.update_error")
111
+ render :action => :edit
112
+ end
113
+ end
114
+ end
115
+ end
116
+
117
+ def destroy
118
+ @new_label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
119
+ raise ActiveRecord::RecordNotFound unless @new_label
120
+ authorize! :destroy, @new_label
121
+
122
+ if @new_label.destroy
123
+ flash[:notice] = I18n.t("txt.controllers.label_versions.delete")
124
+ redirect_to dashboard_path
125
+ else
126
+ flash[:notice] = I18n.t("txt.controllers.label_versions.delete_error")
127
+ redirect_to label_path(:published => 0, :id => @new_label)
128
+ end
129
+ end
130
+ end