search_youtube 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/Gemfile +15 -0
  4. data/Gemfile.lock +132 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +31 -0
  7. data/Rakefile +32 -0
  8. data/app/assets/config/search_youtube_manifest.js +2 -0
  9. data/app/assets/images/search_youtube/.keep +0 -0
  10. data/app/assets/javascripts/search_youtube/application.js +15 -0
  11. data/app/assets/javascripts/search_youtube/search.js +35 -0
  12. data/app/assets/stylesheets/search_youtube/application.css +15 -0
  13. data/app/assets/stylesheets/search_youtube/search.css +4 -0
  14. data/app/controllers/search_youtube/application_controller.rb +5 -0
  15. data/app/controllers/search_youtube/search_controller.rb +8 -0
  16. data/app/helpers/search_youtube/application_helper.rb +4 -0
  17. data/app/helpers/search_youtube/search_helper.rb +4 -0
  18. data/app/jobs/search_youtube/application_job.rb +4 -0
  19. data/app/mailers/search_youtube/application_mailer.rb +6 -0
  20. data/app/models/search_youtube/application_record.rb +5 -0
  21. data/app/views/layouts/application.html.erb +17 -0
  22. data/app/views/layouts/search_youtube/application.html.erb +17 -0
  23. data/app/views/search_youtube/search/index.html.erb +4 -0
  24. data/bin/rails +14 -0
  25. data/config/routes.rb +3 -0
  26. data/lib/generators/search/USAGE +8 -0
  27. data/lib/generators/search/search_generator.rb +14 -0
  28. data/lib/search_youtube.rb +5 -0
  29. data/lib/search_youtube/engine.rb +5 -0
  30. data/lib/search_youtube/version.rb +3 -0
  31. data/lib/tasks/search_youtube_tasks.rake +4 -0
  32. data/search_youtube.gemspec +24 -0
  33. data/test/controllers/search_youtube/search_controller_test.rb +13 -0
  34. data/test/dummy/.ruby-version +1 -0
  35. data/test/dummy/Rakefile +6 -0
  36. data/test/dummy/app/assets/config/manifest.js +4 -0
  37. data/test/dummy/app/assets/images/.keep +0 -0
  38. data/test/dummy/app/assets/javascripts/application.js +15 -0
  39. data/test/dummy/app/assets/javascripts/cable.js +13 -0
  40. data/test/dummy/app/assets/javascripts/channels/.keep +0 -0
  41. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  42. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  43. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  44. data/test/dummy/app/controllers/application_controller.rb +2 -0
  45. data/test/dummy/app/controllers/concerns/.keep +0 -0
  46. data/test/dummy/app/helpers/application_helper.rb +2 -0
  47. data/test/dummy/app/jobs/application_job.rb +2 -0
  48. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  49. data/test/dummy/app/models/application_record.rb +3 -0
  50. data/test/dummy/app/models/concerns/.keep +0 -0
  51. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  52. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  53. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  54. data/test/dummy/bin/bundle +3 -0
  55. data/test/dummy/bin/rails +4 -0
  56. data/test/dummy/bin/rake +4 -0
  57. data/test/dummy/bin/setup +36 -0
  58. data/test/dummy/bin/update +31 -0
  59. data/test/dummy/bin/yarn +11 -0
  60. data/test/dummy/config.ru +5 -0
  61. data/test/dummy/config/application.rb +19 -0
  62. data/test/dummy/config/boot.rb +5 -0
  63. data/test/dummy/config/cable.yml +10 -0
  64. data/test/dummy/config/database.yml +25 -0
  65. data/test/dummy/config/environment.rb +5 -0
  66. data/test/dummy/config/environments/development.rb +61 -0
  67. data/test/dummy/config/environments/production.rb +94 -0
  68. data/test/dummy/config/environments/test.rb +46 -0
  69. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  70. data/test/dummy/config/initializers/assets.rb +14 -0
  71. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  72. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  73. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  74. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  75. data/test/dummy/config/initializers/inflections.rb +16 -0
  76. data/test/dummy/config/initializers/mime_types.rb +4 -0
  77. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  78. data/test/dummy/config/locales/en.yml +33 -0
  79. data/test/dummy/config/puma.rb +34 -0
  80. data/test/dummy/config/routes.rb +3 -0
  81. data/test/dummy/config/spring.rb +6 -0
  82. data/test/dummy/config/storage.yml +34 -0
  83. data/test/dummy/lib/assets/.keep +0 -0
  84. data/test/dummy/log/.keep +0 -0
  85. data/test/dummy/package.json +5 -0
  86. data/test/dummy/public/404.html +67 -0
  87. data/test/dummy/public/422.html +67 -0
  88. data/test/dummy/public/500.html +66 -0
  89. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  90. data/test/dummy/public/apple-touch-icon.png +0 -0
  91. data/test/dummy/public/favicon.ico +0 -0
  92. data/test/integration/navigation_test.rb +7 -0
  93. data/test/lib/generators/search_youtube/search_generator_test.rb +16 -0
  94. data/test/search_youtube_test.rb +7 -0
  95. data/test/test_helper.rb +20 -0
  96. metadata +186 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a7b305e210b6372e592fd234b5cf38e741e448e05128b849bd7229e9a3ae8af1
