quick_search-core 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -55
  3. data/Rakefile +30 -4
  4. data/app/assets/javascripts/quick_search/event_tracking.js.erb +2 -8
  5. data/app/assets/stylesheets/{quick_search.css.scss.erb → quick_search.scss.erb} +0 -0
  6. data/app/assets/stylesheets/quick_search/{appstats.css.scss → appstats.scss} +0 -0
  7. data/app/assets/stylesheets/quick_search/{opensearch.css.scss → opensearch.scss} +0 -0
  8. data/app/assets/stylesheets/quick_search/{pages.css.scss → pages.scss} +0 -0
  9. data/app/assets/stylesheets/quick_search/{quick_search.css.scss → quick_search.scss} +1 -0
  10. data/app/assets/stylesheets/quick_search/{search.css.scss → search.scss} +0 -0
  11. data/app/controllers/concerns/quick_search/searcher_concern.rb +8 -1
  12. data/app/controllers/concerns/quick_search/searcher_config.rb +5 -2
  13. data/app/controllers/quick_search/appstats_controller.rb +2 -2
  14. data/app/controllers/quick_search/search_controller.rb +7 -7
  15. data/app/models/application_record.rb +3 -0
  16. data/app/models/event.rb +1 -1
  17. data/app/models/search.rb +1 -1
  18. data/app/searchers/quick_search/best_bets_searcher.rb +25 -7
  19. data/app/views/layouts/quick_search/_google_analytics.html.erb +0 -9
  20. data/lib/generators/quick_search/install_generator.rb +101 -0
  21. data/lib/generators/quick_search/templates/best_bets.yml +86 -0
  22. data/lib/generators/quick_search/templates/post_install.txt +3 -1
  23. data/lib/generators/quick_search/templates/quick_search_config.yml +25 -3
  24. data/lib/quick_search.rb +0 -2
  25. data/lib/quick_search/engine.rb +16 -1
  26. data/lib/quick_search/version.rb +1 -1
  27. data/lib/tasks/best_bets.rake +2 -0
  28. data/test/controllers/concerns/doi_trap_test.rb +3 -3
  29. data/test/controllers/concerns/on_campus_test.rb +4 -4
  30. data/test/controllers/concerns/query_parser_test.rb +6 -6
  31. data/test/controllers/{appstats_controller_test.rb → quick_search/appstats_controller_test.rb} +1 -1
  32. data/test/controllers/{opensearch_controller_test.rb → quick_search/opensearch_controller_test.rb} +6 -1
  33. data/test/controllers/{pages_controller_test.rb → quick_search/pages_controller_test.rb} +1 -1
  34. data/test/controllers/quick_search/search_controller_test.rb +15 -0
  35. data/test/dummy/README.rdoc +28 -0
  36. data/test/dummy/Rakefile +6 -0
  37. data/test/dummy/app/assets/javascripts/application.js +13 -0
  38. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  39. data/test/dummy/app/controllers/application_controller.rb +5 -0
  40. data/test/dummy/app/helpers/application_helper.rb +2 -0
  41. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  42. data/test/dummy/bin/bundle +3 -0
  43. data/test/dummy/bin/rails +4 -0
  44. data/test/dummy/bin/rake +4 -0
  45. data/test/dummy/config.ru +4 -0
  46. data/{config → test/dummy/config}/application.rb +6 -8
  47. data/test/dummy/config/best_bets.yml +86 -0
  48. data/test/dummy/config/boot.rb +5 -0
  49. data/test/dummy/config/database.yml +25 -0
  50. data/test/dummy/config/environment.rb +5 -0
  51. data/test/dummy/config/environments/development.rb +37 -0
  52. data/test/dummy/config/environments/production.rb +78 -0
  53. data/test/dummy/config/environments/test.rb +39 -0
  54. data/test/dummy/config/initializers/assets.rb +8 -0
  55. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  56. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  57. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  58. data/test/dummy/config/initializers/inflections.rb +16 -0
  59. data/test/dummy/config/initializers/mime_types.rb +4 -0
  60. data/test/dummy/config/initializers/session_store.rb +3 -0
  61. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  62. data/test/dummy/config/locales/en.yml +23 -0
  63. data/test/dummy/config/quick_search_config.yml +58 -0
  64. data/test/dummy/config/routes.rb +6 -0
  65. data/test/dummy/config/secrets.yml +22 -0
  66. data/test/dummy/db/schema.rb +31 -0
  67. data/test/dummy/db/test.sqlite3 +0 -0
  68. data/test/dummy/log/benchmark.log +241 -0
  69. data/test/dummy/log/test.log +4762 -0
  70. data/test/dummy/public/404.html +67 -0
  71. data/test/dummy/public/422.html +67 -0
  72. data/test/dummy/public/500.html +66 -0
  73. data/test/dummy/public/favicon.ico +0 -0
  74. data/test/dummy/tmp/cache/assets/sprockets/v3.0/0_/0_w_ydOOEFQOoETxJa-IxKppQocaiDwM5V08djCPYso.cache +3 -0
  75. data/test/dummy/tmp/cache/assets/sprockets/v3.0/1n/1nStVaWIQEwAlksUpB1fInwq6v3TikPvuRaSwwCnCLQ.cache +1 -0
  76. data/test/dummy/tmp/cache/assets/sprockets/v3.0/3m/3mWfBeEpm_bJvaPQZYvnnAVtE_2helOWh_Tv-cEflrk.cache +5 -0
  77. data/test/dummy/tmp/cache/assets/sprockets/v3.0/4s/4sg52OgD5l4qx4GnojCVxg2itqwqb-KRanEdmdMus3Y.cache +0 -0
  78. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5U/5UPnsccuZFLk9OqbmFMvB55mbvGptApx9Z55HWjEN90.cache +3 -0
  79. data/test/dummy/tmp/cache/assets/sprockets/v3.0/9a/9acKNgyVD8_WK401tMy6Ce98g-LS4VpwFvGQdzCV9mI.cache +0 -0
  80. data/test/dummy/tmp/cache/assets/sprockets/v3.0/B5/B5ptGSZGmgHvoK2UDCAtpMhWxJEKxKFhyL9ACeBfzQk.cache +1 -0
  81. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ba/BaymviI8cwAJQMOIzWCf6Lt-PM2sNFTvY9hQKsfDNNw.cache +3 -0
  82. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Dd/DdFHg3C_voetfvKGKX7t8PGzZlkO45-huHNtaou5rxg.cache +1 -0
  83. data/test/dummy/tmp/cache/assets/sprockets/v3.0/F0/F0oWBwLHpGFYNNtnGav-dJFH8rMDpNA5L8_aWm5Wq34.cache +0 -0
  84. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fp/FprCQeeZguht46WNSpA3Y3JHKehovFXrj63nDrvvwFE.cache +1 -0
  85. data/test/dummy/tmp/cache/assets/sprockets/v3.0/GJ/GJrfWiarIi0Dt6sdKVMfUF1cdZ6NbqZxXHhzNbFtpBw.cache +1 -0
  86. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Gp/GpoziOxxB-hisco0rl7Nnsnw0UWud7R9Yge2Q3o1eN4.cache +2 -0
  87. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Hr/Hr-kCuPY72nIKAdnsDTz9JqXd_z1WL6FSGMAq4HppZg.cache +1 -0
  88. data/test/dummy/tmp/cache/assets/sprockets/v3.0/It/It5VkJv-53-LICLKZWWyp2WcbD86DGotAL0MY3hhfpg.cache +6 -0
  89. data/test/dummy/tmp/cache/assets/sprockets/v3.0/MA/MAY_nSUZSFcwPf9b-AWcqad4OIb_VKmHGs5E7PYdgvI.cache +2 -0
  90. data/test/dummy/tmp/cache/assets/sprockets/v3.0/O6/O6dw148Xya7NYlsRFMEzJyvRcySM6iOL1jRUpdQo9B8.cache +1 -0
  91. data/test/dummy/tmp/cache/assets/sprockets/v3.0/O8/O8akbUwAbmIKY-AhITimq-JDQ6IgsO3Hvq2v5etufFw.cache +2 -0
  92. data/test/dummy/tmp/cache/assets/sprockets/v3.0/OD/ODHapE0li3WI1laVJoksoI5nmQd-8dDJXq_VxS4XefE.cache +1 -0
  93. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Oj/OjMkKTW7OkthjJAQHDID8GV30IZC9F0dJ1zGiFame9U.cache +4 -0
  94. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Os/OsQkEOfE0Pfy_sIdEIVWLojZnQm4mcrZpXg4suYrV70.cache +2 -0
  95. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SU/SUtZ_ltPqy9A9A-_zqNPhNPvjxCOnrdqXHSZv5S9mOk.cache +1 -0
  96. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Tv/TvZgmm69VEMHUJQIBoij61oXMkgzp6whVo7l8mJ9qpw.cache +3 -0
  97. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UA/UAOIipK_ejTAUFI6XxASoweyUiC3t64VfVzV-MfsFD8.cache +0 -0
  98. data/test/dummy/tmp/cache/assets/sprockets/v3.0/YJ/YJZdK01T1KTS84Mb6p_2TasmJNZeGZc4FMtBPCKGr_M.cache +3 -0
  99. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ah/ahhhd3ysbQmVDNzq2L_rb4t6rqqdnqeY6ujztBoZDA8.cache +1 -0
  100. data/test/dummy/tmp/cache/assets/sprockets/v3.0/dz/dzCaa80YgyvJINTgsyrVhKv9UQ1OC82GfAsA-IP96iQ.cache +0 -0
  101. data/test/dummy/tmp/cache/assets/sprockets/v3.0/fI/fInu_Gja7ik39t207tqj4CtlL0akQRbjD2T7qEtd0zE.cache +1 -0
  102. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gv/gvZKkbgiExbcQrT4eo0HB-j4JoDRAxdmDjKRxeEdK0Y.cache +1 -0
  103. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hj/hj_r-O1QjHJIPcZVnlB_FGPdIRAi9NkxpT2oXDRIsGE.cache +1 -0
  104. data/test/dummy/tmp/cache/assets/sprockets/v3.0/jj/jjdQCKZsewws2eRP7b2AVxRMvseOp8djjlDkB8UOtac.cache +3 -0
  105. data/test/dummy/tmp/cache/assets/sprockets/v3.0/o2/o2V1ahk8vFR6sXWNh5BB7w6MBj04zCyX-o1xFZONydE.cache +1 -0
  106. data/test/dummy/tmp/cache/assets/sprockets/v3.0/o6/o6ZQbq1aBFuVrE2xLbSbyZH2736sWM3Yj4ky9chT1bI.cache +1 -0
  107. data/test/dummy/tmp/cache/assets/sprockets/v3.0/os/os0qWv3yDfep0e7vVSGTgfn_n3xc4C4QZgmMzLQn0Ks.cache +1 -0
  108. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pO/pO8hHVwybv1ZJBdPa2YC6bjqmk020OYFl85TYxtmrWQ.cache +0 -0
  109. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pj/pjJDYrBipDo6Tr9_-W4UDzfZZ4UPTy9YpXrBQFRXnlo.cache +3 -0
  110. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pw/pwiIhcWPwTuy5Miz5zqOQGYFx-K3TbaCVQ6ls7EBkk0.cache +0 -0
  111. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sR/sRU-UT8qK_38kkiFDXKBPogO1oOZuSvJFH-pgqPL_Ms.cache +0 -0
  112. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tE/tEO71oPPFXN_2c4p39nU0OiF9ARg13fjdQlnPqAx1KY.cache +4 -0
  113. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tP/tPF6H9NRpGO3whu2y5_e_R_1EACKdCwu5437D83qJT0.cache +2 -0
  114. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tW/tWFRsAv4WWu2ch-x3AJZd3KOvBXG3MwH6Q6Xn-tFBtw.cache +1 -0
  115. data/test/dummy/tmp/cache/assets/sprockets/v3.0/x6/x6W754ylumshr3wBUHHmcgyWs8UR3Od7FaI6tqvjKmk.cache +1 -0
  116. data/test/dummy/tmp/cache/assets/sprockets/v3.0/yy/yyJ1P7RQciOiW8TgQiu1RMDdbWd4rqxd2BGU9HkY3L8.cache +0 -0
  117. data/test/integration/searching_test.rb +15 -27
  118. data/test/searcher/best_bets_test.rb +13 -18
  119. data/test/test_helper.rb +23 -10
  120. data/test/vcr_cassettes/searches/best_bets_acm.yml +31 -0
  121. data/test/vcr_cassettes/searches/harry_potter.yml +6901 -0
  122. data/test/vcr_cassettes/searches/hunt_library.yml +66736 -0
  123. data/test/vcr_cassettes/searches/printing.yml +191 -0
  124. data/test/vcr_cassettes/searches/speling.yml +1172 -0
  125. metadata +197 -71
  126. data/test/controllers/search_controller_test.rb +0 -15
  127. data/test/integration/catalog_search_test.rb +0 -8
  128. data/test/integration/google_analytics_test.rb +0 -23
  129. data/test/integration/smart_subjects_test.rb +0 -8
  130. data/test/integration/website_search_test.rb +0 -8
  131. data/test/searcher/catalog_test.rb +0 -35
  132. data/test/searcher/ematrix_database_test.rb +0 -27
  133. data/test/searcher/ematrix_journal_test.rb +0 -27
  134. data/test/searcher/faq_test.rb +0 -27
  135. data/test/searcher/smart_subjects_test.rb +0 -27
  136. data/test/searcher/summon_test.rb +0 -13
  137. data/test/searcher/website_test.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 321f0450148c73d170124fa2c0ba56f5e2762a45
