Skip to content

Commit

Permalink
Merge pull request #14 from anusharanganathan/style_guide_conformance
Browse files Browse the repository at this point in the history
Style guide conformance
  • Loading branch information
Jessie Keck committed Jan 4, 2016
2 parents 6592a11 + e1c9ed0 commit 441dc08
Show file tree
Hide file tree
Showing 31 changed files with 1,124 additions and 1,130 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ config/settings/*.local.yml
config/environments/*.local.yml

# Ignore coverage directory
coverage
coverage
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Metrics/LineLength:
Enabled: false
AllCops:
Exclude:
- 'db/**/*'
2 changes: 1 addition & 1 deletion Capfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require 'capistrano/deploy'
# require 'capistrano/passenger'
require 'capistrano/bundler'
require 'capistrano/rails'
#require 'dlss/capistrano'
# require 'dlss/capistrano'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
Expand Down Expand Up @@ -57,8 +56,8 @@ gem 'devise'
gem 'devise-guests', '~> 0.3'
gem 'blacklight-marc', '~> 5.0'
gem 'config', '~> 1.0.0.beta3'
gem "mods_display", "0.3.4"
gem "coderay"
gem 'mods_display', '0.3.4'
gem 'coderay'

group :deployment do
gem 'capistrano', '~> 3.0'
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks

ZIP_URL = "https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.3.zip"
ZIP_URL = 'https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.3.zip'
require 'jettywrapper'

desc 'Execute the test build that runs on travis'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ApplicationController < ActionController::Base
# Adds a few additional behaviors into the application controller
# Adds a few additional behaviors into the application controller
include Blacklight::Controller
layout 'blacklight'

Expand Down
173 changes: 85 additions & 88 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
# -*- encoding : utf-8 -*-
class CatalogController < ApplicationController
class CatalogController < ApplicationController
include Blacklight::Marc::Catalog

include Blacklight::Catalog

configure_blacklight do |config|
## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
config.default_solr_params = {
:qt => 'search',
:rows => 10
config.default_solr_params = {
qt: 'search',
rows: 10
}

# solr path which will be added to solr base url before the other solr params.
#config.solr_path = 'select'
# config.solr_path = 'select'

# items to show per page, each number in the array represent another option to choose from.
#config.per_page = [10,20,50,100]
# config.per_page = [10,20,50,100]

## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SearchHelper#solr_doc_params) or
## parameters included in the Blacklight-jetty document requestHandler.
#
#config.default_document_solr_params = {
# config.default_document_solr_params = {
# :qt => 'document',
# ## These are hard-coded in the blacklight 'document' requestHandler
# # :fl => '*',
# # :rows => 1
# # :q => '{!raw f=id v=$id}'
#}
# # :q => '{!raw f=id v=$id}'
# }

# solr field configuration for search results/index views
config.index.title_field = 'title_display'
config.index.display_type_field = 'format'

# solr field configuration for document/show views
#config.show.title_field = 'title_display'
#config.show.display_type_field = 'format'
# config.show.title_field = 'title_display'
# config.show.display_type_field = 'format'

# solr fields that will be treated as facets by the blacklight application
# The ordering of the field names is the order of the display
Expand All @@ -43,68 +43,67 @@ class CatalogController < ApplicationController
# * If left unset, then all facet values returned by solr will be displayed.
# * If set to an integer, then "f.somefield.facet.limit" will be added to
# solr request, with actual solr request being +1 your configured limit --
# you configure the number of items you actually want _displayed_ in a page.
# you configure the number of items you actually want _displayed_ in a page.
# * If set to 'true', then no additional parameters will be sent to solr,
# but any 'sniffed' request limit parameters will be used for paging, with
# paging at requested limit -1. Can sniff from facet.limit or
# paging at requested limit -1. Can sniff from facet.limit or
# f.specific_field.facet.limit solr request params. This 'true' config
# can be used if you set limits in :default_solr_params, or as defaults
# on the solr side in the request handler itself. Request handler defaults
# sniffing requires solr requests to be made with "echoParams=all", for
# app code to actually have it echo'd back to see it.
# app code to actually have it echo'd back to see it.
#
# :show may be set to false if you don't want the facet to be drawn in the
# :show may be set to false if you don't want the facet to be drawn in the
# facet bar
config.add_facet_field 'format', :label => 'Format'
config.add_facet_field 'pub_date', :label => 'Publication Year', :single => true
config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
config.add_facet_field 'language_facet', :label => 'Language', :limit => true
config.add_facet_field 'lc_1letter_facet', :label => 'Call Number'
config.add_facet_field 'subject_geo_facet', :label => 'Region'
config.add_facet_field 'subject_era_facet', :label => 'Era'

config.add_facet_field 'example_pivot_field', :label => 'Pivot Field', :pivot => ['format', 'language_facet']

config.add_facet_field 'example_query_facet_field', :label => 'Publish Date', :query => {
:years_5 => { :label => 'within 5 Years', :fq => "pub_date:[#{Time.now.year - 5 } TO *]" },
:years_10 => { :label => 'within 10 Years', :fq => "pub_date:[#{Time.now.year - 10 } TO *]" },
:years_25 => { :label => 'within 25 Years', :fq => "pub_date:[#{Time.now.year - 25 } TO *]" }
config.add_facet_field 'format', label: 'Format'
config.add_facet_field 'pub_date', label: 'Publication Year', single: true
config.add_facet_field 'subject_topic_facet', label: 'Topic', limit: 20
config.add_facet_field 'language_facet', label: 'Language', limit: true
config.add_facet_field 'lc_1letter_facet', label: 'Call Number'
config.add_facet_field 'subject_geo_facet', label: 'Region'
config.add_facet_field 'subject_era_facet', label: 'Era'

config.add_facet_field 'example_pivot_field', label: 'Pivot Field', pivot: %w(format language_facet)

config.add_facet_field 'example_query_facet_field', label: 'Publish Date', query: {
years_5: { label: 'within 5 Years', fq: "pub_date:[#{Time.now.year - 5} TO *]" },
years_10: { label: 'within 10 Years', fq: "pub_date:[#{Time.now.year - 10} TO *]" },
years_25: { label: 'within 25 Years', fq: "pub_date:[#{Time.now.year - 25} TO *]" }
}


# Have BL send all facet field names to Solr, which has been the default
# previously. Simply remove these lines if you'd rather use Solr request
# handler defaults, or have no facets.
config.add_facet_fields_to_solr_request!

# solr fields to be displayed in the index (search results) view
# The ordering of the field names is the order of the display
config.add_index_field 'title_display', :label => 'Title'
config.add_index_field 'title_vern_display', :label => 'Title'
config.add_index_field 'author_display', :label => 'Author'
config.add_index_field 'author_vern_display', :label => 'Author'
config.add_index_field 'format', :label => 'Format'
config.add_index_field 'language_facet', :label => 'Language'
config.add_index_field 'published_display', :label => 'Published'
config.add_index_field 'published_vern_display', :label => 'Published'
config.add_index_field 'lc_callnum_display', :label => 'Call number'
# The ordering of the field names is the order of the display
config.add_index_field 'title_display', label: 'Title'
config.add_index_field 'title_vern_display', label: 'Title'
config.add_index_field 'author_display', label: 'Author'
config.add_index_field 'author_vern_display', label: 'Author'
config.add_index_field 'format', label: 'Format'
config.add_index_field 'language_facet', label: 'Language'
config.add_index_field 'published_display', label: 'Published'
config.add_index_field 'published_vern_display', label: 'Published'
config.add_index_field 'lc_callnum_display', label: 'Call number'

# solr fields to be displayed in the show (single result) view
# The ordering of the field names is the order of the display
config.add_show_field 'title_display', :label => 'Title'
config.add_show_field 'title_vern_display', :label => 'Title'
config.add_show_field 'subtitle_display', :label => 'Subtitle'
config.add_show_field 'subtitle_vern_display', :label => 'Subtitle'
config.add_show_field 'author_display', :label => 'Author'
config.add_show_field 'author_vern_display', :label => 'Author'
config.add_show_field 'format', :label => 'Format'
config.add_show_field 'url_fulltext_display', :label => 'URL'
config.add_show_field 'url_suppl_display', :label => 'More Information'
config.add_show_field 'language_facet', :label => 'Language'
config.add_show_field 'published_display', :label => 'Published'
config.add_show_field 'published_vern_display', :label => 'Published'
config.add_show_field 'lc_callnum_display', :label => 'Call number'
config.add_show_field 'isbn_t', :label => 'ISBN'
# The ordering of the field names is the order of the display
config.add_show_field 'title_display', label: 'Title'
config.add_show_field 'title_vern_display', label: 'Title'
config.add_show_field 'subtitle_display', label: 'Subtitle'
config.add_show_field 'subtitle_vern_display', label: 'Subtitle'
config.add_show_field 'author_display', label: 'Author'
config.add_show_field 'author_vern_display', label: 'Author'
config.add_show_field 'format', label: 'Format'
config.add_show_field 'url_fulltext_display', label: 'URL'
config.add_show_field 'url_suppl_display', label: 'More Information'
config.add_show_field 'language_facet', label: 'Language'
config.add_show_field 'published_display', label: 'Published'
config.add_show_field 'published_vern_display', label: 'Published'
config.add_show_field 'lc_callnum_display', label: 'Call number'
config.add_show_field 'isbn_t', label: 'ISBN'

# "fielded" search configuration. Used by pulldown among other places.
# For supported keys in hash, see rdoc for Blacklight::SearchFields
Expand All @@ -118,65 +117,63 @@ class CatalogController < ApplicationController
# The :key is what will be used to identify this BL search field internally,
# as well as in URLs -- so changing it after deployment may break bookmarked
# urls. A display label will be automatically calculated from the :key,
# or can be specified manually to be different.
# or can be specified manually to be different.

# This one uses all the defaults set by the solr request handler. Which
# solr request handler? The one set in config[:default_solr_parameters][:qt],
# since we aren't specifying it otherwise.

config.add_search_field 'all_fields', :label => 'All Fields'

# since we aren't specifying it otherwise.

config.add_search_field 'all_fields', label: 'All Fields'

# Now we see how to over-ride Solr request handler defaults, in this
# case for a BL "search field", which is really a dismax aggregate
# of Solr search fields.
# of Solr search fields.

config.add_search_field('title') do |field|
# solr_parameters hash are sent to Solr as ordinary url query params.
field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
# solr_parameters hash are sent to Solr as ordinary url query params.
field.solr_parameters = { 'spellcheck.dictionary': 'title' }

# :solr_local_parameters will be sent using Solr LocalParams
# syntax, as eg {! qf=$title_qf }. This is neccesary to use
# Solr parameter de-referencing like $title_qf.
# See: http://wiki.apache.org/solr/LocalParams
field.solr_local_parameters = {
:qf => '$title_qf',
:pf => '$title_pf'
field.solr_local_parameters = {
qf: '$title_qf',
pf: '$title_pf'
}
end

config.add_search_field('author') do |field|
field.solr_parameters = { :'spellcheck.dictionary' => 'author' }
field.solr_local_parameters = {
:qf => '$author_qf',
:pf => '$author_pf'
field.solr_parameters = { 'spellcheck.dictionary': 'author' }
field.solr_local_parameters = {
qf: '$author_qf',
pf: '$author_pf'
}
end

# Specifying a :qt only to show it's possible, and so our internal automated
# tests can test it. In this case it's the same as
# config[:default_solr_parameters][:qt], so isn't actually neccesary.
# tests can test it. In this case it's the same as
# config[:default_solr_parameters][:qt], so isn't actually neccesary.
config.add_search_field('subject') do |field|
field.solr_parameters = { :'spellcheck.dictionary' => 'subject' }
field.solr_parameters = { 'spellcheck.dictionary': 'subject' }
field.qt = 'search'
field.solr_local_parameters = {
:qf => '$subject_qf',
:pf => '$subject_pf'
field.solr_local_parameters = {
qf: '$subject_qf',
pf: '$subject_pf'
}
end

# "sort results by" select (pulldown)
# label in pulldown is followed by the name of the SOLR field to sort by and
# whether the sort is ascending or descending (it must be asc or desc
# except in the relevancy case).
config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', :label => 'relevance'
config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
config.add_sort_field 'author_sort asc, title_sort asc', :label => 'author'
config.add_sort_field 'title_sort asc, pub_date_sort desc', :label => 'title'
config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', label: 'relevance'
config.add_sort_field 'pub_date_sort desc, title_sort asc', label: 'year'
config.add_sort_field 'author_sort asc, title_sort asc', label: 'author'
config.add_sort_field 'title_sort asc, pub_date_sort desc', label: 'title'

# If there are more than this many search results, no spelling ("did you
# If there are more than this many search results, no spelling ("did you
# mean") suggestion is offered.
config.spell_max = 5
end

end
end
Loading

0 comments on commit 441dc08

Please sign in to comment.