showtube 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +33 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/showtube/application.js +15 -0
  5. data/app/assets/javascripts/showtube/videos.js +2 -0
  6. data/app/assets/stylesheets/scaffold.css +56 -0
  7. data/app/assets/stylesheets/showtube/application.css +13 -0
  8. data/app/assets/stylesheets/showtube/videos.css +4 -0
  9. data/app/controllers/showtube/application_controller.rb +4 -0
  10. data/app/controllers/showtube/videos_controller.rb +85 -0
  11. data/app/helpers/showtube/application_helper.rb +14 -0
  12. data/app/helpers/showtube/videos_helper.rb +4 -0
  13. data/app/models/showtube/video.rb +11 -0
  14. data/app/views/layouts/showtube/application.html.erb +14 -0
  15. data/app/views/showtube/videos/_form.html.erb +29 -0
  16. data/app/views/showtube/videos/edit.html.erb +6 -0
  17. data/app/views/showtube/videos/index.html.erb +27 -0
  18. data/app/views/showtube/videos/new.html.erb +5 -0
  19. data/app/views/showtube/videos/show.html.erb +20 -0
  20. data/config/routes.rb +4 -0
  21. data/db/migrate/20120325221502_create_showtube_videos.rb +15 -0
  22. data/lib/showtube/engine.rb +5 -0
  23. data/lib/showtube/version.rb +3 -0
  24. data/lib/showtube.rb +4 -0
  25. data/lib/tasks/showtube_tasks.rake +4 -0
  26. data/test/dummy/README.rdoc +261 -0
  27. data/test/dummy/Rakefile +7 -0
  28. data/test/dummy/app/assets/javascripts/application.js +15 -0
  29. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  30. data/test/dummy/app/controllers/application_controller.rb +3 -0
  31. data/test/dummy/app/helpers/application_helper.rb +2 -0
  32. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  33. data/test/dummy/config/application.rb +56 -0
  34. data/test/dummy/config/boot.rb +10 -0
  35. data/test/dummy/config/database.yml +25 -0
  36. data/test/dummy/config/environment.rb +5 -0
  37. data/test/dummy/config/environments/development.rb +37 -0
  38. data/test/dummy/config/environments/production.rb +67 -0
  39. data/test/dummy/config/environments/test.rb +37 -0
  40. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  41. data/test/dummy/config/initializers/inflections.rb +15 -0
  42. data/test/dummy/config/initializers/mime_types.rb +5 -0
  43. data/test/dummy/config/initializers/secret_token.rb +7 -0
  44. data/test/dummy/config/initializers/session_store.rb +8 -0
  45. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  46. data/test/dummy/config/locales/en.yml +5 -0
  47. data/test/dummy/config/routes.rb +4 -0
  48. data/test/dummy/config.ru +4 -0
  49. data/test/dummy/public/404.html +26 -0
  50. data/test/dummy/public/422.html +26 -0
  51. data/test/dummy/public/500.html +25 -0
  52. data/test/dummy/public/favicon.ico +0 -0
  53. data/test/dummy/script/rails +6 -0
  54. data/test/fixtures/showtube/videos.yml +11 -0
  55. data/test/functional/showtube/videos_controller_test.rb +51 -0
  56. data/test/integration/navigation_test.rb +10 -0
  57. data/test/showtube_test.rb +7 -0
  58. data/test/test_helper.rb +10 -0
  59. data/test/unit/helpers/showtube/videos_helper_test.rb +6 -0
  60. data/test/unit/showtube/video_test.rb +9 -0
  61. metadata +162 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
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.rdoc ADDED
@@ -0,0 +1,33 @@
1
+ = Showtube
2
+
3
+ PT-BR:
4
+ Essa é uma gem que tem a função de exibir videos do youtube em uma app rails.
5
+
6
+ para utilizar, acrescente em seu model:
7
+
8
+ has_many :videos
9
+
10
+ acrescente em sua view:
11
+ Para exibir o iframe do video:
12
+
13
+ <%= showtube_tag(video.vid) %>
14
+
15
+ Para exibir a imagem do video:
16
+
17
+ <%= showtube_img_tag(video.vid) %>
18
+
19
+ En:
20
+ This is a gem that show youtube videos in a app rails.
21
+
22
+ for use, add in your model:
23
+
24
+ has_many :videos
25
+
26
+ add in your view:
27
+ For show the video iframe:
28
+
29
+ <%= showtube_tag(video.vid) %>
30
+
31
+ For show the video image :
32
+
33
+ <%= showtube_img_tag(video.vid) %>
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Showtube'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -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 vendor/assets/javascripts of plugins, if any, 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
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,13 @@
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -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,4 @@
1
+ module Showtube
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,85 @@
1
+ module Showtube
2
+ class VideosController < ApplicationController
3
+ # GET /videos
4
+ # GET /videos.json
5
+ def index
6
+ @videos = Video.all
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @videos }
11
+ end
12
+ end
13
+
14
+ # GET /videos/1
15
+ # GET /videos/1.json
16
+ def show
17
+ @video = Video.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.json { render json: @video }
22
+ end
23
+ end
24
+
25
+ # GET /videos/new
26
+ # GET /videos/new.json
27
+ def new
28
+ @video = Video.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.json { render json: @video }
33
+ end
34
+ end
35
+
36
+ # GET /videos/1/edit
37
+ def edit
38
+ @video = Video.find(params[:id])
39
+ end
40
+
41
+ # POST /videos
42
+ # POST /videos.json
43
+ def create
44
+ @video = Video.new(params[:video])
45
+
46
+ respond_to do |format|
47
+ if @video.save
48
+ format.html { redirect_to @video, notice: 'Video was successfully created.' }
49
+ format.json { render json: @video, status: :created, location: @video }
50
+ else
51
+ format.html { render action: "new" }
52
+ format.json { render json: @video.errors, status: :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /videos/1
58
+ # PUT /videos/1.json
59
+ def update
60
+ @video = Video.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @video.update_attributes(params[:video])
64
+ format.html { redirect_to @video, notice: 'Video was successfully updated.' }
65
+ format.json { head :no_content }
66
+ else
67
+ format.html { render action: "edit" }
68
+ format.json { render json: @video.errors, status: :unprocessable_entity }
69
+ end
70
+ end
71
+ end
72
+
73
+ # DELETE /videos/1
74
+ # DELETE /videos/1.json
75
+ def destroy
76
+ @video = Video.find(params[:id])
77
+ @video.destroy
78
+
79
+ respond_to do |format|
80
+ format.html { redirect_to videos_url }
81
+ format.json { head :no_content }
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,14 @@
1
+ module Showtube
2
+ module ApplicationHelper
3
+ #youtube videos
4
+ def youtube_tag(vid, shwidth, shheight, html_options = {})
5
+ %{<iframe width="#{shwidth}" height="#{shheight}" src="http://www.youtube.com/embed/#{vid}" frameborder="0" allowfullscreen></iframe>}.html_safe
6
+ end
7
+
8
+ # imagem de video Youtube
9
+ def showtube_img_tag(vid, imwidth, imheight, html_options = {})
10
+ image_tag("http://img.youtube.com/vi/#{vid}/0.jpg", :size => "#{imwidth}x#{imheight}")
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ module Showtube
2
+ module VideosHelper
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ module Showtube
2
+ class Video < ActiveRecord::Base
3
+ def vid
4
+ if url.match(/youtube.com.*(?:\/|v=)([^&$]+)/)
5
+ Regexp.last_match[1]
6
+ else
7
+ nil
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Showtube</title>
5
+ <%= stylesheet_link_tag "showtube/application", :media => "all" %>
6
+ <%= javascript_include_tag "showtube/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,29 @@
1
+ <%= form_for(@video) do |f| %>
2
+ <% if @video.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@video.errors.count, "error") %> prohibited this video from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @video.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :title %><br />
16
+ <%= f.text_field :title %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :url %><br />
20
+ <%= f.text_field :url %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :description %><br />
24
+ <%= f.text_area :description %>
25
+ </div>
26
+ <div class="actions">
27
+ <%= f.submit %>
28
+ </div>
29
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing video</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @video %> |
6
+ <%= link_to 'Back', videos_path %>
@@ -0,0 +1,27 @@
1
+ <h1>Listing videos</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Title</th>
6
+ <th>Url</th>
7
+ <th>Description</th>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <% @videos.each do |video| %>
14
+ <tr>
15
+ <td><%= video.title %></td>
16
+ <td><%= video.url %></td>
17
+ <td><%= video.description %></td>
18
+ <td><%= link_to 'Show', video %></td>
19
+ <td><%= link_to 'Edit', edit_video_path(video) %></td>
20
+ <td><%= link_to 'Destroy', video, confirm: 'Are you sure?', method: :delete %></td>
21
+ </tr>
22
+ <% end %>
23
+ </table>
24
+
25
+ <br />
26
+
27
+ <%= link_to 'New Video', new_video_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New video</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', videos_path %>
@@ -0,0 +1,20 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Title:</b>
5
+ <%= @video.title %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Url:</b>
10
+ <%= @video.url %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Description:</b>
15
+ <%= @video.description %>
16
+ </p>
17
+
18
+
19
+ <%= link_to 'Edit', edit_video_path(@video) %> |
20
+ <%= link_to 'Back', videos_path %>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Showtube::Engine.routes.draw do
2
+ resources :videos
3
+
4
+ end
@@ -0,0 +1,15 @@
1
+ class CreateShowtubeVideos < ActiveRecord::Migration
2
+ def change
3
+ create_table :showtube_videos do |t|
4
+ t.string :title
5
+ t.string :url
6
+ t.string :shwidth
7
+ t.string :shheight
8
+ t.string :imwidth
9
+ t.string :imheight
10
+ t.text :description
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Showtube
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Showtube
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Showtube
2
+ VERSION = "0.0.1"
3
+ end
data/lib/showtube.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "showtube/engine"
2
+
3
+ module Showtube
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :showtube do
3
+ # # Task goes here
4
+ # end