refinerycms-sl-videos 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/Gemfile +71 -0
  2. data/Gemfile.lock +289 -0
  3. data/Guardfile +27 -0
  4. data/Rakefile +22 -0
  5. data/app/controllers/refinery/videos/admin/videos_controller.rb +12 -0
  6. data/app/controllers/refinery/videos/videos_controller.rb +34 -0
  7. data/app/models/refinery/videos/video.rb +64 -0
  8. data/app/views/refinery/videos/admin/shared/_locale_picker.html.erb +11 -0
  9. data/app/views/refinery/videos/admin/videos/_actions.html.erb +25 -0
  10. data/app/views/refinery/videos/admin/videos/_form.html.erb +44 -0
  11. data/app/views/refinery/videos/admin/videos/_records.html.erb +18 -0
  12. data/app/views/refinery/videos/admin/videos/_sortable_list.html.erb +5 -0
  13. data/app/views/refinery/videos/admin/videos/_video.html.erb +33 -0
  14. data/app/views/refinery/videos/admin/videos/_videos.html.erb +2 -0
  15. data/app/views/refinery/videos/admin/videos/edit.html.erb +1 -0
  16. data/app/views/refinery/videos/admin/videos/index.html.erb +7 -0
  17. data/app/views/refinery/videos/admin/videos/new.html.erb +1 -0
  18. data/app/views/refinery/videos/videos/index.html.erb +11 -0
  19. data/app/views/refinery/videos/videos/show.html.erb +25 -0
  20. data/config/locales/en.yml +34 -0
  21. data/config/locales/es.yml +35 -0
  22. data/config/routes.rb +19 -0
  23. data/db/migrate/1_create_videos_videos.rb +31 -0
  24. data/db/migrate/2_create_videos_translations.rb +17 -0
  25. data/db/migrate/3_add_dimensions_to_videos.rb +13 -0
  26. data/db/seeds.rb +25 -0
  27. data/lib/generators/refinery/videos_generator.rb +19 -0
  28. data/lib/refinery/videos/engine.rb +26 -0
  29. data/lib/refinery/videos/version.rb +18 -0
  30. data/lib/refinery/videos.rb +22 -0
  31. data/lib/refinerycms-sl-videos.rb +1 -0
  32. data/lib/tasks/refinery/videos.rake +13 -0
  33. data/readme.md +43 -0
  34. data/refinerycms-sl-videos.gemspec +23 -0
  35. data/script/rails +10 -0
  36. data/spec/models/refinery/videos/video_spec.rb +18 -0
  37. data/spec/requests/refinery/videos/admin/videos_spec.rb +101 -0
  38. data/spec/spec_helper.rb +61 -0
  39. data/spec/support/factories/refinery/videos.rb +7 -0
  40. data/tasks/rspec.rake +6 -0
  41. data/tasks/testing.rake +8 -0
  42. metadata +112 -0
