links/app/controllers/web_resources_controller.rb

51 lines
1.3 KiB
Ruby

class WebResourcesController < ApplicationController
def index
links = WebLink.where(:title.ne => "").can_display.filter_by_categories
web_link = links.collect do |link|
statuses = link.statuses_with_classname.collect do |status|
{
"status" => status["name"],
"status-class" => "status-#{status['classname']}"
}
end
{
"title" => link.title,
"context" => link.context,
"statuses" => statuses,
"link_to_show" => link.url
}
end
{
"web_link" => web_link,
"extras" => {
"widget-title"=>t(:web_resource)
},
"total_pages" => links.total_pages
}
end
def widget
links = WebLink.where(:title.ne => "").can_display.filter_by_widget_categories
web_link = links.collect do |link|
statuses = link.statuses_with_classname.collect do |status|
{
"status" => status["name"],
"status-class" => "status-#{status['classname']}"
}
end
{
"title" => link.title,
"context" => link.context,
"statuses" => statuses,
"link_to_show" => link.url
}
end
{
"web_link" => web_link,
"extras" => {"widget-title"=>t(:web_resource),"more_url" => OrbitHelper.widget_more_url}
}
end
end