Module: SufiaHelper
- Included in:
- EventJob
- Defined in:
- app/helpers/sufia_helper.rb
Instance Method Summary collapse
- #display_user_name(recent_document) ⇒ Object
- #iconify_auto_link(text, showLink = true) ⇒ Object
-
#link_back_to_catalog(opts = {:label=>nil}) ⇒ Object
Create a link back to the index screen, keeping the user’s facet, query and paging choices intact by using session.
-
#link_back_to_dashboard(opts = {:label=>'Back to Search'}) ⇒ Object
link_back_to_dashboard(:label=>‘Back to Search’) Create a link back to the dashboard screen, keeping the user’s facet, query and paging choices intact by using session.
- #link_to_dashboard_query(query) ⇒ Object
- #link_to_facet(field, field_string) ⇒ Object
- #link_to_facet_list(list, field_string, emptyText = "No value entered", separator = ", ") ⇒ Object
- #link_to_field(fieldname, fieldvalue, displayvalue = nil) ⇒ Object
- #link_to_profile(login) ⇒ Object
- #linkify_chat_id(chat_id) ⇒ Object
- #number_of_deposits(user) ⇒ Object
Instance Method Details
#display_user_name(recent_document) ⇒ Object
22 23 24 25 |
# File 'app/helpers/sufia_helper.rb', line 22 def display_user_name(recent_document) return "no display name" unless recent_document.depositor return User.find_by_user_key(recent_document.depositor).name rescue recent_document.depositor end |
#iconify_auto_link(text, showLink = true) ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/helpers/sufia_helper.rb', line 49 def iconify_auto_link(text, showLink = true) auto_link(text) do |value| link = "<i class='icon-external-link'></i> #{value}<br />" if showLink link = "<i class='icon-external-link'></i> <br />" unless showLink link end end |
#link_back_to_catalog(opts = {:label=>nil}) ⇒ Object
Create a link back to the index screen, keeping the user’s facet, query and paging choices intact by using session. We should be able to do away with this method in Blacklight 5
82 83 84 85 86 87 88 |
# File 'app/helpers/sufia_helper.rb', line 82 def link_back_to_catalog(opts={:label=>nil}) scope = opts.delete(:route_set) || self query_params = current_search_session.try(:query_params) || {} link_url = scope.url_for(query_params) opts[:label] ||= t('blacklight.back_to_search') link_to opts[:label], link_url end |
#link_back_to_dashboard(opts = {:label=>'Back to Search'}) ⇒ Object
link_back_to_dashboard(:label=>‘Back to Search’) Create a link back to the dashboard screen, keeping the user’s facet, query and paging choices intact by using session.
5 6 7 8 9 10 11 |
# File 'app/helpers/sufia_helper.rb', line 5 def link_back_to_dashboard(opts={:label=>'Back to Search'}) query_params = session[:search] ? session[:search].dup : {} query_params.delete :counter query_params.delete :total link_url = dashboard_index_path + "?" + query_params.to_query link_to opts[:label], link_url end |
#link_to_dashboard_query(query) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/helpers/sufia_helper.rb', line 13 def link_to_dashboard_query(query) p = params.dup p.delete :page p.delete :action p[:q]=query link_url = dashboard_index_path(p) link_to(query, link_url) end |
#link_to_facet(field, field_string) ⇒ Object
31 32 33 |
# File 'app/helpers/sufia_helper.rb', line 31 def link_to_facet(field, field_string) link_to(field, add_facet_params(field_string, field).merge!({"controller" => "catalog", :action=> "index"})) end |
#link_to_facet_list(list, field_string, emptyText = "No value entered", separator = ", ") ⇒ Object
35 36 37 38 39 |
# File 'app/helpers/sufia_helper.rb', line 35 def link_to_facet_list(list, field_string, emptyText="No value entered", separator=", ") facet_field = Solrizer.solr_name(field_string, :facetable) return list.map{ |item| link_to_facet(item, facet_field) }.join(separator) unless list.blank? return emptyText end |
#link_to_field(fieldname, fieldvalue, displayvalue = nil) ⇒ Object
42 43 44 45 46 47 |
# File 'app/helpers/sufia_helper.rb', line 42 def link_to_field(fieldname, fieldvalue, displayvalue = nil) p = {:search_field=>'advanced', fieldname=>'"'+fieldvalue+'"'} link_url = catalog_index_path(p) display = displayvalue.blank? ? fieldvalue: displayvalue link_to(display, link_url) end |
#link_to_profile(login) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/helpers/sufia_helper.rb', line 57 def link_to_profile(login) user = User.find_by_user_key(login) return login if user.nil? text = if user.respond_to? :name user.name else login end link_to text, Sufia::Engine.routes.url_helpers.profile_path(user) end |
#linkify_chat_id(chat_id) ⇒ Object
70 71 72 73 74 75 76 |
# File 'app/helpers/sufia_helper.rb', line 70 def linkify_chat_id(chat_id) if chat_id.end_with? '@chat.psu.edu' "<a href=\"xmpp:#{chat_id}\">#{chat_id}</a>" else chat_id end end |
#number_of_deposits(user) ⇒ Object
27 28 29 |
# File 'app/helpers/sufia_helper.rb', line 27 def number_of_deposits(user) ActiveFedora::Base.where(Solrizer.solr_name('depositor', :stored_searchable) => user.user_key).count end |