75 lines
1.8 KiB
Ruby
75 lines
1.8 KiB
Ruby
class Panel::Video::BackEnd::VideosController < OrbitBackendController
|
|
|
|
#before_filter :clean_values, :only => [:create, :update]
|
|
|
|
# before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete]
|
|
# before_filter :force_order_for_user,:except => [:get_videos,:index]
|
|
# before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_videos]
|
|
|
|
def index
|
|
@videos = Video.all
|
|
@client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA")
|
|
|
|
respond_to do |format|
|
|
format.html # new.html.erb
|
|
format.json { render json: @videos }
|
|
end
|
|
end
|
|
|
|
def new
|
|
@video = Video.new
|
|
|
|
respond_to do |format|
|
|
format.html # new.html.erb
|
|
format.json { render json: @video }
|
|
end
|
|
end
|
|
|
|
def edit
|
|
@video = Video.find(params[:id])
|
|
end
|
|
|
|
def show
|
|
@video = Video.find(params[:id])
|
|
respond_to do |format|
|
|
format.html
|
|
format.json { render json: @video }
|
|
end
|
|
end
|
|
|
|
def create
|
|
@video = Video.new(params[:video])
|
|
@video.save!
|
|
redirect_to panel_videos_back_end_videos_url
|
|
end
|
|
|
|
def update
|
|
@video = Video.find(params[:id])
|
|
@video.update_attributes(params[:video])
|
|
redirect_to panel_videos_back_end_videos_url
|
|
end
|
|
|
|
def destroy
|
|
@video = Video.find(params[:id])
|
|
@video.destroy
|
|
redirect_to panel_videos_back_end_videos_url
|
|
|
|
end
|
|
|
|
def get_videos
|
|
videos = Video.all
|
|
@data = Array.new
|
|
|
|
videos.each do |video|
|
|
@data << { title: video.title,
|
|
url: video.url,
|
|
description: video.description }
|
|
end
|
|
|
|
#print readable json
|
|
render :json => JSON.pretty_generate({video: @data})
|
|
|
|
#render :json => {video: @data}.to_json
|
|
end
|
|
end
|