ld4l_virtual_collection 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +34 -0
  3. data/.travis.yml +14 -0
  4. data/CHANGES.md +12 -0
  5. data/Gemfile +5 -0
  6. data/LICENSE.txt +14 -0
  7. data/README.md +128 -0
  8. data/Rakefile +34 -0
  9. data/app/assets/images/ld4l_virtual_collection/loading_spinner.gif +0 -0
  10. data/app/assets/javascripts/ld4l_virtual_collection/application.js +19 -0
  11. data/app/assets/javascripts/ld4l_virtual_collection/collections.js +2 -0
  12. data/app/assets/javascripts/ld4l_virtual_collection/items.js +2 -0
  13. data/app/assets/stylesheets/ld4l_virtual_collection/_bootstrap-custom.scss +50 -0
  14. data/app/assets/stylesheets/ld4l_virtual_collection/application.css.scss +22 -0
  15. data/app/assets/stylesheets/ld4l_virtual_collection/collections.css.scss +4 -0
  16. data/app/assets/stylesheets/ld4l_virtual_collection/items.css.scss +4 -0
  17. data/app/assets/stylesheets/ld4l_virtual_collection/my_virtual_collections.css.scss +4 -0
  18. data/app/assets/stylesheets/scaffold.css +56 -0
  19. data/app/controllers/ld4l_virtual_collection/application_controller.rb +9 -0
  20. data/app/controllers/ld4l_virtual_collection/collections_controller.rb +101 -0
  21. data/app/controllers/ld4l_virtual_collection/items_controller.rb +94 -0
  22. data/app/controllers/ld4l_virtual_collection/my_virtual_collections_controller.rb +189 -0
  23. data/app/controllers/ld4l_virtual_collection/notes_controller.rb +84 -0
  24. data/app/controllers/ld4l_virtual_collection/tags_controller.rb +105 -0
  25. data/app/helpers/ld4l_virtual_collection/application_helper.rb +4 -0
  26. data/app/helpers/ld4l_virtual_collection/collections_helper.rb +4 -0
  27. data/app/helpers/ld4l_virtual_collection/items_helper.rb +4 -0
  28. data/app/models/ld4l_virtual_collection/collection.rb +47 -0
  29. data/app/models/ld4l_virtual_collection/item.rb +50 -0
  30. data/app/models/ld4l_virtual_collection/note.rb +52 -0
  31. data/app/models/ld4l_virtual_collection/tag.rb +94 -0
  32. data/app/views/layouts/ld4l_virtual_collection/application.html.erb +14 -0
  33. data/app/views/ld4l_virtual_collection/collections/_form.html.erb +28 -0
  34. data/app/views/ld4l_virtual_collection/collections/edit.html.erb +13 -0
  35. data/app/views/ld4l_virtual_collection/collections/index.html.erb +30 -0
  36. data/app/views/ld4l_virtual_collection/collections/new.html.erb +12 -0
  37. data/app/views/ld4l_virtual_collection/collections/show.html.erb +43 -0
  38. data/app/views/ld4l_virtual_collection/items/_collection_info.html.erb +14 -0
  39. data/app/views/ld4l_virtual_collection/items/_form.html.erb +25 -0
  40. data/app/views/ld4l_virtual_collection/items/edit.html.erb +14 -0
  41. data/app/views/ld4l_virtual_collection/items/index.html.erb +24 -0
  42. data/app/views/ld4l_virtual_collection/items/new.html.erb +14 -0
  43. data/app/views/ld4l_virtual_collection/items/show.html.erb +23 -0
  44. data/app/views/ld4l_virtual_collection/my_virtual_collections/_collection_lists.html.erb +82 -0
  45. data/app/views/ld4l_virtual_collection/my_virtual_collections/_edit_collection_modal.html.erb +20 -0
  46. data/app/views/ld4l_virtual_collection/my_virtual_collections/_form_collection.html.erb +51 -0
  47. data/app/views/ld4l_virtual_collection/my_virtual_collections/_form_collection_item.html.erb +48 -0
  48. data/app/views/ld4l_virtual_collection/my_virtual_collections/_form_collection_items_query.html.erb +37 -0
  49. data/app/views/ld4l_virtual_collection/my_virtual_collections/_form_item_note.html.erb +31 -0
  50. data/app/views/ld4l_virtual_collection/my_virtual_collections/_form_item_tag.html.erb +30 -0
  51. data/app/views/ld4l_virtual_collection/my_virtual_collections/_modals.html.erb +8 -0
  52. data/app/views/ld4l_virtual_collection/my_virtual_collections/_new_collection_item_modal.html.erb +20 -0
  53. data/app/views/ld4l_virtual_collection/my_virtual_collections/_new_collection_items_by_query_modal.html.erb +20 -0
  54. data/app/views/ld4l_virtual_collection/my_virtual_collections/_new_collection_modal.html.erb +20 -0
  55. data/app/views/ld4l_virtual_collection/my_virtual_collections/_selected_collection_header.html.erb +17 -0
  56. data/app/views/ld4l_virtual_collection/my_virtual_collections/_selected_collection_items.html.erb +121 -0
  57. data/app/views/ld4l_virtual_collection/my_virtual_collections/_selected_collection_range.html.erb +44 -0
  58. data/app/views/ld4l_virtual_collection/my_virtual_collections/edit_collection_modal.js.erb +1 -0
  59. data/app/views/ld4l_virtual_collection/my_virtual_collections/index.html.erb +4 -0
  60. data/app/views/ld4l_virtual_collection/my_virtual_collections/new_collection_item_modal.js.erb +1 -0
  61. data/app/views/ld4l_virtual_collection/my_virtual_collections/new_collection_items_by_query_modal.js.erb +1 -0
  62. data/app/views/ld4l_virtual_collection/my_virtual_collections/new_collection_modal.js.erb +1 -0
  63. data/app/views/ld4l_virtual_collection/my_virtual_collections/show.html.erb +14 -0
  64. data/bin/rails +12 -0
  65. data/config/routes.rb +16 -0
  66. data/ld4l_virtual_collection.gemspec +50 -0
  67. data/lib/ld4l_virtual_collection.rb +34 -0
  68. data/lib/ld4l_virtual_collection/configuration.rb +86 -0
  69. data/lib/ld4l_virtual_collection/engine.rb +23 -0
  70. data/lib/ld4l_virtual_collection/version.rb +3 -0
  71. data/lib/tasks/ld4l_virtual_collection_tasks.rake +4 -0
  72. data/test/controllers/ld4l_virtual_collection/collections_controller_test.rb +51 -0
  73. data/test/controllers/ld4l_virtual_collection/items_controller_test.rb +51 -0
  74. data/test/controllers/ld4l_virtual_collection/my_virtual_collections_controller_test.rb +51 -0
  75. data/test/controllers/ld4l_virtual_collection/virtual_collections_controller_test.rb +51 -0
  76. data/test/dummy/Gemfile +20 -0
  77. data/test/dummy/README.rdoc +28 -0
  78. data/test/dummy/Rakefile +6 -0
  79. data/test/dummy/app/assets/images/.keep +0 -0
  80. data/test/dummy/app/assets/javascripts/application.js +13 -0
  81. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  82. data/test/dummy/app/controllers/application_controller.rb +5 -0
  83. data/test/dummy/app/controllers/concerns/.keep +0 -0
  84. data/test/dummy/app/helpers/application_helper.rb +2 -0
  85. data/test/dummy/app/mailers/.keep +0 -0
  86. data/test/dummy/app/models/.keep +0 -0
  87. data/test/dummy/app/models/concerns/.keep +0 -0
  88. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  89. data/test/dummy/bin/bundle +3 -0
  90. data/test/dummy/bin/rails +4 -0
  91. data/test/dummy/bin/rake +4 -0
  92. data/test/dummy/config.ru +4 -0
  93. data/test/dummy/config/application.rb +23 -0
  94. data/test/dummy/config/boot.rb +5 -0
  95. data/test/dummy/config/database.yml +25 -0
  96. data/test/dummy/config/environment.rb +5 -0
  97. data/test/dummy/config/environments/development.rb +37 -0
  98. data/test/dummy/config/environments/production.rb +78 -0
  99. data/test/dummy/config/environments/test.rb +39 -0
  100. data/test/dummy/config/initializers/assets.rb +8 -0
  101. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  102. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  103. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  104. data/test/dummy/config/initializers/inflections.rb +16 -0
  105. data/test/dummy/config/initializers/mime_types.rb +4 -0
  106. data/test/dummy/config/initializers/rdf_repositories.rb +32 -0
  107. data/test/dummy/config/initializers/session_store.rb +3 -0
  108. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  109. data/test/dummy/config/locales/en.yml +23 -0
  110. data/test/dummy/config/routes.rb +3 -0
  111. data/test/dummy/config/secrets.yml +22 -0
  112. data/test/dummy/lib/assets/.keep +0 -0
  113. data/test/dummy/log/.keep +0 -0
  114. data/test/dummy/public/404.html +67 -0
  115. data/test/dummy/public/422.html +67 -0
  116. data/test/dummy/public/500.html +66 -0
  117. data/test/dummy/public/favicon.ico +0 -0
  118. data/test/fixtures/ld4l_virtual_collection/collections.yml +11 -0
  119. data/test/fixtures/ld4l_virtual_collection/items.yml +11 -0
  120. data/test/fixtures/ld4l_virtual_collection/my_virtual_collections.yml +11 -0
  121. data/test/fixtures/ld4l_virtual_collection/virtual_collections.yml +9 -0
  122. data/test/helpers/ld4l_virtual_collection/collections_helper_test.rb +6 -0
  123. data/test/helpers/ld4l_virtual_collection/items_helper_test.rb +6 -0
  124. data/test/helpers/ld4l_virtual_collection/my_virtual_collections_helper_test.rb +6 -0
  125. data/test/helpers/ld4l_virtual_collection/virtual_collections_helper_test.rb +6 -0
  126. data/test/integration/navigation_test.rb +10 -0
  127. data/test/ld4l_virtual_collection_test.rb +7 -0
  128. data/test/models/ld4l_virtual_collection/collection_test.rb +9 -0
  129. data/test/models/ld4l_virtual_collection/item_test.rb +9 -0
  130. data/test/models/ld4l_virtual_collection/my_virtual_collection_test.rb +9 -0
  131. data/test/models/ld4l_virtual_collection/virtual_collection_test.rb +9 -0
  132. data/test/test_helper.rb +17 -0
  133. metadata +544 -0
