Video and Channel Fetching now working
This commit is contained in:
parent
36c3635bbb
commit
75eeec737c
|
@ -0,0 +1,38 @@
|
||||||
|
class Panel::Videos::BackEnd::ChannelVideosController < OrbitBackendController
|
||||||
|
before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete]
|
||||||
|
before_filter :force_order_for_user,:except => [:index]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@videos = ChannelVideo.all
|
||||||
|
client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA")
|
||||||
|
@client_videos = client.videos_by(:user => 'ntuprs', :per_page => 5)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @videos }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@video = ChannelVideo.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@video = ChannelVideo.new(params[:video])
|
||||||
|
@video.save!
|
||||||
|
redirect_to panel_videos_back_end_channel_videos_url
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@video = ChannelVideo.find(params[:id])
|
||||||
|
@video.update_attributes(params[:video])
|
||||||
|
redirect_to panel_videos_back_end_channel_videos_url
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@video = ChannelVideo.find(params[:id])
|
||||||
|
@video.destroy
|
||||||
|
redirect_to panel_videos_back_end_channel_videos_url
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,6 +8,8 @@ class Panel::Videos::BackEnd::VideosController < OrbitBackendController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@videos = Video.all
|
@videos = Video.all
|
||||||
|
@client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA")
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # new.html.erb
|
format.html # new.html.erb
|
||||||
format.json { render json: @videos }
|
format.json { render json: @videos }
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class ChannelVideo
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
field :channel_name
|
||||||
|
end
|
12
vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/_form.html.erb
vendored
Normal file
12
vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/_form.html.erb
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for=""><%= t 'title' %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :channel_name, :class=>"span2", :placeholder => "Channel Name" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.submit t("submit"), :class=>"btn" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
3
vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/edit.html.erb
vendored
Normal file
3
vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/edit.html.erb
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<%= form_for @video, :url=> panel_videos_back_end_channel_video_path(@video), :html => { :class=>"form-horizontal"} do |f| %>
|
||||||
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||||
|
<% end %>
|
30
vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/index.html.erb
vendored
Normal file
30
vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/index.html.erb
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<table class="table main-list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="span1"></th>
|
||||||
|
<%if is_manager? %>
|
||||||
|
<th class="span1"><%= t('videos.edit') %></th>
|
||||||
|
<th class="span1"><%= t('videos.delete') %></th>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbody_locations" class="sort-holder">
|
||||||
|
<% @videos.each do |video| %>
|
||||||
|
<% @client_videos.videos.each do |v| %>
|
||||||
|
<tr class="with_action">
|
||||||
|
<% @video = v.video_id.split(/tag:youtube.com,2008:video:+/).last %>
|
||||||
|
<% @vd = UnvlogIt.new("https://www.youtube.com/watch?v=#{@video}")%>
|
||||||
|
<td><%= @vd.embed_html(400, 300).html_safe %></td>
|
||||||
|
<td><%= @vd.title %></td>
|
||||||
|
<%if is_manager? %>
|
||||||
|
<td><%= link_to 'Edit', edit_panel_videos_back_end_channel_video_path(video) %></td>
|
||||||
|
<td><%= link_to 'Destroy', panel_videos_back_end_channel_video_path(video), method: :delete , :confirm => t(:sure?) %></td>
|
||||||
|
<%end%>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<%if is_manager? %>
|
||||||
|
<td><%= link_to 'New', new_panel_videos_back_end_channel_video_path, :class => "btn btn-primary", :id=>"create_event_btn", :ref=>"add-btn" %></td>
|
||||||
|
<% end %>
|
3
vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/new.html.erb
vendored
Normal file
3
vendor/built_in_modules/videos/app/views/panel/videos/back_end/channel_videos/new.html.erb
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<%= form_for @video, :url=> panel_videos_back_end_channel_videos_path, :html => { :class=>"form-horizontal"} do |f| %>
|
||||||
|
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||||
|
<% end %>
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for=""><%= t 'title' %></label>
|
<label class="control-label" for=""><%= t 'title' %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :title, :class=>"span2", :placeholder => "Tiele" %>
|
<%= f.text_field :title, :class=>"span2", :placeholder => "Title" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
<% video_display = UnvlogIt.new(video.url)%>
|
<% video_display = UnvlogIt.new(video.url)%>
|
||||||
<td><%= video_display.embed_html(400, 300).html_safe %></td>
|
<td><%= video_display.embed_html(400, 300).html_safe %></td>
|
||||||
<td><%= video.title %></td>
|
<td><%= video.title %></td>
|
||||||
<td><%= video.description %></td>
|
<% @client_videos = @client.videos_by(:user => 'ntuprs', :per_page => 5) %>
|
||||||
|
|
||||||
|
<td><% @client_videos.videos.each do |v| %> <% @video = v.video_id.split(/tag:youtube.com,2008:video:+/).last %><% vd = UnvlogIt.new("https://www.youtube.com/watch?v=#{@video}")%><%= vd.embed_html(200, 150).html_safe %><br/><br/><br/> <% end %></td>
|
||||||
<%if is_manager? %>
|
<%if is_manager? %>
|
||||||
<td><%= link_to 'Edit', edit_panel_videos_back_end_video_path(video) %></td>
|
<td><%= link_to 'Edit', edit_panel_videos_back_end_video_path(video) %></td>
|
||||||
<td><%= link_to 'Destroy', panel_videos_back_end_video_path(video), method: :delete , :confirm => t(:sure?) %></td>
|
<td><%= link_to 'Destroy', panel_videos_back_end_video_path(video), method: :delete , :confirm => t(:sure?) %></td>
|
||||||
|
|
|
@ -4,6 +4,7 @@ Rails.application.routes.draw do
|
||||||
namespace :back_end do
|
namespace :back_end do
|
||||||
match "videos/get_videos" => "videos#get_videos"
|
match "videos/get_videos" => "videos#get_videos"
|
||||||
resources :videos
|
resources :videos
|
||||||
|
resources :channel_videos
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue