dbla 0.0.1 → 0.0.2

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: edd97f400f8dfae0835dc039528d2a3c7871a263
4
- data.tar.gz: 898b2b9ebce6a913683681001be63c6fc1b1c8c1
3
+ metadata.gz: cb8fae248060253ada17d9cbc785ec9bef380173
4
+ data.tar.gz: f9c302e800a86a250dcbf215b16464e73e07f438
5
5
  SHA512:
6
- metadata.gz: db96548cea5437ab103e652e8664d443ec57385cc7433bb1975ef6b11b8ecbc9cec4e3efd0a2dd1372213d1d4ac8f72504ce71bb8af9b0ef5c2bcb4dd85928bb
7
- data.tar.gz: 441f24c79d6bec54919ffd7edcdc8880cc464f64b19da454ef753849fcea862fd0a5c647420d9a395879866f06b7cc6dda7562924ddd2638efabe111f7d46722
6
+ metadata.gz: d86878a38f42a993afc633916a57e83a251f78dba365c28cccccaf2035e6528c663ac6bbcdacae8139684b68356bdc8117f5aeefcbc7876643e5bb1732450536
7
+ data.tar.gz: 37ad200951dfc84c7b99c005daa60465db099b5c4b3857115e402f74f9006ee2f9dee669d6750913f90bd9670bad5836cdd7ed3e3290b26a02a06c73cc1f471a
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ = Dbla
2
+
3
+ 1. Generate a Blacklight app:
4
+ ```
5
+ rails new search_app -m https://raw.github.com/projectblacklight/blacklight/master/template.demo.rb
6
+ cd search_app
7
+ ```
8
+
9
+ 2. Add the dbla gem to the Gemfile:
10
+ ```
11
+ gem "dbla"
12
+ ```
13
+ and bundle install.
14
+
15
+ 3. Run the dbla generators:
16
+ ```
17
+ rails g dbla:install
18
+ ```
19
+
20
+ 4. Create a config/dpla.yml file of the form:
21
+ ```
22
+ api_key: 00000000
23
+ api_email: ab@dp.la
24
+ url: http://api.dp.la/v2/
25
+ ```
26
+ This file can be stubbed out with a rake task:
27
+ ```
28
+ rake dbla:key:get email=my.email@my.server.org
29
+ # get your email
30
+ rake dbla:key:config key=YOURKEY00000000
31
+ ```
32
+ 5. Configure the CatalogController
33
+ ```
34
+ config.repository_class = Dbla::Repository
35
+ config.document_model = Item
36
+ config.response_model = Dbla::Response
37
+ config.document_presenter_class = Dbla::DocumentPresenter
38
+ # solr field configuration for search results/index views
39
+ config.index.title_field = 'sourceResource/title'
40
+ config.index.thumbnail_field = 'object'
41
+ config.index.display_type_field = 'format'
42
+ ```
43
+
44
+ 6. Fire it up!
45
+ ``` rails s```
46
+
47
+ Go to localhost:3000
48
+
49
+ Search for kittens!
@@ -0,0 +1,9 @@
1
+ @charset "UTF-8";
2
+
3
+ DIV.document-thumbnail IMG {
4
+ width: auto;
5
+ max-height: 150px;
6
+ max-width: 100%;
7
+ vertical-align: middle;
8
+ border:0;
9
+ }
@@ -26,6 +26,10 @@ module Dbla
26
26
  params[:sort]
27
27
  end
28
28
 
29
+ # Facets are built from this method's output
30
+ def aggregations
31
+ {}
32
+ end
29
33
  # secret api
30
34
  def grouped?
31
35
  false
data/lib/dbla/response.rb CHANGED
@@ -6,11 +6,12 @@ module Dbla
6
6
  @request_params = request_params
7
7
  self.document_model = options[:solr_document_model] || options[:document_model] || Item
8
8
  self.blacklight_config = options[:blacklight_config]
