hydra-head 3.2.0.pre3 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hydra-head (3.2.0.pre2)
4
+ hydra-head (3.2.0)
5
5
  RedCloth (= 4.2.3)
6
- active-fedora (>= 3.2.0.pre6)
7
- blacklight (= 3.1.2)
6
+ active-fedora (>= 3.2.0)
7
+ blacklight (~> 3.1.2)
8
8
  block_helpers
9
9
  builder (= 2.1.2)
10
10
  columnize
@@ -55,7 +55,7 @@ GEM
55
55
  rack-mount (~> 0.6.14)
56
56
  rack-test (~> 0.5.7)
57
57
  tzinfo (~> 0.3.23)
58
- active-fedora (3.2.0.pre7)
58
+ active-fedora (3.2.0)
59
59
  activeresource (>= 3.0.0)
60
60
  activesupport (>= 3.0.0)
61
61
  equivalent-xml
data/README.textile CHANGED
@@ -175,13 +175,6 @@ Most projects add hydra jetty to their code as a git submodule
175
175
  <pre>
176
176
  git submodule add git://github.com/projecthydra/hydra-jetty.git jetty
177
177
  git commit -m"added jetty submodule"
178
- cd jetty
179
- git fetch --tags
180
- git checkout last_solr_multicore
181
- git checkout -b last_solr_multicore
182
- cd ..
183
- git add jetty
184
- git commit -m "Pinned jetty to last_solr_multicore"
185
178
  </pre>
186
179
 
187
180
  Now that you've added the submodule to your git repository, whenever you grab a new working copy of the code, you can get hydra-jetty by running:
data/hydra-head.gemspec CHANGED
@@ -13,9 +13,8 @@ Gem::Specification.new do |s|
13
13
  s.description = %q{Hydra-Head is a Rails Engine containing the core code for a Hydra application. The full hydra stack includes: Blacklight, Fedora, Solr, active-fedora, solrizer, and om}
14
14
 
15
15
  s.add_dependency "rails", '~> 3.0.10'
16
- # s.add_dependency "rsolr", '1.0.2' ## version 1.0.6 breaks when using blacklight 3.1.0
17
16
  s.add_dependency "blacklight", '~>3.1.2'
18
- s.add_dependency "active-fedora", '>=3.2.0.pre6'
17
+ s.add_dependency "active-fedora", '>=3.2.0'
19
18
  s.add_dependency 'builder', '2.1.2'
20
19
  s.add_dependency 'columnize'
21
20
  s.add_dependency 'crack'
@@ -24,8 +24,7 @@ module HydraHead
24
24
  end
25
25
 
26
26
  def default_route_sets
27
- #[:file_assets, :assets, :downloads, :contributors, :grants, :permissions, :superuser,:catalog, :get]
28
- [:get, :catalog, :superuser, :permissions, :assets_with_all_nested_routes]
27
+ [:catalog, :superuser, :permissions, :assets_with_all_nested_routes]
29
28
  end
30
29
 
31
30
  module RouteSets
@@ -83,11 +82,6 @@ module HydraHead
83
82
  end
84
83
 
85
84
 
86
- def get
87
- add_routes do |options|
88
- resources :get, :only=>:show
89
- end
90
- end
91
85
 
92
86
 
93
87
  end
@@ -1,4 +1,4 @@
1
1
  module HydraHead
2
- VERSION = "3.2.0.pre3"
2
+ VERSION = "3.2.0"
3
3
  end
4
4
 
data/lib/hydra.rb CHANGED
@@ -3,12 +3,21 @@ require "blacklight"
3
3
  module Hydra
4
4
  extend Blacklight::Configurable
5
5
  extend ActiveSupport::Autoload
6
- ## Matz says that autoload is going away, so we ought to discontinue this.
7
- autoload :Configurable, 'blacklight/configurable'
8
- autoload :Assets
9
- autoload :FileAssets
10
6
  autoload :AccessControlsEvaluation
11
7
  autoload :AccessControlsEnforcement
8
+ autoload :Assets
9
+ autoload :Catalog
10
+ autoload :Configurable, 'blacklight/configurable'
11
+ autoload :Controller
12
+ autoload :FileAssets
13
+ autoload :GenericContent
14
+ autoload :GenericImage
15
+ autoload :GenericUserAttributes
16
+ autoload :ModelMixins
17
+ autoload :ModsGenericContent
18
+ autoload :ModsImage
19
+ autoload :SuperuserAttributes
20
+ autoload :User
12
21
  end
13
22
 
14
23
 
@@ -24,4 +33,3 @@ require 'hydra/mods_article'
24
33
  require 'hydra/model_methods'
25
34
  require 'hydra/models/file_asset'
26
35
 
27
- Dir[File.join(File.dirname(__FILE__), "hydra", "*.rb")].each {|f| require f}
data/lib/hydra/image.rb CHANGED
@@ -28,8 +28,6 @@ require "httparty"
28
28
 
29
29
  module Hydra
30
30
  class Image < ActiveFedora::Base
31
- =begin
32
- TODO This doesn't seem to be used anywhere. Commenting out until I hear back. Justin 2011-12-21
33
31
  include Hydra::ModelMethods
34
32
  include HTTParty
35
33
 
@@ -47,6 +45,7 @@ class Image < ActiveFedora::Base
47
45
  attr_accessor :derivations, :generate_derived_images
48
46
 
49
47
  def initialize( attrs={})
48
+ ActiveSupport::Deprecation.warn("Hydra:Image will be removed in the next version")
50
49
  existing_image = true if attrs[:pid]
51
50
  @generate_derived_images = attrs[:derivatives] ? attrs[:derivatives] : false
52
51
  super
@@ -175,6 +174,5 @@ class Image < ActiveFedora::Base
175
174
  "#{admin_site}fedora/objects/#{pid}/datastreams/#{ds_name}/content"
176
175
  end
177
176
 
178
- =end
179
177
  end
180
178
  end
@@ -49,7 +49,7 @@ module Hydra
49
49
  datastreams["descMetadata"].extent_values = size
50
50
  end
51
51
 
52
- # Override ActiveFedora::Base.to_solr to...
52
+ # Override ActiveFedora::Base.to_solr to...
53
53
  # Check if we are dealing with a child of FileAsset and if so when calling to_solr from Solrizer indexer we want to skip loading parent metadata again
54
54
  #
55
55
  # if known models greater than one (without ActiveFedora::Base) and
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-head
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1923832047
5
- prerelease: 6
4
+ hash: 15
5
+ prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
9
  - 0
10
- - pre
11
- - 3
12
- version: 3.2.0.pre3
10
+ version: 3.2.0
13
11
  platform: ruby
14
12
  authors:
15
13
  - Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield, Justin Coyne & many more. See https://github.com/projecthydra/hydra-head/contributors
@@ -17,7 +15,7 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2012-01-06 00:00:00 -06:00
18
+ date: 2012-01-09 00:00:00 -06:00
21
19
  default_executable:
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
@@ -60,14 +58,12 @@ dependencies:
60
58
  requirements:
61
59
  - - ">="
62
60
  - !ruby/object:Gem::Version
63
- hash: 1923832037
61
+ hash: 15
64
62
  segments:
65
63
  - 3
66
64
  - 2
67
65
  - 0
68
- - pre
69
- - 6
70
- version: 3.2.0.pre6
66
+ version: 3.2.0
71
67
  type: :runtime
72
68
  version_requirements: *id003
73
69
  - !ruby/object:Gem::Dependency
@@ -726,7 +722,6 @@ files:
726
722
  - app/controllers/contributors_controller.rb
727
723
  - app/controllers/downloads_controller.rb
728
724
  - app/controllers/file_assets_controller.rb
729
- - app/controllers/get_controller.rb
730
725
  - app/controllers/permissions_controller.rb
731
726
  - app/controllers/user_sessions_controller.rb
732
727
  - app/helpers/application_helper.rb
@@ -944,8 +939,6 @@ files:
944
939
  - install.rb
945
940
  - lib/application_controller.rb
946
941
  - lib/application_helper.rb
947
- - lib/blacklight/blacklight_helper_behavior.rb
948
- - lib/blacklight/catalog_helper.rb
949
942
  - lib/block_mapper.rb
950
943
  - lib/ead_mapper.rb
951
944
  - lib/field_maps.rb
@@ -1142,7 +1135,7 @@ files:
1142
1135
  - vendor/cache/abstract-1.0.0.gem
1143
1136
  - vendor/cache/actionmailer-3.0.11.gem
1144
1137
  - vendor/cache/actionpack-3.0.11.gem
1145
- - vendor/cache/active-fedora-3.2.0.pre7.gem
1138
+ - vendor/cache/active-fedora-3.2.0.gem
1146
1139
  - vendor/cache/activemodel-3.0.11.gem
1147
1140
  - vendor/cache/activerecord-3.0.11.gem
1148
1141
  - vendor/cache/activeresource-3.0.11.gem
@@ -1256,14 +1249,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
1256
1249
  required_rubygems_version: !ruby/object:Gem::Requirement
1257
1250
  none: false
1258
1251
  requirements:
1259
- - - ">"
1252
+ - - ">="
1260
1253
  - !ruby/object:Gem::Version
1261
- hash: 25
1254
+ hash: 3
1262
1255
  segments:
1263
- - 1
1264
- - 3
1265
- - 1
1266
- version: 1.3.1
1256
+ - 0
1257
+ version: "0"
1267
1258
  requirements: []
1268
1259
 
1269
1260
  rubyforge_project:
@@ -1,23 +0,0 @@
1
- require 'mediashelf/active_fedora_helper'
2
- class GetController < ApplicationController
3
- include MediaShelf::ActiveFedoraHelper
4
- include Hydra::RepositoryController
5
- include Hydra::AssetsControllerHelper
6
- helper :downloads
7
-
8
- def show
9
- fedora_object = ActiveFedora::Base.load_instance(params[:id])
10
-
11
- respond_to do |format|
12
- format.html { send_datastream downloadables( fedora_object, :canonical=>true ) }
13
- format.pdf { send_datastream downloadables( fedora_object, :canonical=>true, :mime_type=>"application/pdf" ) }
14
- format.jp2 do
15
- canonical_jp2 = downloadables( fedora_object, :canonical=>true, :mime_type=>"image/jp2" )
16
- jp2_content_url = "#{canonical_jp2.url}/content"
17
- send_datastream canonical_jp2
18
- end
19
- end
20
-
21
- end
22
-
23
- end
@@ -1,612 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- # -*- coding: utf-8 -*-
3
- # Copied from blacklight 3.0. Do not change this file inside hydra. Override in app/helpers/hydra/blacklight_helper_behavior.rb
4
- # When Blacklight 3.2 comes out, remove this file.
5
- #
6
- # Methods added to this helper will be available to all templates in the hosting application
7
- #
8
- # module Blacklight::BlacklightHelperBehavior
9
- # include HashAsHiddenFields
10
- # include RenderConstraintsHelper
11
- #
12
- #
13
- # def application_name
14
- # 'Blacklight'
15
- # end
16
- #
17
- # ##
18
- # # This method should be included in any Blacklight layout, including
19
- # # custom ones. It will output results of #render_js_includes,
20
- # # #render_stylesheet_includes, and all the content of
21
- # # current_controller#extra_head_content.
22
- # #
23
- # # Uses controller methods #extra_head_content, #javascript_includes,
24
- # # and #stylesheet_links to find content. Tolerates it if those
25
- # # methods don't exist, silently skipping.
26
- # #
27
- # # By a layout outputting this in html HEAD, it provides an easy way for
28
- # # local config or extra plugins to add HEAD content.
29
- # #
30
- # # Add your own css or remove the defaults by simply editing
31
- # # controller.stylesheet_links, controller.javascript_includes,
32
- # # or controller.extra_head_content.
33
- # #
34
- # #
35
- # #
36
- # # in an initializer or other startup file (plugin init.rb?):
37
- # #
38
- # # == Apply to all actions in all controllers:
39
- # #
40
- # # ApplicationController.before_filter do |controller|
41
- # # # remove default jquery-ui theme.
42
- # # controller.stylesheet_links.each do |args|
43
- # # args.delete_if {|a| a =~ /^|\/jquery-ui-[\d.]+\.custom\.css$/ }
44
- # # end
45
- # #
46
- # # # add in a different jquery-ui theme, or any other css or what have you
47
- # # controller.stylesheet_links << 'my_css.css'
48
- # #
49
- # # controller.javascript_includes << "my_local_behaviors.js"
50
- # #
51
- # # controller.extra_head_content << '<link rel="something" href="something">'
52
- # # end
53
- # #
54
- # # == Apply to a particular action in a particular controller:
55
- # #
56
- # # CatalogController.before_filter :only => :show |controller|
57
- # # controller.extra_head_content << '<link rel="something" href="something">'
58
- # # end
59
- # #
60
- # # == Or in a view file that wants to add certain header content? no problem:
61
- # #
62
- # # <% stylesheet_links << "mystylesheet.css" %>
63
- # # <% javascript_includes << "my_js.js" %>
64
- # # <% extra_head_content << capture do %>
65
- # # <%= tag :link, { :href => some_method_for_something, :rel => "alternate" } %>
66
- # # <% end %>
67
- # #
68
- # # == Full power of javascript_include_tag and stylesheet_link_tag
69
- # # Note that the elements added to stylesheet_links and javascript_links
70
- # # are arguments to Rails javascript_include_tag and stylesheet_link_tag
71
- # # respectively, you can pass complex arguments. eg:
72
- # #
73
- # # stylesheet_links << ["stylesheet1.css", "stylesheet2.css", {:cache => "mykey"}]
74
- # # javascript_includes << ["myjavascript.js", {:plugin => :myplugin} ]
75
- # def render_head_content
76
- # render_stylesheet_includes +
77
- # render_js_includes +
78
- # render_extra_head_content
79
- # end
80
- #
81
- # ##
82
- # # Assumes controller has a #stylesheet_link_tag method, array with
83
- # # each element being a set of arguments for stylesheet_link_tag
84
- # # See #render_head_content for instructions on local code or plugins
85
- # # adding stylesheets.
86
- # def render_stylesheet_includes
87
- # return "".html_safe unless respond_to?(:stylesheet_links)
88
- #
89
- # stylesheet_links.uniq.collect do |args|
90
- # stylesheet_link_tag(*args)
91
- # end.join("\n").html_safe
92
- # end
93
- #
94
- #
95
- # ##
96
- # # Assumes controller has a #js_includes method, array with each
97
- # # element being a set of arguments for javsascript_include_tag.
98
- # # See #render_head_content for instructions on local code or plugins
99
- # # adding js files.
100
- # def render_js_includes
101
- # return "".html_safe unless respond_to?(:javascript_includes)
102
- #
103
- # javascript_includes.uniq.collect do |args|
104
- # javascript_include_tag(*args)
105
- # end.join("\n").html_safe
106
- # end
107
- #
108
- # ##
109
- # # Assumes controller has a #extra_head_content method
110
- # #
111
- # def render_extra_head_content
112
- # return "".html_safe unless respond_to?(:extra_head_content)
113
- #
114
- # extra_head_content.join("\n").html_safe
115
- # end
116
- #
117
- # # Create <link rel="alternate"> links from a documents dynamically
118
- # # provided export formats. Currently not used by standard BL layouts,
119
- # # but available for your custom layouts to provide link rel alternates.
120
- # #
121
- # # Returns empty string if no links available.
122
- # #
123
- # # :unique => true, will ensure only one link is output for every
124
- # # content type, as required eg in atom. Which one 'wins' is arbitrary.
125
- # # :exclude => array of format shortnames, formats to not include at all.
126
- # def render_link_rel_alternates(document=@document, options = {})
127
- # options = {:unique => false, :exclude => []}.merge(options)
128
- #
129
- # return nil if document.nil?
130
- #
131
- # seen = Set.new
132
- #
133
- # html = ""
134
- # document.export_formats.each_pair do |format, spec|
135
- # unless( options[:exclude].include?(format) ||
136
- # (options[:unique] && seen.include?(spec[:content_type]))
137
- # )
138
- # html << tag(:link, {:rel=>"alternate", :title=>format, :type => spec[:content_type], :href=> catalog_url(document.id, format)}) << "\n"
139
- #
140
- # seen.add(spec[:content_type]) if options[:unique]
141
- # end
142
- # end
143
- # return html.html_safe
144
- # end
145
- #
146
- # def render_opensearch_response_metadata
147
- # render :partial => 'catalog/opensearch_response_metadata'
148
- # end
149
- #
150
- # def render_body_class
151
- # extra_body_classes.join " "
152
- # end
153
- #
154
- # # collection of items to be rendered in the @sidebar
155
- # def sidebar_items
156
- # @sidebar_items ||= []
157
- # end
158
- #
159
- # def extra_body_classes
160
- # @extra_body_classes ||= ['blacklight-' + controller.controller_name, 'blacklight-' + [controller.controller_name, controller.action_name].join('-')]
161
- # end
162
- #
163
- # #
164
- # # Blacklight.config based helpers ->
165
- # #
166
- #
167
- # # used in the catalog/_facets partial
168
- # def facet_field_labels
169
- # Blacklight.config[:facet][:labels]
170
- # end
171
- #
172
- # # used in the catalog/_facets partial
173
- # def facet_field_names
174
- # Blacklight.config[:facet][:field_names]
175
- # end
176
- #
177
- # # used in the catalog/_facets partial and elsewhere
178
- # # Renders a single section for facet limit with a specified
179
- # # solr field used for faceting. Can be over-ridden for custom
180
- # # display on a per-facet basis.
181
- # def render_facet_limit(solr_field)
182
- # render( :partial => "catalog/facet_limit", :locals => {:solr_field =>solr_field })
183
- # end
184
- #
185
- # def render_document_list_partial options={}
186
- # render :partial=>'catalog/document_list'
187
- # end
188
- #
189
- # # Save function area for search results 'index' view, normally
190
- # # renders next to title. Includes just 'Folder' by default.
191
- # def render_index_doc_actions(document, options={})
192
- # content_tag("div", :class=>"documentFunctions") do
193
- # raw("#{render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options))}
194
- # #{render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))}")
195
- # end
196
- # end
197
- #
198
- # # Save function area for item detail 'show' view, normally
199
- # # renders next to title. By default includes 'Folder' and 'Bookmarks'
200
- # def render_show_doc_actions(document=@document, options={})
201
- # content_tag("div", :class=>"documentFunctions") do
202
- # raw("#{render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options))}
203
- # #{render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))}")
204
- # end
205
- # end
206
- #
207
- # # used in the catalog/_index_partials/_default view
208
- # def index_field_names
209
- # Blacklight.config[:index_fields][:field_names]
210
- # end
211
- #
212
- # # used in the _index_partials/_default view
213
- # def index_field_labels
214
- # Blacklight.config[:index_fields][:labels]
215
- # end
216
- #
217
- # def spell_check_max
218
- # Blacklight.config[:spell_max] || 0
219
- # end
220
- #
221
- # def render_index_field_label args
222
- # field = args[:field]
223
- # html_escape index_field_labels[field]
224
- # end
225
- #
226
- # def render_index_field_value args
227
- # value = args[:value]
228
- # value ||= args[:document].get(args[:field], :sep => nil) if args[:document] and args[:field]
229
- # render_field_value value
230
- # end
231
- #
232
- # # Used in the show view for displaying the main solr document heading
233
- # def document_heading
234
- # @document[Blacklight.config[:show][:heading]] || @document.id
235
- # end
236
- # def render_document_heading
237
- # content_tag(:h1, document_heading)
238
- # end
239
- #
240
- # # Used in the show view for setting the main html document title
241
- # def document_show_html_title
242
- # @document[Blacklight.config[:show][:html_title]]
243
- # end
244
- #
245
- # # Used in citation view for displaying the title
246
- # def citation_title(document)
247
- # document[Blacklight.config[:show][:html_title]]
248
- # end
249
- #
250
- # # Used in the document_list partial (search view) for building a select element
251
- # def sort_fields
252
- # Blacklight.config[:sort_fields]
253
- # end
254
- #
255
- # # Used in the document list partial (search view) for creating a link to the document show action
256
- # def document_show_link_field
257
- # Blacklight.config[:index][:show_link].to_sym
258
- # end
259
- #
260
- # # Used in the search form partial for building a select tag
261
- # def search_fields
262
- # Blacklight.search_field_options_for_select
263
- # end
264
- #
265
- # # used in the catalog/_show/_default partial
266
- # def document_show_fields
267
- # Blacklight.config[:show_fields][:field_names]
268
- # end
269
- #
270
- # # used in the catalog/_show/_default partial
271
- # def document_show_field_labels
272
- # Blacklight.config[:show_fields][:labels]
273
- # end
274
- #
275
- # def render_document_show_field_label args
276
- # field = args[:field]
277
- # html_escape document_show_field_labels[field]
278
- # end
279
- #
280
- # def render_document_show_field_value args
281
- # value = args[:value]
282
- # value ||= args[:document].get(args[:field], :sep => nil) if args[:document] and args[:field]
283
- # render_field_value value
284
- # end
285
- #
286
- # def render_field_value value=nil
287
- # value = [value] unless value.is_a? Array
288
- # value = value.collect { |x| x.respond_to?(:force_encoding) ? x.force_encoding("UTF-8") : x}
289
- # return value.map { |v| html_escape v }.join(field_value_separator).html_safe
290
- # end
291
- #
292
- # def field_value_separator
293
- # ', '
294
- # end
295
- #
296
- # # Return a normalized partial name that can be used to contruct view partial path
297
- # def document_partial_name(document)
298
- # # .to_s is necessary otherwise the default return value is not always a string
299
- # # using "_" as sep. to more closely follow the views file naming conventions
300
- # # parameterize uses "-" as the default sep. which throws errors
301
- # display_type = document[Blacklight.config[:show][:display_type]]
302
- #
303
- # return 'default' unless display_type
304
- # display_type = display_type.join(" ") if display_type.respond_to?(:join)
305
- #
306
- # "#{display_type.gsub("-"," ")}".parameterize("_").to_s
307
- # end
308
- #
309
- # # given a doc and action_name, this method attempts to render a partial template
310
- # # based on the value of doc[:format]
311
- # # if this value is blank (nil/empty) the "default" is used
312
- # # if the partial is not found, the "default" partial is rendered instead
313
- # def render_document_partial(doc, action_name)
314
- # format = document_partial_name(doc)
315
- # begin
316
- # render :partial=>"catalog/_#{action_name}_partials/#{format}", :locals=>{:document=>doc}
317
- # rescue ActionView::MissingTemplate
318
- # render :partial=>"catalog/_#{action_name}_partials/default", :locals=>{:document=>doc}
319
- # end
320
- # end
321
- #
322
- # # Search History and Saved Searches display
323
- # def link_to_previous_search(params)
324
- # link_to(raw(render_search_to_s(params)), catalog_index_path(params)).html_safe
325
- # end
326
- #
327
- # #
328
- # # facet param helpers ->
329
- # #
330
- #
331
- # # Standard display of a facet value in a list. Used in both _facets sidebar
332
- # # partial and catalog/facet expanded list. Will output facet value name as
333
- # # a link to add that to your restrictions, with count in parens.
334
- # # first arg item is a facet value item from rsolr-ext.
335
- # # options consist of:
336
- # # :suppress_link => true # do not make it a link, used for an already selected value for instance
337
- # def render_facet_value(facet_solr_field, item, options ={})
338
- # (link_to_unless(options[:suppress_link], item.value, add_facet_params_and_redirect(facet_solr_field, item.value), :class=>"facet_select label") + " " + render_facet_count(item.hits)).html_safe
339
- # end
340
- #
341
- # # Standard display of a SELECTED facet value, no link, special span
342
- # # with class, and 'remove' button.
343
- # def render_selected_facet_value(facet_solr_field, item)
344
- # content_tag(:span, render_facet_value(facet_solr_field, item, :suppress_link => true), :class => "selected label") +
345
- # link_to("[remove]", remove_facet_params(facet_solr_field, item.value, params), :class=>"remove")
346
- # end
347
- #
348
- # # Renders a count value for facet limits. Can be over-ridden locally
349
- # # to change style, for instance not use parens. And can be called
350
- # # by plugins to get consistent display.
351
- # def render_facet_count(num)
352
- # content_tag("span", "(" + format_num(num) + ")", :class => "count")
353
- # end
354
- #
355
- # # adds the value and/or field to params[:f]
356
- # # Does NOT remove request keys and otherwise ensure that the hash
357
- # # is suitable for a redirect. See
358
- # # add_facet_params_and_redirect
359
- # def add_facet_params(field, value)
360
- # p = params.dup
361
- # p[:f] = (p[:f] || {}).dup # the command above is not deep in rails3, !@#$!@#$
362
- # p[:f][field] = (p[:f][field] || []).dup
363
- # p[:f][field].push(value)
364
- # p
365
- # end
366
- #
367
- # # Used in catalog/facet action, facets.rb view, for a click
368
- # # on a facet value. Add on the facet params to existing
369
- # # search constraints. Remove any paginator-specific request
370
- # # params, or other request params that should be removed
371
- # # for a 'fresh' display.
372
- # # Change the action to 'index' to send them back to
373
- # # catalog/index with their new facet choice.
374
- # def add_facet_params_and_redirect(field, value)
375
- # new_params = add_facet_params(field, value)
376
- #
377
- # # Delete page, if needed.
378
- # new_params.delete(:page)
379
- #
380
- # # Delete any request params from facet-specific action, needed
381
- # # to redir to index action properly.
382
- # Blacklight::Solr::FacetPaginator.request_keys.values.each do |paginator_key|
383
- # new_params.delete(paginator_key)
384
- # end
385
- # new_params.delete(:id)
386
- #
387
- # # Force action to be index.
388
- # new_params[:action] = "index"
389
- # new_params
390
- # end
391
- # # copies the current params (or whatever is passed in as the 3rd arg)
392
- # # removes the field value from params[:f]
393
- # # removes the field if there are no more values in params[:f][field]
394
- # # removes additional params (page, id, etc..)
395
- # def remove_facet_params(field, value, source_params=params)
396
- # p = source_params.dup
397
- # # need to dup the facet values too,
398
- # # if the values aren't dup'd, then the values
399
- # # from the session will get remove in the show view...
400
- # p[:f] = p[:f].dup
401
- # p[:f][field] = p[:f][field].nil? ? [] : p[:f][field].dup
402
- # p.delete :page
403
- # p.delete :id
404
- # p.delete :counter
405
- # p.delete :commit
406
- # #return p unless p[field]
407
- # p[:f][field] = p[:f][field] - [value]
408
- # p[:f].delete(field) if p[:f][field].size == 0
409
- # p
410
- # end
411
- #
412
- # # true or false, depending on whether the field and value is in params[:f]
413
- # def facet_in_params?(field, value)
414
- # params[:f] and params[:f][field] and params[:f][field].include?(value)
415
- # end
416
- #
417
- # #
418
- # # shortcut for built-in Rails helper, "number_with_delimiter"
419
- # #
420
- # def format_num(num); number_with_delimiter(num) end
421
- #
422
- # #
423
- # # link based helpers ->
424
- # #
425
- #
426
- # # create link to query (e.g. spelling suggestion)
427
- # def link_to_query(query)
428
- # p = params.dup
429
- # p.delete :page
430
- # p.delete :action
431
- # p[:q]=query
432
- # link_url = catalog_index_path(p)
433
- # link_to(query, link_url)
434
- # end
435
- #
436
- # def render_document_index_label doc, opts
437
- # label = nil
438
- # label ||= doc.get(opts[:label]) if opts[:label].instance_of? Symbol
439
- # label ||= opts[:label].call(doc, opts) if opts[:label].instance_of? Proc
440
- # label ||= opts[:label] if opts[:label].is_a? String
441
- # label ||= doc.id
442
- # end
443
- #
444
- # # link_to_document(doc, :label=>'VIEW', :counter => 3)
445
- # # Use the catalog_path RESTful route to create a link to the show page for a specific item.
446
- # # catalog_path accepts a HashWithIndifferentAccess object. The solr query params are stored in the session,
447
- # # so we only need the +counter+ param here. We also need to know if we are viewing to document as part of search results.
448
- # def link_to_document(doc, opts={:label=>Blacklight.config[:index][:show_link].to_sym, :counter => nil, :results_view => true})
449
- # label = render_document_index_label doc, opts
450
- # link_to_with_data(label, catalog_path(doc.id), {:method => :put, :class => label.parameterize, :data => opts}).html_safe
451
- # end
452
- #
453
- # # link_back_to_catalog(:label=>'Back to Search')
454
- # # Create a link back to the index screen, keeping the user's facet, query and paging choices intact by using session.
455
- # def link_back_to_catalog(opts={:label=>'Back to Search'})
456
- # query_params = session[:search] ? session[:search].dup : {}
457
- # query_params.delete :counter
458
- # query_params.delete :total
459
- # link_url = catalog_index_path + "?" + query_params.to_query
460
- # link_to opts[:label], link_url
461
- # end
462
- #
463
- # # Create form input type=hidden fields representing the entire search context,
464
- # # for inclusion in a form meant to change some aspect of it, like
465
- # # re-sort or change records per page. Can pass in params hash
466
- # # as :params => hash, otherwise defaults to #params. Can pass
467
- # # in certain top-level params keys to _omit_, defaults to :page
468
- # def search_as_hidden_fields(options={})
469
- #
470
- # options = {:params => params, :omit_keys => [:page]}.merge(options)
471
- # my_params = options[:params].dup
472
- # options[:omit_keys].each {|omit_key| my_params.delete(omit_key)}
473
- # # removing action and controller from duplicate params so that we don't get hidden fields for them.
474
- # my_params.delete(:action)
475
- # my_params.delete(:controller)
476
- # # commit is just an artifact of submit button, we don't need it, and
477
- # # don't want it to pile up with another every time we press submit again!
478
- # my_params.delete(:commit)
479
- # # hash_as_hidden_fields in hash_as_hidden_fields.rb
480
- # return hash_as_hidden_fields(my_params)
481
- # end
482
- #
483
- #
484
- #
485
- # def link_to_previous_document(previous_document)
486
- # return if previous_document == nil
487
- # link_to_document previous_document, :label=>'« Previous', :counter => session[:search][:counter].to_i - 1
488
- # end
489
- #
490
- # def link_to_next_document(next_document)
491
- # return if next_document == nil
492
- # link_to_document next_document, :label=>'Next »', :counter => session[:search][:counter].to_i + 1
493
- # end
494
- #
495
- # # Use case, you want to render an html partial from an XML (say, atom)
496
- # # template. Rails API kind of lets us down, we need to hack Rails internals
497
- # # a bit. code taken from:
498
- # # http://stackoverflow.com/questions/339130/how-do-i-render-a-partial-of-a-different-format-in-rails
499
- # def with_format(format, &block)
500
- # old_format = @template_format
501
- # @template_format = format
502
- # result = block.call
503
- # @template_format = old_format
504
- # return result
505
- # end
506
- #
507
- #
508
- # # This is an updated +link_to+ that allows you to pass a +data+ hash along with the +html_options+
509
- # # which are then written to the generated form for non-GET requests. The key is the form element name
510
- # # and the value is the value:
511
- # #
512
- # # link_to_with_data('Name', some_path(some_id), :method => :post, :html)
513
- # def link_to_with_data(*args, &block)
514
- # if block_given?
515
- # options = args.first || {}
516
- # html_options = args.second
517
- # concat(link_to(capture(&block), options, html_options))
518
- # else
519
- # name = args.first
520
- # options = args.second || {}
521
- # html_options = args.third
522
- #
523
- # url = url_for(options)
524
- #
525
- # if html_options
526
- # html_options = html_options.stringify_keys
527
- # href = html_options['href']
528
- # convert_options_to_javascript_with_data!(html_options, url)
529
- # tag_options = tag_options(html_options)
530
- # else
531
- # tag_options = nil
532
- # end
533
- #
534
- # href_attr = "href=\"#{url}\"" unless href
535
- # "<a #{href_attr}#{tag_options}>#{h(name) || h(url)}</a>".html_safe
536
- # end
537
- # end
538
- #
539
- # # This is derived from +convert_options_to_javascript+ from module +UrlHelper+ in +url_helper.rb+
540
- # def convert_options_to_javascript_with_data!(html_options, url = '')
541
- # confirm, popup = html_options.delete("confirm"), html_options.delete("popup")
542
- #
543
- # method, href = html_options.delete("method"), html_options['href']
544
- # data = html_options.delete("data")
545
- # data = data.stringify_keys if data
546
- #
547
- # html_options["onclick"] = case
548
- # when method
549
- # "#{method_javascript_function_with_data(method, url, href, data)}return false;"
550
- # else
551
- # html_options["onclick"]
552
- # end
553
- # end
554
- #
555
- # # This is derived from +method_javascript_function+ from module +UrlHelper+ in +url_helper.rb+
556
- # def method_javascript_function_with_data(method, url = '', href = nil, data=nil)
557
- # action = (href && url.size > 0) ? "'#{url}'" : 'this.href'
558
- # submit_function =
559
- # "var f = document.createElement('form'); f.style.display = 'none'; " +
560
- # "this.parentNode.appendChild(f); f.method = 'POST'; f.action = #{action};"+
561
- # "if(event.metaKey || event.ctrlKey){f.target = '_blank';};" # if the command or control key is being held down while the link is clicked set the form's target to _blank
562
- # if data
563
- # data.each_pair do |key, value|
564
- # submit_function << "var d = document.createElement('input'); d.setAttribute('type', 'hidden'); "
565
- # submit_function << "d.setAttribute('name', '#{key}'); d.setAttribute('value', '#{escape_javascript(value.to_s)}'); f.appendChild(d);"
566
- # end
567
- # end
568
- # unless method == :post
569
- # submit_function << "var m = document.createElement('input'); m.setAttribute('type', 'hidden'); "
570
- # submit_function << "m.setAttribute('name', '_method'); m.setAttribute('value', '#{method}'); f.appendChild(m);"
571
- # end
572
- #
573
- # if protect_against_forgery?
574
- # submit_function << "var s = document.createElement('input'); s.setAttribute('type', 'hidden'); "
575
- # submit_function << "s.setAttribute('name', '#{request_forgery_protection_token}'); s.setAttribute('value', '#{escape_javascript form_authenticity_token}'); f.appendChild(s);"
576
- # end
577
- # submit_function << "f.submit();"
578
- # end
579
- #
580
- # # determines if the given document id is in the folder
581
- # def item_in_folder?(doc_id)
582
- # session[:folder_document_ids] && session[:folder_document_ids].include?(doc_id) ? true : false
583
- # end
584
- #
585
- # # puts together a collection of documents into one refworks export string
586
- # def render_refworks_texts(documents)
587
- # val = ''
588
- # documents.each do |doc|
589
- # if doc.respond_to?(:to_marc)
590
- # val += doc.export_as_refworks_marc_txt + "\n"
591
- # end
592
- # end
593
- # val
594
- # end
595
- #
596
- # # puts together a collection of documents into one endnote export string
597
- # def render_endnote_texts(documents)
598
- # val = ''
599
- # documents.each do |doc|
600
- # if doc.respond_to?(:to_marc)
601
- # val += doc.export_as_endnote + "\n"
602
- # end
603
- # end
604
- # val
605
- # end
606
- #
607
- #
608
- # def render_document_unapi_microformat(document, options={})
609
- # render(:partial=>'catalog/unapi_microformat', :locals => {:document=> document}.merge(options))
610
- # end
611
- #
612
- # end
@@ -1,44 +0,0 @@
1
- # Note: not sure we're still using this in hydrangea...
2
- # This is a replica of some methods that are in Blacklight's CatalogController that we wanted to re-use in other controllers
3
- module Blacklight::CatalogHelper
4
- # calls setup_previous_document then setup_next_document.
5
- # used in the show action for single view pagination.
6
- def setup_next_and_previous_documents
7
- setup_previous_document
8
- setup_next_document
9
- end
10
-
11
- # gets a document based on its position within a resultset
12
- def setup_document_by_counter(counter)
13
- return if counter < 1 || session[:search].blank?
14
- # need to duplicate search session hash so we aren't modifying the original (and don't get the qt in the Back to search results link)
15
- search = session[:search].dup || {}
16
- # enforcing search restrictions
17
- # if the user is not a reader then use the pulic qt, otherwise use the default qt (using logic from enforce_search_permissions method)
18
- if !reader?
19
- search[:qt] = Blacklight.config[:public_qt]
20
- end
21
- get_single_doc_via_search(search.merge({:page => counter}))
22
- end
23
-
24
- def setup_previous_document
25
- @previous_document = session[:search][:counter] ? setup_document_by_counter(session[:search][:counter].to_i - 1) : nil
26
- end
27
-
28
- def setup_next_document
29
- @next_document = session[:search][:counter] ? setup_document_by_counter(session[:search][:counter].to_i + 1) : nil
30
- end
31
-
32
- # sets up the session[:search] hash if it doesn't already exist
33
- def search_session
34
- session[:search] ||= {}
35
- end
36
-
37
- # sets up the session[:history] hash if it doesn't already exist.
38
- # assigns all Search objects (that match the searches in session[:history]) to a variable @searches.
39
- def history_session
40
- session[:history] ||= []
41
- @searches = searches_from_history # <- in ApplicationController
42
- end
43
-
44
- end