dbla 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ec4c36f34bce118a8f7742e32040622e68c76d8
4
- data.tar.gz: 44f112fa2dd872c43aaa9c93394c5f995a4ce733
3
+ metadata.gz: 75c9521ff855accf2dab0da8198d25967aa43751
4
+ data.tar.gz: 1ec160bbcea255947aee766adbcf51bb7b19a96a
5
5
  SHA512:
6
- metadata.gz: fef1b5003cbb9895b39ec794e9eece9e5dfeb4bfd173c7d48e40fc9a80f9b1007b82fb657a18ae408595a2d2533140fd9ad62bb4b4c7dae72647e1e3b72155a5
7
- data.tar.gz: 0b86c1b40dd2cae506feb38ec78dcae7e53d048e6bd6160895e75eb80bcae7ae65a4816bf6909f6032afa20633e4b4c1f86316f3aa7f09722659d770d083cdc3
6
+ metadata.gz: 9d664cf531f499dbe6f78f1948d4cda665d9b4bf4d410d3126edb71ebf816eeb96851c87d129132ac2f8508f2387e8389629b1a56ce70293850fafd34fc7a95d
7
+ data.tar.gz: b7882621624b0811c9d71c3776a2a7a2fa5a9dd1bc374b630ddab1b6a8e630fbe67165d58f1c8be773fc9c7c04f0e1989563056afecdb3da9545de09c0a48f7b
data/README.md CHANGED
@@ -52,7 +52,7 @@ Replace the following code in your CatalogController:
52
52
  config.index.display_type_field = 'format'
53
53
  ```
54
54
 
55
- With the Dbla options.
55
+ With Dbla options.
56
56
 
57
57
  ```ruby
58
58
  config.repository_class = Dbla::Repository
@@ -65,6 +65,12 @@ With the Dbla options.
65
65
  config.index.display_type_field = 'format'
66
66
  ```
67
67
 
68
+ ... or just copy the most recent mimicry of the DP.LA portal:
69
+
70
+ ```console
71
+ rails g dbla:catalog
72
+ ```
73
+
68
74
  6. Fire it up!
69
75
 
70
76
  ```console
@@ -0,0 +1,3 @@
1
+ module CollectionsHelper
2
+ include Dbla::CollectionsHelperBehavior
3
+ end
@@ -0,0 +1,10 @@
1
+ module Dbla
2
+ module ApplicationHelperBehavior
3
+ def dbla_external_link(options, text='')
4
+ url = options[:value]
5
+ link_to(url, 'class' => 'dbla-view-object') do
6
+ content_tag(:span, text, 'class'=> 'glyphicon glyphicon-new-window')
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ module Dbla::CollectionsHelperBehavior
2
+ def dbla_collection_link(options)
3
+ doc = options[:document]
4
+ type = doc['ingestType']
5
+ title = (type.eql? 'collection') ? doc['sourceResource.title'].first : doc['sourceResource.collection.title'].first
6
+ id = (type.eql? 'collection') ? doc['id'].first : doc['sourceResource.collection.id'].first
7
+ link_to(title, controller: :collections, action: 'show',:id=>id)
8
+ end
9
+ def dbla_collection_search_link(options)
10
+ doc = options[:document]
11
+ type = doc['ingestType']
12
+ title = (type.eql? 'collection') ? doc['sourceResource.title'].first : doc['sourceResource.collection.title'].first
13
+ id = (type.eql? 'collection') ? doc['id'].first : doc['sourceResource.collection.id'].first
14
+ link_to(title, controller: :catalog, action: 'index','f[sourceResource.collection.id][]'=>id,'q'=>'')
15
+ end
16
+ end
@@ -8,6 +8,7 @@ module Dbla
8
8
  @config ||= YAML.load(File.read(config_path)).symbolize_keys
9
9
  end
10
10
  autoload :AbstractResponse, 'dbla/abstract_response'
11
+ autoload :Document, 'dbla/document'
11
12
  autoload :DocumentPresenter, 'dbla/document_presenter'
12
13
  autoload :Repository, 'dbla/repository'
13
14
  autoload :Response, 'dbla/response'
@@ -0,0 +1,40 @@
1
+ module Dbla
2
+ module Document
3
+ # accessors for reading attribute
4
+ def [] *args
5
+ if args.first && args.first.to_s.index('.')
6
+ keys = args.first.to_s.split('.')
7
+ keys.inject(_source) do |m,key|
8
+ # Array() has a special behavior we do not want for hashes
9
+ m = (m.is_a? Array) ? m : [m]
10
+ m.inject([]) do |m2, a|
11
+ if (a.respond_to? :[])
12
+ r = a.send :[], *(args[1..-1].unshift(key))
13
+ if r
14
+ # Array() has a special behavior we do not want for hashes
15
+ r = (r.is_a? Array) ? r : [r]
16
+ m2 += r
17
+ else
18
+ m2
19
+ end
20
+ else
21
+ m2
22
+ end
23
+ end
24
+ end
25
+ else
26
+ _source.send :[], *args
27
+ end
28
+ end
29
+ def fetch(field, default)
30
+ (r = self[field]).empty? ? default : r
31
+ end
32
+ def has? f, *values
33
+ if values.empty?
34
+ !self[f].empty?
35
+ else
36
+ !(self[f] & values).empty?
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  module Dbla
2
- class DocumentPresenter
2
+ class DocumentPresenter < Blacklight::DocumentPresenter
3
3
  include ActionView::Helpers::OutputSafetyHelper
4
4
  include ActionView::Helpers::TagHelper
5
5
  extend Deprecation
@@ -14,6 +14,9 @@ module Dbla
14
14
  @configuration = configuration
15
15
  @controller = controller
16
16
  end
17
+ def source_resource_title
18
+ @document[DESCRIPTIVE_METADATA_KEY] ? (@document[DESCRIPTIVE_METADATA_KEY]['title'] || @document['id']) : @document['id']
19
+ end
17
20
  ##
18
21
  # Get the value of the document's "title" field, or a placeholder
19
22
  # value (if empty)
@@ -21,7 +24,7 @@ module Dbla
21
24
  # @param [SolrDocument] document
22
25
  # @return [String]
23
26
  def document_heading
24
- @document[DESCRIPTIVE_METADATA_KEY]['title']
27
+ source_resource_title
25
28
  end
26
29
  ##
27
30
  # Get the document's "title" to display in the <title> element.
@@ -30,7 +33,7 @@ module Dbla
30
33
  # @see #document_heading
31
34
  # @return [String]
32
35
  def document_show_html_title
33
- @document[DESCRIPTIVE_METADATA_KEY]['title']
36
+ source_resource_title
34
37
  end
35
38
  ##
36
39
  # Render a value (or array of values) from a field
@@ -39,6 +42,7 @@ module Dbla
39
42
  # @param [Blacklight::Solr::Configuration::Field] solr field configuration
40
43
  # @return [String]
41
44
  def render_field_value value=nil, field_config=nil
45
+ super
42
46
  end
43
47
  ##
44
48
  # Render the document index heading
@@ -49,14 +53,7 @@ module Dbla
49
53
  # @option opts [String] :label Render the given string
50
54
  # @param [Symbol, Proc, String] field Render the given field or evaluate the proc or render the given string
51
55
  def render_document_index_label field, opts ={}
52
- if Symbol === field
53
- # these are shenanigans to find a nested field
54
- field.to_s.split('.').inject(@document) {|m,v| m[v]}
55
- elsif Proc === field
56
- field.call
57
- else
58
- field
59
- end
56
+ super
60
57
  end
61
58
  ##
62
59
  # Render the index field label for a document
@@ -67,7 +64,7 @@ module Dbla
67
64
  # @param [Hash] opts
68
65
  # @options opts [String] :value
69
66
  def render_index_field_value field, options = {}
70
- field.to_s.split('.').inject(@document) {|m,v| m[v]}
67
+ super
71
68
  end
72
69
  ##
73
70
  # Render the show field value for a document
@@ -78,7 +75,7 @@ module Dbla
78
75
  # @param [Hash] options
79
76
  # @options opts [String] :value
80
77
  def render_document_show_field_value field, options={}
81
- field.to_s.split('.').inject(@document) {|m,v| m[v]}
78
+ super
82
79
  end
83
80
 
84
81
  ##
@@ -97,6 +94,7 @@ module Dbla
97
94
  # @param [Blacklight::Solr::Configuration::Field] solr field configuration
98
95
  # @param [Hash] options additional options to pass to the rendering helpers
99
96
  def get_field_values field, field_config, options = {}
97
+ super
100
98
  end
101
99
 
102
100
  ##
