Class: FoldersController
- Inherits:
-
CatalogController
- Object
- CatalogController
- FoldersController
- Includes:
- Blacklight::Configurable, Blacklight::SearchHelper, Blacklight::TokenBasedUser
- Defined in:
- app/controllers/folders_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#edit ⇒ Object
end.
- #index ⇒ Object
- #new ⇒ Object
-
#public_list ⇒ Object
return a list of publicly visible folders that have items.
-
#search_action_url(options = {}) ⇒ Object
Blacklight uses #search_action_url to figure out the right URL for the global search box.
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/folders_controller.rb', line 47 def create @folder = current_user.folders.build(folder_params) if @folder.save flash[:notice] = "Folder created." redirect_to :action => "index" else render :action => "new" end end |
#destroy ⇒ Object
97 98 99 100 101 102 |
# File 'app/controllers/folders_controller.rb', line 97 def destroy # @folder is set by correct_user_for_folder @folder.destroy flash[:notice] = t('blacklight.folders.delete.success') redirect_to :action => "index" end |
#edit ⇒ Object
end
83 84 85 |
# File 'app/controllers/folders_controller.rb', line 83 def edit @folder = Bpluser::Folder.find(params[:id]) end |
#index ⇒ Object
22 23 24 25 26 27 |
# File 'app/controllers/folders_controller.rb', line 22 def index flash[:notice] = flash[:notice].html_safe if flash[:notice].present? and flash[:notice] == %Q[Welcome! You're viewing Digital Stacks items using a link from a temporary card. To save these items to a free permanent account, click <a href="#{new_user_session_path}" title="Sign Up Link">Sign Up / Log In</a>.] if current_or_guest_user @folders = current_or_guest_user.folders end end |
#new ⇒ Object
43 44 45 |
# File 'app/controllers/folders_controller.rb', line 43 def new @folder = current_user.folders.new end |
#public_list ⇒ Object
return a list of publicly visible folders that have items
105 106 107 108 |
# File 'app/controllers/folders_controller.rb', line 105 def public_list # TODO create a named scope for this query in Bplmodels::Folder? @folders = Bpluser::Folder.where(:visibility => 'public').joins(:folder_items).uniq.order('updated_at DESC') end |
#search_action_url(options = {}) ⇒ Object
Blacklight uses #search_action_url to figure out the right URL for the global search box
13 14 15 |
# File 'app/controllers/folders_controller.rb', line 13 def search_action_url = {} search_catalog_url(.except(:controller, :action)) end |
#show ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/folders_controller.rb', line 29 def show flash[:notice] = flash[:notice].html_safe if flash[:notice].present? and flash[:notice] == %Q[Welcome! You're viewing Digital Stacks items using a link from a temporary card. To save these items to a free permanent account, click <a href="#{new_user_session_path}" title="Sign Up Link">Sign Up / Log In</a>.] # @folder is set by correct_user_for_folder @folder_items = @folder.folder_items folder_items_ids = @folder_items.collect { |f_item| f_item.document_id.to_s } params[:sort] ||= 'title_info_primary_ssort asc, date_start_dtsi asc' @response, @document_list = fetch(folder_items_ids) # have to declare this so view uses catalog/index partials # uh, maybe not? default templates won't get invoked if below is set #@partial_path_templates = ["catalog/%{action_name}_%{index_view_type}_%{format}"] end |
#update ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'app/controllers/folders_controller.rb', line 87 def update # @folder is set by correct_user_for_folder if @folder.update_attributes(folder_params) flash[:notice] = "Folder updated." redirect_to @folder else render :action => "edit" end end |