Class: FoldersController

Inherits:
CatalogController
  • Object
show all
Includes:
Blacklight::Configurable, Blacklight::SearchHelper, Blacklight::TokenBasedUser
Defined in:
app/controllers/folders_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#editObject

end



83
84
85
# File 'app/controllers/folders_controller.rb', line 83

def edit
  @folder = Bpluser::Folder.find(params[:id])
end

#indexObject



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

#newObject



43
44
45
# File 'app/controllers/folders_controller.rb', line 43

def new
  @folder = current_user.folders.new
end

#public_listObject

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 options = {}
  search_catalog_url(options.except(:controller, :action))
end

#showObject



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

#updateObject



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