refinerycms-vimeo-videos 0.1.2

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 (33) hide show
  1. data/.gitignore +45 -0
  2. data/app/controllers/admin/vimeo_account_controller.rb +31 -0
  3. data/app/controllers/admin/vimeo_base_controller.rb +40 -0
  4. data/app/controllers/admin/vimeo_videos_controller.rb +75 -0
  5. data/app/models/vimeo_embed_cache.rb +62 -0
  6. data/app/models/vimeo_meta_cache.rb +56 -0
  7. data/app/models/vimeo_video.rb +21 -0
  8. data/app/views/admin/vimeo_videos/_existing_vimeo_video.html.erb +35 -0
  9. data/app/views/admin/vimeo_videos/_form.html.erb +55 -0
  10. data/app/views/admin/vimeo_videos/_vimeo_video.html.haml +1 -0
  11. data/app/views/admin/vimeo_videos/index.js.erb +12 -0
  12. data/app/views/admin/vimeo_videos/insert.html.erb +60 -0
  13. data/app/views/shared/admin/_vimeo_picker.html.erb +63 -0
  14. data/config/locales/en.yml +40 -0
  15. data/config/locales/lolcat.yml +25 -0
  16. data/config/locales/nb.yml +21 -0
  17. data/config/locales/nl.yml +21 -0
  18. data/config/routes.rb +14 -0
  19. data/db/migrate/create_vimeo_embed_cache.rb +18 -0
  20. data/db/migrate/create_vimeo_meta_cache.rb +26 -0
  21. data/db/migrate/create_vimeo_videos.rb +18 -0
  22. data/db/seeds/vimeo_videos.rb +6 -0
  23. data/features/manage_vimeo_videos.feature +63 -0
  24. data/features/step_definitions/vimeo_video_steps.rb +14 -0
  25. data/features/support/paths.rb +17 -0
  26. data/lib/generators/refinerycms_vimeo_videos_generator.rb +6 -0
  27. data/lib/refinerycms-vimeo-videos.rb +27 -0
  28. data/lib/tasks/vimeo_videos.rake +13 -0
  29. data/public/javascripts/refinery/vimeo_videos.js +178 -0
  30. data/public/stylesheets/admin/vimeo_videos.css +59 -0
  31. data/readme.md +10 -0
  32. data/spec/models/vimeo_video_spec.rb +32 -0
  33. metadata +129 -0