@@ -2,8 +2,8 @@ module Dbla
2
2
  module SearchBuilderBehavior
3
3
  def processed_parameters
4
4
  request.tap do |request_parameters|
5
- if blacklight_params[:q]
6
- request_parameters[:q] = blacklight_params[:q]
5
+ if blacklight_params[:q] || blacklight_params[:f]
6
+ request_parameters[:q] = blacklight_params.fetch(:q,'')
7
7
  end
8
8
  end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Dbla
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -5,6 +5,7 @@ module Dbla
5
5
 
6
6
  def assets
7
7
  copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
8
+ copy_file "collections_controller.rb", "app/controllers/collections_controller.rb"
8
9
  end
9
10
  end
10
11
  end
@@ -4,6 +4,8 @@ class CatalogController < ApplicationController
4
4
 
5
5
  include Blacklight::Catalog
6
6
 
7
+ helper CollectionsHelper
8
+
7
9
  configure_blacklight do |config|
8
10
  ## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
9
11
  config.default_solr_params = {
@@ -36,7 +38,7 @@ class CatalogController < ApplicationController
36
38
  # solr field configuration for search results/index views
37
39
  config.index.title_field = 'sourceResource.title'
38
40
  config.index.thumbnail_field = 'object'
39
- config.index.display_type_field = 'format'
41
+ config.index.display_type_field = 'ingestType'
40
42
 
41
43
  # solr field configuration for document/show views
42
44
  #config.show.title_field = 'title_display'
@@ -66,6 +68,7 @@ class CatalogController < ApplicationController
66
68
  config.add_facet_field 'provider.name', label: 'Partner'
67
69
  config.add_facet_field 'sourceResource.language.name', label: 'By Language'
68
70
  config.add_facet_field 'sourceResource.subject.name', label: 'By Subject'
71
+ config.add_facet_field 'sourceResource.collection.id', label: 'Collection', display: false
69
72
 
70
73
  # Have BL send all facet field names to Solr, which has been the default
71
74
  # previously. Simply remove these lines if you'd rather use Solr request
@@ -76,7 +79,8 @@ class CatalogController < ApplicationController
76
79
  # The ordering of the field names is the order of the display
77
80
  config.add_index_field 'sourceResource.format', :label => 'Format'
78
81
  config.add_index_field 'sourceResource.creator', :label => 'Creator'
79
-
82
+ config.add_index_field 'sourceResource.collection.title', label: 'In Collection', :helper_method => 'dbla_collection_search_link'
83
+ config.add_index_field 'isShownAt', :label => 'View Object', :helper_method => 'dbla_external_link'
80
84
  # solr fields to be displayed in the show (single result) view
81
85
  # The ordering of the field names is the order of the display
82
86
 
@@ -2,7 +2,8 @@
2
2
  class Collection
3
3
 
4
4
  include Blacklight::Solr::Document
5
- # The following shows how to setup this blacklight document to display marc documents
5
+ include Dbla::Document
6
+ # The following shows how to setup this blacklight document to display marc documents
6
7
  extension_parameters[:marc_source_field] = :marc_display
7
8
  extension_parameters[:marc_format_type] = :marcxml
8
9
  use_extension( Blacklight::Solr::Document::Marc) do |document|
@@ -33,13 +34,4 @@ class Collection
33
34
  # Recommendation: Use field names from Dublin Core
34
35
  use_extension( Blacklight::Document::DublinCore)
35
36
 
36
- def has? f, *values
37
- # these are shenanigans to find a nested field
38
- if f.is_a? String and f.index('.')
39
- f = f.split('.')
40
- f.inject(self) {|m,v| (m || {})[v]}
41
- else
42
- super
43
- end
44
- end
45
37
  end
@@ -0,0 +1,161 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class CollectionsController < ApplicationController
3
+ include Blacklight::Marc::Catalog
4
+
5
+ include Blacklight::Catalog
6
+
7
+ helper CollectionsHelper
8
+
9
+ def self.local_prefixes
10
+ super + ['catalog']
11
+ end
12
+ configure_blacklight do |config|
13
+ ## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
14
+ config.default_solr_params = {
15
+ :qt => 'search',
16
+ :rows => 10
17
+ }
18
+
19
+ # solr path which will be added to solr base url before the other solr params.
20
+ #config.solr_path = 'select'
21
+
22
+ # items to show per page, each number in the array represent another option to choose from.
23
+ #config.per_page = [10,20,50,100]
24
+
25
+ ## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SearchHelper#solr_doc_params) or
26
+ ## parameters included in the Blacklight-jetty document requestHandler.
27
+ #
28
+ #config.default_document_solr_params = {
29
+ # :qt => 'document',
30
+ # ## These are hard-coded in the blacklight 'document' requestHandler
31
+ # # :fl => '*',
32
+ # # :rows => 1
33
+ # # :q => '{!raw f=id v=$id}'
34
+ #}
35
+
36
+ config.repository_class = Dbla::Repository
37
+ config.document_model = Collection
38
+ config.response_model = Dbla::Response
39
+ config.document_presenter_class = Dbla::DocumentPresenter
40
+ config.search_builder_class = SearchBuilder
41
+ # solr field configuration for search results/index views
42
+ config.index.title_field = 'title'
43
+ config.index.thumbnail_field = 'object'
44
+ config.index.display_type_field = Proc.new {'default'}
45
+
46
+ # solr field configuration for document/show views
47
+ #config.show.title_field = 'title_display'
48
+ #config.show.display_type_field = 'format'
49
+
50
+ # solr fields that will be treated as facets by the blacklight application
51
+ # The ordering of the field names is the order of the display
52
+ #
53
+ # Setting a limit will trigger Blacklight's 'more' facet values link.
54
+ # * If left unset, then all facet values returned by solr will be displayed.
55
+ # * If set to an integer, then "f.somefield.facet.limit" will be added to
56
+ # solr request, with actual solr request being +1 your configured limit --
57
+ # you configure the number of items you actually want _displayed_ in a page.
58
+ # * If set to 'true', then no additional parameters will be sent to solr,
59
+ # but any 'sniffed' request limit parameters will be used for paging, with
60
+ # paging at requested limit -1. Can sniff from facet.limit or
61
+ # f.specific_field.facet.limit solr request params. This 'true' config
62
+ # can be used if you set limits in :default_solr_params, or as defaults
63
+ # on the solr side in the request handler itself. Request handler defaults
64
+ # sniffing requires solr requests to be made with "echoParams=all", for
65
+ # app code to actually have it echo'd back to see it.
66
+ #
67
+ # :show may be set to false if you don't want the facet to be drawn in the
68
+ # facet bar
69
+ #config.add_facet_field 'sourceResource.format', label: 'By Format'
70
+ #config.add_facet_field 'dataProvider', label: 'Contributing Institution'
71
+ #config.add_facet_field 'provider.name', label: 'Partner'
72
+ #config.add_facet_field 'sourceResource.language.name', label: 'By Language'
73
+ #config.add_facet_field 'sourceResource.subject.name', label: 'By Subject'
74
+
75
+ # Have BL send all facet field names to Solr, which has been the default
76
+ # previously. Simply remove these lines if you'd rather use Solr request
77
+ # handler defaults, or have no facets.
78
+ config.add_facet_fields_to_solr_request!
79
+
80
+ # solr fields to be displayed in the index (search results) view
81
+ # The ordering of the field names is the order of the display
82
+ config.add_index_field 'description', :label => 'Description'
83
+ config.add_index_field 'ingestDate', :label => 'Ingest Date'
84
+ config.add_index_field 'id', :label => 'Search for', helper_method: 'dbla_collection_search_link'
85
+ # solr fields to be displayed in the show (single result) view
86
+ # The ordering of the field names is the order of the display
87
+
88
+ # "fielded" search configuration. Used by pulldown among other places.
89
+ # For supported keys in hash, see rdoc for Blacklight::SearchFields
90
+ #
91
+ # Search fields will inherit the :qt solr request handler from
92
+ # config[:default_solr_parameters], OR can specify a different one
93
+ # with a :qt key/value. Below examples inherit, except for subject
94
+ # that specifies the same :qt as default for our own internal
95
+ # testing purposes.
96
+ #
97
+ # The :key is what will be used to identify this BL search field internally,
98
+ # as well as in URLs -- so changing it after deployment may break bookmarked
99
+ # urls. A display label will be automatically calculated from the :key,
100
+ # or can be specified manually to be different.
101
+
102
+ # This one uses all the defaults set by the solr request handler. Which
103
+ # solr request handler? The one set in config[:default_solr_parameters][:qt],
104
+ # since we aren't specifying it otherwise.
105
+
106
+ config.add_search_field 'all_fields', :label => 'All Fields'
107
+
108
+
109
+ # Now we see how to over-ride Solr request handler defaults, in this
110
+ # case for a BL "search field", which is really a dismax aggregate
111
+ # of Solr search fields.
112
+
113
+ config.add_search_field('title') do |field|
114
+ # solr_parameters hash are sent to Solr as ordinary url query params.
115
+ field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
116
+
117
+ # :solr_local_parameters will be sent using Solr LocalParams
118
+ # syntax, as eg {! qf=$title_qf }. This is neccesary to use
119
+ # Solr parameter de-referencing like $title_qf.
120
+ # See: http://wiki.apache.org/solr/LocalParams
121
+ field.solr_local_parameters = {
122
+ :qf => '$title_qf',
123
+ :pf => '$title_pf'
124
+ }
125
+ end
126
+
127
+ config.add_search_field('author') do |field|
128
+ field.solr_parameters = { :'spellcheck.dictionary' => 'author' }
129
+ field.solr_local_parameters = {
130
+ :qf => '$author_qf',
131
+ :pf => '$author_pf'
132
+ }
133
+ end
134
+
135
+ # Specifying a :qt only to show it's possible, and so our internal automated
136
+ # tests can test it. In this case it's the same as
137
+ # config[:default_solr_parameters][:qt], so isn't actually neccesary.
138
+ config.add_search_field('subject') do |field|
139
+ field.solr_parameters = { :'spellcheck.dictionary' => 'subject' }
140
+ field.qt = 'search'
141
+ field.solr_local_parameters = {
142
+ :qf => '$subject_qf',
143
+ :pf => '$subject_pf'
144
+ }
145
+ end
146
+
147
+ # "sort results by" select (pulldown)
148
+ # label in pulldown is followed by the name of the SOLR field to sort by and
149
+ # whether the sort is ascending or descending (it must be asc or desc
150
+ # except in the relevancy case).
151
+ config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', :label => 'relevance'
152
+ config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
153
+ config.add_sort_field 'author_sort asc, title_sort asc', :label => 'author'
154
+ config.add_sort_field 'title_sort asc, pub_date_sort desc', :label => 'title'
155
+
156
+ # If there are more than this many search results, no spelling ("did you
157
+ # mean") suggestion is offered.
158
+ config.spell_max = 5
159
+ end
160
+
161
+ end
@@ -1,8 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class Item
3
3
 
4
- include Blacklight::Solr::Document
5
- # The following shows how to setup this blacklight document to display marc documents
4
+ include Blacklight::Solr::Document
5
+ include Dbla::Document
6
+ # The following shows how to setup this blacklight document to display marc documents
6
7
  extension_parameters[:marc_source_field] = :marc_display
7
8
  extension_parameters[:marc_format_type] = :marcxml
8
9
  use_extension( Blacklight::Solr::Document::Marc) do |document|
@@ -33,13 +34,4 @@ class Item
33
34
  # Recommendation: Use field names from Dublin Core
34
35
  use_extension( Blacklight::Document::DublinCore)
35
36
 
36
- def has? f, *values
37
- # these are shenanigans to find a nested field
38
- if f.is_a? String and f.index('.')
39
- f = f.split('.')
40
- f.inject(self) {|m,v| (m || {})[v]}
41
- else
42
- super
43
- end
44
- end
45
37
  end
@@ -0,0 +1 @@
1
+ {"@context":"http://dp.la/api/items/context","isShownAt":"http://digital.ncdcr.gov/u?/p15012coll10,2498","dataProvider":"North Carolina Department of Cultural Resources","@type":"ore:Aggregation","provider":{"@id":"http://dp.la/api/contributor/digitalnc","name":"North Carolina Digital Heritage Center"},"object":"http://digital.ncdcr.gov/utils/getthumbnail/collection/p15012coll10/id/2498","ingestionSequence":17,"ingestDate":"2015-03-30T21:39:40.943180Z","_rev":"2-81807c34b00ea3fd4eceeff3dec03b03","id":"45ebfcc104f740cf27d0db423b8f667f","aggregatedCHO":"#sourceResource","_id":"digitalnc--urn:brevard.lib.unc.edudcr_p15012coll10:oai:server16062.contentdm.oclc.org:p15012coll10/2498","admin":{"validation_message":null,"sourceResource":{"title":"Camp Lee, U.S. National Army Cantonment, Petersburg, Virginia"},"valid_after_enrich":true},"sourceResource":{"title":["Camp Lee, U.S. National Army Cantonment, Petersburg, Virginia"],"spatial":[{"county":"City of Petersburg","name":"Petersburg, Petersburg (city), Virginia, United States","state":"Virginia","coordinates":"37.22793, -77.40193","country":"United States"}],"description":["Camp Lee, U.S. National Army Cantonment, Petersburg, Virginia. Photograph printed by Everett Waddey Company, Richmond, Virginia."],"subject":[{"name":"(1900-1929) North Carolina's industrial revolution and World War One"},{"name":"World War, 1914-1918"},{"name":"United States. Army"},{"name":"Camp Lee (Va.)"}],"rights":"The SA of NC considers this item in the public domain by U.S. law but responsibility for permissions rests with researchers.","@id":"http://dp.la/api/items/45ebfcc104f740cf27d0db423b8f667f#sourceResource","format":["9.5\" x 50\" (sheet size) Panorama (Photographs)","Photographs"],"collection":{"id":"8091c81a295ff66e3b9b89e9241b422c","description":"","title":"World War I","@id":"http://dp.la/api/collections/8091c81a295ff66e3b9b89e9241b422c"},"stateLocatedIn":[{"name":"North Carolina"}],"isPartOf":["North Carolina in World War I"],"type":"image","identifier":["MilColl.WWI.Panoramas.23","5757.15.2.8","http://server16062.contentdm.oclc.org/u?/p15012coll10,2498"]},"@id":"http://dp.la/api/items/45ebfcc104f740cf27d0db423b8f667f","ingestType":"item","originalRecord":{"about":{"oaiProvenance:provenance":{"xsi:schemaLocation":"http://www.openarchives.org/OAI/2.0/provenance http://www.openarchives.org/OAI/2.0/provenance.xsd","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","xmlns:oaiProvenance":"http://www.openarchives.org/OAI/2.0/provenance","oaiProvenance:originDescription":{"oaiProvenance:datestamp":"2015-01-21","oaiProvenance:metadataNamespace":"http://www.openarchives.org/OAI/2.0/","altered":"true","oaiProvenance:baseURL":"https://server16062.contentdm.oclc.org/cgi-bin/oai.exe","harvestDate":"2015-01-21","oaiProvenance:identifier":"oai:server16062.contentdm.oclc.org:p15012coll10/2498"}}},"id":"urn:brevard.lib.unc.edudcr_p15012coll10:oai:server16062.contentdm.oclc.org:p15012coll10/2498","provider":{"@id":"http://dp.la/api/contributor/digitalnc","name":"North Carolina Digital Heritage Center"},"collection":{"id":"8091c81a295ff66e3b9b89e9241b422c","description":"","title":"World War I","@id":"http://dp.la/api/collections/8091c81a295ff66e3b9b89e9241b422c"},"header":{"identifier":"urn:brevard.lib.unc.edudcr_p15012coll10:oai:server16062.contentdm.oclc.org:p15012coll10/2498","setSpec":"dcr_p15012coll10","datestamp":"2015-01-21"},"metadata":{"mods":{"genre":"Image","location":[{"url":{"usage":"primary display","#text":"http://digital.ncdcr.gov/u?/p15012coll10,2498","access":"object in context"}},{"url":{"#text":"http://digital.ncdcr.gov/utils/getthumbnail/collection/p15012coll10/id/2498","access":"preview"}}],"subject":[{"geographic":"Petersburg, Petersburg (city), Virginia, United States"},{"topic":"(1900-1929) North Carolina's industrial revolution and World War One"},{"topic":"World War, 1914-1918"},{"topic":"United States. Army"},{"topic":"Camp Lee (Va.)"}],"originInfo":null,"relatedItem":{"titleInfo":{"title":"North Carolina in World War I"}},"physicalDescription":{"form":["9.5\" x 50\" (sheet size) Panorama (Photographs)","Photographs","image/jpeg"]},"xmlns":"http://www.loc.gov/mods/v3","titleInfo":{"title":"Camp Lee, U.S. National Army Cantonment, Petersburg, Virginia"},"xsi:schemaLocation":"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd","xmlns:dc":"http://purl.org/dc/elements/1.1/","version":"3.4","accessCondition":"The SA of NC considers this item in the public domain by U.S. law but responsibility for permissions rests with researchers.","xmlns:oai_dc":"http://www.openarchives.org/OAI/2.0/oai_dc/","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","identifier":["MilColl.WWI.Panoramas.23","5757.15.2.8","http://server16062.contentdm.oclc.org/u?/p15012coll10,2498"],"note":[{"#text":"Camp Lee, U.S. National Army Cantonment, Petersburg, Virginia. Photograph printed by Everett Waddey Company, Richmond, Virginia.","type":"content"},{"#text":"North Carolina Department of Cultural Resources","type":"ownership"}]}}},"score":4.0575137}
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ describe Dbla::Document do
3
+ before(:all) do
4
+ class DocumentRig
5
+ include Blacklight::Solr::Document
6
+ include Dbla::Document
7
+ end
8
+ end
9
+ after(:all) do
10
+ Object.send :remove_const, :DocumentRig
11
+ end
12
+ subject { DocumentRig.new(data) }
13
+ context "doc-001.json" do
14
+ let(:data) { fixture('doc-001.json') { |b| JSON.parse(b.read) } }
15
+ describe "[]" do
16
+ it do
17
+ expect(subject['sourceResource.title']).to eql(["Camp Lee, U.S. National Army Cantonment, Petersburg, Virginia"])
18
+ expect(subject['sourceResource.format']).to eql(["9.5\" x 50\" (sheet size) Panorama (Photographs)", "Photographs"])
19
+ end
20
+ end
21
+ describe "has?" do
22
+ it "should work with only a key" do
23
+ expect(subject.has? 'sourceResource.title').to be(true)
24
+ end
25
+ it "should work with a value" do
26
+ end
27
+ end
28
+ end
29
+ end
@@ -4,8 +4,24 @@ ENV["environment"] ||= 'test'
4
4
  ENV["RAILS_ENV"] ||= 'test'
5
5
  require File.expand_path("../../spec/dummy/config/environment.rb", __FILE__)
6
6
  require 'rspec/rails'
7
-
7
+ require 'blacklight'
8
8
  RSpec.configure do |config|
9
9
  config.mock_with :mocha
10
10
  end
11
11
 
12
+ def fixtures_path(path)
13
+ path = File.join("..","..","spec","fixtures",path)
14
+ puts path
15
+ path = File.expand_path(path, __FILE__)
16
+ puts path
17
+ path
18
+ end
19
+
20
+ def fixture(path)
21
+ path = fixtures_path(path)
22
+ if block_given?
23
+ open(path) {|b| yield b}
24
+ else
25
+ open(path)
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ describe Dbla::DocumentPresenter do
3
+ subject { Dbla::DocumentPresenter.new(data,{},{}) }
4
+ describe "title methods" do
5
+ context "with field" do
6
+ let(:data) {{'sourceResource' => {'title' =>'foo'}}}
7
+ it do
8
+ expect(subject.document_heading).to eql('foo')
9
+ expect(subject.document_show_html_title).to eql('foo')
10
+ end
11
+ end
12
+ context "without field" do
13
+ let(:data) {{'sourceResource' => {},'id' => 'foo'}}
14
+ it do
15
+ expect(subject.document_heading).to eql('foo')
16
+ expect(subject.document_show_html_title).to eql('foo')
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+ describe Dbla::Document do
3
+ before(:all) do
4
+ class DocumentRig
5
+ include Blacklight::Solr::Document
6
+ include Dbla::Document
7
+ end
8
+ end
9
+ after(:all) do
10
+ Object.send :remove_const, :DocumentRig
11
+ end
12
+ subject { DocumentRig.new(data) }
13
+ context "flat fields" do
14
+ let(:data) { {'foo' => 'bar', 'lol' => ['wut', 'no']} }
15
+ describe "[]" do
16
+ it do
17
+ expect(subject['foo']).to eql('bar')
18
+ expect(subject['lol']).to eql(['wut', 'no'])
19
+ end
20
+ end
21
+ end
22
+ context "nested document references" do
23
+ let(:data) { {'foo' => 'bar', 'lol' => ['wut', 'no'], 'o' => {'hai' => {'rly' => ['yarly','norly']}}} }
24
+ describe "[]" do
25
+ it do
26
+ expect(subject['foo']).to eql('bar')
27
+ expect(subject['lol']).to eql(['wut', 'no'])
28
+ expect(subject['o.hai.rly']).to eql(['yarly','norly'])
29
+ expect(subject['o.hai.wut']).to eql([])
30
+ end
31
+ end
32
+ describe "fetch" do
33
+ it do
34
+ expect(subject.fetch('o.hai.wut','foo')).to eql('foo')
35
+ end
36
+ end
37
+ describe "has?" do
38
+ it "should work with only a key" do
39
+ expect(subject.has? 'foo').to eql(true)
40
+ expect(subject.has? 'o.hai.rly').to eql(true)
41
+ expect(subject.has? 'o.hai.rly','norly').to eql(true)
42
+ expect(subject.has? 'o.hai.rly','gnarly').to eql(false)
43
+ expect(subject.has? 'o.hai.wut').to eql(false)
44
+ end
45
+ it "should work with a value" do
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ describe Dbla::SearchBuilderBehavior do
3
+ before(:all) do
4
+ class BuilderRig < Blacklight::SearchBuilder
5
+ include Dbla::SearchBuilderBehavior
6
+ end
7
+ end
8
+ after(:all) do
9
+ Object.send :remove_const, :BuilderRig
10
+ end
11
+ let(:blacklight_params) { [] }
12
+ subject { BuilderRig.new(blacklight_params,nil) }
13
+ describe "blacklight_params" do
14
+ it do
15
+ expect(subject.blacklight_params).to be
16
+ end
17
+ end
18
+ context "configured params" do
19
+ #TODO what should these be
20
+ let(:blacklight_params) { [] }
21
+ describe "facet_filters" do
22
+ it do
23
+ subject.facet_filters
24
+ end
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Audrey Altman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-18 00:00:00.000000000 Z
13
+ date: 2015-04-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -111,11 +111,14 @@ files:
111
111
  - app/assets/javascripts/dbla/application.js
112
112
  - app/assets/stylesheets/dbla/dbla.scss
113
113
  - app/controllers/dbla/application_controller.rb
114
- - app/helpers/dbla/application_helper.rb
114
+ - app/helpers/collections_helper.rb
115
+ - app/helpers/dbla/application_helper_behavior.rb
116
+ - app/helpers/dbla/collections_helper_behavior.rb
115
117
  - app/views/layouts/dbla/application.html.erb
116
118
  - config/routes.rb
117
119
  - lib/dbla.rb
118
120
  - lib/dbla/abstract_response.rb
121
+ - lib/dbla/document.rb
119
122
  - lib/dbla/document_presenter.rb
120
123
  - lib/dbla/engine.rb
121
124
  - lib/dbla/repository.rb
@@ -132,6 +135,7 @@ files:
132
135
  - lib/generators/dbla/search_builder_generator.rb
133
136
  - lib/generators/dbla/templates/catalog_controller.rb
134
137
  - lib/generators/dbla/templates/collection.rb
138
+ - lib/generators/dbla/templates/collections_controller.rb
135
139
  - lib/generators/dbla/templates/dbla.css.scss
136
140
  - lib/generators/dbla/templates/item.rb
137
141
  - lib/generators/dbla/templates/search_builder.rb
@@ -172,7 +176,12 @@ files:
172
176
  - spec/dummy/public/422.html
173
177
  - spec/dummy/public/500.html
174
178
  - spec/dummy/public/favicon.ico
179
+ - spec/fixtures/doc-001.json
180
+ - spec/integration/document_spec.rb
175
181
  - spec/spec_helper.rb
182
+ - spec/unit/document_presenter_spec.rb
183
+ - spec/unit/document_spec.rb
184
+ - spec/unit/search_builder_spec.rb
176
185
  homepage: https://github.com/barmintor/dbla
177
186
  licenses:
178
187
  - MIT
@@ -234,5 +243,10 @@ test_files:
234
243
  - spec/dummy/public/favicon.ico
235
244
  - spec/dummy/Rakefile
236
245
  - spec/dummy/README.rdoc
246
+ - spec/fixtures/doc-001.json
247
+ - spec/integration/document_spec.rb
237
248
  - spec/spec_helper.rb
249
+ - spec/unit/document_presenter_spec.rb
250
+ - spec/unit/document_spec.rb
251
+ - spec/unit/search_builder_spec.rb
238
252
  has_rdoc:
@@ -1,4 +0,0 @@
1
- module Dbla
2
- module ApplicationHelper
3
- end
4
- end