blacklight 3.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.gitignore +17 -0
  2. data/.gitmodules +6 -0
  3. data/.yardopts +4 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +14 -0
  6. data/README.rdoc +168 -0
  7. data/Rakefile +9 -0
  8. data/app/controllers/bookmarks_controller.rb +98 -0
  9. data/app/controllers/feedback_controller.rb +37 -0
  10. data/app/controllers/folder_controller.rb +49 -0
  11. data/app/controllers/saved_searches_controller.rb +45 -0
  12. data/app/controllers/search_history_controller.rb +25 -0
  13. data/app/helpers/blacklight_helper.rb +606 -0
  14. data/app/helpers/bookmarks_helper.rb +3 -0
  15. data/app/helpers/catalog_helper.rb +65 -0
  16. data/app/helpers/feedback_helper.rb +2 -0
  17. data/app/helpers/hash_as_hidden_fields.rb +57 -0
  18. data/app/helpers/render_constraints_helper.rb +120 -0
  19. data/app/helpers/saved_searches_helper.rb +2 -0
  20. data/app/helpers/search_history_helper.rb +2 -0
  21. data/app/models/bookmark.rb +6 -0
  22. data/app/models/record_mailer.rb +43 -0
  23. data/app/models/search.rb +19 -0
  24. data/app/views/_flash_msg.html.erb +6 -0
  25. data/app/views/_user_util_links.html.erb +13 -0
  26. data/app/views/bookmarks/index.html.erb +33 -0
  27. data/app/views/catalog/_bookmark_control.html.erb +25 -0
  28. data/app/views/catalog/_bookmark_form.html.erb +8 -0
  29. data/app/views/catalog/_citation.html.erb +15 -0
  30. data/app/views/catalog/_constraints.html.erb +7 -0
  31. data/app/views/catalog/_constraints_element.html.erb +33 -0
  32. data/app/views/catalog/_did_you_mean.html.erb +10 -0
  33. data/app/views/catalog/_document_list.html.erb +30 -0
  34. data/app/views/catalog/_email_form.html.erb +11 -0
  35. data/app/views/catalog/_facet_limit.html.erb +33 -0
  36. data/app/views/catalog/_facet_pagination.html.erb +28 -0
  37. data/app/views/catalog/_facets.html.erb +9 -0
  38. data/app/views/catalog/_folder_control.html.erb +12 -0
  39. data/app/views/catalog/_home.html.erb +6 -0
  40. data/app/views/catalog/_home_text.html.erb +6 -0
  41. data/app/views/catalog/_index_partials/_default.erb +11 -0
  42. data/app/views/catalog/_marc_view.html.erb +33 -0
  43. data/app/views/catalog/_opensearch_response_metadata.html.erb +3 -0
  44. data/app/views/catalog/_previous_next_doc.html.erb +6 -0
  45. data/app/views/catalog/_refworks_form.html.erb +7 -0
  46. data/app/views/catalog/_results_pagination.html.erb +11 -0
  47. data/app/views/catalog/_search_form.html.erb +14 -0
  48. data/app/views/catalog/_show_partials/_default.html.erb +9 -0
  49. data/app/views/catalog/_show_sidebar.html.erb +1 -0
  50. data/app/views/catalog/_show_tools.html.erb +46 -0
  51. data/app/views/catalog/_sms_form.html.erb +23 -0
  52. data/app/views/catalog/_solr_request.html.erb +5 -0
  53. data/app/views/catalog/_sort_and_per_page.html.erb +20 -0
  54. data/app/views/catalog/_unapi_microformat.html.erb +1 -0
  55. data/app/views/catalog/citation.html.erb +1 -0
  56. data/app/views/catalog/email.erb +1 -0
  57. data/app/views/catalog/endnote.endnote.erb +1 -0
  58. data/app/views/catalog/facet.html.erb +28 -0
  59. data/app/views/catalog/index.atom.builder +108 -0
  60. data/app/views/catalog/index.html.erb +37 -0
  61. data/app/views/catalog/index.rss.builder +19 -0
  62. data/app/views/catalog/librarian_view.html.erb +3 -0
  63. data/app/views/catalog/opensearch.json.erb +0 -0
  64. data/app/views/catalog/opensearch.xml.erb +11 -0
  65. data/app/views/catalog/send_email_record.erb +0 -0
  66. data/app/views/catalog/show.endnote.erb +1 -0
  67. data/app/views/catalog/show.html.erb +42 -0
  68. data/app/views/catalog/show.refworks.erb +1 -0
  69. data/app/views/catalog/sms.erb +1 -0
  70. data/app/views/catalog/unapi.xml.builder +6 -0
  71. data/app/views/feedback/complete.html.erb +3 -0
  72. data/app/views/feedback/show.html.erb +20 -0
  73. data/app/views/folder/_tools.html.erb +23 -0
  74. data/app/views/folder/index.html.erb +44 -0
  75. data/app/views/layouts/blacklight.html.erb +49 -0
  76. data/app/views/record_mailer/email_record.erb +6 -0
  77. data/app/views/record_mailer/sms_record.erb +4 -0
  78. data/app/views/saved_searches/index.html.erb +27 -0
  79. data/app/views/search_history/index.html.erb +23 -0
  80. data/blacklight.gemspec +50 -0
  81. data/config.ru +4 -0
  82. data/config/routes.rb +54 -0
  83. data/db/seeds.rb +7 -0
  84. data/features/generators.feature +77 -0
  85. data/features/support/aruba.rb +9 -0
  86. data/install.rb +0 -0
  87. data/install/solr.yml +8 -0
  88. data/lib/blacklight.rb +121 -0
  89. data/lib/blacklight/catalog.rb +311 -0
  90. data/lib/blacklight/comma_link_renderer.rb +27 -0
  91. data/lib/blacklight/configurable.rb +46 -0
  92. data/lib/blacklight/controller.rb +121 -0
  93. data/lib/blacklight/engine.rb +32 -0
  94. data/lib/blacklight/exceptions.rb +13 -0
  95. data/lib/blacklight/marc.rb +46 -0
  96. data/lib/blacklight/marc/citation.rb +251 -0
  97. data/lib/blacklight/search_fields.rb +107 -0
  98. data/lib/blacklight/solr.rb +7 -0
  99. data/lib/blacklight/solr/document.rb +239 -0
  100. data/lib/blacklight/solr/document/dublin_core.rb +40 -0
  101. data/lib/blacklight/solr/document/email.rb +15 -0
  102. data/lib/blacklight/solr/document/marc.rb +84 -0
  103. data/lib/blacklight/solr/document/marc_export.rb +430 -0
  104. data/lib/blacklight/solr/document/sms.rb +13 -0
  105. data/lib/blacklight/solr/facet_paginator.rb +93 -0
  106. data/lib/blacklight/solr_helper.rb +413 -0
  107. data/lib/blacklight/user.rb +55 -0
  108. data/lib/blacklight/version.rb +3 -0
  109. data/lib/colorize.rb +196 -0
  110. data/lib/generators/blacklight/blacklight_generator.rb +134 -0
  111. data/lib/generators/blacklight/templates/SolrMarc.jar +0 -0
  112. data/lib/generators/blacklight/templates/catalog_controller.rb +8 -0
  113. data/lib/generators/blacklight/templates/config/SolrMarc/config-test.properties +37 -0
  114. data/lib/generators/blacklight/templates/config/SolrMarc/config.properties +37 -0
  115. data/lib/generators/blacklight/templates/config/SolrMarc/index.properties +97 -0
  116. data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/dewey.bsh +47 -0
  117. data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/format.bsh +126 -0
  118. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/README_MAPS +1 -0
  119. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/callnumber_map.properties +407 -0
  120. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/composition_era_map.properties +56 -0
  121. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/country_map.properties +379 -0
  122. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/format_map.properties +50 -0
  123. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/instrument_map.properties +101 -0
  124. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/language_map.properties +490 -0
  125. data/lib/generators/blacklight/templates/config/blacklight_config.rb +245 -0
  126. data/lib/generators/blacklight/templates/config/solr.yml +6 -0
  127. data/lib/generators/blacklight/templates/migrations/add_user_types_to_bookmarks_searches.rb +11 -0
  128. data/lib/generators/blacklight/templates/migrations/create_bookmarks.rb +17 -0
  129. data/lib/generators/blacklight/templates/migrations/create_searches.rb +15 -0
  130. data/lib/generators/blacklight/templates/migrations/remove_editable_fields_from_bookmarks.rb +11 -0
  131. data/lib/generators/blacklight/templates/public/images/blacklight/bg.png +0 -0
  132. data/lib/generators/blacklight/templates/public/images/blacklight/border.png +0 -0
  133. data/lib/generators/blacklight/templates/public/images/blacklight/bul_sq_gry.gif +0 -0
  134. data/lib/generators/blacklight/templates/public/images/blacklight/checkmark.gif +0 -0
  135. data/lib/generators/blacklight/templates/public/images/blacklight/logo.png +0 -0
  136. data/lib/generators/blacklight/templates/public/images/blacklight/magnifying_glass.gif +0 -0
  137. data/lib/generators/blacklight/templates/public/images/blacklight/remove.gif +0 -0
  138. data/lib/generators/blacklight/templates/public/images/blacklight/separator.gif +0 -0
  139. data/lib/generators/blacklight/templates/public/images/blacklight/start_over.gif +0 -0
  140. data/lib/generators/blacklight/templates/public/javascripts/blacklight.js +485 -0
  141. data/lib/generators/blacklight/templates/public/javascripts/jquery-1.4.2.min.js +154 -0
  142. data/lib/generators/blacklight/templates/public/javascripts/jquery-ui-1.8.1.custom.min.js +756 -0
  143. data/lib/generators/blacklight/templates/public/stylesheets/blacklight.css +487 -0
  144. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  145. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  146. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  147. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  148. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  149. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  150. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_gloss-wave_35_558fd0_500x100.png +0 -0
  151. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  152. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  153. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  154. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  155. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_2e4f81_256x240.png +0 -0
  156. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  157. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  158. data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/jquery-ui-1.8.1.custom.css +486 -0
  159. data/lib/generators/blacklight/templates/public/stylesheets/yui.css +31 -0
  160. data/lib/generators/blacklight/templates/solr_document.rb +30 -0
  161. data/lib/railties/blacklight.rake +66 -0
  162. data/lib/railties/cucumber.rake +53 -0
  163. data/lib/railties/rspec.rake +188 -0
  164. data/lib/railties/solr_marc.rake +148 -0
  165. data/lib/railties/test_solr_server.rb +130 -0
  166. data/spec/helpers/catalog_helper_spec.rb +111 -0
  167. data/spec/views/catalog/_sms_form.html.erb_spec.rb +19 -0
  168. data/tasks/blacklight_tasks.rake +4 -0
  169. data/uninstall.rb +1 -0
  170. metadata +431 -0
