class VlogsController < ApplicationController def index vlogs = VLog.all.order_by(:created_at=>'desc').filter_by_categories.filter_by_tags.collect do |vlog| { "thumbnail" => (vlog.type == "youtube" ? vlog.youtube_thumbnail : vlog.thumbnail), "title" => vlog.title, "username" => (!vlog.create_user_id.nil? ? User.find(vlog.create_user_id).name : ""), "url_to_show" => OrbitHelper.url_to_show(vlog.to_param) } end heads = ["vlog.thumbnail", :title, "vlog.uploaded_by"].collect do |title| { "column-title" => t(title) } end { "heads" => heads, "vlogs" => vlogs } end def widget vlog = VLog.all.filter_by_widget_categories.sample(1).first if vlog.type == "upload" && !vlog.v_log_video.nil? video = "" elsif vlog.type == "youtube" && !vlog.youtube_link.nil? video = "" end { "extras" => {"widget-title"=>t(:web_resource),"more_url" => OrbitHelper.widget_more_url, "video" => video, "title" => vlog.title, "subtitle" => vlog.subtitle} } end def show params = OrbitHelper.params vlog = VLog.where(:uid => params[:uid]).first if vlog.type == "upload" && !vlog.v_log_video.nil? video = "" elsif vlog.type == "youtube" && !vlog.youtube_link.nil? video = "" end files = vlog.v_log_files.collect do |file| title = (file.title.blank? ? File.basename(file.file.path) : file.title) rescue "" { "title" => title, "link" => "/xhr/vlogfiles/download?file=#{file.id}" } end { "files" => files, "data" => { "title" => vlog.title, "subtitle" => vlog.subtitle, "type" => vlog.type, "video" => video } } end def download_file file_id = params[:file] file = VLogFile.find(file_id) rescue nil if !file.nil? redirect_to file.file.url and return end render :nothing => true end end