@@ -0,0 +1,105 @@
1
+ require_dependency "ld4l_virtual_collection/application_controller"
2
+
3
+ module Ld4lVirtualCollection
4
+ class TagsController < ApplicationController
5
+ before_action :set_collection_and_item, only: [:new, :create, :index]
6
+ before_action :set_item, only: [:manage_all]
7
+ before_action :set_tag, only: [:show, :edit, :update, :destroy]
8
+
9
+ # GET /collections/1/tags
10
+ # GET /collections/1/items/1/tags
11
+ def index
12
+ @tags = Tag.all(@collection,@item)
13
+ end
14
+
15
+ # GET /tags/1
16
+ def show
17
+ end
18
+
19
+ # GET /collections/1/tags/new
20
+ # GET /collections/1/items/1/tags/new
21
+ def new
22
+ # puts("*** Entering CTRL: new tag")
23
+ @tag = Tag.new(@collection,@item)
24
+ end
25
+
26
+ # GET /tags/1/edit
27
+ def edit
28
+ # puts("*** Entering CTRL: edit tag")
29
+ end
30
+
31
+ # POST /collections/1/items/1/tags
32
+ def create
33
+ # puts("*** Entering CTRL: create tag")
34
+ @tag = Tag.new(@item, tag_params)
35
+ # TODO: Any error checking that the ones to delete are deleted and the ones to add are added?
36
+ if @tag.persist! == true
37
+ redirect_to my_virtual_collection_path(@collection.id.to_s), notice: 'Tag was successfully created.'
38
+ else
39
+ # TODO How to add error message about what failed to persist???
40
+ render :new
41
+ end
42
+ end
43
+
44
+ # PATCH/PUT /item/1/tags
45
+ def manage_all
46
+ # puts("*** Entering CTRL: manage_all tag")
47
+ @tags = Tag.update_all(@item, tag_params)
48
+ @tags[:delete_list].each { |t| t.destroy! }
49
+ @tags[:add_list].each { |t| t.persist! }
50
+ # TODO: Any error checking that the ones to delete are deleted and the ones to add are added?
51
+ # if @tag.persist! == true
52
+ redirect_to my_virtual_collection_path(tag_params[:collection_id]), notice: 'Tags were successfully set.'
53
+ # else
54
+ # # TODO How to add error message about what failed to persist???
55
+ # render :new
56
+ # end
57
+ end
58
+
59
+ # PATCH/PUT /tags/1
60
+ def update
61
+ # puts("*** Entering CTRL: update tag")
62
+ @tag = Tag.update(@tag, tag_params)
63
+ if @tag.persist! == true
64
+ redirect_to my_virtual_collection_path(@collection.id.to_s), notice: 'Tag were successfully updated.'
65
+ else
66
+ # TODO How to add error message about what failed to persist???
67
+ render :edit
68
+ end
69
+ end
70
+
71
+ # DELETE /tags/1
72
+ def destroy
73
+ # puts("*** Entering CTRL: destroy tag")
74
+ @tag.destroy
75
+ # if LD4L::OreRDF::DestroyProxy.call(@collection,@item.rdf_subject) == true
76
+ redirect_to my_virtual_collection_path(@collection.id.to_s), notice: 'Tag was successfully removed.'
77
+ # else
78
+ # # TODO Should it redirect to edit??? OR list??? OR where???
79
+ # # TODO How to add error message about what failed to be destroyed???
80
+ # render :edit
81
+ # end
82
+ end
83
+
84
+ private
85
+ # Use callbacks to share common setup or constraints between actions.
86
+ def set_tag
87
+ @tag = Tag.find(params[:id])
88
+ end
89
+
90
+ # Only allow a trusted parameter "white list" through.
91
+ def tag_params
92
+ params[:tag]
93
+ end
94
+
95
+ def set_collection_and_item
96
+ @collection = Collection.find(tag_params["collection_id"])
97
+ @item = Item.find(tag_params["item_id"])
98
+ @proxy_for = @item && @item.proxy_for && @item.proxy_for.first ? @item.proxy_for.first.rdf_subject : ""
99
+ end
100
+
101
+ def set_item
102
+ @item = Item.find(tag_params["item_id"])
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,4 @@
1
+ module Ld4lVirtualCollection
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ld4lVirtualCollection
2
+ module CollectionsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ld4lVirtualCollection
2
+ module ItemsHelper
3
+ end
4
+ end
@@ -0,0 +1,47 @@
1
+ require 'ld4l/ore_rdf'
2
+
3
+ module Ld4lVirtualCollection
4
+ class Collection < ActiveRecord::Base
5
+
6
+ def self.all
7
+ LD4L::OreRDF::FindAggregations.call(
8
+ :properties => { :title => RDF::DC.title, :description => RDF::DC.description } )
9
+ end
10
+
11
+ def self.new(*params)
12
+ Ld4lVirtualCollection::Engine.configuration.debug_logger.warn("*** Entering MODEL: new collection")
13
+ aggregation = LD4L::OreRDF::CreateAggregation.call
14
+ aggregation.title = params[0][:title] if params && params.size > 0 && params[0].has_key?('title')
15
+ aggregation.description = params[0][:description] if params && params.size > 0 && params[0].has_key?('description')
16
+ aggregation
17
+ end
18
+
19
+ def self.update(*params)
20
+ Ld4lVirtualCollection::Engine.configuration.debug_logger.warn("*** Entering MODEL: update collection")
21
+ aggregation = LD4L::OreRDF::ResumeAggregation.call(params[0][:id])
22
+ aggregation.title = params[0][:title] if params && params.size > 0 && params[0].has_key?('title')
23
+ aggregation.description = params[0][:description] if params && params.size > 0 && params[0].has_key?('description')
24
+ aggregation
25
+ end
26
+
27
+ def self.destroy
28
+ Ld4lVirtualCollection::Engine.configuration.debug_logger.warn("*** Entering MODEL: destroy collection")
29
+ end
30
+
31
+ def self.find(uri)
32
+ Ld4lVirtualCollection::Engine.configuration.debug_logger.warn("*** Entering MODEL: find collection -- uri=#{uri}")
33
+ LD4L::OreRDF::ResumeAggregation.call(uri)
34
+ end
35
+
36
+ def self.collections_for_droplist
37
+ Ld4lVirtualCollection::Engine.configuration.debug_logger.warn("*** Entering MODEL: collections_for_droplist")
38
+ full_collections = Collection.all
39
+ collections = []
40
+ full_collections.each do |id,collection|
41
+ collections << { :title => collection[:title].to_s, :id => id.to_s }
42
+ end
43
+ collections
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,50 @@
1
+ require 'ld4l/ore_rdf'
2
+
3
+ module Ld4lVirtualCollection
4
+ class Item < ActiveRecord::Base
5
+
6
+ def self.all(collection)
7
+ LD4L::OreRDF::FindProxies.call(
8
+ :aggregation => collection.id,
9
+ :properties => { :proxy_for => RDFVocabularies::ORE.proxyFor, :description => RDF::DC.description } )
10
+ end
11
+
12
+ def self.new(collection, *params)
13
+ # puts("*** Entering MODEL: new item")
14
+ item_uri = params[0][:proxy_for].strip if params && params.size > 0 && params[0].has_key?('proxy_for')
15
+ if(item_uri && item_uri.start_with?("http://da-stg-ssolr.library.cornell.edu/solr/") )
16
+ add_items_by_query(collection, item_uri)
17
+ else
18
+ (item_uri && item_uri.size > 0) ? LD4L::OreRDF::AddAggregatedResource.call( collection, item_uri ) :
19
+ LD4L::OreRDF::ProxyResource.new
20
+ end
21
+ end
22
+
23
+ def self.update(collection, item, *params)
24
+ # puts("*** Entering MODEL: update item")
25
+ item_uri = params[0][:proxy_for] if params && params.size > 0 && params[0].has_key?('proxy_for')
26
+ item.set_value('proxy_for', item_uri)
27
+ item
28
+ end
29
+
30
+ def self.destroy(collection,item)
31
+ # puts("*** Entering MODEL: destroy item")
32
+
33
+ end
34
+
35
+ def self.find(uri)
36
+ # puts("*** Entering MODEL: find item")
37
+ LD4L::OreRDF::ProxyResource.new(uri)
38
+ end
39
+
40
+
41
+ # TODO XXX
42
+ def self.add_items_by_query(collection, solr_query)
43
+ # puts("### Entering MODEL: add_items_by_query #{solr_query}")
44
+ metadata = LD4L::WorksRDF::GetMetadataFromSolrQuery.call(solr_query, nil)
45
+ metadata.each do |m|
46
+ LD4L::OreRDF::AddAggregatedResource.call(collection, m.uri)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,52 @@
1
+ module Ld4lVirtualCollection
2
+ class Note < ActiveRecord::Base
3
+
4
+ def self.all(collection,item)
5
+ notes = []
6
+ item_uri = item.id
7
+ all_annotations_uris = LD4L::OpenAnnotationRDF::Annotation.find_by_target(item_uri)
8
+ all_annotations_uris.each do |uri|
9
+ anno = LD4L::OpenAnnotationRDF::Annotation.resume(uri)
10
+ notes << anno if anno.kind_of?(LD4L::OpenAnnotationRDF::CommentAnnotation)
11
+ end
12
+ notes
13
+ end
14
+
15
+ def self.new(collection,item,*params)
16
+ # puts("*** Entering MODEL: new note")
17
+ item_uri = item.id
18
+ item_uri = RDF::URI(item_uri) unless item_uri.kind_of?(RDF::URI)
19
+ note = LD4L::OpenAnnotationRDF::CommentAnnotation.new(ActiveTriples::LocalName::Minter.generate_local_name(
20
+ LD4L::OpenAnnotationRDF::CommentAnnotation, 5, {:prefix=>'n'} ))
21
+ note.hasTarget = item_uri
22
+ note.setComment("") unless params && params.size > 0 && params[0][:new_value]
23
+ note.setComment(params[0][:new_value]) if params && params.size > 0 && params[0][:new_value]
24
+ # note.annotatedBy = p
25
+ note.setAnnotatedAtNow
26
+ note
27
+ end
28
+
29
+ def self.update(note,*params)
30
+ # puts("*** Entering MODEL: update note")
31
+ item_uri = params.first[:item_id]
32
+ item_uri = RDF::URI(item_uri) unless item_uri.kind_of?(RDF::URI)
33
+ note.hasTarget = item_uri
34
+ comment = params.first[:new_value]
35
+ note.setComment(comment)
36
+ note.setAnnotatedAtNow
37
+ # note.annotatedBy = p
38
+ note
39
+ end
40
+
41
+ def self.destroy(note)
42
+ # puts("*** Entering MODEL: destroy note")
43
+
44
+ end
45
+
46
+ def self.find(uri)
47
+ # puts("*** Entering MODEL: find note")
48
+ LD4L::OpenAnnotationRDF::CommentAnnotation.new(uri)
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,94 @@
1
+ module Ld4lVirtualCollection
2
+ class Tag < ActiveRecord::Base
3
+
4
+ def self.all(collection,item)
5
+ # puts("*** Entering MODEL: all tags")
6
+ self.all_hash(item).to_a
7
+ end
8
+
9
+ def self.all_hash(target)
10
+ # puts("*** Entering MODEL: all tags as hash")
11
+ tags = {}
12
+ target_uri = target.id
13
+ all_annotations_uris = LD4L::OpenAnnotationRDF::Annotation.find_by_target(target_uri)
14
+ all_annotations_uris.each do |uri|
15
+ anno = LD4L::OpenAnnotationRDF::Annotation.resume(uri)
16
+ tags[anno.getTag] = anno if anno.kind_of?(LD4L::OpenAnnotationRDF::TagAnnotation)
17
+ end
18
+ tags
19
+ end
20
+
21
+ def self.all_values(target)
22
+ # puts("*** Entering MODEL: values for all tags")
23
+ self.all_hash(target).keys.join("; ")
24
+ end
25
+
26
+ def self.update_all(target,*params)
27
+ # puts("*** Entering MODEL: update_all tags")
28
+ all_anno_hash = self.all_hash(target)
29
+
30
+ target_uri = target.id
31
+ target_uri = RDF::URI(target_uri) unless target_uri.kind_of?(RDF::URI)
32
+
33
+ old_tags = params.first[:old_tags]
34
+ new_tags = params.first[:new_tags]
35
+
36
+ old_tags = old_tags.split(";").collect { |tag_value| tag_value.strip }
37
+ new_tags = new_tags.split(";").collect { |tag_value| tag_value.strip }
38
+
39
+ delete_list = []
40
+ add_list = []
41
+ old_tags.each { |tag_value| delete_list << tag_value unless new_tags.include? tag_value }
42
+ new_tags.each { |tag_value| add_list << tag_value unless old_tags.include? tag_value }
43
+
44
+ delete_list.collect! { |tag_value| all_anno_hash[tag_value] }
45
+ add_list.collect! do |tag_value|
46
+ tag = LD4L::OpenAnnotationRDF::TagAnnotation.new(ActiveTriples::LocalName::Minter.generate_local_name(
47
+ LD4L::OpenAnnotationRDF::TagAnnotation, 5, {:prefix=>'n'} ))
48
+ tag.hasTarget = target_uri
49
+ tag.setTag(tag_value)
50
+ tag.setAnnotatedAtNow
51
+ # tag.annotatedBy = p
52
+ tag
53
+ end
54
+ { :delete_list => delete_list, :add_list => add_list }
55
+ end
56
+
57
+ def self.new(collection,item,*params)
58
+ # puts("*** Entering MODEL: new tag")
59
+ item_uri = item.id
60
+ item_uri = RDF::URI(item_uri) unless item_uri.kind_of?(RDF::URI)
61
+ tag = LD4L::OpenAnnotationRDF::TagAnnotation.new(ActiveTriples::LocalName::Minter.generate_local_name(
62
+ LD4L::OpenAnnotationRDF::TagAnnotation, 5, {:prefix=>'n'} ))
63
+ tag.hasTarget = item_uri
64
+ tag_value = params.first[:new_value] if params && params.size > 0 && params.has_key?(:new_value)
65
+ tag.setTag(tag_value) if tag_value
66
+ tag.setAnnotatedAtNow
67
+ # tag.annotatedBy = p
68
+ tag
69
+ end
70
+
71
+
72
+ def self.update(tag,*params)
73
+ # puts("*** Entering MODEL: update tag")
74
+ item_uri = params.first[:item_id]
75
+ item_uri = RDF::URI(item_uri) unless item_uri.kind_of?(RDF::URI)
76
+ tag.hasTarget = item_uri
77
+ tag_value = params.first[:new_value]
78
+ tag.setTag(tag_value)
79
+ tag.setAnnotatedAtNow
80
+ # tag.annotatedBy = p
81
+ tag
82
+ end
83
+
84
+ def self.destroy(tag)
85
+ # puts("*** Entering MODEL: destroy tag")
86
+ end
87
+
88
+ def self.find(uri)
89
+ # puts("*** Entering MODEL: find tag")
90
+ LD4L::OpenAnnotationRDF::TagAnnotation.new(uri)
91
+ end
92
+
93
+ end
94
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Ld4lVirtualCollection</title>
5
+ <%= stylesheet_link_tag "ld4l_virtual_collection/application", media: "all" %>
6
+ <%= javascript_include_tag "ld4l_virtual_collection/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,28 @@
1
+ <%= form_tag( {action: form_action}, method: form_method, id: form_id, class: form_class ) do %>
2
+ <% if @collection.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@collection.errors.count, "error") %> prohibited this collection from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @collection.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <%= hidden_field( "collection", "id" ) %>
15
+
16
+ <div class="field">
17
+ <%= label_tag("collection_title", "Title") %>
18
+ <%= text_field "collection", "title", "size" => 20, "value" => @collection.title %>
19
+ </div>
20
+ <div class="field">
21
+ <%= label_tag("collection_description", "Description") %>
22
+ <%= text_area "collection", "description", "cols" => 80, "rows" => 8, "value" => @collection.description %>
23
+ </div>
24
+
25
+ <div class="actions">
26
+ <%= submit_tag("Save") %>
27
+ </div>
28
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <h1>Editing collection</h1>
2
+
3
+ <%=
4
+ render :partial =>'form',
5
+ :locals => {
6
+ :form_action => 'update',
7
+ :form_class => 'edit_collection',
8
+ :form_id => "edit_collection_#{@collection.id}",
9
+ :form_method => 'patch' }
10
+ %>
11
+
12
+ <%= link_to 'Show', collection_path(@collection.id.to_s) %>
13
+ <%= link_to 'Back', collections_path %>
@@ -0,0 +1,30 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Listing collections</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Title</th>
9
+ <th>Description</th>
10
+ <th colspan="3"></th>
11
+ </tr>
12
+ </thead>
13
+
14
+ <tbody>
15
+ <% @collections.each do |id,collection| %>
16
+ <tr>
17
+ <td><%= collection[:title].to_s %></td>
18
+ <td><%= collection[:description].to_s %></td>
19
+ <td><%= link_to 'Show', collection_path(id.to_s) %></td>
20
+ <td><%= link_to 'Edit', edit_collection_path(id.to_s) %></td>
21
+ <td><%= link_to 'Destroy', collection_path(id.to_s), method: :delete, data: { confirm: 'Are you sure?' } %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+
27
+ <br>
28
+
29
+ <%= link_to 'New Collection', new_collection_path %>
30
+