@@ -0,0 +1,11 @@
1
+ <% content_for :body do %>
2
+ <ul id="videos">
3
+ <% @videos.each do |video| %>
4
+ <li>
5
+ <%= link_to video.title, refinery.videos_video_path(video) %>
6
+ </li>
7
+ <% end %>
8
+ </ul>
9
+ <% end %>
10
+
11
+ <%= render '/refinery/content_page' %>
@@ -0,0 +1,25 @@
1
+ <% content_for :body_content_title do %>
2
+ <%= @video.title %>
3
+ <% end %>
4
+
5
+ <% content_for :body do %>
6
+ <section>
7
+ <%= raw @video.embed_html_with_dimensions %>
8
+ <div id="video-text"><%= raw @video.video_text %></div>
9
+ </section>
10
+ <% end %>
11
+
12
+ <% content_for :side_body do %>
13
+ <aside>
14
+ <h2><%= t('.other') %></h2>
15
+ <ul id="videos">
16
+ <% @videos.each do |video| %>
17
+ <li>
18
+ <%= link_to video.title, refinery.videos_video_path(video) %>
19
+ </li>
20
+ <% end %>
21
+ </ul>
22
+ </aside>
23
+ <% end %>
24
+
25
+ <%= render '/refinery/content_page' %>
@@ -0,0 +1,34 @@
1
+ en:
2
+ refinery:
3
+ plugins:
4
+ videos:
5
+ title: Videos
6
+ videos:
7
+ admin:
8
+ videos:
9
+ actions:
10
+ create_new: Add New Video
11
+ reorder: Reorder Videos
12
+ reorder_done: Done Reordering Videos
13
+ records:
14
+ title: Videos
15
+ sorry_no_results: Sorry! There are no results found.
16
+ no_items_yet: There are no Videos yet. Click "Add New Video" to add your first video.
17
+ video:
18
+ view_live_html: View this video live <br/><em>(opens in a new window)</em>
19
+ edit: Edit this video
20
+ delete: Remove this video forever
21
+ form:
22
+ title_description: Leave blank to set title from video
23
+ videos:
24
+ show:
25
+ other: Other Videos
26
+ activerecord:
27
+ attributes:
28
+ 'refinery/videos/video':
29
+ title: Title
30
+ video_url: Video url
31
+ video_text: Video text
32
+ custom_url: Custom url
33
+ height: Height
34
+ width: Width
@@ -0,0 +1,35 @@
1
+ es:
2
+ refinery:
3
+ plugins:
4
+ videos:
5
+ title: Vídeos
6
+ # article: masculino/femenino
7
+ videos:
8
+ admin:
9
+ videos:
10
+ actions:
11
+ create_new: Crear nuevo video
12
+ reorder: Reordenar vídeos
13
+ reorder_done: Reordenación de vídeos completada
14
+ records:
15
+ title: Vídeos
16
+ sorry_no_results: Lo siento, no hay resultados
17
+ no_items_yet: No hay vídeos todavía. Pulsa en "Crear nuevo Video" para crear tu primer video.
18
+ video:
19
+ view_live_html: Ver este video como abierto al público <br/><em>(abre en ventana nueva)</em>
20
+ edit: Editar este video
21
+ delete: Borrar este video para siempre
22
+ form:
23
+ title_description: Dejar vacío para recoger el título del vídeo
24
+ videos:
25
+ show:
26
+ other: Otros vídeos
27
+ activerecord:
28
+ attributes:
29
+ 'refinery/videos/video':
30
+ title: Título
31
+ video_url: Url del video
32
+ video_text: Texto del vídeo
33
+ custom_url: Url personalizada
34
+ height: Alto
35
+ width: Ancho
data/config/routes.rb ADDED
@@ -0,0 +1,19 @@
1
+ Refinery::Core::Engine.routes.append do
2
+
3
+ # Frontend routes
4
+ namespace :videos do
5
+ resources :videos, :path => '', :only => [:index, :show]
6
+ end
7
+
8
+ # Admin routes
9
+ namespace :videos, :path => '' do
10
+ namespace :admin, :path => 'refinery' do
11
+ resources :videos, :except => :show do
12
+ collection do
13
+ post :update_positions
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,31 @@
1
+ class CreateVideosVideos < ActiveRecord::Migration
2
+
3
+ def up
4
+ create_table Refinery::Videos::Video.table_name do |t|
5
+ t.string :title
6
+ t.string :video_text
7
+ t.string :video_url
8
+ t.string :custom_url
9
+ t.integer :position
10
+ t.string :slug
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ add_index Refinery::Videos::Video.table_name, :slug
16
+ end
17
+
18
+ def down
19
+ if defined?(::Refinery::UserPlugin)
20
+ ::Refinery::UserPlugin.destroy_all({:name => "refinerycms-videos"})
21
+ end
22
+
23
+ if defined?(::Refinery::Page)
24
+ ::Refinery::Page.delete_all({:link_url => "/videos/videos"})
25
+ end
26
+
27
+ drop_table Refinery::Videos::Video.table_name
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,17 @@
1
+ class CreateVideosTranslations < ActiveRecord::Migration
2
+ def up
3
+ Refinery::Videos::Video.create_translation_table!({
4
+ :title => :string,
5
+ :video_text => :text,
6
+ :video_url => :string,
7
+ :custom_url => :string,
8
+ :slug => :string
9
+ }, {
10
+ :migrate_data => true
11
+ })
12
+ end
13
+
14
+ def down
15
+ Refinery::Videos::Video.drop_translation_table! :migrate_data => true
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ class AddDimensionsToVideos < ActiveRecord::Migration
2
+
3
+ def up
4
+ add_column Refinery::Videos::Video.table_name, :width, :integer
5
+ add_column Refinery::Videos::Video.table_name, :height, :integer
6
+ end
7
+
8
+ def down
9
+ remove_column Refinery::Videos::Video.table_name, :width
10
+ remove_column Refinery::Videos::Video.table_name, :height
11
+ end
12
+
13
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,25 @@
1
+ (Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
2
+ I18n.locale = lang
3
+
4
+ if defined?(Refinery::User)
5
+ Refinery::User.all.each do |user|
6
+ if user.plugins.where(:name => 'refinerycms-videos').blank?
7
+ user.plugins.create(:name => 'refinerycms-videos',
8
+ :position => (user.plugins.maximum(:position) || -1) +1)
9
+ end
10
+ end
11
+ end
12
+
13
+ url = "/videos"
14
+ if defined?(Refinery::Page) && Refinery::Page.where(:link_url => url).empty?
15
+ page = Refinery::Page.create(
16
+ :title => 'Videos',
17
+ :link_url => url,
18
+ :deletable => false,
19
+ :menu_match => "^#{url}(\/|\/.+?|)$"
20
+ )
21
+ Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
22
+ page.parts.create(:title => default_page_part, :body => nil, :position => index)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ module Refinery
2
+ class VideosGenerator < Rails::Generators::Base
3
+
4
+ def rake_db
5
+ rake("refinery_videos:install:migrations")
6
+ end
7
+
8
+ def append_load_seed_data
9
+ create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
10
+ append_file 'db/seeds.rb', :verbose => true do
11
+ <<-EOH
12
+
13
+ # Added by Refinery CMS Videos extension
14
+ Refinery::Videos::Engine.load_seed
15
+ EOH
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ module Refinery
2
+ module Videos
3
+ class Engine < Rails::Engine
4
+ include Refinery::Engine
5
+ isolate_namespace Refinery::Videos
6
+
7
+ engine_name :refinery_videos
8
+
9
+ initializer "register refinerycms_videos plugin" do
10
+ Refinery::Plugin.register do |plugin|
11
+ plugin.name = "videos"
12
+ plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.videos_admin_videos_path }
13
+ plugin.pathname = root
14
+ plugin.activity = {
15
+ :class_name => :'refinery/videos/video'
16
+ }
17
+
18
+ end
19
+ end
20
+
21
+ config.after_initialize do
22
+ Refinery.register_extension(Refinery::Videos)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ module Refinery
2
+ module Videos
3
+ class Version
4
+ @major = 2
5
+ @minor = 0
6
+ @tiny = 0
7
+ @build = nil
8
+
9
+ class << self
10
+ attr_reader :major, :minor, :tiny, :build
11
+
12
+ def to_s
13
+ [@major, @minor, @tiny, @build].compact.join('.')
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ require 'refinerycms-core'
2
+ require 'acts_as_unvlogable'
3
+
4
+ module Refinery
5
+ autoload :VideosGenerator, 'generators/refinery/videos_generator'
6
+
7
+ module Videos
8
+ require 'refinery/videos/engine'
9
+
10
+ class << self
11
+ attr_writer :root
12
+
13
+ def root
14
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
15
+ end
16
+
17
+ def factory_paths
18
+ @factory_paths ||= [ root.join('spec', 'factories').to_s ]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1 @@
1
+ require 'refinery/videos'
@@ -0,0 +1,13 @@
1
+ namespace :refinery do
2
+
3
+ namespace :videos do
4
+
5
+ # call this task by running: rake refinery:videos:my_task
6
+ # desc "Description of my task below"
7
+ # task :my_task => :environment do
8
+ # # add your logic here
9
+ # end
10
+
11
+ end
12
+
13
+ end
data/readme.md ADDED
@@ -0,0 +1,43 @@
1
+ # Videos extension for Refinery CMS.
2
+
3
+ ## About
4
+
5
+ A page for videos from diferent sources, in a blog format with multilingual support, custom urls and seo.
6
+ Check supported video formats of [acts\_as\_unvlogable](https://github.com/mamuso/acts_as_unvlogable).
7
+
8
+ For RefineryCMS 2.0.0.
9
+
10
+ ## Requirements
11
+
12
+ * [acts\_as\_unvlogable](https://github.com/mamuso/acts_as_unvlogable) gem (>= 1.0.0)
13
+
14
+ ## TODO
15
+
16
+ * Fix SEO (seo data is stored but for some reason data is not in html head)
17
+ * Build the gem
18
+ * Documentation
19
+ * Tests
20
+
21
+ ## Install
22
+
23
+ Add this line to your applications `Gemfile`
24
+
25
+ gem 'refinerycms-sl-videos', '~> 2.0.0'
26
+
27
+ Next, run
28
+
29
+ bundle install
30
+ rails g refinery:videos
31
+ rake db:migrate
32
+
33
+ ## Thanks
34
+
35
+ To people from [acts\_as\_unvlogable](https://github.com/mamuso/acts_as_unvlogable), for the great video sources support.
36
+
37
+ ## How to build this extension as a gem
38
+
39
+ gem build refinerycms-sl-videos.gemspec
40
+ gem install refinerycms-sl-videos.gem
41
+
42
+ # Sign up for a http://rubygems.org/ account and publish the gem
43
+ gem push refinerycms-sl-videos.gem
@@ -0,0 +1,23 @@
1
+ # Encoding: UTF-8
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'refinery/videos/version'
4
+
5
+ version = Refinery::Videos::Version.to_s
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = %q{refinerycms-sl-videos}
9
+ s.version = version
10
+ s.description = %q{Ruby on Rails Videos extension for Refinery CMS.}
11
+ s.summary = %q{A page for videos from diferent sources, in a blog format with multilingual support, custom urls and seo.}
12
+ s.email = %q{simplelogica@simplelogica.net}
13
+ s.homepage = %q{http://www.github.com/simplelogica/refinerycms-sl-videos}
14
+ s.authors = ['Simplelógica']
15
+ s.require_paths = %w(lib)
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- spec/*`.split("\n")
19
+
20
+ # Runtime dependencies
21
+ s.add_dependency 'refinerycms-core', '~> 2.0.0'
22
+ s.add_dependency 'acts_as_unvlogable', '~> 1.0.0'
23
+ end
data/script/rails ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
5
+ dummy_rails_path = File.expand_path('../../spec/dummy/script/rails', __FILE__)
6
+ if File.exist?(dummy_rails_path)
7
+ load dummy_rails_path
8
+ else
9
+ puts "Please first run 'rake refinery:testing:dummy_app' to create a dummy Refinery CMS application."
10
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module Refinery
4
+ module Videos
5
+ describe Video do
6
+ describe "validations" do
7
+ subject do
8
+ FactoryGirl.create(:video,
9
+ :title => "Refinery CMS")
10
+ end
11
+
12
+ it { should be_valid }
13
+ its(:errors) { should be_empty }
14
+ its(:title) { should == "Refinery CMS" }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,101 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Refinery do
5
+ describe "Videos" do
6
+ describe "Admin" do
7
+ describe "videos" do
8
+ login_refinery_user
9
+
10
+ describe "videos list" do
11
+ before do
12
+ FactoryGirl.create(:video, :title => "UniqueTitleOne")
13
+ FactoryGirl.create(:video, :title => "UniqueTitleTwo")
14
+ end
15
+
16
+ it "shows two items" do
17
+ visit refinery.videos_admin_videos_path
18
+ page.should have_content("UniqueTitleOne")
19
+ page.should have_content("UniqueTitleTwo")
20
+ end
21
+ end
22
+
23
+ describe "create" do
24
+ before do
25
+ visit refinery.videos_admin_videos_path
26
+
27
+ click_link "Add New Video"
28
+ end
29
+
30
+ context "valid data" do
31
+ it "should succeed" do
32
+ fill_in "Title", :with => "This is a test of the first string field"
33
+ click_button "Save"
34
+
35
+ page.should have_content("'This is a test of the first string field' was successfully added.")
36
+ Refinery::Videos::Video.count.should == 1
37
+ end
38
+ end
39
+
40
+ context "invalid data" do
41
+ it "should fail" do
42
+ click_button "Save"
43
+
44
+ page.should have_content("Title can't be blank")
45
+ Refinery::Videos::Video.count.should == 0
46
+ end
47
+ end
48
+
49
+ context "duplicate" do
50
+ before { FactoryGirl.create(:video, :title => "UniqueTitle") }
51
+
52
+ it "should fail" do
53
+ visit refinery.videos_admin_videos_path
54
+
55
+ click_link "Add New Video"
56
+
57
+ fill_in "Title", :with => "UniqueTitle"
58
+ click_button "Save"
59
+
60
+ page.should have_content("There were problems")
61
+ Refinery::Videos::Video.count.should == 1
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ describe "edit" do
68
+ before { FactoryGirl.create(:video, :title => "A title") }
69
+
70
+ it "should succeed" do
71
+ visit refinery.videos_admin_videos_path
72
+
73
+ within ".actions" do
74
+ click_link "Edit this video"
75
+ end
76
+
77
+ fill_in "Title", :with => "A different title"
78
+ click_button "Save"
79
+
80
+ page.should have_content("'A different title' was successfully updated.")
81
+ page.should have_no_content("A title")
82
+ end
83
+ end
84
+
85
+ describe "destroy" do
86
+ before { FactoryGirl.create(:video, :title => "UniqueTitleOne") }
87
+
88
+ it "should succeed" do
89
+ visit refinery.videos_admin_videos_path
90
+
91
+ click_link "Remove this video forever"
92
+
93
+ page.should have_content("'UniqueTitleOne' was successfully removed.")
94
+ Refinery::Videos::Video.count.should == 0
95
+ end
96
+ end
97
+
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+
3
+ def setup_environment
4
+ # Configure Rails Environment
5
+ ENV["RAILS_ENV"] ||= 'test'
6
+
7
+ if File.exist?(dummy_path = File.expand_path('../dummy/config/environment.rb', __FILE__))
8
+ require dummy_path
9
+ elsif File.dirname(__FILE__) =~ %r{vendor/extensions}
10
+ # Require the path to the refinerycms application this is vendored inside.
11
+ require File.expand_path('../../../../../config/environment', __FILE__)
12
+ end
13
+
14
+ require 'rspec/rails'
15
+ require 'capybara/rspec'
16
+ require 'factory_girl_rails'
17
+
18
+ Rails.backtrace_cleaner.remove_silencers!
19
+
20
+ RSpec.configure do |config|
21
+ config.mock_with :rspec
22
+ config.treat_symbols_as_metadata_keys_with_true_values = true
23
+ config.filter_run :focus => true
24
+ config.run_all_when_everything_filtered = true
25
+ end
26
+
27
+ # set javascript driver for capybara
28
+ Capybara.javascript_driver = :selenium
29
+ end
30
+
31
+ def each_run
32
+ Rails.cache.clear
33
+ ActiveSupport::Dependencies.clear
34
+ FactoryGirl.reload
35
+
36
+ # Requires supporting files with custom matchers and macros, etc,
37
+ # in ./support/ and its subdirectories including factories.
38
+ ([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
39
+ Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
40
+ }.flatten.sort.each do |support_file|
41
+ require support_file
42
+ end
43
+ end
44
+
45
+ # If spork is available in the Gemfile it'll be used but we don't force it.
46
+ unless (begin; require 'spork'; rescue LoadError; nil end).nil?
47
+ Spork.prefork do
48
+ # Loading more in this block will cause your tests to run faster. However,
49
+ # if you change any configuration or code from libraries loaded here, you'll
50
+ # need to restart spork for it take effect.
51
+ setup_environment
52
+ end
53
+
54
+ Spork.each_run do
55
+ # This code will be run each time you run your specs.
56
+ each_run
57
+ end
58
+ else
59
+ setup_environment
60
+ each_run
61
+ end
@@ -0,0 +1,7 @@
1
+
2
+ FactoryGirl.define do
3
+ factory :video, :class => Refinery::Videos::Video do
4
+ sequence(:title) { |n| "refinery#{n}" }
5
+ end
6
+ end
7
+
data/tasks/rspec.rake ADDED
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc "Run specs"
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.pattern = "./spec"
6
+ end
@@ -0,0 +1,8 @@
1
+ namespace :refinery do
2
+ namespace :testing do
3
+ # Put any code in here that you want run when you test this extension against a dummy app.
4
+ # For example, the call to require your gem and start your generator.
5
+ task :setup_extension do
6
+ end
7
+ end
8
+ end