spree_videos 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.
data/README.textile ADDED
@@ -0,0 +1,30 @@
1
+ h1. Spree Videos Extension
2
+
3
+ h2. How to install
4
+
5
+ add `gem "formtastic"` in Gemfile
6
+ add `gem "spree_videos", :git => http://github.com/niamtech/spree_videos.git` in Gemfile
7
+ run `bundle install` on command or terminal
8
+ run `rake spree_videos:install`
9
+ run `rake db:migrate`
10
+
11
+ h2. How to use
12
+
13
+ # Go to configuration Tab > Video Type
14
+ # Add a new Video Type ex :
15
+
16
+ * Name : Youtube
17
+ * Embed Code :
18
+
19
+ bc. <object width="[[WIDTH]]" height="[[HEIGHT]]"><param name="movie" value="http://www.youtube.com/v/[[KEYWORD]]"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/[[KEYWORD]]" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="[[WIDTH]]" height="[[HEIGHT]]"></embed></object>
20
+
21
+ # Go to product edition
22
+ # Choose Video
23
+ # Add a new Video ex :
24
+
25
+ * name : "Name"
26
+ * Video Type : "Youtube"
27
+ * Keyword : "p8t41avFuCc"
28
+
29
+ h2. How to display video
30
+ # In products/show view, add code <%= raw(@product.movies.last.content(:normal)) %>
@@ -0,0 +1,15 @@
1
+ class Admin::MovieSitesController < Admin::BaseController
2
+ resource_controller
3
+
4
+ layout proc { |controller| controller.request.xhr? ? false : 'admin' }
5
+
6
+ create.response do |wants|
7
+ wants.html{ redirect_to admin_movie_sites_url()}
8
+ end
9
+ update.response do |wants|
10
+ wants.html{ redirect_to admin_movie_sites_url()}
11
+ end
12
+
13
+ destroy.success.wants.js { render_js_for_destroy }
14
+
15
+ end
@@ -0,0 +1,16 @@
1
+ class Admin::MoviesController < Admin::BaseController
2
+ resource_controller
3
+ belongs_to :product
4
+
5
+ layout proc { |controller| controller.request.xhr? ? false : 'admin' }
6
+
7
+ create.response do |wants|
8
+ wants.html{ redirect_to admin_product_movies_url(@product)}
9
+ end
10
+ update.response do |wants|
11
+ wants.html{ redirect_to admin_product_movies_url(@product)}
12
+ end
13
+
14
+ destroy.success.wants.js { render_js_for_destroy }
15
+
16
+ end
@@ -0,0 +1,25 @@
1
+ class Movie < ActiveRecord::Base
2
+ belongs_to :product
3
+ belongs_to :movie_site
4
+
5
+ validates_presence_of :name, :movie_site,:keyword
6
+
7
+
8
+ def content(option=:normal)
9
+ case true
10
+ when option == :mini
11
+ width = "100"
12
+ height = "60"
13
+ when option == :normal
14
+ width = self.movie_site.width.to_s
15
+ height = self.movie_site.height.to_s
16
+ else
17
+ width = self.movie_site.width.to_s
18
+ height = self.movie_site.height.to_s
19
+ end
20
+ self.movie_site.embed.gsub("[[WIDTH]]",width).gsub("[[HEIGHT]]",height).gsub("[[KEYWORD]]",self.keyword)
21
+
22
+ end
23
+
24
+
25
+ end
@@ -0,0 +1,7 @@
1
+ class MovieSite < ActiveRecord::Base
2
+ has_many :movies
3
+
4
+ validates_presence_of :name, :height, :width, :embed
5
+ validates_uniqueness_of :name
6
+
7
+ end
@@ -0,0 +1,6 @@
1
+ <% semantic_form_for [:admin,@movie_site] do |f| %>
2
+ <%= f.inputs %>
3
+ <%= f.buttons %>
4
+ <% end %>
5
+
6
+ <%= t("how_to_use_movies") %>
@@ -0,0 +1,7 @@
1
+ <%= render :partial => 'admin/shared/configuration_menu' %>
2
+
3
+ <h1><%= t("editing_movie_site") %></h1>
4
+
5
+ <%= error_messages_for :movie_site %>
6
+
7
+ <%= render :partial => "form" %>
@@ -0,0 +1,36 @@
1
+ <%= render :partial => 'admin/shared/configuration_menu' %>
2
+
3
+ <div class='toolbar'>
4
+ <ul class='actions'>
5
+ <li>
6
+ <%= button_link_to t("new_movie_site"), new_object_url, :icon => 'add' %>
7
+ </li>
8
+ </ul>
9
+ <br class='clear' />
10
+ </div>
11
+
12
+ <table class="index">
13
+ <thead>
14
+ <tr>
15
+ <th><%= t("name") %></th>
16
+ <th><%= t("width") %></th>
17
+ <th><%= t("height") %></th>
18
+ <th><%= t('action') %></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% @movie_sites.each do |movie_site| %>
23
+ <tr id="<%= dom_id movie_site %>">
24
+ <td><%= movie_site.name %></td>
25
+ <td><%= movie_site.width %></td>
26
+ <td><%= movie_site.height %></td>
27
+ <td>
28
+ <%= link_to_edit movie_site %>
29
+ &nbsp;
30
+ <%= link_to_delete movie_site %>
31
+ </td>
32
+ </tr>
33
+ <% end %>
34
+ </tbody>
35
+ </table>
36
+
@@ -0,0 +1,7 @@
1
+ <%= render :partial => 'admin/shared/configuration_menu' %>
2
+
3
+ <h1><%= t("new_movie_site") %></h1>
4
+
5
+ <%= error_messages_for :movie_site %>
6
+
7
+ <%= render :partial => "form" %>
@@ -0,0 +1,7 @@
1
+
2
+ <% semantic_form_for [:admin,@product,@movie] do |f| %>
3
+ <%= f.input :name %>
4
+ <%= f.input :movie_site %>
5
+ <%= f.input :keyword %>
6
+ <%= f.buttons %>
7
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <%= render :partial => 'admin/shared/product_sub_menu' %>
2
+ <%= render :partial => 'admin/shared/product_tabs', :locals => {:current => "Movies" } %>
3
+
4
+ <h1><%= t("editing_movie") %></h1>
5
+
6
+ <%= error_messages_for :movie %>
7
+
8
+ <%= render :partial => "form" %>
@@ -0,0 +1,39 @@
1
+ <%= render :partial => 'admin/shared/product_sub_menu' %>
2
+
3
+ <%= render :partial => 'admin/shared/product_tabs', :locals => {:current => "Movies" } %>
4
+
5
+ <div class='toolbar'>
6
+ <ul class='actions'>
7
+ <li>
8
+ <%= button_link_to t("new_movie_site"), new_admin_movie_site_url, :icon => 'add' %>
9
+ <%= button_link_to t("new_movie"), new_object_url, :icon => 'add' %>
10
+ </li>
11
+ </ul>
12
+ <br class='clear' />
13
+ </div>
14
+
15
+ <table class="index">
16
+ <thead>
17
+ <tr>
18
+ <th><%= t("movie") %></th>
19
+ <th><%= t("name") %></th>
20
+ <th><%= t("movie_sites") %></th>
21
+ <th><%= t('action') %></th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <% @movies.each do |movie| %>
26
+ <tr id="<%= dom_id movie %>">
27
+ <td><%= movie.content(:normal) %></td>
28
+ <td><%= movie.name %></td>
29
+ <td><%= movie.movie_site.name %></td>
30
+ <td>
31
+ <%= link_to_edit movie %>
32
+ &nbsp;
33
+ <%= link_to_delete movie %>
34
+ </td>
35
+ </tr>
36
+ <% end %>
37
+ </tbody>
38
+ </table>
39
+
@@ -0,0 +1,8 @@
1
+ <%= render :partial => 'admin/shared/product_sub_menu' %>
2
+ <%= render :partial => 'admin/shared/product_tabs', :locals => {:current => "Movies" } %>
3
+
4
+ <h1><%= t("new_movie") %></h1>
5
+
6
+ <%= error_messages_for :movie %>
7
+
8
+ <%= render :partial => "form" %>
@@ -0,0 +1,3 @@
1
+ <li<%== ' class=active' if current == "Videos" %>>
2
+ <%= link_to t("movies"), admin_product_movies_url(@product) %>
3
+ </li>
@@ -0,0 +1,21 @@
1
+ ---
2
+ en:
3
+ activerecord:
4
+ attributes:
5
+ movie:
6
+ keyword: "Keyword"
7
+ movie_site: "Video Type"
8
+ movie_site:
9
+ embed: "Embed Code"
10
+ width: "Width"
11
+ height: "height"
12
+ name: "Name"
13
+ editing_movie: "Edit video"
14
+ editing_movie_site: "Edit video type"
15
+ how_to_use_movies: "3 Mot clés sont obligatoire [[WIDTH]] = taille de la vidéo, [[HEIGHT]] = hauteur de la video, [[KEYWORD]] mot clé de la vidéo"
16
+ movie: "Video"
17
+ movies: "Videos"
18
+ movie_sites: "Video Type"
19
+ movie_sites_description: "Manage Video Type"
20
+ new_movie: "New video"
21
+ new_movie_site: "New Video Type"
@@ -0,0 +1,21 @@
1
+ ---
2
+ fr:
3
+ activerecord:
4
+ attributes:
5
+ movie:
6
+ keyword: "Mot clé"
7
+ movie_site: "Type de vidéo"
8
+ movie_site:
9
+ embed: "Code Embed"
10
+ width: "Largeur"
11
+ height: "Hauteur"
12
+ name: "Nom"
13
+ editing_movie: "Editer la vidéo"
14
+ editing_movie_site: "Editer le type de vidéo"
15
+ how_to_use_movies: "3 Mot clés sont obligatoire [[WIDTH]] = taille de la vidéo, [[HEIGHT]] = hauteur de la video, [[KEYWORD]] mot clé de la vidéo"
16
+ movie: "Vidéo"
17
+ movies: "Vidéos"
18
+ movie_sites: "Type de vidéo"
19
+ movie_sites_description: "Gestion des Types de Vidéos"
20
+ new_movie: "Nouvelle vidéo"
21
+ new_movie_site: "Nouveau Type de vidéo"
data/config/routes.rb ADDED
@@ -0,0 +1,9 @@
1
+ # Put your extension routes here.
2
+ Rails.application.routes.draw do
3
+ namespace :admin do
4
+ resources :products do
5
+ resources :movies
6
+ end
7
+ resources :movie_sites
8
+ end
9
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Use this file to load your own seed data from extensions.
2
+ # See the db/seeds.rb file in the Spree core for some ideas on what you can do here.
@@ -0,0 +1,18 @@
1
+ require 'spree_core'
2
+ require 'spree_videos_hooks'
3
+
4
+ module SpreeVideos
5
+ class Engine < Rails::Engine
6
+
7
+ def self.activate
8
+
9
+ Product.class_eval do
10
+ has_many :movies
11
+ end
12
+
13
+ end
14
+
15
+ config.to_prepare &method(:activate).to_proc
16
+
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ class SpreeVideosHooks < Spree::ThemeSupport::HookListener
2
+
3
+ insert_after :admin_product_tabs, "admin/products/movies"
4
+ insert_after(:admin_configurations_menu) do
5
+ '<tr>
6
+ <td><%= link_to t("video_sites"), admin_movie_sites_url %></td>
7
+ <td><%= t("movie_sites_description") %></td>
8
+ </tr>'
9
+ end
10
+
11
+ end
@@ -0,0 +1,16 @@
1
+ namespace :spree_videos do
2
+ desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
3
+ task :install do
4
+ Rake::Task['spree_videos:install:migrations'].invoke
5
+ end
6
+
7
+ namespace :install do
8
+ desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
9
+ task :migrations do
10
+ source = File.join(File.dirname(__FILE__), '..', '..', 'db')
11
+ destination = File.join(Rails.root, 'db')
12
+ Spree::FileUtilz.mirror_files(source, destination)
13
+ end
14
+ end
15
+
16
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_videos
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Chetan Mittal
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-02 00:00:00 +05:30
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: spree_core
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.40.3
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: formtastic
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: Allows videos (Youtube) to be added on products
39
+ email: chetan.mittal@niamtech.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - README.textile
48
+ - lib/tasks/install.rake
49
+ - lib/spree_videos_hooks.rb
50
+ - lib/spree_videos.rb
51
+ - app/views/admin/movie_sites/edit.html.erb
52
+ - app/views/admin/movie_sites/new.html.erb
53
+ - app/views/admin/movie_sites/_form.html.erb
54
+ - app/views/admin/movie_sites/index.html.erb
55
+ - app/views/admin/products/_movies.html.erb
56
+ - app/views/admin/movies/edit.html.erb
57
+ - app/views/admin/movies/new.html.erb
58
+ - app/views/admin/movies/_form.html.erb
59
+ - app/views/admin/movies/index.html.erb
60
+ - app/models/movie_site.rb
61
+ - app/models/movie.rb
62
+ - app/controllers/admin/movie_sites_controller.rb
63
+ - app/controllers/admin/movies_controller.rb
64
+ - config/routes.rb
65
+ - config/locales/en.yml
66
+ - config/locales/fr.yml
67
+ - db/seeds.rb
68
+ has_rdoc: true
69
+ homepage: http://www.niamtech.com
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options: []
74
+
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.7
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ requirements:
90
+ - none
91
+ rubyforge_project: spree_videos
92
+ rubygems_version: 1.5.0
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Allows videos to be added on products
96
+ test_files: []
97
+