From a5c800d3fedb7ca13ea7f20e369f4874a1838380 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Fri, 9 Aug 2013 10:44:06 +0800 Subject: [PATCH] Added video widget to new UI --- Gemfile | 2 + vendor/built_in_modules/video/.gitignore | 6 ++ vendor/built_in_modules/video/Gemfile | 17 +++++ vendor/built_in_modules/video/MIT-LICENSE | 20 +++++ vendor/built_in_modules/video/README.rdoc | 3 + vendor/built_in_modules/video/Rakefile | 39 ++++++++++ .../video/app/assets/images/gprs/.gitkeep | 0 .../video/app/assets/images/location/.gitkeep | 0 .../app/assets/javascripts/gprs/.gitkeep | 0 .../panel/gprs/back_end/locations.js | 2 + .../panel/location/back_end/locations.js | 2 + .../app/assets/stylesheets/gprs/.gitkeep | 0 .../app/assets/stylesheets/location/.gitkeep | 0 .../panel/gprs/back_end/locations.css | 4 + .../panel/location/back_end/locations.css | 4 + .../video/app/controllers/.gitkeep | 0 .../back_end/channel_videos_controller.rb | 58 +++++++++++++++ .../panel/video/back_end/videos_controller.rb | 74 +++++++++++++++++++ .../front_end/channel_videos_controller.rb | 24 ++++++ .../video/widget/channel_videos_controller.rb | 62 ++++++++++++++++ .../video/app/helpers/.gitkeep | 0 .../panel/videos/back_end/videos_helper.rb | 2 + .../video/app/mailers/.gitkeep | 0 .../video/app/models/.gitkeep | 0 .../video/app/models/channel_video.rb | 10 +++ .../video/app/models/video.rb | 8 ++ .../video/app/uploaders/locations_uploader.rb | 61 +++++++++++++++ .../built_in_modules/video/app/views/.gitkeep | 0 .../back_end/channel_videos/_form.html.erb | 14 ++++ .../back_end/channel_videos/edit.html.erb | 3 + .../back_end/channel_videos/index.html.erb | 29 ++++++++ .../back_end/channel_videos/new.html.erb | 3 + .../back_end/channel_videos/show.html.erb | 7 ++ .../video/back_end/videos/_form.html.erb | 26 +++++++ .../panel/video/back_end/videos/edit.html.erb | 4 + .../video/back_end/videos/index.html.erb | 32 ++++++++ .../panel/video/back_end/videos/new.html.erb | 3 + .../video/front_end/channel_videos.html.erb | 8 ++ .../channel_videos/channel_videos.html.erb | 9 +++ .../video/config/locales/en.yml | 5 ++ .../video/config/locales/zh_tw.yml | 5 ++ .../built_in_modules/video/config/routes.rb | 19 +++++ vendor/built_in_modules/video/init.rb | 71 ++++++++++++++++++ .../video/lib/tasks/location_tasks.rake | 4 + vendor/built_in_modules/video/script/rails | 6 ++ .../video/test/dummy/Rakefile | 7 ++ .../app/assets/javascripts/application.js | 9 +++ .../app/assets/stylesheets/application.css | 7 ++ .../app/controllers/application_controller.rb | 3 + .../dummy/app/helpers/application_helper.rb | 2 + .../video/test/dummy/app/mailers/.gitkeep | 0 .../video/test/dummy/app/models/.gitkeep | 0 .../app/views/layouts/application.html.erb | 14 ++++ .../video/test/dummy/config.ru | 4 + .../video/test/dummy/config/application.rb | 45 +++++++++++ .../video/test/dummy/config/boot.rb | 10 +++ .../video/test/dummy/config/database.yml | 25 +++++++ .../video/test/dummy/config/environment.rb | 5 ++ .../dummy/config/environments/development.rb | 30 ++++++++ .../dummy/config/environments/production.rb | 60 +++++++++++++++ .../test/dummy/config/environments/test.rb | 39 ++++++++++ .../initializers/backtrace_silencers.rb | 7 ++ .../dummy/config/initializers/inflections.rb | 10 +++ .../dummy/config/initializers/mime_types.rb | 5 ++ .../dummy/config/initializers/secret_token.rb | 7 ++ .../config/initializers/session_store.rb | 8 ++ .../config/initializers/wrap_parameters.rb | 14 ++++ .../video/test/dummy/config/locales/en.yml | 5 ++ .../video/test/dummy/config/routes.rb | 58 +++++++++++++++ .../video/test/dummy/lib/assets/.gitkeep | 0 .../video/test/dummy/log/.gitkeep | 0 .../video/test/dummy/public/404.html | 26 +++++++ .../video/test/dummy/public/422.html | 26 +++++++ .../video/test/dummy/public/500.html | 26 +++++++ .../video/test/dummy/public/favicon.ico | 0 .../video/test/dummy/script/rails | 6 ++ .../back_end/locations_controller_test.rb | 14 ++++ .../back_end/locations_controller_test.rb | 14 ++++ .../video/test/integration/navigation_test.rb | 10 +++ .../video/test/location_test.rb | 7 ++ .../video/test/test_helper.rb | 10 +++ .../gprs/back_end/locations_helper_test.rb | 4 + .../back_end/locations_helper_test.rb | 4 + vendor/built_in_modules/video/video.gemspec | 23 ++++++ vendor/built_in_modules/video/video.json | 12 +++ 85 files changed, 1202 insertions(+) create mode 100644 vendor/built_in_modules/video/.gitignore create mode 100644 vendor/built_in_modules/video/Gemfile create mode 100644 vendor/built_in_modules/video/MIT-LICENSE create mode 100644 vendor/built_in_modules/video/README.rdoc create mode 100644 vendor/built_in_modules/video/Rakefile create mode 100644 vendor/built_in_modules/video/app/assets/images/gprs/.gitkeep create mode 100644 vendor/built_in_modules/video/app/assets/images/location/.gitkeep create mode 100644 vendor/built_in_modules/video/app/assets/javascripts/gprs/.gitkeep create mode 100644 vendor/built_in_modules/video/app/assets/javascripts/panel/gprs/back_end/locations.js create mode 100644 vendor/built_in_modules/video/app/assets/javascripts/panel/location/back_end/locations.js create mode 100644 vendor/built_in_modules/video/app/assets/stylesheets/gprs/.gitkeep create mode 100644 vendor/built_in_modules/video/app/assets/stylesheets/location/.gitkeep create mode 100644 vendor/built_in_modules/video/app/assets/stylesheets/panel/gprs/back_end/locations.css create mode 100644 vendor/built_in_modules/video/app/assets/stylesheets/panel/location/back_end/locations.css create mode 100644 vendor/built_in_modules/video/app/controllers/.gitkeep create mode 100644 vendor/built_in_modules/video/app/controllers/panel/video/back_end/channel_videos_controller.rb create mode 100644 vendor/built_in_modules/video/app/controllers/panel/video/back_end/videos_controller.rb create mode 100644 vendor/built_in_modules/video/app/controllers/panel/video/front_end/channel_videos_controller.rb create mode 100644 vendor/built_in_modules/video/app/controllers/panel/video/widget/channel_videos_controller.rb create mode 100644 vendor/built_in_modules/video/app/helpers/.gitkeep create mode 100644 vendor/built_in_modules/video/app/helpers/panel/videos/back_end/videos_helper.rb create mode 100644 vendor/built_in_modules/video/app/mailers/.gitkeep create mode 100644 vendor/built_in_modules/video/app/models/.gitkeep create mode 100644 vendor/built_in_modules/video/app/models/channel_video.rb create mode 100644 vendor/built_in_modules/video/app/models/video.rb create mode 100644 vendor/built_in_modules/video/app/uploaders/locations_uploader.rb create mode 100644 vendor/built_in_modules/video/app/views/.gitkeep create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/_form.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/edit.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/index.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/new.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/show.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/videos/_form.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/videos/edit.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/videos/index.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/back_end/videos/new.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/front_end/channel_videos.html.erb create mode 100644 vendor/built_in_modules/video/app/views/panel/video/widget/channel_videos/channel_videos.html.erb create mode 100644 vendor/built_in_modules/video/config/locales/en.yml create mode 100644 vendor/built_in_modules/video/config/locales/zh_tw.yml create mode 100644 vendor/built_in_modules/video/config/routes.rb create mode 100644 vendor/built_in_modules/video/init.rb create mode 100644 vendor/built_in_modules/video/lib/tasks/location_tasks.rake create mode 100755 vendor/built_in_modules/video/script/rails create mode 100644 vendor/built_in_modules/video/test/dummy/Rakefile create mode 100644 vendor/built_in_modules/video/test/dummy/app/assets/javascripts/application.js create mode 100644 vendor/built_in_modules/video/test/dummy/app/assets/stylesheets/application.css create mode 100644 vendor/built_in_modules/video/test/dummy/app/controllers/application_controller.rb create mode 100644 vendor/built_in_modules/video/test/dummy/app/helpers/application_helper.rb create mode 100644 vendor/built_in_modules/video/test/dummy/app/mailers/.gitkeep create mode 100644 vendor/built_in_modules/video/test/dummy/app/models/.gitkeep create mode 100644 vendor/built_in_modules/video/test/dummy/app/views/layouts/application.html.erb create mode 100644 vendor/built_in_modules/video/test/dummy/config.ru create mode 100644 vendor/built_in_modules/video/test/dummy/config/application.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/boot.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/database.yml create mode 100644 vendor/built_in_modules/video/test/dummy/config/environment.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/environments/development.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/environments/production.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/environments/test.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/initializers/backtrace_silencers.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/initializers/inflections.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/initializers/mime_types.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/initializers/secret_token.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/initializers/session_store.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/initializers/wrap_parameters.rb create mode 100644 vendor/built_in_modules/video/test/dummy/config/locales/en.yml create mode 100644 vendor/built_in_modules/video/test/dummy/config/routes.rb create mode 100644 vendor/built_in_modules/video/test/dummy/lib/assets/.gitkeep create mode 100644 vendor/built_in_modules/video/test/dummy/log/.gitkeep create mode 100644 vendor/built_in_modules/video/test/dummy/public/404.html create mode 100644 vendor/built_in_modules/video/test/dummy/public/422.html create mode 100644 vendor/built_in_modules/video/test/dummy/public/500.html create mode 100644 vendor/built_in_modules/video/test/dummy/public/favicon.ico create mode 100755 vendor/built_in_modules/video/test/dummy/script/rails create mode 100644 vendor/built_in_modules/video/test/functional/panel/gprs/back_end/locations_controller_test.rb create mode 100644 vendor/built_in_modules/video/test/functional/panel/location/back_end/locations_controller_test.rb create mode 100644 vendor/built_in_modules/video/test/integration/navigation_test.rb create mode 100644 vendor/built_in_modules/video/test/location_test.rb create mode 100644 vendor/built_in_modules/video/test/test_helper.rb create mode 100644 vendor/built_in_modules/video/test/unit/helpers/panel/gprs/back_end/locations_helper_test.rb create mode 100644 vendor/built_in_modules/video/test/unit/helpers/panel/location/back_end/locations_helper_test.rb create mode 100644 vendor/built_in_modules/video/video.gemspec create mode 100644 vendor/built_in_modules/video/video.json diff --git a/Gemfile b/Gemfile index 45ec242d..350e290d 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,8 @@ gem 'jquery-ui-rails' gem "select2-rails", '3.3.1' gem 'kaminari' gem 'time_difference' +gem "acts_as_unvlogable" +gem 'youtube_it' # gem "memcached", "~> 1.4.3" # gem "memcache-client" diff --git a/vendor/built_in_modules/video/.gitignore b/vendor/built_in_modules/video/.gitignore new file mode 100644 index 00000000..1463de6d --- /dev/null +++ b/vendor/built_in_modules/video/.gitignore @@ -0,0 +1,6 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/log/*.log +test/dummy/tmp/ \ No newline at end of file diff --git a/vendor/built_in_modules/video/Gemfile b/vendor/built_in_modules/video/Gemfile new file mode 100644 index 00000000..a6e487f4 --- /dev/null +++ b/vendor/built_in_modules/video/Gemfile @@ -0,0 +1,17 @@ +source "http://rubygems.org" + +# Declare your gem's dependencies in location.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# jquery-rails is used by the dummy application +gem "jquery-rails" + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'ruby-debug19', :require => 'ruby-debug' diff --git a/vendor/built_in_modules/video/MIT-LICENSE b/vendor/built_in_modules/video/MIT-LICENSE new file mode 100644 index 00000000..406f17b7 --- /dev/null +++ b/vendor/built_in_modules/video/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2012 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/built_in_modules/video/README.rdoc b/vendor/built_in_modules/video/README.rdoc new file mode 100644 index 00000000..937b4141 --- /dev/null +++ b/vendor/built_in_modules/video/README.rdoc @@ -0,0 +1,3 @@ += Location + +This project rocks and uses MIT-LICENSE. diff --git a/vendor/built_in_modules/video/Rakefile b/vendor/built_in_modules/video/Rakefile new file mode 100644 index 00000000..66353374 --- /dev/null +++ b/vendor/built_in_modules/video/Rakefile @@ -0,0 +1,39 @@ +#!/usr/bin/env rake +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end +begin + require 'rdoc/task' +rescue LoadError + require 'rdoc/rdoc' + require 'rake/rdoctask' + RDoc::Task = Rake::RDocTask +end + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'Location' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task :default => :test diff --git a/vendor/built_in_modules/video/app/assets/images/gprs/.gitkeep b/vendor/built_in_modules/video/app/assets/images/gprs/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/assets/images/location/.gitkeep b/vendor/built_in_modules/video/app/assets/images/location/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/assets/javascripts/gprs/.gitkeep b/vendor/built_in_modules/video/app/assets/javascripts/gprs/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/assets/javascripts/panel/gprs/back_end/locations.js b/vendor/built_in_modules/video/app/assets/javascripts/panel/gprs/back_end/locations.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/vendor/built_in_modules/video/app/assets/javascripts/panel/gprs/back_end/locations.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/vendor/built_in_modules/video/app/assets/javascripts/panel/location/back_end/locations.js b/vendor/built_in_modules/video/app/assets/javascripts/panel/location/back_end/locations.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/vendor/built_in_modules/video/app/assets/javascripts/panel/location/back_end/locations.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/vendor/built_in_modules/video/app/assets/stylesheets/gprs/.gitkeep b/vendor/built_in_modules/video/app/assets/stylesheets/gprs/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/assets/stylesheets/location/.gitkeep b/vendor/built_in_modules/video/app/assets/stylesheets/location/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/assets/stylesheets/panel/gprs/back_end/locations.css b/vendor/built_in_modules/video/app/assets/stylesheets/panel/gprs/back_end/locations.css new file mode 100644 index 00000000..afad32db --- /dev/null +++ b/vendor/built_in_modules/video/app/assets/stylesheets/panel/gprs/back_end/locations.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/vendor/built_in_modules/video/app/assets/stylesheets/panel/location/back_end/locations.css b/vendor/built_in_modules/video/app/assets/stylesheets/panel/location/back_end/locations.css new file mode 100644 index 00000000..afad32db --- /dev/null +++ b/vendor/built_in_modules/video/app/assets/stylesheets/panel/location/back_end/locations.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/vendor/built_in_modules/video/app/controllers/.gitkeep b/vendor/built_in_modules/video/app/controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/controllers/panel/video/back_end/channel_videos_controller.rb b/vendor/built_in_modules/video/app/controllers/panel/video/back_end/channel_videos_controller.rb new file mode 100644 index 00000000..e9ba49fe --- /dev/null +++ b/vendor/built_in_modules/video/app/controllers/panel/video/back_end/channel_videos_controller.rb @@ -0,0 +1,58 @@ +class Panel::Video::BackEnd::ChannelVideosController < OrbitBackendController + before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete] + before_filter :force_order_for_user,:except => [:index] + + def index + @channel_videos = ChannelVideo.all + respond_to do |format| + format.html # new.html.erb + format.json { render json: @videos } + end + end + + def show + @channel_video = ChannelVideo.find(params[:id]) + client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA") + @client_videos = client.videos_by(:user => @channel_video.channel_name, :per_page => 5) + + respond_to do |format| + format.html + format.json { render json: @location } + end + end + + def new + @channel_video = ChannelVideo.new + end + + def edit + @channel_video = ChannelVideo.find(params[:id]) + end + + def create + @channel_video = ChannelVideo.new(params[:channel_video]) + + if @channel_video.save + redirect_to panel_video_back_end_channel_videos_url + else + render 'new' + end + end + + def update + @channel_video = ChannelVideo.find(params[:id]) + + if @channel_video.update_attributes(params[:channel_video]) + redirect_to panel_video_back_end_channel_videos_url + else + render 'edit' + end + end + + def destroy + @channel_video = ChannelVideo.find(params[:id]) + @channel_video.destroy + redirect_to panel_video_back_end_channel_videos_url + + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/video/app/controllers/panel/video/back_end/videos_controller.rb b/vendor/built_in_modules/video/app/controllers/panel/video/back_end/videos_controller.rb new file mode 100644 index 00000000..078b134a --- /dev/null +++ b/vendor/built_in_modules/video/app/controllers/panel/video/back_end/videos_controller.rb @@ -0,0 +1,74 @@ +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 diff --git a/vendor/built_in_modules/video/app/controllers/panel/video/front_end/channel_videos_controller.rb b/vendor/built_in_modules/video/app/controllers/panel/video/front_end/channel_videos_controller.rb new file mode 100644 index 00000000..c6cd7305 --- /dev/null +++ b/vendor/built_in_modules/video/app/controllers/panel/video/front_end/channel_videos_controller.rb @@ -0,0 +1,24 @@ +class Panel::Video::FrontEnd::ChannelVideosController < OrbitWidgetController + def initialize + super + @app_title = 'video' + end + + def channel_videos + @item = Page.find(params[:page_id]) rescue nil + if @item + if @item.frontend_data_count + @page_num = @item.frontend_data_count + else + @page_num = 15 + end + @frontend_style = @item.frontend_style + end + @item = Page.find(params[:page_id]) rescue nil + if !params[:category_id].blank? || !params[:tag_id].blank? + @channel_video = ChannelVideo.find(@part.widget_options['channel_videos']) rescue nil + client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA") + @client_videos = client.videos_by(:user => @channel_video.channel_name, :per_page => 5) + end + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/video/app/controllers/panel/video/widget/channel_videos_controller.rb b/vendor/built_in_modules/video/app/controllers/panel/video/widget/channel_videos_controller.rb new file mode 100644 index 00000000..bccea587 --- /dev/null +++ b/vendor/built_in_modules/video/app/controllers/panel/video/widget/channel_videos_controller.rb @@ -0,0 +1,62 @@ +class Panel::Video::Widget::ChannelVideosController < OrbitWidgetController + + def initialize + super + @app_title = 'video' + end + + # GET /bulletins + # GET /bulletins.xml + + def channel_videos + @part = PagePart.find(params[:part_id]) + + if @part.widget_data_count + @page_num = @part.widget_data_count + else + @page_num = 4 + end + + if @part.widget_field + @widget_fields = @part.widget_field + else + @widget_fields = [] + end + + @channel_video = ChannelVideo.find(@part.widget_options['channel_videos']) rescue nil + client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA") + @client_videos = client.videos_by(:user => @channel_video.channel_name, :per_page => 5) + + + end + + # def bulletins_list_and_pic + + # if params[:widget_data_count] + # @page_num = params[:widget_data_count]; + # else + # @page_num = 4; + # end + + # @title = params[:part_title] + # date_now = Time.now + # if !params[:category_id].blank? + # @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num ) + # @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil + # elsif !params[:tag_id].blank? + # @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) + # else + # @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num ) + # end + + # get_categorys + + # end + + # def reload_bulletins + # @selected_tag = Tag.find(params[:tag_id]) + # @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort).page(params[:page]).per(5) rescue nil + # end + + +end diff --git a/vendor/built_in_modules/video/app/helpers/.gitkeep b/vendor/built_in_modules/video/app/helpers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/helpers/panel/videos/back_end/videos_helper.rb b/vendor/built_in_modules/video/app/helpers/panel/videos/back_end/videos_helper.rb new file mode 100644 index 00000000..8cc8935a --- /dev/null +++ b/vendor/built_in_modules/video/app/helpers/panel/videos/back_end/videos_helper.rb @@ -0,0 +1,2 @@ +module Panel::Locations::BackEnd::VideosHelper +end diff --git a/vendor/built_in_modules/video/app/mailers/.gitkeep b/vendor/built_in_modules/video/app/mailers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/models/.gitkeep b/vendor/built_in_modules/video/app/models/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/models/channel_video.rb b/vendor/built_in_modules/video/app/models/channel_video.rb new file mode 100644 index 00000000..86493e9a --- /dev/null +++ b/vendor/built_in_modules/video/app/models/channel_video.rb @@ -0,0 +1,10 @@ +class ChannelVideo + include Mongoid::Document + include Mongoid::Timestamps + + attr_accessible :channel_name + + field :channel_name + + validates_presence_of :channel_name +end \ No newline at end of file diff --git a/vendor/built_in_modules/video/app/models/video.rb b/vendor/built_in_modules/video/app/models/video.rb new file mode 100644 index 00000000..62b55e55 --- /dev/null +++ b/vendor/built_in_modules/video/app/models/video.rb @@ -0,0 +1,8 @@ +class Video + include Mongoid::Document + include Mongoid::Timestamps + + field :title + field :description + field :url +end diff --git a/vendor/built_in_modules/video/app/uploaders/locations_uploader.rb b/vendor/built_in_modules/video/app/uploaders/locations_uploader.rb new file mode 100644 index 00000000..55056a5b --- /dev/null +++ b/vendor/built_in_modules/video/app/uploaders/locations_uploader.rb @@ -0,0 +1,61 @@ +class LocationsUploader < CarrierWave::Uploader::Base + + # Include RMagick or ImageScience support: + # include CarrierWave::RMagick + # include CarrierWave::ImageScience + include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + # storage :file + # storage :s3 + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "location/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process :scale => [50, 50] + # end + + version :thumb do + process :resize_to_fill => [150, 120] + end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + # def extension_white_list + # %w(jpg jpeg gif png) + # end + + # Override the filename of the uploaded files: + # def filename + # "something.jpg" if original_filename + # end + +# def manipulate! +# raise current_path.inspect +# image = ::MiniMagick::Image.open(current_path) +# image = yield(image) +# image.write(current_path) +# ::MiniMagick::Image.open(current_path) +# rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e +# raise CarrierWave::ProcessingError.new("Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: #{e}") +# end + +end + diff --git a/vendor/built_in_modules/video/app/views/.gitkeep b/vendor/built_in_modules/video/app/views/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/_form.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/_form.html.erb new file mode 100644 index 00000000..27c3be5d --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/_form.html.erb @@ -0,0 +1,14 @@ +
+