4
- data.tar.gz: 0993b7ba6e88ba4f2f130be31fa081cfb5b04591
3
+ metadata.gz: 23539ea74f21394249a312b7eabb3931fb9db0ed
4
+ data.tar.gz: 2bd211e5230357b90c760babca649e4c4d7b138e
5
5
  SHA512:
6
- metadata.gz: 36dad4fb86f7fd80d2e09962e0cf377b7dbfa4a11d6465a3a6879338a22cf75ddf02324cf7b5a4372a405e7c8e9c4287dfd7d32197e39b89a1332fbb1790f89e
7
- data.tar.gz: 38a1a60600c059987b4db18f864cad3ef3d5f730ac7d653c8ff7d12d7796759f826b2be5b306fb7e554d5452bd7dd92690522a0a5a059bc3ac6d70b09f624546
6
+ metadata.gz: e71d9c5dbaf542ed012c57906721d8e6558083977b5b671d362711e57aa9268650f26c171ef754e33f30f0066c78e8401315ed35e2d021ffccd092b0dfba2129
7
+ data.tar.gz: e7228c8b1cd7d08a63fa0ca3f837bdcf92d986b2e00cd7bb689fd902ead185d939fc53783d98d6e495b11bfda82661981718ec8123f0d57e4be59b541b2f9119
data/README.md CHANGED
@@ -4,6 +4,9 @@
4
4
  > looking for the original release of QuickSearch as a standalone Rails project, it can be found here:
5
5
  > https://github.com/NCSU-Libraries/quick_search/tree/pre-gem
6
6
 
7
+ [![Build Status](https://travis-ci.org/NCSU-Libraries/quick_search.svg?branch=master)](https://travis-ci.org/NCSU-Libraries/quick_search)
8
+ [![Gem Version](https://badge.fury.io/rb/quick_search-core.svg)](https://badge.fury.io/rb/quick_search-core)
9
+
7
10
  QuickSearch is a customized federated search tool designed to connect people to a variety of library resources, services, and tools. QuickSearch is designed to complement and increase use of existing dedicated library resource discovery tools, such as the catalog, electronic resource search, and subject guides/portals, by directing people to them via an intuitive search interface. The aim of QuickSearch is to provide people with a quick and easy way to find the information they need.
8
11
 
9
12
  For more information about NCSU Libraries' QuickSearch and the history of the project, see: http://www.lib.ncsu.edu/reports/quicksearch
@@ -27,52 +30,15 @@ production, but still should be considered an early release.
27
30
 
28
31
  ## Installation
29
32
 
30
- The aim of QuickSearch is to make it very easy to get up and running. There are several ways that you can go about installing it, depending on your situation.
31
-
32
- ### Vagrant
33
-
34
- If you’re interested in trying out QuickSearch, or you’re a developer looking to get a development environment up and running, the easiest way is to use Vagrant to create a virtual environment which automatically installs QuickSearch and its dependencies in only a couple easy steps.
35
-
36
- This method uses Ansible playbooks to provision the virtual environment
37
- and install QuickSearch, so it is a good guide to see how you might
38
- configure a server for a QuickSearch production envrionment.
39
-
40
- #### Prerequisites
41
-
42
- - Vagrant 1.8+ (http://www.vagrantup.com)
43
- - VirtualBox (https://www.virtualbox.org/wiki/Downloads)
44
-
45
- #### Instructions
46
-
47
- ##### Clone this repository
48
-
49
- git clone git@github.com:ncsu-libraries/quick_search
50
-
51
- ##### Change into the cloned directory
52
-
53
- cd quick_search
54
-
55
- ##### Run
33
+ The aim of QuickSearch is to make it very easy to get up and running.
56
34
 
57
- vagrant up
58
-
59
- > Note: sometimes the provisioning process will hang at the "dev-bundle |
60
- bundle install" step. If this happens, press Ctrl+C to kill the process,
61
- then run the following command to continue the provisioning process:
62
-
63
- vagrant provision
64
-
65
- #####Once this completes, you'll have a running instance of QuickSearch available at http://localhost:8888/
66
-
67
- ### Manual Installation
68
-
69
- Follow these instructions to manually install QuickSearch for
35
+ Follow these instructions to install QuickSearch for
70
36
  development.
71
37
 
72
38
  #### Prerequisites
73
39
 
74
- - Rails 4.1
75
- - Ruby 2.1
40
+ - Rails 5.0
41
+ - Ruby 2.2.2+ or 2.3.x
76
42
  - MySQL development headers (mysql-devel package on CentOS)
77
43
  - qtwebkit development headers (qtwebkit-devel package on CentOS)
78
44
 
@@ -86,11 +52,11 @@ development.
86
52
 
87
53
  cd my_app
88
54
 
89
- ##### Add quick_search_core gem to your Gemfile:
55
+ ##### Add quick_search-core gem to your Gemfile:
90
56
 
91
57
  gem 'quick_search-core'
92
58
 
93
- > For development, use: gem 'quick_search-core', :git => 'git://github.com/NCSU-Libraries/quick_search.git'
59
+ > For development, use: gem 'quick_search-core', git: 'git://github.com/NCSU-Libraries/quick_search.git'
94
60
 
95
61
  ##### Run 'bundle install'
96
62
 
@@ -98,7 +64,9 @@ development.
98
64
 
99
65
  bundle exec rails generate quick_search:install
100
66
 
101
- ##### Configure QuickSearch (see [Configuring QuickSearch](docs/configuration.md))
67
+ The generator will install the generic QuickSearch theme, and some
68
+ searchers that will work out of the box. For more information on further
69
+ configuring QuickSearch, see: [Configuring QuickSearch](docs/configuration.md)
102
70
 
103
71
  ##### Start the server:
104
72
 
@@ -124,29 +92,48 @@ For more in-depth documentation about this, see:
124
92
  Here are a list of searchers that have been created for QuickSearch so
125
93
  far. Feel free to submit a pull request to add to this list.
126
94
 
127
- |Searcher |Repository URL |
128
- |------------------------|----------------------------------------------------------------------|
129
- |arXiv |http://github.com/NCSU-Libraries/quick_search-arxiv_searcher |
130
- |Wikipedia |http://github.com/NCSU-Libraries/quick_search-wikipedia_searcher |
131
- |OpenLibrary |http://github.com/NCSU-Libraries/quick_search-open_library_searcher |
132
- |Summon |Coming soon |
133
- |NCSU Libraries' Catalog |Coming soon |
95
+ |Searcher |Line to include in Gemfile to install |Repository |
96
+ |------------------------|-----------------------------------------------|-----------------------------------|
97
+ |arxiv |gem 'quick_search-arxiv_searcher' |[quick_search-arxiv_searcher](https://www.github.com/ncsu-libraries/quick_search-arxiv_searcher) |
98
+ |wikipedia |gem 'quick_search-wikipedia_searcher' |[quick_search-wikipedia_searcher](https://www.github.com/ncsu-libraries/quick_search-wikipedia_searcher) |
99
+ |OpenLibrary |gem 'quick_search-open_library_searcher' |[quick_search-open_library_searcher](https://www.github.com/ncsu-libraries/quick_search-open_library_searcher) |
100
+ |Placeholder |gem 'quick_search-placeholder_searcher' |[quick_search-placeholder_searcher](https://www.github.com/ncsu-libraries/quick_search-placeholder_searcher) |
101
+ |Summon |Coming soon | |
102
+ |NCSU Libraries' Catalog |Coming soon | |
134
103
 
135
104
 
136
105
 
137
106
  ### Themes
138
107
 
139
- |Theme |Repository URL |
140
- |---------------|--------------------------------------------------------------------|
141
- |Generic Theme |http://github.com/NCSU-Libraries/quicksearch-generic_theme |
108
+ |Theme |Line to include in Gemfile to install |Repository |
109
+ |---------------|--------------------------------------|-----------------------------------|
110
+ |Generic Theme |gem 'quick_search-generic_theme' |[quick_search-generic_theme](https://www.github.com/ncsu-libraries/quick_search-generic_theme)|
111
+
112
+
113
+ ## Running the Tests
114
+
115
+ In order to run the tests, you'll need to have Xvfb installed. If you
116
+ are on CentOS, you can run:
117
+
118
+ sudo yum install org-x11-server-Xvfb
119
+
120
+ On Ubuntu/Debian:
121
+
122
+ sudo apt-get install xvfb
123
+
124
+ To set up the testing database, run:
125
+
126
+ RAILS_ENV=test bundle exec rake db:schema:load
127
+
128
+ Then, to run the tests:
142
129
 
130
+ bundle exec rake test
143
131
 
144
132
  ## TODO
145
133
 
146
134
  There are still some TODOs left in terms of extracting this code from
147
135
  our production codebase:
148
136
 
149
- - Fix tests
150
137
  - Improve documentation
151
138
 
152
139
  ## Bugs, Feature Requests, etc.
@@ -160,6 +147,7 @@ Here are the people who have contributed code to this implementation of
160
147
  QuickSearch (listed in alphabetical order)
161
148
 
162
149
  - Kevin Beswick
150
+ - Nushrat Khan
163
151
  - Cory Lown
164
152
  - Jason Ronallo
165
153
 
data/Rakefile CHANGED
@@ -1,6 +1,32 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
3
6
 
4
- require File.expand_path('../config/application', __FILE__)
7
+ require 'rdoc/task'
5
8
 
6
- QuickSearch::Application.load_tasks
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'QuickSearch'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ load 'rails/tasks/engine.rake'
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -197,15 +197,9 @@ var quickSearchEventTracking = (function () {
197
197
 
198
198
  function searchPage() {
199
199
  var pathname = window.location.pathname;
200
- if (pathname == '/') {
201
- var page = 'index';
202
- } else if (pathname.indexOf('website') > -1) {
203
- var page = 'search/website_search';
204
- } else {
205
- var page = pathname;
206
- }
207
200
 
208
- return page;
201
+ // Get the pathname relative to the application root
202
+ return pathname.replace("<%= ActionController::Base.relative_url_root || '' %>", "");
209
203
  }
210
204
 
211
205
  function logSearchToDatabase(searchValues) {
@@ -169,6 +169,7 @@
169
169
 
170
170
  .thumbnail {
171
171
  border: 1px solid #555555;
172
+ margin-top: 1.5em;
172
173
  }
173
174
 
174
175
  .citation {
@@ -27,13 +27,20 @@ module QuickSearch::SearcherConcern
27
27
  end
28
28
  end
29
29
 
30
+ # Constantize all searchers before creating searcher threads
31
+ # Excluding this line causes threads to hang indefinitely as of Rails 5
32
+ QuickSearch::Engine::APP_CONFIG['searchers'].each do |searcher_name|
33
+ "QuickSearch::#{searcher_name.camelize}Searcher".constantize
34
+ end
35
+
30
36
  searchers.shuffle.each do |search_method|
31
37
  search_threads << Thread.new(search_method) do |sm|
32
38
  benchmark "%s server #{sm}" % CGI.escape(query.to_str) do
33
39
  begin
34
40
  klass = "QuickSearch::#{sm.camelize}Searcher".constantize
41
+
35
42
  http_client = HTTPClient.new
36
- update_searcher_timeout(http_client, search_method)
43
+ update_searcher_timeout(http_client, sm)
37
44
  # FIXME: Probably want to set paging and offset somewhere else.
38
45
  # searcher = klass.new(http_client, params_q_scrubbed, QuickSearch::Engine::APP_CONFIG['per_page'], 0, 1, on_campus?(request.remote_ip))
39
46
  if sm == primary_searcher
@@ -8,8 +8,11 @@ module QuickSearch::SearcherConfig
8
8
  if searcher == 'best_bets'
9
9
  QuickSearch::Engine::APP_CONFIG['best_bets']
10
10
  else
11
- #TODO: test for the existence of this?
12
- "QuickSearch::Engine::#{searcher.upcase}_CONFIG".constantize
11
+ begin
12
+ "QuickSearch::Engine::#{searcher.upcase}_CONFIG".constantize
13
+ rescue NameError
14
+ nil
15
+ end
13
16
  end
14
17
  end
15
18
 
@@ -19,7 +19,7 @@ module QuickSearch
19
19
  def top_searches
20
20
  @page_title = 'Top Searches'
21
21
  searches_count
22
- searches = Search.where(page: 'index').where(date_range)
22
+ searches = Search.where(page: '/').where(date_range)
23
23
  queries = []
24
24
  searches.each do |search|
25
25
  queries << search["query"].downcase
@@ -83,7 +83,7 @@ module QuickSearch
83
83
  end
84
84
 
85
85
  def searches_count
86
- @searches_count = Search.where(page: 'index').where(date_range).count
86
+ @searches_count = Search.where(page: '/').where(date_range).count
87
87
  end
88
88
 
89
89
  def search_click_ratio
@@ -10,8 +10,8 @@ module QuickSearch
10
10
 
11
11
  require 'benchmark_logger'
12
12
 
13
- before_filter :doi_trap, :log_query
14
- after_filter :realtime_message, only: [:index]
13
+ before_action :doi_trap, :log_query
14
+ after_action :realtime_message, only: [:index]
15
15
  protect_from_forgery except: :log_event
16
16
 
17
17
  def index
@@ -117,9 +117,9 @@ module QuickSearch
117
117
  def log_search
118
118
  if params[:query].present? && params[:page].present?
119
119
  Search.create(query: params[:query], page: params[:page])
120
- render :nothing => true, :status => 200, :content_type => 'text/html'
120
+ head :ok
121
121
  else
122
- render :nothing => true, :status => 500, :content_type => 'text/html'
122
+ head :bad_request
123
123
  end
124
124
  end
125
125
 
@@ -127,12 +127,12 @@ module QuickSearch
127
127
  if params[:category].present? && params[:event_action].present? && params[:label].present?
128
128
  Event.create(category: params[:category], action: params[:event_action], label: params[:label][0..250])
129
129
  if params[:callback].present?
130
- render :nothing => true, :status => 200, :content_type => 'text/javascript'
130
+ head :ok, content_type: 'text/javascript'
131
131
  else
132
- render :nothing => true, :status => 200, :content_type => 'text/html'
132
+ head :ok
133
133
  end
134
134
  else
135
- render :nothing => true, :status => 500, :content_type => 'text/html'
135
+ head :bad_request
136
136
  end
137
137
  end
138
138
 
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
data/app/models/event.rb CHANGED
@@ -1,2 +1,2 @@
1
- class Event < ActiveRecord::Base
1
+ class Event < ApplicationRecord
2
2
  end
data/app/models/search.rb CHANGED
@@ -1,4 +1,4 @@
1
- class Search < ActiveRecord::Base
1
+ class Search < ApplicationRecord
2
2
 
3
3
  def self.get_most_frequent_searches
4
4
  frequent_searches = []
@@ -2,7 +2,13 @@ module QuickSearch
2
2
  class BestBetsSearcher < QuickSearch::Searcher
3
3
 
4
4
  def search
5
- search_best_bets_index
5
+ unless QuickSearch::Engine::APP_CONFIG['best_bets']['solr_url'].empty?
6
+ search_best_bets_index
7
+ else
8
+ if defined? QuickSearch::Engine::BEST_BETS
9
+ search_local_best_bets
10
+ end
11
+ end
6
12
  end
7
13
 
8
14
  def results
@@ -43,6 +49,23 @@ module QuickSearch
43
49
  end
44
50
  end
45
51
 
52
+ def search_local_best_bets
53
+ if QuickSearch::Engine::BEST_BETS_INDEX.has_key? http_request_queries['not_escaped'].downcase
54
+ best_bet_name = QuickSearch::Engine::BEST_BETS_INDEX[http_request_queries['not_escaped'].downcase]
55
+ best_bet = QuickSearch::Engine::BEST_BETS[best_bet_name]
56
+ result = OpenStruct.new
57
+ result.title = title(best_bet)
58
+ result.link = link(best_bet)
59
+ result.id = ''
60
+ result.description = description(best_bet)
61
+ result.best_bets_type = 'best-bets-regular'
62
+
63
+ @response = result
64
+ else
65
+ nil
66
+ end
67
+ end
68
+
46
69
  def base_url
47
70
  QuickSearch::Engine::APP_CONFIG['best_bets']['solr_url']
48
71
  end
@@ -76,12 +99,7 @@ module QuickSearch
76
99
  end
77
100
 
78
101
  def link(value)
79
- # TODO: should we make all URLS in the best_bets index absolute? currently some begin with a /
80
- if value['url'].start_with?('/')
81
- QuickSearch::Engine::APP_CONFIG['website']['website_base_url'] + value['url']
82
- else
83
- value['url']
84
- end
102
+ value['url']
85
103
  end
86
104
 
87
105
  def id(value)
@@ -1,14 +1,5 @@
1
1
  <% if Rails.env == 'production' or Rails.env == 'staging' %>
2
2
  <script>
3
- //Univeral Analytics
4
- // (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5
- // (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6
- // m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7
- // })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
8
-
9
- // ga('create', "<%= APP_CONFIG['google_analytics_tracking_id'] %>", 'ncsu.edu'); //FIXME: Add id for quicksearch GA
10
- // ga('send', 'pageview');
11
-
12
3
  // Classic Analytics
13
4
  var _gaq = _gaq || [];
14
5
  _gaq.push(['_setAccount', "<%= QuickSearch::Engine::APP_CONFIG['google_analytics_tracking_id'] %>"]);
@@ -11,11 +11,105 @@ ROUTES
11
11
  insert_into_file "config/routes.rb", routes, :after => "Rails.application.routes.draw do\n"
12
12
  end
13
13
 
14
+
15
+ desc 'insert generic theme'
16
+ def insert_theme
17
+
18
+ theme_gem_entry = <<-THEME
19
+ \n
20
+ # -Inserted by QuickSearch-
21
+
22
+ # QuickSearch theme
23
+ #
24
+ # Remove the following if you want to use a different theme
25
+
26
+ gem 'quick_search-generic_theme'
27
+
28
+ # END -Inserted by QuickSearch-
29
+
30
+ THEME
31
+
32
+
33
+ say("\nYou'll need to include a theme which QuickSearch uses to render your results. We've built a generic
34
+ theme which can be modified or extended to meet your needs. Alternatively you can build your own from
35
+ scratch and include it.\n\n")
36
+
37
+ @theme_response = ask("Would you like to install the generic theme?", limited_to: ['y', 'n'])
38
+
39
+ if @theme_response == 'y'
40
+ insert_into_file "Gemfile", theme_gem_entry, :after => /gem [\"\']quick_search-core[\"\'].*$/
41
+ end
42
+
43
+ end
44
+
45
+
46
+ desc 'insert searchers'
47
+ def insert_searchers
48
+ searcher_gem_entry = <<-SEARCHERS
49
+ \n
50
+ # -Inserted by QuickSearch-
51
+
52
+ # QuickSearch searchers
53
+ #
54
+ # If you want to use different searchers, remove/replace these and be sure to remove them from
55
+ # your config/quick_search_config.yml file as well as references to them in your theme's search
56
+ # results page template
57
+
58
+ gem 'quick_search-wikipedia_searcher'
59
+ gem 'quick_search-open_library_searcher'
60
+ gem 'quick_search-arxiv_searcher'
61
+ gem 'quick_search-placeholder_searcher'
62
+
63
+ # -END Inserted by QuickSearch-
64
+
65
+ SEARCHERS
66
+
67
+ say("\nTo have a working application you'll need to install some searchers. Searchers are the
68
+ code that integrates with third-party APIs, handles performing searches and creating results objects.
69
+ By default quick_search-core provides no searchers. Some searchers are available and it is easy to
70
+ write your own.\n\n")
71
+
72
+
73
+ @searcher_response = ask("Would you like to install some basic searchers that do not require API keys?", limited_to: ['y', 'n'])
74
+
75
+ if @searcher_response == 'y'
76
+ insert_into_file "Gemfile", searcher_gem_entry, :after => /gem [\"\']quick_search-core[\"\'].*$/
77
+ end
78
+
79
+ end
80
+
81
+
82
+ desc 'bundle install theme/searchers'
83
+ def bundle_install_theme_searchers
84
+ Bundler.with_clean_env do
85
+ run "bundle install"
86
+ end
87
+ end
88
+
14
89
  desc 'create application configuration file'
15
90
  def quick_search_config_yml
16
91
  copy_file 'quick_search_config.yml', 'config/quick_search_config.yml'
17
92
  end
18
93
 
94
+ desc 'update quick_search_config.yml'
95
+ def update_quick_search_config
96
+ if @theme_response == 'y'
97
+ theme_config = 'quick_search_generic_theme'
98
+ insert_into_file "config/quick_search_config.yml", theme_config, :after => /^ theme: '/
99
+ end
100
+ if @searcher_response == 'y'
101
+ included_searchers = ',arxiv,open_library,wikipedia,placeholder'
102
+ included_found_types = 'arxiv,open_library,wikipedia,placeholder,placeholder,placeholder,placeholder'
103
+ insert_into_file "config/quick_search_config.yml", included_searchers, :after => /^ searchers: \[best_bets/
104
+ insert_into_file "config/quick_search_config.yml", included_found_types, :after => /^ found_types: \[/
105
+ end
106
+ end
107
+
108
+ desc 'create best bets configuration file'
109
+ def best_bets_yml
110
+ copy_file 'best_bets.yml', 'config/best_bets.yml'
111
+ end
112
+
19
113
  desc 'create kaminari initializer'
20
114
  def kaminari_initializer
21
115
  copy_file 'kaminari.rb', 'config/initializers/kaminari.rb'
@@ -40,6 +134,13 @@ ROUTES
40
134
 
41
135
  desc 'display messages about what needs to be configured'
42
136
  def configuration_messages
137
+ say "QuickSearch installation complete.\n\n", :green
138
+ if @searcher_response == 'y'
139
+ say "We've installed a set of default searchers.\n", :green
140
+ end
141
+ if @theme_response == 'y'
142
+ say "We've installed the generic theme.\n", :green
143
+ end
43
144
  file = File.read(File.join( File.expand_path('../templates', __FILE__), 'post_install.txt'))
44
145
  say file, :green
45
146
  end