2015-08-11 08:39:31 +00:00
|
|
|
class DigitalArchivesController < ApplicationController
|
|
|
|
def index
|
2015-10-21 07:42:37 +00:00
|
|
|
params = OrbitHelper.params
|
|
|
|
if params[:item_date_low].nil?
|
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/)
|
|
|
|
elsif params[:item_date_low].empty? && params[:item_date_high].empty?
|
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/)
|
|
|
|
elsif params[:item_date_low].empty? && !params[:item_date_high].empty?
|
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/,
|
|
|
|
:item_date.lte => params[:item_date_high])
|
|
|
|
elsif !params[:item_date_low].empty? && params[:item_date_high].empty?
|
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/,
|
|
|
|
:item_date.gte => params[:item_date_low])
|
2015-08-11 08:39:31 +00:00
|
|
|
else
|
2015-10-21 07:42:37 +00:00
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/,
|
|
|
|
:item_date.gte => params[:item_date_low],
|
|
|
|
:item_date.lte => params[:item_date_high])
|
2015-08-11 08:39:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
dcas = @digital_content_archives.collect do |dca|
|
|
|
|
dcafs = dca.digital_content_archive_files.collect do |file|
|
|
|
|
if file.choose_lang.include?(I18n.locale.to_s)
|
|
|
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
|
|
|
extension = file.file.file.extension.downcase rescue ""
|
|
|
|
# url = file.file.url rescue ""
|
|
|
|
{
|
|
|
|
"file-name" => title
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"title" => (dca.title rescue ""),
|
|
|
|
"item-date" => (dca.item_date rescue ""),
|
|
|
|
"files" => dcafs
|
|
|
|
}
|
|
|
|
end
|
2015-10-21 07:42:37 +00:00
|
|
|
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
|
|
|
url = page.nil? ? "#" : "/#{I18n.locale.to_s}/#{page.url}"
|
2015-08-11 08:39:31 +00:00
|
|
|
{
|
2015-10-21 07:42:37 +00:00
|
|
|
"digital_content_archives" => dcas,
|
|
|
|
"page_url" => url
|
2015-08-11 08:39:31 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
end
|