9
- # {"count":228,"start":0,"limit":10,"docs"
10
- @total = data['count']
11
- @documents = (data['docs'] || []).map {|d| document_model.new(d,self)}
12
- @start = data['start']
13
- @limit = data['limit']
9
+ if data
10
+ @total = data['count']
11
+ @documents = (data['docs'] || []).map {|d| document_model.new(d,self)}
12
+ @start = data['start']
13
+ @limit = data['limit']
14
+ end
14
15
  end
15
16
  end
16
17
  end
data/lib/dbla/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dbla
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,10 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Dbla
3
+ class Assets < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def assets
7
+ copy_file "dbla.css.scss", "app/assets/stylesheets/dbla.css.scss"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,35 @@
1
+ module Dbla
2
+ class Install < Rails::Generators::Base
3
+
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ argument :controller_name, type: :string , default: "catalog"
7
+ argument :search_builder_name, type: :string , default: "search_builder"
8
+
9
+ desc """
10
+ This generator makes the following changes to your application:
11
+ 1. Generates dbla:models
12
+ 3. Creates a stylesheet
13
+ 2. Adds Dbla routes to your ./config/routes.rb
14
+ """
15
+
16
+ # Copy all files in templates/public/ directory to public/
17
+ # Call external generator in AssetsGenerator, so we can
18
+ # leave that callable seperately too.
19
+ def copy_public_assets
20
+ generate "dbla:assets"
21
+ end
22
+
23
+ def generate_search_builder
24
+ generate 'dbla:search_builder', search_builder_name
25
+ end
26
+
27
+ def generate_dbla_models
28
+ generate 'dbla:models'
29
+ end
30
+
31
+ def generate_dbla_routes
32
+ generate 'dbla:routes'
33
+ end
34
+ end
35
+ end
@@ -1,7 +1,7 @@
1
1
  require 'rails/generators'
2
2
 
3
3
  module Dbla
4
- class DocumentGenerator < Rails::Generators::Base
4
+ class ModelsGenerator < Rails::Generators::Base
5
5
  include Rails::Generators::Migration
6
6
 
7
7
  source_root File.expand_path('../templates', __FILE__)
@@ -10,7 +10,7 @@ module Dbla
10
10
  1. Adds routes for your controller
11
11
  """
12
12
 
13
- def inject_blacklight_routes
13
+ def inject_dbla_routes
14
14
  # These will end up in routes.rb file in reverse order
15
15
  # we add em, since each is added at the top of file.
16
16
  # we want "root" to be FIRST for optimal url generation.
@@ -0,0 +1 @@
1
+ @import 'dbla/dbla';
@@ -14,7 +14,7 @@ module Dbla
14
14
  end
15
15
  end
16
16
  end
17
- namespace :Dbla do
17
+ namespace :dbla do
18
18
  namespace :key do
19
19
  task get: :environment do
20
20
  if ENV['email']
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Audrey Altman
@@ -90,9 +90,10 @@ extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
92
  - LICENSE
93
+ - README.md
93
94
  - Rakefile
94
95
  - app/assets/javascripts/dbla/application.js
95
- - app/assets/stylesheets/dbla/application.css
96
+ - app/assets/stylesheets/dbla/dbla.scss
96
97
  - app/controllers/dbla/application_controller.rb
97
98
  - app/helpers/dbla/application_helper.rb
98
99
  - app/views/layouts/dbla/application.html.erb
@@ -106,10 +107,13 @@ files:
106
107
  - lib/dbla/routes.rb
107
108
  - lib/dbla/search_builder_behavior.rb
108
109
  - lib/dbla/version.rb
110
+ - lib/generators/dbla/assets_generator.rb
111
+ - lib/generators/dbla/install_generator.rb
109
112
  - lib/generators/dbla/models_generator.rb
110
113
  - lib/generators/dbla/routes_generator.rb
111
114
  - lib/generators/dbla/search_builder_generator.rb
112
115
  - lib/generators/dbla/templates/collection.rb
116
+ - lib/generators/dbla/templates/dbla.css.scss
113
117
  - lib/generators/dbla/templates/item.rb
114
118
  - lib/generators/dbla/templates/search_builder.rb
115
119
  - lib/tasks/dbla_key.rake
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */