quick_search-core 0.0.1.test
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +168 -0
- data/Rakefile +6 -0
- data/app/assets/images/quick_search/askus.gif +0 -0
- data/app/assets/images/quick_search/favicon.ico +0 -0
- data/app/assets/images/quick_search/greybox.png +0 -0
- data/app/assets/images/quick_search/homescreen-icon-64x64.png +0 -0
- data/app/assets/images/quick_search/ncsu-library-logo-white.png +0 -0
- data/app/assets/javascripts/quick_search/appstats.js +8 -0
- data/app/assets/javascripts/quick_search/event_tracking.js.erb +257 -0
- data/app/assets/javascripts/quick_search/google_analytics.js.erb +8 -0
- data/app/assets/javascripts/quick_search/opensearch.js +2 -0
- data/app/assets/javascripts/quick_search/pages.js.coffee +3 -0
- data/app/assets/javascripts/quick_search/quicksearch.js +33 -0
- data/app/assets/javascripts/quick_search/realtime.js.erb +12 -0
- data/app/assets/javascripts/quick_search/search.js +3 -0
- data/app/assets/javascripts/quick_search/xhr_search.js +82 -0
- data/app/assets/javascripts/quick_search.js.erb +20 -0
- data/app/assets/stylesheets/foundation_and_overrides.scss +1327 -0
- data/app/assets/stylesheets/quick_search/appstats.css.scss +7 -0
- data/app/assets/stylesheets/quick_search/opensearch.css.scss +3 -0
- data/app/assets/stylesheets/quick_search/pages.css.scss +3 -0
- data/app/assets/stylesheets/quick_search/quick_search.css.scss +248 -0
- data/app/assets/stylesheets/quick_search/search.css.scss +3 -0
- data/app/assets/stylesheets/quick_search.css.scss.erb +7 -0
- data/app/controllers/concerns/quick_search/auth.rb +22 -0
- data/app/controllers/concerns/quick_search/doi_trap.rb +43 -0
- data/app/controllers/concerns/quick_search/encode_utf8.rb +12 -0
- data/app/controllers/concerns/quick_search/on_campus.rb +43 -0
- data/app/controllers/concerns/quick_search/query_filter.rb +25 -0
- data/app/controllers/concerns/quick_search/query_parser.rb +54 -0
- data/app/controllers/concerns/quick_search/searcher_concern.rb +101 -0
- data/app/controllers/concerns/quick_search/searcher_config.rb +16 -0
- data/app/controllers/quick_search/application_controller.rb +7 -0
- data/app/controllers/quick_search/appstats_controller.rb +210 -0
- data/app/controllers/quick_search/opensearch_controller.rb +9 -0
- data/app/controllers/quick_search/pages_controller.rb +18 -0
- data/app/controllers/quick_search/search_controller.rb +250 -0
- data/app/helpers/quick_search/application_helper.rb +68 -0
- data/app/helpers/quick_search/appstats_helper.rb +2 -0
- data/app/helpers/quick_search/opensearch_helper.rb +2 -0
- data/app/helpers/quick_search/pages_helper.rb +2 -0
- data/app/helpers/quick_search/search_helper.rb +2 -0
- data/app/models/event.rb +2 -0
- data/app/models/search.rb +11 -0
- data/app/searchers/quick_search/best_bets_searcher.rb +102 -0
- data/app/searchers/quick_search/searcher.rb +43 -0
- data/app/views/layouts/quick_search/_best_bets.html.erb +18 -0
- data/app/views/layouts/quick_search/_common_searches.html.erb +15 -0
- data/app/views/layouts/quick_search/_found_types.html.erb +13 -0
- data/app/views/layouts/quick_search/_google_analytics.html.erb +24 -0
- data/app/views/layouts/quick_search/_more_options.html.erb +10 -0
- data/app/views/layouts/quick_search/_page_title.html.erb +8 -0
- data/app/views/layouts/quick_search/_related_topics.html.erb +8 -0
- data/app/views/layouts/quick_search/_search_form.html.erb +19 -0
- data/app/views/layouts/quick_search/_spelling_suggestion.html.erb +13 -0
- data/app/views/layouts/quick_search/_topic_snippet.html.erb +5 -0
- data/app/views/layouts/quick_search/application.html.erb +40 -0
- data/app/views/quick_search/appstats/_click_count_table.html.erb +23 -0
- data/app/views/quick_search/appstats/_datatables.html.erb +12 -0
- data/app/views/quick_search/appstats/_date_range.html.erb +15 -0
- data/app/views/quick_search/appstats/_menu.html.erb +16 -0
- data/app/views/quick_search/appstats/_top_spot_report_table.html.erb +33 -0
- data/app/views/quick_search/appstats/clicks_overview.html.erb +20 -0
- data/app/views/quick_search/appstats/index.html.erb +31 -0
- data/app/views/quick_search/appstats/module_click_detail.html.erb +32 -0
- data/app/views/quick_search/appstats/realtime.html.erb +15 -0
- data/app/views/quick_search/appstats/top_searches.html.erb +38 -0
- data/app/views/quick_search/appstats/top_spot.html.erb +14 -0
- data/app/views/quick_search/appstats/top_spot_detail.html.erb +35 -0
- data/app/views/quick_search/kaminari/_first_page.html.erb +12 -0
- data/app/views/quick_search/kaminari/_gap.html.erb +11 -0
- data/app/views/quick_search/kaminari/_last_page.html.erb +12 -0
- data/app/views/quick_search/kaminari/_next_page.html.erb +12 -0
- data/app/views/quick_search/kaminari/_page.html.erb +13 -0
- data/app/views/quick_search/kaminari/_paginator.html.erb +25 -0
- data/app/views/quick_search/kaminari/_prev_page.html.erb +11 -0
- data/app/views/quick_search/opensearch/opensearch.xml.builder +11 -0
- data/app/views/quick_search/pages/about.html.erb +9 -0
- data/app/views/quick_search/pages/home.html.erb +6 -0
- data/app/views/quick_search/pages/realtime.html.erb +15 -0
- data/app/views/quick_search/search/_citation.html.erb +18 -0
- data/app/views/quick_search/search/_module.html.erb +37 -0
- data/app/views/quick_search/search/_module_with_paging.html.erb +14 -0
- data/app/views/quick_search/search/_no_results.html.erb +11 -0
- data/app/views/quick_search/search/_result.html.erb +17 -0
- data/app/views/quick_search/search/_result_details.html.erb +45 -0
- data/app/views/quick_search/search/_result_no_thumbnail.html.erb +3 -0
- data/app/views/quick_search/search/_result_title.html.erb +4 -0
- data/app/views/quick_search/search/_result_with_thumbnail.html.erb +21 -0
- data/app/views/quick_search/search/_search_error.html.erb +9 -0
- data/app/views/quick_search/search/_see_all.html.erb +11 -0
- data/app/views/quick_search/search/_xhr_response.html.erb +15 -0
- data/app/views/quick_search/search/_xhr_response.json.erb +14 -0
- data/app/views/quick_search/search/_xhr_response_with_paging.html.erb +1 -0
- data/app/views/quick_search/search/index.html.erb +100 -0
- data/config/application.rb +25 -0
- data/config/best_bets.yml +86 -0
- data/config/boot.rb +4 -0
- data/config/database.yml.example +31 -0
- data/config/locales/en.yml +30 -0
- data/config/quicksearch_config.yml.example +69 -0
- data/config/routes.rb +81 -0
- data/db/migrate/20140130202859_create_events.rb +11 -0
- data/db/migrate/20140130202944_create_searches.rb +9 -0
- data/db/migrate/20140225145441_add_page_to_searches.rb +5 -0
- data/db/schema.rb +31 -0
- data/db/seeds.rb +7 -0
- data/lib/benchmark_logger.rb +2 -0
- data/lib/capistrano/tasks/access_check.cap +10 -0
- data/lib/generators/quick_search/install_generator.rb +49 -0
- data/lib/generators/quick_search/templates/kaminari.rb +5 -0
- data/lib/generators/quick_search/templates/post_install.txt +8 -0
- data/lib/generators/quick_search/templates/quick_search_config.yml +58 -0
- data/lib/quick_search/engine.rb +16 -0
- data/lib/quick_search/version.rb +3 -0
- data/lib/quick_search.rb +12 -0
- data/lib/tasks/best_bets.rake +29 -0
- data/test/controllers/appstats_controller_test.rb +7 -0
- data/test/controllers/concerns/doi_trap_test.rb +19 -0
- data/test/controllers/concerns/on_campus_test.rb +19 -0
- data/test/controllers/concerns/query_parser_test.rb +47 -0
- data/test/controllers/opensearch_controller_test.rb +13 -0
- data/test/controllers/pages_controller_test.rb +7 -0
- data/test/controllers/search_controller_test.rb +15 -0
- data/test/fixtures/events.yml +11 -0
- data/test/fixtures/searches.yml +7 -0
- data/test/helpers/appstats_helper_test.rb +4 -0
- data/test/helpers/opensearch_helper_test.rb +4 -0
- data/test/helpers/pages_helper_test.rb +4 -0
- data/test/helpers/search_helper_test.rb +4 -0
- data/test/integration/catalog_search_test.rb +8 -0
- data/test/integration/google_analytics_test.rb +23 -0
- data/test/integration/landing_page_test.rb +8 -0
- data/test/integration/searching_test.rb +40 -0
- data/test/integration/smart_subjects_test.rb +8 -0
- data/test/integration/website_search_test.rb +8 -0
- data/test/models/event_test.rb +7 -0
- data/test/models/search_test.rb +7 -0
- data/test/searcher/best_bets_test.rb +35 -0
- data/test/searcher/catalog_test.rb +35 -0
- data/test/searcher/ematrix_database_test.rb +27 -0
- data/test/searcher/ematrix_journal_test.rb +27 -0
- data/test/searcher/faq_test.rb +27 -0
- data/test/searcher/smart_subjects_test.rb +27 -0
- data/test/searcher/summon_test.rb +13 -0
- data/test/searcher/website_test.rb +34 -0
- data/test/support/vcr_test.rb +40 -0
- data/test/test_helper.rb +42 -0
- metadata +366 -0
data/config/routes.rb
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
QuickSearch::Engine.routes.draw do
|
|
2
|
+
|
|
3
|
+
root 'search#index'
|
|
4
|
+
|
|
5
|
+
get 'xhr_search' => 'search#xhr_search', :defaults => { :format => 'html' }
|
|
6
|
+
get 'log_event' => 'search#log_event'
|
|
7
|
+
get 'log_search' => 'search#log_search'
|
|
8
|
+
|
|
9
|
+
get 'searcher/:searcher_name' => 'search#single_searcher'
|
|
10
|
+
get 'searcher/:searcher_name/xhr_search' => 'search#xhr_search', :defaults => { :format => 'html' }
|
|
11
|
+
get 'searcher/:searcher_name/log_event' => 'search#log_event'
|
|
12
|
+
get 'searcher/:searcher_name/log_search' => 'search#log_search'
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
get 'opensearch' => 'opensearch#opensearch', :defaults => { :format => 'xml' }
|
|
16
|
+
|
|
17
|
+
get 'about' => 'pages#about'
|
|
18
|
+
get 'realtime' => 'pages#realtime'
|
|
19
|
+
|
|
20
|
+
match 'appstats', to: 'appstats#index', via: [:get, :post]
|
|
21
|
+
match 'appstats/clicks_overview', to: 'appstats#clicks_overview', as: 'clicks_overview', via: [:get, :post]
|
|
22
|
+
match 'appstats/top_searches', to: 'appstats#top_searches', as: 'top_searches', via: [:get, :post]
|
|
23
|
+
match 'appstats/top_spot', to: 'appstats#top_spot', as: 'top_spot', via: [:get, :post]
|
|
24
|
+
match 'appstats/detail/:ga_scope', to: 'appstats#detail', via: [:get, :post]
|
|
25
|
+
get 'appstats/realtime' => 'appstats#realtime'
|
|
26
|
+
|
|
27
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
|
28
|
+
# See how all your routes lay out with "rake routes".
|
|
29
|
+
|
|
30
|
+
# You can have the root of your site routed with "root"
|
|
31
|
+
# root 'welcome#index'
|
|
32
|
+
|
|
33
|
+
# Example of regular route:
|
|
34
|
+
# get 'products/:id' => 'catalog#view'
|
|
35
|
+
|
|
36
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
|
37
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
|
38
|
+
|
|
39
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
|
40
|
+
# resources :products
|
|
41
|
+
|
|
42
|
+
# Example resource route with options:
|
|
43
|
+
# resources :products do
|
|
44
|
+
# member do
|
|
45
|
+
# get 'short'
|
|
46
|
+
# post 'toggle'
|
|
47
|
+
# end
|
|
48
|
+
#
|
|
49
|
+
# collection do
|
|
50
|
+
# get 'sold'
|
|
51
|
+
# end
|
|
52
|
+
# end
|
|
53
|
+
|
|
54
|
+
# Example resource route with sub-resources:
|
|
55
|
+
# resources :products do
|
|
56
|
+
# resources :comments, :sales
|
|
57
|
+
# resource :seller
|
|
58
|
+
# end
|
|
59
|
+
|
|
60
|
+
# Example resource route with more complex sub-resources:
|
|
61
|
+
# resources :products do
|
|
62
|
+
# resources :comments
|
|
63
|
+
# resources :sales do
|
|
64
|
+
# get 'recent', on: :collection
|
|
65
|
+
# end
|
|
66
|
+
# end
|
|
67
|
+
|
|
68
|
+
# Example resource route with concerns:
|
|
69
|
+
# concern :toggleable do
|
|
70
|
+
# post 'toggle'
|
|
71
|
+
# end
|
|
72
|
+
# resources :posts, concerns: :toggleable
|
|
73
|
+
# resources :photos, concerns: :toggleable
|
|
74
|
+
|
|
75
|
+
# Example resource route within a namespace:
|
|
76
|
+
# namespace :admin do
|
|
77
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
|
78
|
+
# # (app/controllers/admin/products_controller.rb)
|
|
79
|
+
# resources :products
|
|
80
|
+
# end
|
|
81
|
+
end
|
data/db/schema.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
|
5
|
+
#
|
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
|
7
|
+
# database schema. If you need to create the application database on another
|
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
|
11
|
+
#
|
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
|
13
|
+
|
|
14
|
+
ActiveRecord::Schema.define(version: 20140225145441) do
|
|
15
|
+
|
|
16
|
+
create_table "events", force: true do |t|
|
|
17
|
+
t.string "category"
|
|
18
|
+
t.string "action"
|
|
19
|
+
t.string "label"
|
|
20
|
+
t.datetime "created_at"
|
|
21
|
+
t.datetime "updated_at"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
create_table "searches", force: true do |t|
|
|
25
|
+
t.string "query"
|
|
26
|
+
t.datetime "created_at"
|
|
27
|
+
t.datetime "updated_at"
|
|
28
|
+
t.string "page"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
data/db/seeds.rb
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
|
3
|
+
#
|
|
4
|
+
# Examples:
|
|
5
|
+
#
|
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
desc "Check that we can access everything"
|
|
2
|
+
task :check_write_permissions do
|
|
3
|
+
on roles(:all) do |host|
|
|
4
|
+
if test("[ -w #{fetch(:deploy_to)} ]")
|
|
5
|
+
info "#{fetch(:deploy_to)} is writable on #{host}"
|
|
6
|
+
else
|
|
7
|
+
error "#{fetch(:deploy_to)} is not writable on #{host}"
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module QuickSearch
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
5
|
+
|
|
6
|
+
desc 'insert routes'
|
|
7
|
+
def insert_routes
|
|
8
|
+
routes = <<-ROUTES
|
|
9
|
+
mount QuickSearch::Engine => "/"
|
|
10
|
+
ROUTES
|
|
11
|
+
insert_into_file "config/routes.rb", routes, :after => "Rails.application.routes.draw do\n"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc 'create application configuration file'
|
|
15
|
+
def quick_search_config_yml
|
|
16
|
+
copy_file 'quick_search_config.yml', 'config/quick_search_config.yml'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc 'create kaminari initializer'
|
|
20
|
+
def kaminari_initializer
|
|
21
|
+
copy_file 'kaminari.rb', 'config/initializers/kaminari.rb'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc 'add styles'
|
|
25
|
+
def add_styles
|
|
26
|
+
remove_file 'app/assets/stylesheets/application.css'
|
|
27
|
+
create_file 'app/assets/stylesheets/application.css.scss', %Q|@import "quick_search";\n|
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc 'add javascript'
|
|
31
|
+
def add_javascript
|
|
32
|
+
gsub_file('app/assets/javascripts/application.js', '//= require_tree .', '//= require quick_search')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc 'install migrations'
|
|
36
|
+
def install_migrations
|
|
37
|
+
rake "quick_search:install:migrations"
|
|
38
|
+
rake "db:migrate"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
desc 'display messages about what needs to be configured'
|
|
42
|
+
def configuration_messages
|
|
43
|
+
file = File.read(File.join( File.expand_path('../templates', __FILE__), 'post_install.txt'))
|
|
44
|
+
say file, :green
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
QuickSearch installation complete. To add searchers:
|
|
2
|
+
|
|
3
|
+
1. Add searcher gems (see README for list of gems) to your project's Gemfile
|
|
4
|
+
2. Add a theme gem to Gemfile (see README)
|
|
5
|
+
3. Add the searchers/theme to quick_search_config.yml
|
|
6
|
+
4. Add render_module calls to search results view for each searcher
|
|
7
|
+
|
|
8
|
+
For more information, see README and other documentation at http://github.com/ncsu-libraries/quick_search/
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
defaults: &defaults
|
|
2
|
+
theme: 'quick_search_generic_theme'
|
|
3
|
+
searchers: [best_bets,arxiv,open_library,wikipedia,placeholder]
|
|
4
|
+
found_types: [arxiv,open_library,wikipedia,placeholder,placeholder,placeholder,placeholder]
|
|
5
|
+
per_page: 3
|
|
6
|
+
max_per_page: 50
|
|
7
|
+
http_timeout: 1.5
|
|
8
|
+
xhr_http_timeout: 15
|
|
9
|
+
# google_analytics_tracking_id: ""
|
|
10
|
+
user: "stats"
|
|
11
|
+
password: "stats"
|
|
12
|
+
|
|
13
|
+
on_campus:
|
|
14
|
+
- !ruby/regexp '/^192\.(1|168)\.\d*\.\d*$/'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
common_searches: ["web of science", "google scholar", "refworks", "harvard business review", "pubmed", "ieee"]
|
|
18
|
+
|
|
19
|
+
common_website_searches: ["dissertations", "exhibits", "textbooks", "visit the libraries", "government information", "literature review", "printing"]
|
|
20
|
+
|
|
21
|
+
loaded_searches:
|
|
22
|
+
- name: "Google Scholar"
|
|
23
|
+
landing_page: "http://scholar.google.com/"
|
|
24
|
+
query: "https://scholar.google.com/scholar?hl=en&q="
|
|
25
|
+
- name: "WorldCat"
|
|
26
|
+
landing_page: "https://www.worldcat.org"
|
|
27
|
+
query: "https://www.worldcat.org/search?qt=worldcat_org_all&q="
|
|
28
|
+
- name: "Google"
|
|
29
|
+
landing_page: "https://www.google.com/"
|
|
30
|
+
query: "https://www.google.com/#q="
|
|
31
|
+
|
|
32
|
+
loaded_website_searches:
|
|
33
|
+
- name: "Books, Articles, Journals & More"
|
|
34
|
+
landing_page: "http://search.lib.ncsu.edu"
|
|
35
|
+
query: "http://search.lib.ncsu.edu/?q="
|
|
36
|
+
|
|
37
|
+
doi_loaded_link: "http://doi.org/"
|
|
38
|
+
|
|
39
|
+
best_bets:
|
|
40
|
+
solr_url: "http://localhost:8983/solr/bestbets/select?"
|
|
41
|
+
|
|
42
|
+
development:
|
|
43
|
+
<<: *defaults
|
|
44
|
+
# realtime_url: http://path_to_websockets_server
|
|
45
|
+
|
|
46
|
+
test:
|
|
47
|
+
<<: *defaults
|
|
48
|
+
|
|
49
|
+
staging:
|
|
50
|
+
<<: *defaults
|
|
51
|
+
# realtime_url: http://path_to_websockets_server
|
|
52
|
+
# google_analytics_tracking_id: ""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
production:
|
|
56
|
+
<<: *defaults
|
|
57
|
+
# realtime_url: http://path_to_websockets_server
|
|
58
|
+
# Add or override config options here
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module QuickSearch
|
|
2
|
+
class Engine < ::Rails::Engine
|
|
3
|
+
isolate_namespace QuickSearch
|
|
4
|
+
|
|
5
|
+
initializer :quick_search, :after => :add_view_paths do
|
|
6
|
+
config_file = File.join(Rails.root, "/config/quick_search_config.yml")
|
|
7
|
+
if File.exist?(config_file)
|
|
8
|
+
APP_CONFIG = YAML.load_file(config_file)[Rails.env]
|
|
9
|
+
ActiveSupport.on_load(:action_controller) do
|
|
10
|
+
theme_engine_class = "#{QuickSearch::Engine::APP_CONFIG['theme'].classify}::Engine".constantize
|
|
11
|
+
prepend_view_path theme_engine_class.root.join('app', 'views', QuickSearch::Engine::APP_CONFIG['theme'])
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/quick_search.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
namespace :best_bets do
|
|
2
|
+
desc 'Update the BestBets SOLR index from best_bets.yml'
|
|
3
|
+
task :update_index => :environment do
|
|
4
|
+
best_bets_yaml = File.join Rails.root, "/config/best_bets.yml"
|
|
5
|
+
best_bets = YAML.load_file(best_bets_yaml)['best_bets']
|
|
6
|
+
|
|
7
|
+
solr = RSolr.connect :url => QuickSearch::Engine::APP_CONFIG['best_bets']['solr_url']
|
|
8
|
+
|
|
9
|
+
solr.delete_by_query('*:*')
|
|
10
|
+
|
|
11
|
+
records = []
|
|
12
|
+
|
|
13
|
+
best_bets.each do |id, value|
|
|
14
|
+
record = {
|
|
15
|
+
:id => id,
|
|
16
|
+
:title => value['title'],
|
|
17
|
+
:url => value['url'],
|
|
18
|
+
:description => value['description'],
|
|
19
|
+
:keywords => value['keywords']
|
|
20
|
+
}
|
|
21
|
+
records << record
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
solr.add(records)
|
|
25
|
+
solr.commit
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class DoiTrapTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
include DoiTrap
|
|
6
|
+
|
|
7
|
+
test "should be a doi" do
|
|
8
|
+
doi = '10.1016/0046-8177(95)90302-X'
|
|
9
|
+
is_a_doi = is_a_doi?(doi)
|
|
10
|
+
assert is_a_doi
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
test "should not be a doi" do
|
|
14
|
+
doi = '0046-8177(95)90302-X'
|
|
15
|
+
is_a_doi = is_a_doi?(doi)
|
|
16
|
+
assert_not is_a_doi
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class OnCampusTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
include OnCampus
|
|
6
|
+
|
|
7
|
+
test "should be on campus" do
|
|
8
|
+
ip = '152.14.1.1'
|
|
9
|
+
on_campus = on_campus?(ip)
|
|
10
|
+
assert on_campus
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
test "should not be on campus" do
|
|
14
|
+
ip = '152.2.1.1'
|
|
15
|
+
on_campus = on_campus?(ip)
|
|
16
|
+
assert_not on_campus
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class QueryParserTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
include QueryParser
|
|
6
|
+
|
|
7
|
+
test "should extract basic prefixed scoped query" do
|
|
8
|
+
full_query = 'scope:scrc libraries'
|
|
9
|
+
|
|
10
|
+
query = extracted_query(full_query)
|
|
11
|
+
assert_equal('libraries', query)
|
|
12
|
+
|
|
13
|
+
scope = extracted_scope(full_query)
|
|
14
|
+
assert_equal('scrc', scope)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test "should extract basic suffixed scoped query" do
|
|
18
|
+
full_query = 'libraries scope:scrc'
|
|
19
|
+
|
|
20
|
+
query = extracted_query(full_query)
|
|
21
|
+
assert_equal('libraries', query)
|
|
22
|
+
|
|
23
|
+
scope = extracted_scope(full_query)
|
|
24
|
+
assert_equal('scrc', scope)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test "should extract compound prefixed scoped query" do
|
|
28
|
+
full_query = 'scope:(scrc OR jobs) libraries'
|
|
29
|
+
|
|
30
|
+
query = extracted_query(full_query)
|
|
31
|
+
assert_equal('libraries', query)
|
|
32
|
+
|
|
33
|
+
scope = extracted_scope(full_query)
|
|
34
|
+
assert_equal('scrc OR jobs', scope)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "should extract compound suffixed scoped query" do
|
|
38
|
+
full_query = 'libraries scope:(scrc OR jobs)'
|
|
39
|
+
|
|
40
|
+
query = extracted_query(full_query)
|
|
41
|
+
assert_equal('libraries', query)
|
|
42
|
+
|
|
43
|
+
scope = extracted_scope(full_query)
|
|
44
|
+
assert_equal('scrc OR jobs', scope)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class OpensearchControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
test "should return xml" do
|
|
6
|
+
@request.env['HTTP_ACCEPT'] = 'application/xml'
|
|
7
|
+
get :opensearch
|
|
8
|
+
|
|
9
|
+
assert_response :success
|
|
10
|
+
assert_select 'OpenSearchDescription'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class SearchControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
vcr_test "should return a summon searcher" do
|
|
6
|
+
get :index, q: 'printing'
|
|
7
|
+
assert assigns(:summon)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "should redirect to link resolver" do
|
|
11
|
+
get :index, q: 'doi:10.1002/0470841559.ch1'
|
|
12
|
+
assert_redirected_to 'http://js8lb8ft5y.search.serialssolutions.com/criteriarefiner/?SS_doi=10.1002/0470841559.ch1'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class GoogleAnalyticsTest < ActionDispatch::IntegrationTest
|
|
4
|
+
|
|
5
|
+
# FIXME maybe should use puffing-billy gem for this?
|
|
6
|
+
setup do
|
|
7
|
+
WebMock.disable!
|
|
8
|
+
Capybara.current_driver = Capybara.javascript_driver
|
|
9
|
+
visit root_path(q: 'printing')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
test "should capture google analytics data for all links in module" do
|
|
13
|
+
within("#catalog") do
|
|
14
|
+
click_link('Books & Media')
|
|
15
|
+
end
|
|
16
|
+
assert page.has_content?('heading')
|
|
17
|
+
|
|
18
|
+
click_link('book results')
|
|
19
|
+
assert page.has_content?('see-all-results')
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class SearchingTest < ActionDispatch::IntegrationTest
|
|
4
|
+
|
|
5
|
+
vcr_test "search box should give search results", "searches", cassette: 'printing' do
|
|
6
|
+
visit root_path
|
|
7
|
+
within('#quicksearch') do
|
|
8
|
+
fill_in :q, with: 'printing'
|
|
9
|
+
click_on('Search')
|
|
10
|
+
assert page.has_content?('Articles')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
vcr_test "should have article results", "searches", cassette: 'printing' do
|
|
15
|
+
visit root_path
|
|
16
|
+
within('#quicksearch') do
|
|
17
|
+
fill_in :q, with: 'printing'
|
|
18
|
+
click_on('Search')
|
|
19
|
+
assert page.has_content?('Beginning Os X Lion Apps ')
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
vcr_test "should present a spelling suggestion", "searches", cassette: 'speling' do
|
|
24
|
+
visit root_path
|
|
25
|
+
within('#quicksearch') do
|
|
26
|
+
fill_in :q, with: 'speling'
|
|
27
|
+
click_on('Search')
|
|
28
|
+
assert page.has_content?('Did you mean')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
vcr_test "should have FAQ results", "searches", cassette: 'printing' do
|
|
33
|
+
visit root_path
|
|
34
|
+
within('#quicksearch') do
|
|
35
|
+
fill_in :q, with: 'printing'
|
|
36
|
+
click_on('Search')
|
|
37
|
+
assert page.has_content?('Where is the Makerspace in Hunt Library')
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class SmartSubjectsSearchTest < ActionDispatch::IntegrationTest
|
|
4
|
+
vcr_test "should show smart subjects results", 'searches', cassette: 'printing' do
|
|
5
|
+
visit root_path(q: 'printing')
|
|
6
|
+
assert page.has_content?('Textile Chemistry')
|
|
7
|
+
end
|
|
8
|
+
end
|