YouTube Channel

+
+ +
+ <%= f.text_field :channel_name, :class=>'span4', :placeholder => 'Channel Name'%> +
+
+ +
+
+ <%= f.submit t("submit"), :class=>"btn" %> +
+
diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/edit.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/edit.html.erb new file mode 100644 index 00000000..fa13c6ee --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/edit.html.erb @@ -0,0 +1,3 @@ +<%= form_for @channel_video, :url => panel_video_back_end_channel_video_path, :method => :put, :html => { :class=>"form-horizontal"} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/index.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/index.html.erb new file mode 100644 index 00000000..673ada29 --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/index.html.erb @@ -0,0 +1,29 @@ +
+

YouTube Channel

+ + + + + + <%if is_manager? %> + + + <% end %> + + + + <% @channel_videos.each do |video| %> + + + + <%if is_manager? %> + + + <% end %> + + <% end %> + +
<%= t('channel_name') %><%= t('videos.show') %><%= t('videos.edit') %><%= t('videos.delete') %>
<%= video.channel_name %><%= link_to 'Show Channel Videos', panel_video_back_end_channel_video_path(video) %><%= link_to 'Edit', edit_panel_video_back_end_channel_video_path(video) %><%= link_to 'Delete Channel', panel_video_back_end_channel_video_path(video), method: :delete , :confirm => t(:sure?) %>
+<%if is_manager? %> +<%= link_to 'New', new_panel_video_back_end_channel_video_path, :class => "btn btn-primary pull-right", :id=>"create_event_btn", :ref=>"add-btn" %> +<% end %> diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/new.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/new.html.erb new file mode 100644 index 00000000..72191ada --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/new.html.erb @@ -0,0 +1,3 @@ +<%= form_for @channel_video, :url => panel_video_back_end_channel_videos_path, :html => { :class=>"form-horizontal"} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/show.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/show.html.erb new file mode 100644 index 00000000..1e7bd2af --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/channel_videos/show.html.erb @@ -0,0 +1,7 @@ +<% @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(400, 300).html_safe %> + <%= @vd.title %> + <%end%> \ No newline at end of file diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/_form.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/_form.html.erb new file mode 100644 index 00000000..c715d916 --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/_form.html.erb @@ -0,0 +1,26 @@ +
+ +
+ <%= f.text_field :title, :class=>"span2", :placeholder => "Title" %> +
+
+ +
+ +
+ <%= f.text_field :url, :class=>"span2", :placeholder => "URL" %> +
+
+
+ +
+ <%= f.fields_for :description_translations do |f| %> + <%= f.text_area locale, :class=>'span4', :cols=>"30", :row=>"5", :value => (@video.description_translations[locale.to_s] rescue nil) %> + <% end %> +
+
+
+
+ <%= f.submit t("submit"), :class=>"btn" %> +
+
diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/edit.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/edit.html.erb new file mode 100644 index 00000000..bb4e9336 --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/edit.html.erb @@ -0,0 +1,4 @@ +<%= form_for @video, :url=> panel_videos_back_end_video_path(@video), :html => { :class=>"form-horizontal"} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> + diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/index.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/index.html.erb new file mode 100644 index 00000000..a5653f95 --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/index.html.erb @@ -0,0 +1,32 @@ + + + + + + + <%if is_manager? %> + + + <% end %> + + + + <% @videos.each do |video| %> + + <% video_display = UnvlogIt.new(video.url)%> + + + <% @client_videos = @client.videos_by(:user => 'ntuprs', :per_page => 5) %> + + + <%if is_manager? %> + + + <%end%> + + <% end %> + +
<%= t('videos.title') %><%= t('videos.description') %><%= t('videos.edit') %><%= t('videos.delete') %>
<%= video_display.embed_html(400, 300).html_safe %><%= video.title %><% @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 %>


<% end %>
<%= link_to 'Edit', edit_panel_videos_back_end_video_path(video) %><%= link_to 'Destroy', panel_videos_back_end_video_path(video), method: :delete , :confirm => t(:sure?) %>
+<%if is_manager? %> +<%= link_to 'New', new_panel_videos_back_end_video_path, :class => "btn btn-primary", :id=>"create_event_btn", :ref=>"add-btn" %> +<% end %> diff --git a/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/new.html.erb b/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/new.html.erb new file mode 100644 index 00000000..0b876d1a --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/back_end/videos/new.html.erb @@ -0,0 +1,3 @@ +<%= form_for @video, :url=> panel_videos_back_end_videos_path, :html => { :class=>"form-horizontal"} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> diff --git a/vendor/built_in_modules/video/app/views/panel/video/front_end/channel_videos.html.erb b/vendor/built_in_modules/video/app/views/panel/video/front_end/channel_videos.html.erb new file mode 100644 index 00000000..5be9eba7 --- /dev/null +++ b/vendor/built_in_modules/video/app/views/panel/video/front_end/channel_videos.html.erb @@ -0,0 +1,8 @@ +

Videos

+