@@ -0,0 +1,17 @@
1
+ .DS_Store
2
+ .svn
3
+ coverage.data
4
+ coverage/
5
+ db/*.sqlite3
6
+ db/schema.rb
7
+ jetty/logs/*.log
8
+ jetty/solr/data/*
9
+ log/*
10
+ webrat-*
11
+ config/SolrMarc/*.log*
12
+ rerun.txt
13
+ solr_marc/solrmarc.log
14
+
15
+ *.log
16
+ .bundle
17
+ Gemfile.lock
@@ -0,0 +1,6 @@
1
+ [submodule "test_app/jetty"]
2
+ path = test_app/jetty
3
+ url = git://github.com/projectblacklight/blacklight-jetty.git
4
+ [submodule "test_app/data"]
5
+ path = test_app/data
6
+ url = git://github.com/projectblacklight/blacklight-data.git
@@ -0,0 +1,4 @@
1
+ --protected
2
+ -
3
+ app/**/*.rb
4
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Please see blacklight.gemspec for dependency information.
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ ##########################################################################
2
+ # Copyright 2008 Rector and Visitors of the University of Virginia
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
@@ -0,0 +1,168 @@
1
+ Please note: The main Blacklight website is http://projectblacklight.org
2
+
3
+ =Installing Blacklight
4
+
5
+ == Some background information
6
+
7
+ Blacklight is open source discovery software. Libraries (or anyone else) can use Blacklight to enable searching and browsing of their collections online. Blacklight uses the Apache SOLR ( http://lucene.apache.org/solr ) search engine to index and search full text and/or metadata, and Blacklight has a highly configurable Ruby on Rails front-end. Blacklight was originally developed at the University of Virginia Library and is made public under an Apache 2.0 license.
8
+
9
+ == Install & Use (With Devise)
10
+
11
+ Create a new rails 3 application
12
+
13
+ $ rails new my_app
14
+
15
+ Add blacklight to your gem file
16
+
17
+ /my_app/Gemfile
18
+ ...
19
+ gem 'blackight'
20
+
21
+ Install blacklight
22
+
23
+ $ rails generate blacklight --devise
24
+
25
+ Run your database migrations
26
+
27
+ $ rake db:migrate
28
+
29
+ Start up your application
30
+
31
+ $ rails server
32
+
33
+ Visit the catalog at: http://localhost/catalog
34
+
35
+
36
+ == Install and Use (with a custom user authentication system)
37
+
38
+ Blacklight 3 requires Rails 3.0 or greater.
39
+
40
+ Add the blacklight gem to your ./Gemfile
41
+
42
+ gem 'blacklight'
43
+
44
+ $ bundle install
45
+
46
+ If you have a user model already, the Blacklight generator will connect to it automatically during installation. However, you will need to make sure the following named routes are included in your /config/routes.rb file:
47
+
48
+ match 'new_user_session', :to => 'Your User Session Controller # Log in action'
49
+ match 'destroy_user_session', :to => 'Your User Session Controller # Log Out action'
50
+
51
+ And you will need to make sure the following helper methods are available:
52
+
53
+ current_user - Which should return a user object that include Blacklight::User
54
+ user_session - Which should return a user session
55
+
56
+ Once these are in place, you can run the Blacklight Installation Generator:
57
+
58
+ rails generate blacklight
59
+
60
+ Execute your migrations, and you should be good to go.
61
+
62
+ rake db:migrate
63
+
64
+ Start up your application
65
+
66
+ $ rails server
67
+
68
+ Visit the catalog at: http://localhost/catalog
69
+
70
+ == Setting up a development environment
71
+
72
+ Checkout the code:
73
+
74
+ $ git clone git@github.com:projectblacklight/blacklight.git blacklight
75
+ $ cd blacklight
76
+
77
+ (While the rails3 branch is still a seperate branch called 'rails3':)
78
+ $ git checkout -t origin/rails3
79
+
80
+ Now create a test bed application inside of Blacklight that will allow you
81
+ to include Blacklight as a gem.
82
+ The test_app directory already exists, and contains a .gitignore file that
83
+ will mean all of the generated code is ingored. - There are a few directories
84
+ already in palce in test_app that WILL be included in the git repository. These
85
+ include:
86
+ * test_app/features - which contains cucumber tests for blacklight
87
+ * test_app/spec - rspec tests
88
+ * test_app/jetty - The blacklight Jetty module (discussed later)
89
+ * test_app/data - Another remote module.
90
+
91
+ To create the rails application:
92
+
93
+ $ rails new test_app --skip-test-unit --skip-git
94
+
95
+ Or if you are using Jruby:
96
+
97
+ $ jruby -S rails new test_app -m http://jruby.org/rails3.rb --skip-test-unit --skip-git
98
+
99
+ Add gem 'blacklight' to the test applications Gemfile:
100
+
101
+ gem 'blacklight', :path => '../'
102
+
103
+ Run bundle install in the test app
104
+ $ bundle install
105
+
106
+ Install and configure blacklight (with devise setting)
107
+ $ rails generate blacklight --devise
108
+
109
+ Remove index.html - which will allow the routes to take you directly to the catalog page.
110
+ $ rm public/index.html (allow us to redirect to catalog)
111
+
112
+ Migrate your database
113
+ $ rake db:migrate
114
+
115
+ Get Solr running somewhere. If you don't have Solr installed, blacklight comes with a default setup.
116
+ $ cd blacklight
117
+ $ git submodule init
118
+ $ git submodule update
119
+ $ cd test_app
120
+ $ rake solr:marc:index_test_data RAILS_ENV=test
121
+ $ cd jetty
122
+ $ java -jar start.jar
123
+
124
+ Start up your Server, and take a test run. (from blacklight/test_app)
125
+ $ rails server
126
+
127
+ Now go check it out, should be running.
128
+
129
+ == Running the tests
130
+
131
+ You will need to add some gems to your test_app's Gemfile
132
+
133
+ group :development, :test do
134
+ gem "rspec"
135
+ gem "rspec-rails", "~>2.5.0"
136
+ gem "cucumber-rails"
137
+ gem "database_cleaner"
138
+ gem "capybara"
139
+ gem "webrat"
140
+ gem "aruba"
141
+ end
142
+
143
+ Run bundle install
144
+
145
+ $ bundle install
146
+
147
+ Install cucumber
148
+
149
+ $ rails generate cucumber:install
150
+
151
+ If you haven't yet done this to load the bundled jetty/solr environment and test data in your blacklight checkout, from the blacklight checkout dir:
152
+ git submodule init
153
+ git submodule update
154
+
155
+ Load in the test data
156
+
157
+ $ rake solr:marc:index_test_data RAILS_ENV=test
158
+
159
+ Run the tests
160
+
161
+ $ rake solr:spec
162
+ $ rake solr:features
163
+
164
+ ==Pre-requisites
165
+ Whichever method you choose for installation, be sure you have all the pre-requisites in place. You can find these detailed in {PRE-REQUISITES}[https://github.com/projectblacklight/blacklight/wiki/PRE-REQUISITES]
166
+
167
+ ==Running solr
168
+ You'll also want some information about how Blacklight expects Apache SOLR ( http://lucene.apache.org/solr ) to run, which you can find in {README_SOLR}[https://github.com/projectblacklight/blacklight/wiki/README_SOLR]
@@ -0,0 +1,9 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rake'
@@ -0,0 +1,98 @@
1
+ # note that while this is mostly restful routing, the #update and #destroy actions
2
+ # take the Solr document ID as the :id, NOT the id of the actual Bookmark action.
3
+ class BookmarksController < ApplicationController
4
+
5
+ before_filter :verify_user
6
+
7
+ # Beware, :id is the Solr document_id, not the actual Bookmark id.
8
+ # idempotent, as PUT is supposed to be.
9
+ # you can also send a bookmark[title] param, which will be used for simplest case
10
+ # or fall through display of Bookmark in list.
11
+ def update
12
+ bookmark = current_user.existing_bookmark_for(params[:id])
13
+ if bookmark
14
+ #update existing one with new values if present
15
+ bookmark.attributes = params[:bookmark] if params[:bookmark]
16
+ else
17
+ # create new one with values and document_id
18
+ bookmark = current_user.bookmarks.build(params[:bookmark].merge(:document_id => params[:id]))
19
+ end
20
+
21
+ success = bookmark.save
22
+
23
+ unless request.xhr?
24
+ if bookmark.save
25
+ flash[:notice] = "Successfully added bookmark."
26
+ else
27
+ flash[:error] = "Could not save bookmark."
28
+ end
29
+ redirect_to :back
30
+ else
31
+ #ajaxy request doesn't need a redirect and shouldn't have flash set
32
+ render :text => "", :status => (success ? "200" : "500" )
33
+ end
34
+ end
35
+
36
+ def index
37
+ @bookmarks = current_user.bookmarks.paginate :page => params[:page]
38
+ end
39
+
40
+ # For adding a single bookmark, suggest use PUT/#update to
41
+ # /bookmarks/$docuemnt_id instead.
42
+ # But this method, accessed via POST to /bookmarks, can be used for
43
+ # creating multiple bookmarks at once, by posting with keys
44
+ # such as bookmarks[n][document_id], bookmarks[n][title].
45
+ # It can also be used for creating a single bookmark by including keys
46
+ # bookmark[title] and bookmark[document_id], but in that case #update
47
+ # is simpler.
48
+ def create
49
+ @bookmarks = params[:bookmarks] || []
50
+ @bookmarks << params[:bookmark] if params[:bookmark]
51
+
52
+ success = true
53
+ @bookmarks.each do |key, bookmark|
54
+ success = false unless current_user.bookmarks.create(bookmark)
55
+ end
56
+ if @bookmarks.length > 0 && success
57
+ flash[:notice] = "Successfully added bookmarks."
58
+ elsif @bookmarks.length > 0
59
+ flash[:error] = "There was a problem adding bookmarks"
60
+ end
61
+
62
+ redirect_to :back
63
+ end
64
+
65
+ # Beware, :id is the Solr document_id, not the actual Bookmark id.
66
+ # idempotent, as DELETE is supposed to be.
67
+ def destroy
68
+ bookmark = current_user.existing_bookmark_for(params[:id])
69
+
70
+ success = (!bookmark) || current_user.bookmarks.delete(bookmark)
71
+
72
+ unless request.xhr?
73
+ if success
74
+ flash[:notice] = "Successfully removed bookmark."
75
+ else
76
+ flash[:error] = "Sorry, there was a problem removing the bookmark."
77
+ end
78
+ redirect_to :back
79
+ else
80
+ # ajaxy request needs no redirect and should not have flash set
81
+ render :text => "", :status => (success ? "200" : "500")
82
+ end
83
+ end
84
+
85
+ def clear
86
+ if current_user.bookmarks.clear
87
+ flash[:notice] = "Cleared your bookmarks."
88
+ else
89
+ flash[:error] = "There was a problem clearing your bookmarks."
90
+ end
91
+ redirect_to :action => "index"
92
+ end
93
+
94
+ protected
95
+ def verify_user
96
+ flash[:notice] = "Please log in to manage and view your bookmarks." and raise Blacklight::Exceptions::AccessDenied unless current_user
97
+ end
98
+ end
@@ -0,0 +1,37 @@
1
+ class FeedbackController < ApplicationController
2
+
3
+ # http://expressica.com/simple_captcha/
4
+ # include SimpleCaptcha::ControllerHelpers
5
+
6
+ # show the feedback form
7
+ def show
8
+ @errors=[]
9
+ if request.post?
10
+ if validate
11
+ Notifier.feedback(params)
12
+ redirect_to feedback_complete_path
13
+ end
14
+ end
15
+ end
16
+
17
+ protected
18
+
19
+ # validates the incoming params
20
+ # returns either an empty array or an array with error messages
21
+ def validate
22
+ unless params[:name] =~ /\w+/
23
+ @errors << 'A valid name is required'
24
+ end
25
+ unless params[:email] =~ /\w+@\w+\.\w+/
26
+ @errors << 'A valid email address is required'
27
+ end
28
+ unless params[:message] =~ /\w+/
29
+ @errors << 'A message is required'
30
+ end
31
+ #unless simple_captcha_valid?
32
+ # @errors << 'Captcha did not match'
33
+ #end
34
+ @errors.empty?
35
+ end
36
+
37
+ end
@@ -0,0 +1,49 @@
1
+ class FolderController < ApplicationController
2
+
3
+ include Blacklight::SolrHelper
4
+
5
+ # fetch the documents that match the ids in the folder
6
+ def index
7
+ @response, @documents = get_solr_response_for_field_values("id",session[:folder_document_ids] || [])
8
+ end
9
+
10
+
11
+ # add a document_id to the folder. :id of action is solr doc id
12
+ def update
13
+ session[:folder_document_ids] = session[:folder_document_ids] || []
14
+ session[:folder_document_ids] << params[:id]
15
+ # Rails 3 uses a one line notation for setting the flash notice.
16
+ # flash[:notice] = "#{params[:title] || "Item"} successfully added to Folder"
17
+ respond_to do |format|
18
+ format.html { redirect_to :back, :notice => "#{params[:title] || "Item"} successfully added to Folder"}
19
+ format.js { render :json => session[:folder_document_ids] }
20
+ end
21
+ end
22
+
23
+ # remove a document_id from the folder. :id of action is solr_doc_id
24
+ def destroy
25
+ session[:folder_document_ids].delete(params[:id])
26
+
27
+ unless request.xhr?
28
+ respond_to do |format|
29
+ format.html do
30
+ flash[:notice] = "#{params[:title] || "Item"} successfully removed from selected items"
31
+ redirect_to :back
32
+ end
33
+ end
34
+ else
35
+ render :text => "OK"
36
+ end
37
+ end
38
+
39
+ # get rid of the items in the folder
40
+ def clear
41
+ flash[:notice] = "Cleared Selected Items"
42
+ session[:folder_document_ids] = []
43
+ respond_to do |format|
44
+ format.html { redirect_to :back }
45
+ format.js { render :json => session[:folder_document_ids] }
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,45 @@
1
+ class SavedSearchesController < ApplicationController
2
+ before_filter :verify_user
3
+
4
+ def index
5
+ @searches = current_user.searches
6
+ end
7
+
8
+ def save
9
+ current_user.searches << Search.find(params[:id])
10
+ if current_user.save
11
+ flash[:notice] = "Successfully saved your search."
12
+ else
13
+ flash[:error] = "The was a problem saving your search."
14
+ end
15
+ redirect_to :back
16
+ end
17
+
18
+ # Only dereferences the user rather than removing the item in case it
19
+ # is in the session[:history]
20
+ def forget
21
+ if current_user.search_ids.include?(params[:id].to_i) && Search.update(params[:id].to_i, :user_id => nil)
22
+ flash[:notice] = "Successfully removed that saved search."
23
+ else
24
+ flash[:error] = "Couldn't remove that saved search."
25
+ end
26
+ redirect_to :back
27
+ end
28
+
29
+ # Only dereferences the user rather than removing the items in case they
30
+ # are in the session[:history]
31
+ def clear
32
+ if Search.update_all("user_id = NULL", "user_id = #{current_user.id}")
33
+ flash[:notice] = "Cleared your saved searches."
34
+ else
35
+ flash[:error] = "There was a problem clearing your saved searches."
36
+ end
37
+ redirect_to :action => "index"
38
+ end
39
+
40
+
41
+ protected
42
+ def verify_user
43
+ flash[:notice] = "Please log in to manage and view your saved searches." and raise Blacklight::Exceptions::AccessDenied unless current_user
44
+ end
45
+ end