2014-05-14 11:52:06 +00:00
|
|
|
class ArchivesController < ApplicationController
|
|
|
|
def index
|
|
|
|
categories = OrbitHelper.page_categories
|
|
|
|
@categories = []
|
|
|
|
if categories.first == "all"
|
|
|
|
module_app = OrbitHelper.this_module_app
|
|
|
|
@categories = module_app.categories.collect do |cat|
|
|
|
|
{
|
|
|
|
"title" => cat.title,
|
|
|
|
"id" => cat.id.to_s
|
|
|
|
}
|
|
|
|
end
|
|
|
|
else
|
|
|
|
categories.each do |cat|
|
|
|
|
c = Category.find(cat)
|
|
|
|
@categories << {"title" => c.title, "id" => c.id.to_s}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
cats = @categories.collect do |cat|
|
|
|
|
archives = ArchiveFile.where(:category_id => cat["id"]).collect do |archive|
|
|
|
|
statuses = archive.statuses.collect do |status|
|
|
|
|
{
|
|
|
|
"archive-status" => status
|
|
|
|
}
|
|
|
|
end
|
|
|
|
files = archive.archive_file_multiples.collect do |file|
|
|
|
|
{
|
|
|
|
"file-name" => file.file_title,
|
|
|
|
"file-type" => file.file.file.extension.downcase,
|
|
|
|
"file-url" => file.file.url
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"archive-title" => archive.title,
|
|
|
|
"status" => statuses,
|
|
|
|
"files" => files
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"category-title" => cat["title"],
|
|
|
|
"archives" => archives
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"categories" => cats,
|
|
|
|
"extras" => {"widget-title" => "Archives"}
|
|
|
|
}
|
|
|
|
end
|
2014-05-23 06:00:49 +00:00
|
|
|
|
|
|
|
def widget
|
|
|
|
categories = OrbitHelper.widget_categories
|
|
|
|
@categories = []
|
|
|
|
if categories.first == "all"
|
|
|
|
module_app = OrbitHelper.widget_module_app
|
|
|
|
@categories = module_app.categories.collect do |cat|
|
|
|
|
{
|
|
|
|
"title" => cat.title,
|
|
|
|
"id" => cat.id.to_s
|
|
|
|
}
|
|
|
|
end
|
|
|
|
else
|
|
|
|
categories.each do |cat|
|
|
|
|
c = Category.find(cat)
|
|
|
|
@categories << {"title" => c.title, "id" => c.id.to_s}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
cats = @categories.collect do |cat|
|
|
|
|
archives = ArchiveFile.where(:category_id => cat["id"]).collect do |archive|
|
|
|
|
{
|
2014-05-24 11:37:07 +00:00
|
|
|
"archive-title" => archive.title,
|
|
|
|
"archive_url" => OrbitHelper.widget_more_url
|
2014-05-23 06:00:49 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"category-title" => cat["title"],
|
|
|
|
"archives" => archives
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"categories" => cats,
|
2014-05-24 11:37:07 +00:00
|
|
|
"extras" => {"widget-title" => "Archives","more_url"=>OrbitHelper.widget_more_url}
|
2014-05-23 06:00:49 +00:00
|
|
|
}
|
|
|
|
end
|
2014-05-14 11:52:06 +00:00
|
|
|
end
|