@@ -0,0 +1,60 @@
1
+ <% content_for :stylesheets do %>
2
+ <%= stylesheet_link_tag "admin/vimeo_videos" %>
3
+ <% end %>
4
+ <% content_for :javascripts do %>
5
+ <%= javascript_include_tag "refinery/vimeo_videos" %>
6
+ <% end %>
7
+
8
+ <% user_can_modify_vimeo_videos = Refinery::Plugins.active.names.include?("vimeo_videos") %>
9
+ <div class='clearfix'>
10
+ <div id='dialog_menu_left'>
11
+ <% if (any_vimeo_videos = @vimeo_videos.any?) %>
12
+ <span id='existing_vimeo_video_radio' class='radio<%= " selected_radio" if @vimeo_video.errors.empty? %>'>
13
+ <input type='radio' name='vimeo_video_type' value='existing_vimeo_video' id='vimeo_video_type_existing' <%= "checked='true'" if @vimeo_video.errors.empty? %> />
14
+ <label for='vimeo_video_type_existing' class='stripped'>
15
+ <%= t('.existing') %>
16
+ </label>
17
+ </span>
18
+ <% end %>
19
+ <% if user_can_modify_vimeo_videos %>
20
+ <span id='upload_vimeo_video_radio' class='radio<%= " selected_radio" if @vimeo_video.errors.any? or @vimeo_videos.empty? %>'>
21
+ <input type='radio' name='vimeo_video_type' value='upload_vimeo_video' id='vimeo_video_type_upload' <%= "checked='true'" if @vimeo_videos.empty? or @vimeo_video.errors.any? %> />
22
+ <label for='vimeo_video_type_upload' class='stripped'>
23
+ <%= t('.new') %>
24
+ </label>
25
+ </span>
26
+ <% end %>
27
+ </div>
28
+
29
+ <div id='dialog_main'>
30
+ <% if any_vimeo_videos or user_can_modify_vimeo_videos %>
31
+ <%= render :partial => 'existing_vimeo_video' if any_vimeo_videos %>
32
+
33
+ <% if user_can_modify_vimeo_videos %>
34
+ <div id='upload_vimeo_video_area' class='dialog_area' <%= "style='display:none;'" if any_vimeo_videos and @vimeo_video.errors.empty? %>>
35
+ <%= render :partial => "form", :locals => {:insert => true} %>
36
+ </div>
37
+ <% end %>
38
+ <% else %>
39
+ <% flash.now[:error] = t('.no_files') %>
40
+ <%= render :partial => "/shared/admin/form_actions",
41
+ :locals => {
42
+ :f => nil,
43
+ :cancel_url => '',
44
+ :hide_cancel => false,
45
+ :hide_delete => true,
46
+ :hide_submit => true,
47
+ :cancel_button_text => t('close', :scope => 'shared.admin.form_actions'),
48
+ :cancel_title => nil
49
+ } %>
50
+ <% end %>
51
+ </div>
52
+ </div>
53
+
54
+ <% content_for :javascripts do %>
55
+ <script>
56
+ $(document).ready(function(){
57
+ vimeo_video_dialog.init(<%= @callback.present? ? "self.parent.#{@callback}" : "null" %>);
58
+ });
59
+ </script>
60
+ <% end %>
@@ -0,0 +1,63 @@
1
+ <% content_for :javascripts do %>
2
+ <%= javascript_include_tag "refinery/vimeo_videos" %>
3
+ <% end %>
4
+
5
+ <%
6
+ description ||= 'vimeo_video'
7
+ thumbnail ||= 'medium'
8
+ toggle_vimeo_video_display ||= false
9
+ randomiser = rand(Time.now.yesterday.to_i * Time.now.to_i)
10
+ current_vimeo_video_link_href = insert_admin_vimeo_videos_url(:dialog => true, :callback => "vimeo_video_picker_#{randomiser}_changed",
11
+ :width => 866, :height => 510)
12
+ current_vimeo_video_title = t('.change', :what => description.titleize)
13
+ -%>
14
+ <div id='vimeo_video_picker_container_<%= randomiser %>'>
15
+ <%= link_to t('.show'), '', :class => "current_vimeo_video_toggler" if toggle_vimeo_video_display %>
16
+ <%= f.hidden_field field, :class => "current_vimeo_video_id" -%>
17
+
18
+ <div class='current_vimeo_video_container'<%= " style='display: none'" if toggle_vimeo_video_display %> style="margin-top: 10px;">
19
+ <a class='current_vimeo_video_link dialog' href="<%= current_vimeo_video_link_href %>" style='border: 0px' title='<%= current_vimeo_video_title %>' name='<%= current_vimeo_video_title %>'>
20
+ <% unless vimeo_video.nil? -%>
21
+ <%= image_fu vimeo_video.image, ::Image.user_image_sizes[thumbnail.to_sym], :class => "brown_border",
22
+ :class => "current_picked_vimeo_video" %>
23
+ <% else -%>
24
+ <img class="current_picked_vimeo_video" src="" alt="" style='display: none' />
25
+ <% end -%>
26
+ <span class='no_picked_vimeo_video_selected nothing_selected' <%= "style='display: none;'" if vimeo_video.present? %>>
27
+ <%= t('.none_selected', :what => t('.' + description )) %>
28
+ </span>
29
+ </a>
30
+ <br/>
31
+ <%= link_to t('.remove_current', :what => t('.' + description )), "#",
32
+ :class => "remove_picked_vimeo_video",
33
+ :style => "#{"display:none;" if vimeo_video.nil?}" %>
34
+ </div>
35
+ </div>
36
+
37
+ <% content_for :javascripts do -%>
38
+ <script>
39
+ var vimeo_video_picker_<%= randomiser %> = null;
40
+ $(document).ready(function(e) {
41
+ vimeo_video_picker_<%= randomiser %> = vimeo_video_picker.init({
42
+ thumbnail: '<%= thumbnail.html_safe %>'
43
+ , vimeo_video_toggler: '<%= toggle_vimeo_video_display ? ".current_vimeo_video_toggler" : "null" %>'
44
+ , description: '<%= description %>'
45
+ , field: '.current_vimeo_video_id'
46
+ , vimeo_video_display: '.current_picked_vimeo_video'
47
+ , no_vimeo_video_message: '.no_picked_vimeo_video_selected'
48
+ , remove_vimeo_video_button: '.remove_picked_vimeo_video'
49
+ , picker_container: '#vimeo_video_picker_container_<%= randomiser %>'
50
+ , vimeo_video_container: '.current_vimeo_video_container'
51
+ , vimeo_video_link: '.current_vimeo_video_link'
52
+ });
53
+ });
54
+
55
+ vimeo_video_picker_<%= randomiser %>_changed = function(args){
56
+ $.proxy(vimeo_video_picker_<%= randomiser %>.changed, {
57
+ container: '#vimeo_video_picker_container_<%= randomiser %>'
58
+ , picker: vimeo_video_picker_<%= randomiser %>
59
+ , vimeo_video: args
60
+ })();
61
+ };
62
+ </script>
63
+ <% end %>
@@ -0,0 +1,40 @@
1
+ en:
2
+ shared:
3
+ admin:
4
+ vimeo_video_picker:
5
+ vimeo_video: vimeo_video
6
+ vimeo_picker:
7
+ no_vimeo_video_selected: There is currently no video selected, please click here to add one.
8
+ name: Insert a video from your account
9
+ vimeo_video: vimeo_video
10
+ none_selected: There is currently no video selected, please click here to add one.
11
+ remove_current: Remove current video
12
+ change: Change video
13
+ plugins:
14
+ vimeo_videos:
15
+ title: Vimeo Videos
16
+ admin:
17
+ vimeo_videos:
18
+ form:
19
+ maximum_file_size: Maximale Dateigröße ist %{megabytes} Megabytes.
20
+ insert:
21
+ existing: Von account
22
+ new: Neues Video
23
+ actions:
24
+ create_new: Add New Vimeo Video
25
+ reorder: Reorder Vimeo Videos
26
+ reorder_done: Done Reordering Vimeo Videos
27
+ records:
28
+ title: Vimeo Videos
29
+ sorry_no_results: Sorry! There are no results found.
30
+ no_items_yet: There are no Vimeo Videos yet. Click "Add New Vimeo Video" to add your first vimeo video.
31
+ vimeo_video:
32
+ view_live_html: View this vimeo video live <br/><em>(opens in a new window)</em>
33
+ edit: Edit this vimeo video
34
+ delete: Remove this vimeo video forever
35
+ existing_vimeo_video:
36
+ button_text: Save
37
+ vimeo_videos:
38
+ show:
39
+ other: Other Vimeo Videos
40
+ i18n: en.admin.vimeo_videos.existing_vimeo_video.button_text
@@ -0,0 +1,25 @@
1
+ lolcat:
2
+ shared:
3
+ admin:
4
+ vimeo_video_picker:
5
+ vimeo_video: IMAGE
6
+ plugins:
7
+ vimeo_videos:
8
+ title: Vimeo Videos
9
+ admin:
10
+ vimeo_videos:
11
+ actions:
12
+ create_new: CREATE NEW Vimeo Video
13
+ reorder: REORDR Vimeo Videos
14
+ reorder_done: DUN REORDERIN Vimeo Videos
15
+ records:
16
+ title: Vimeo Videos
17
+ sorry_no_results: SRY! THAR R NO RESULTS FINDZ.
18
+ no_items_yet: THAR R NO Vimeo Videos YET. CLICK "CREATE NEW Vimeo Video" 2 ADD UR FURST vimeo video.
19
+ vimeo_video:
20
+ view_live_html: VIEW DIS vimeo video LIV <BR/><EM>(OPENS IN NEW WINDOW)</EM>
21
+ edit: EDIT DIS vimeo video
22
+ delete: REMOOV DIS vimeo video FOREVR
23
+ vimeo_videos:
24
+ show:
25
+ other: OTHR Vimeo Videos
@@ -0,0 +1,21 @@
1
+ nb:
2
+ plugins:
3
+ vimeo_videos:
4
+ title: Vimeo Videos
5
+ admin:
6
+ vimeo_videos:
7
+ actions:
8
+ create_new: Lag en ny Vimeo Video
9
+ reorder: Endre rekkefølgen på Vimeo Videos
10
+ reorder_done: Ferdig å endre rekkefølgen Vimeo Videos
11
+ records:
12
+ title: Vimeo Videos
13
+ sorry_no_results: Beklager! Vi fant ikke noen resultater.
14
+ no_items_yet: Det er ingen Vimeo Videos enda. Klikk på "Lag en ny Vimeo Video" for å legge til din første vimeo video.
15
+ vimeo_video:
16
+ view_live_html: Vis hvordan denne vimeo video ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
17
+ edit: Rediger denne vimeo video
18
+ delete: Fjern denne vimeo video permanent
19
+ vimeo_videos:
20
+ show:
21
+ other: Andre Vimeo Videos
@@ -0,0 +1,21 @@
1
+ nl:
2
+ plugins:
3
+ vimeo_videos:
4
+ title: Vimeo Videos
5
+ admin:
6
+ vimeo_videos:
7
+ actions:
8
+ create_new: Maak een nieuwe Vimeo Video
9
+ reorder: Wijzig de volgorde van de Vimeo Videos
10
+ reorder_done: Klaar met het wijzingen van de volgorde van de Vimeo Videos
11
+ records:
12
+ title: Vimeo Videos
13
+ sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
14
+ no_items_yet: Er zijn nog geen Vimeo Videos. Druk op 'Maak een nieuwe Vimeo Video' om de eerste aan te maken.
15
+ vimeo_video:
16
+ view_live_html: Bekijk deze vimeo video op de website <br/><em>(opent een nieuw venster)</em>
17
+ edit: Bewerk deze vimeo video
18
+ delete: Verwijder deze vimeo video voor eeuwig
19
+ vimeo_videos:
20
+ show:
21
+ other: Andere Vimeo Videos
data/config/routes.rb ADDED
@@ -0,0 +1,14 @@
1
+ Refinery::Application.routes.draw do
2
+ scope(:path => 'admin', :as => 'admin', :module => 'admin') do
3
+ resources :vimeo_videos, :except => :show do
4
+ collection do
5
+ get :insert
6
+ end
7
+ end
8
+ end
9
+
10
+ namespace :admin do
11
+ get 'vimeo_videos/authorization', :to => 'vimeo_account#authorization'
12
+ get 'vimeo_videos/callback', :to => 'vimeo_account#callback'
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ class CreateVimeoEmbedCache < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :vimeo_embed_cache do |t|
5
+ t.integer :vid
6
+ t.string :code
7
+ t.text :configuration
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :vimeo_embed_cache, [:vid]
12
+ end
13
+
14
+ def self.down
15
+ drop_table :vimeo_embed_cache
16
+ end
17
+
18
+ end
@@ -0,0 +1,26 @@
1
+ class CreateVimeoMetaCache < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :vimeo_meta_cache do |t|
5
+ t.string :vid, :unique => true
6
+ t.string :title
7
+ t.text :description
8
+ t.integer :image_id
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :vimeo_meta_cache, [:vid]
14
+
15
+ load(Rails.root.join('db', 'seeds', 'vimeo_videos.rb'))
16
+ end
17
+
18
+ def self.down
19
+ UserPlugin.destroy_all({:name => "vimeo_videos"})
20
+
21
+ Page.delete_all({:link_url => "/vimeo_videos"})
22
+
23
+ drop_table :vimeo_meta_cache
24
+ end
25
+
26
+ end
@@ -0,0 +1,18 @@
1
+ class CreateVimeoVideos < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :vimeo_videos do |t|
5
+ t.string :vid, :unique => true
6
+ t.string :title
7
+ t.text :description
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ end
13
+
14
+ def self.down
15
+ drop_table :vimeo_videos
16
+ end
17
+
18
+ end
@@ -0,0 +1,6 @@
1
+ User.find(:all).each do |user|
2
+ if user.plugins.find_by_name('vimeo_videos').nil?
3
+ user.plugins.create(:name => 'vimeo_videos',
4
+ :position => (user.plugins.maximum(:position) || -1) +1)
5
+ end
6
+ end
@@ -0,0 +1,63 @@
1
+ @vimeo_videos
2
+ Feature: Vimeo Videos
3
+ In order to have vimeo_videos on my website
4
+ As an administrator
5
+ I want to manage vimeo_videos
6
+
7
+ Background:
8
+ Given I am a logged in refinery user
9
+ And I have no vimeo_videos
10
+
11
+ @vimeo_videos-list @list
12
+ Scenario: Vimeo Videos List
13
+ Given I have vimeo_videos titled UniqueTitleOne, UniqueTitleTwo
14
+ When I go to the list of vimeo_videos
15
+ Then I should see "UniqueTitleOne"
16
+ And I should see "UniqueTitleTwo"
17
+
18
+ @vimeo_videos-valid @valid
19
+ Scenario: Create Valid Vimeo Video
20
+ When I go to the list of vimeo_videos
21
+ And I follow "Add New Vimeo Video"
22
+ And I fill in "Title" with "This is a test of the first string field"
23
+ And I press "Save"
24
+ Then I should see "'This is a test of the first string field' was successfully added."
25
+ And I should have 1 vimeo_video
26
+
27
+ @vimeo_videos-invalid @invalid
28
+ Scenario: Create Invalid Vimeo Video (without title)
29
+ When I go to the list of vimeo_videos
30
+ And I follow "Add New Vimeo Video"
31
+ And I press "Save"
32
+ Then I should see "Title can't be blank"
33
+ And I should have 0 vimeo_videos
34
+
35
+ @vimeo_videos-edit @edit
36
+ Scenario: Edit Existing Vimeo Video
37
+ Given I have vimeo_videos titled "A title"
38
+ When I go to the list of vimeo_videos
39
+ And I follow "Edit this vimeo_video" within ".actions"
40
+ Then I fill in "Title" with "A different title"
41
+ And I press "Save"
42
+ Then I should see "'A different title' was successfully updated."
43
+ And I should be on the list of vimeo_videos
44
+ And I should not see "A title"
45
+
46
+ @vimeo_videos-duplicate @duplicate
47
+ Scenario: Create Duplicate Vimeo Video
48
+ Given I only have vimeo_videos titled UniqueTitleOne, UniqueTitleTwo
49
+ When I go to the list of vimeo_videos
50
+ And I follow "Add New Vimeo Video"
51
+ And I fill in "Title" with "UniqueTitleTwo"
52
+ And I press "Save"
53
+ Then I should see "There were problems"
54
+ And I should have 2 vimeo_videos
55
+
56
+ @vimeo_videos-delete @delete
57
+ Scenario: Delete Vimeo Video
58
+ Given I only have vimeo_videos titled UniqueTitleOne
59
+ When I go to the list of vimeo_videos
60
+ And I follow "Remove this vimeo video forever"
61
+ Then I should see "'UniqueTitleOne' was successfully removed."
62
+ And I should have 0 vimeo_videos
63
+
@@ -0,0 +1,14 @@
1
+ Given /^I have no vimeo_videos$/ do
2
+ VimeoVideo.delete_all
3
+ end
4
+
5
+ Given /^I (only )?have vimeo_videos titled "?([^\"]*)"?$/ do |only, titles|
6
+ VimeoVideo.delete_all if only
7
+ titles.split(', ').each do |title|
8
+ VimeoVideo.create(:title => title)
9
+ end
10
+ end
11
+
12
+ Then /^I should have ([0-9]+) vimeo_videos?$/ do |count|
13
+ VimeoVideo.count.should == count.to_i
14
+ end
@@ -0,0 +1,17 @@
1
+ module NavigationHelpers
2
+ module Refinery
3
+ module VimeoVideos
4
+ def path_to(page_name)
5
+ case page_name
6
+ when /the list of vimeo_videos/
7
+ admin_vimeo_videos_path
8
+
9
+ when /the new vimeo_video form/
10
+ new_admin_vimeo_video_path
11
+ else
12
+ nil
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ class RefinerycmsVimeoVideos < Refinery::Generators::EngineInstaller
2
+
3
+ source_root File.expand_path('../../../', __FILE__)
4
+ engine_name "vimeo_videos"
5
+
6
+ end
@@ -0,0 +1,27 @@
1
+ require 'refinery'
2
+
3
+ module Refinery
4
+ module VimeoVideos
5
+ class Engine < Rails::Engine
6
+ initializer "static assets" do |app|
7
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
8
+ end
9
+
10
+ # Make sure these settings exist
11
+ initializer "account settings" do |app|
12
+ RefinerySetting.find_or_set('vimeo_consumer_key', :value => "Consumer Key")
13
+ RefinerySetting.find_or_set('vimeo_consumer_secret', :value => "Consumer Secret")
14
+ RefinerySetting.find_or_set('vimeo_token', :value => "Token")
15
+ RefinerySetting.find_or_set('vimeo_secret', :value => "Secret")
16
+ RefinerySetting.find_or_set('vimeo_username', :value => "Username")
17
+ end
18
+
19
+ config.after_initialize do
20
+ Refinery::Plugin.register do |plugin|
21
+ plugin.name = "vimeo_videos"
22
+ plugin.hide_from_menu = true
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end