4
+ data.tar.gz: ee431a33457c61af7add51a1b5b9f8f9a50aaf3ca8b0089e08d4843977f9ba0f
5
+ SHA512:
6
+ metadata.gz: 87e3ee20fb4b70c7b4be3654c1d13a940857eca3b303faeaf5764d204d14bf5812c25c4679276061061475248f7e4bc365d8ae457d6876895cd0406654e9c110
7
+ data.tar.gz: 9a2f86739d4c2e5ed1ffb19afc9b85b898d6cd094cf2fcb17cc1e5cb9fd58451cfc9165037ed89aab907690650bd875994ada5406dc2044b940c27f7d1a9a5e2
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/log/*.log
7
+ test/dummy/node_modules/
8
+ test/dummy/yarn-error.log
9
+ test/dummy/storage/
10
+ test/dummy/tmp/
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in search_youtube.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # To use a debugger
15
+ # gem 'byebug', group: [:development, :test]
data/Gemfile.lock ADDED
@@ -0,0 +1,132 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ search_youtube (0.1.0)
5
+ jquery-rails (~> 4.3, >= 4.3.3)
6
+ rails (~> 5.2.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (5.2.1)
12
+ actionpack (= 5.2.1)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.1)
16
+ actionpack (= 5.2.1)
17
+ actionview (= 5.2.1)
18
+ activejob (= 5.2.1)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 2.0)
21
+ actionpack (5.2.1)
22
+ actionview (= 5.2.1)
23
+ activesupport (= 5.2.1)
24
+ rack (~> 2.0)
25
+ rack-test (>= 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (5.2.1)
29
+ activesupport (= 5.2.1)
30
+ builder (~> 3.1)
31
+ erubi (~> 1.4)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
+ activejob (5.2.1)
35
+ activesupport (= 5.2.1)
36
+ globalid (>= 0.3.6)
37
+ activemodel (5.2.1)
38
+ activesupport (= 5.2.1)
39
+ activerecord (5.2.1)
40
+ activemodel (= 5.2.1)
41
+ activesupport (= 5.2.1)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.1)
44
+ actionpack (= 5.2.1)
45
+ activerecord (= 5.2.1)
46
+ marcel (~> 0.3.1)
47
+ activesupport (5.2.1)
48
+ concurrent-ruby (~> 1.0, >= 1.0.2)
49
+ i18n (>= 0.7, < 2)
50
+ minitest (~> 5.1)
51
+ tzinfo (~> 1.1)
52
+ arel (9.0.0)
53
+ builder (3.2.3)
54
+ concurrent-ruby (1.0.5)
55
+ crass (1.0.4)
56
+ erubi (1.7.1)
57
+ globalid (0.4.1)
58
+ activesupport (>= 4.2.0)
59
+ i18n (1.1.0)
60
+ concurrent-ruby (~> 1.0)
61
+ jquery-rails (4.3.3)
62
+ rails-dom-testing (>= 1, < 3)
63
+ railties (>= 4.2.0)
64
+ thor (>= 0.14, < 2.0)
65
+ loofah (2.2.2)
66
+ crass (~> 1.0.2)
67
+ nokogiri (>= 1.5.9)
68
+ mail (2.7.0)
69
+ mini_mime (>= 0.1.1)
70
+ marcel (0.3.2)
71
+ mimemagic (~> 0.3.2)
72
+ method_source (0.9.0)
73
+ mimemagic (0.3.2)
74
+ mini_mime (1.0.1)
75
+ mini_portile2 (2.3.0)
76
+ minitest (5.11.3)
77
+ nio4r (2.3.1)
78
+ nokogiri (1.8.4)
79
+ mini_portile2 (~> 2.3.0)
80
+ rack (2.0.5)
81
+ rack-test (1.1.0)
82
+ rack (>= 1.0, < 3)
83
+ rails (5.2.1)
84
+ actioncable (= 5.2.1)
85
+ actionmailer (= 5.2.1)
86
+ actionpack (= 5.2.1)
87
+ actionview (= 5.2.1)
88
+ activejob (= 5.2.1)
89
+ activemodel (= 5.2.1)
90
+ activerecord (= 5.2.1)
91
+ activestorage (= 5.2.1)
92
+ activesupport (= 5.2.1)
93
+ bundler (>= 1.3.0)
94
+ railties (= 5.2.1)
95
+ sprockets-rails (>= 2.0.0)
96
+ rails-dom-testing (2.0.3)
97
+ activesupport (>= 4.2.0)
98
+ nokogiri (>= 1.6)
99
+ rails-html-sanitizer (1.0.4)
100
+ loofah (~> 2.2, >= 2.2.2)
101
+ railties (5.2.1)
102
+ actionpack (= 5.2.1)
103
+ activesupport (= 5.2.1)
104
+ method_source
105
+ rake (>= 0.8.7)
106
+ thor (>= 0.19.0, < 2.0)
107
+ rake (12.3.1)
108
+ sprockets (3.7.2)
109
+ concurrent-ruby (~> 1.0)
110
+ rack (> 1, < 3)
111
+ sprockets-rails (3.2.1)
112
+ actionpack (>= 4.0)
113
+ activesupport (>= 4.0)
114
+ sprockets (>= 3.0.0)
115
+ sqlite3 (1.3.13)
116
+ thor (0.20.0)
117
+ thread_safe (0.3.6)
118
+ tzinfo (1.2.5)
119
+ thread_safe (~> 0.1)
120
+ websocket-driver (0.7.0)
121
+ websocket-extensions (>= 0.1.0)
122
+ websocket-extensions (0.1.3)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ search_youtube!
129
+ sqlite3
130
+
131
+ BUNDLED WITH
132
+ 1.16.4
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Felipe Llerena
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # SearchYoutube
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'search_youtube'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install search_youtube
22
+ ```
23
+
24
+ ## Instructions
25
+ Add "//= require jquery" in app/assets/javascripts/application.js
26
+
27
+ ## Contributing
28
+ Contribution directions go here.
29
+
30
+ ## License
31
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'SearchYoutube'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/search_youtube .js
2
+ //= link_directory ../stylesheets/search_youtube .css
File without changes
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require activestorage
15
+ //= require_tree .
@@ -0,0 +1,35 @@
1
+ function onClientLoad() {
2
+ gapi.client.load('youtube', 'v3', onYouTubeApiLoad);
3
+ }
4
+
5
+ function onYouTubeApiLoad() {
6
+ gapi.client.setApiKey('AIzaSyAWhX3xLCfnJ-U0HEPo7R0Zc-5J9jCJoXc');
7
+ }
8
+
9
+ function search() {
10
+ var query = document.getElementById('query').value;
11
+ var request = gapi.client.youtube.search.list({
12
+ part: 'snippet',
13
+ type: 'playlist, video',
14
+ maxResults: '49',
15
+ q:query
16
+ });
17
+ request.execute(onSearchResponse);
18
+ }
19
+
20
+ var ytplayer;
21
+ function onYouTubeIframeAPIReady() {
22
+ ytplayer = new YT.Player('spherical-video-player', {
23
+ height: '30',
24
+ width: '640',
25
+ videoId: 'FAtdv94yzp4',
26
+ });
27
+ }
28
+
29
+
30
+ function onSearchResponse(response) {
31
+ $("#response").html('');
32
+ response.items.forEach(function(e){
33
+ $("#response").append('<iframe id="ytplayer" allowfullscreen="allowfullscreen" src="https://www.youtube.com/embed/'+ e.id.videoId +'"><img width="'+ e.snippet.thumbnails.default.width + '"src="'+ e.snippet.thumbnails.default.url +'" height="'+ e.snippet.thumbnails.default.height +'"></iframe>');
34
+ });
35
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,5 @@
1
+ module SearchYoutube
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require_dependency "search_youtube/application_controller"
2
+
3
+ module SearchYoutube
4
+ class SearchController < ApplicationController
5
+ def index
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module SearchYoutube
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module SearchYoutube
2
+ module SearchHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module SearchYoutube
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module SearchYoutube
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module SearchYoutube
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Search youtube</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "search_youtube/application", media: "all" %>
9
+ <%= javascript_include_tag "search_youtube/application" %>
10
+ <script src="https://apis.google.com/js/client.js?onload=onClientLoad" type="text/javascript"></script>
11
+ </head>
12
+ <body>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Search youtube</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "search_youtube/application", media: "all" %>
9
+ <%= javascript_include_tag "search_youtube/application" %>
10
+ <script src="https://apis.google.com/js/client.js?onload=onClientLoad" type="text/javascript"></script>
11
+ </head>
12
+ <body>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,4 @@
1
+ <h1>Youtube search</h1>
2
+ <input class="w3-input w3-animate-input" style="width:30%" id="query" placeholder="Search video">
3
+ <button class="w3-button w3-black" onclick="search()">Search</button>
4
+ <div id="response"></div>
data/bin/rails ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/search_youtube/engine', __dir__)
7
+ APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
11
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+
13
+ require 'rails/all'
14
+ require 'rails/engine/commands'