refinerycms-vimeo-videos 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
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,13 @@
1
+ namespace :refinery do
2
+
3
+ namespace :vimeo_videos do
4
+
5
+ # call this task my running: rake refinery:vimeo_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
@@ -0,0 +1,178 @@
1
+ var vimeo_video_dialog = {
2
+ initialised: false
3
+ , callback: null
4
+
5
+ , init: function(callback){
6
+ this.callback = callback;
7
+ this.init_tabs();
8
+ this.init_select();
9
+ this.init_actions();
10
+ this.initialised = true;
11
+ return this;
12
+ }
13
+
14
+ , init_tabs: function(){
15
+ var radios = $('#dialog_menu_left input:radio');
16
+ var selected = radios.parent().filter(".selected_radio").find('input:radio').first() || radios.first();
17
+
18
+ radios.click(function(){
19
+ link_dialog.switch_area($(this));
20
+ });
21
+
22
+ selected.attr('checked', 'true');
23
+ link_dialog.switch_area(selected);
24
+ }
25
+
26
+ , switch_area: function(radio){
27
+ $('#dialog_menu_left .selected_radio').removeClass('selected_radio');
28
+ $(radio).parent().addClass('selected_radio');
29
+ $('#dialog_main .dialog_area').hide();
30
+ $('#' + radio.value + '_area').show();
31
+ }
32
+
33
+ , init_select: function(){
34
+ $('#existing_vimeo_video_area_content ul li img').click(function(){
35
+ vimeo_video_dialog.set_vimeo_video(this);
36
+ });
37
+ //Select any currently selected, just uploaded...
38
+ if ((selected_img = $('#existing_vimeo_video_area_content ul li.selected img')).length > 0) {
39
+ vimeo_video_dialog.set_vimeo_video(selected_img.first());
40
+ }
41
+ }
42
+
43
+ , set_vimeo_video: function(img){
44
+ if ($(img).length > 0) {
45
+ $('#existing_vimeo_video_area_content ul li.selected').removeClass('selected');
46
+
47
+ $(img).parent().addClass('selected');
48
+ var vimeo_videoId = $(img).attr('data-id');
49
+ var geometry = $('#existing_vimeo_video_size_area li.selected a').attr('data-geometry');
50
+ var size = $('#existing_vimeo_video_size_area li.selected a').attr('data-size');
51
+ vimeo_video_url = $(img).attr('data-original');
52
+
53
+ if (parent) {
54
+ if ((wym_src = parent.document.getElementById('wym_src')) != null) {
55
+ wym_src.value = vimeo_video_url;
56
+ }
57
+ if ((wym_title = parent.document.getElementById('wym_title')) != null) {
58
+ wym_title.value = $(img).attr('title');
59
+ }
60
+ if ((wym_alt = parent.document.getElementById('wym_alt')) != null) {
61
+ wym_alt.value = $(img).attr('alt');
62
+ }
63
+ }
64
+ }
65
+ }
66
+
67
+ , submit_vimeo_video_choice: function(e) {
68
+ e.preventDefault();
69
+ if((img_selected = $('#existing_vimeo_video_area_content ul li.selected img').get(0)) && $.isFunction(this.callback))
70
+ {
71
+ this.callback(img_selected);
72
+ }
73
+
74
+ close_dialog(e);
75
+ }
76
+
77
+ , init_actions: function(){
78
+ var _this = this;
79
+ // get submit buttons not inside a wymeditor iframe
80
+ $('#existing_vimeo_video_area .form-actions-dialog #submit_button')
81
+ .not('.wym_iframe_body #existing_vimeo_video_area .form-actions-dialog #submit_button')
82
+ .click($.proxy(_this.submit_vimeo_video_choice, _this));
83
+
84
+ // get cancel buttons not inside a wymeditor iframe
85
+ $('.form-actions-dialog #cancel_button')
86
+ .not('.wym_iframe_body .form-actions-dialog #cancel_button')
87
+ .click($.proxy(close_dialog, _this));
88
+
89
+ $('#existing_vimeo_video_size_area ul li a').click(function(e) {
90
+ $('#existing_vimeo_video_size_area ul li').removeClass('selected');
91
+ $(this).parent().addClass('selected');
92
+ $('#existing_vimeo_video_size_area #wants_to_resize_vimeo_video').attr('checked', 'checked');
93
+ vimeo_video_dialog.set_vimeo_video($('#existing_vimeo_video_area_content ul li.selected img'));
94
+ e.preventDefault();
95
+ });
96
+
97
+ $('#existing_vimeo_video_size_area #wants_to_resize_vimeo_video').change(function(){
98
+ if($(this).is(":checked")) {
99
+ $('#existing_vimeo_video_size_area ul li:first a').click();
100
+ } else {
101
+ $('#existing_vimeo_video_size_area ul li').removeClass('selected');
102
+ vimeo_video_dialog.set_vimeo_video($('#existing_vimeo_video_area_content ul li.selected img'));
103
+ }
104
+ });
105
+
106
+ vimeo_video_area = $('#existing_vimeo_video_area').not('#wym_iframe_body #existing_vimeo_video_area');
107
+ vimeo_video_area.find('.form-actions input#submit_button').click($.proxy(function(e) {
108
+ e.preventDefault();
109
+ $(this.document.getElementById('wym_dialog_submit')).click();
110
+ }, parent));
111
+ vimeo_video_area.find('.form-actions a.close_dialog').click(close_dialog);
112
+ }
113
+ };
114
+
115
+
116
+ var vimeo_video_picker = {
117
+ initialised: false
118
+ , options: {
119
+ selected: ''
120
+ , thumbnail: 'medium'
121
+ , field: '#vimeo_video'
122
+ , vimeo_video_display: '.current_picked_vimeo_video'
123
+ , no_vimeo_video_message: '.no_picked_vimeo_video_selected'
124
+ , vimeo_video_container: '.current_vimeo_video_container'
125
+ , remove_vimeo_video_button: '.remove_picked_vimeo_video'
126
+ , picker_container: '.vimeo_video_picker_container'
127
+ , vimeo_video_link: '.current_vimeo_video_link'
128
+ , vimeo_video_toggler: null
129
+ }
130
+
131
+ , init: function(new_options){
132
+ this.options = $.extend(this.options, new_options);
133
+ $(this.options.picker_container).find(this.options.remove_vimeo_video_button)
134
+ .click($.proxy(this.remove_vimeo_video, {container: this.options.picker_container, picker: this}));
135
+ $(this.options.picker_container).find(this.options.vimeo_video_toggler)
136
+ .click($.proxy(this.toggle_vimeo_video, {container: this.options.picker_container, picker: this}));
137
+
138
+ this.initialised = true;
139
+
140
+ return this;
141
+ }
142
+
143
+ , remove_vimeo_video: function(e) {
144
+ e.preventDefault();
145
+
146
+ $(this.container).find(this.picker.options.vimeo_video_display)
147
+ .removeClass('brown_border')
148
+ .attr({'src': '', 'width': '', 'height': ''})
149
+ .css({'width': 'auto', 'height': 'auto'})
150
+ .hide();
151
+ $(this.container).find(this.picker.options.field).val('');
152
+ $(this.container).find(this.picker.options.no_vimeo_video_message).show();
153
+ $(this.container).find(this.picker.options.remove_vimeo_video_button).hide();
154
+ $(this).hide();
155
+ }
156
+
157
+ , toggle_vimeo_video: function(e) {
158
+ $(this.container).find(this.options.vimeo_video_toggler).html(
159
+ ($(this.container).find(options.vimeo_video_toggler).html() == 'Show' ? 'Hide' : 'Show')
160
+ );
161
+ $(this.container).find(this.options.vimeo_video_container).toggle();
162
+ e.preventDefault();
163
+ }
164
+
165
+ , changed: function(e) {
166
+ $(this.container).find(this.picker.options.field).val(
167
+ this.vimeo_video.id.replace("vimeo_video_", "")
168
+ );
169
+
170
+ current_vimeo_video = $(this.container).find(this.picker.options.vimeo_video_display);
171
+ current_vimeo_video.replaceWith(
172
+ $("<img src='"+$(this.vimeo_video).attr('data-image')+"?"+Math.floor(Math.random() * 100000)+"' id='"+current_vimeo_video.attr('id')+"' class='"+this.picker.options.vimeo_video_display.replace(/^./, '')+" brown_border' />")
173
+ );
174
+
175
+ $(this.container).find(this.picker.options.remove_vimeo_video_button).show();
176
+ $(this.container).find(this.picker.options.no_vimeo_video_message).hide();
177
+ }
178
+ };
@@ -0,0 +1,59 @@
1
+ .dialog #existing_vimeo_video_area_content {
2
+ margin-top: 28px;
3
+ }
4
+ .dialog #existing_vimeo_video_area_content ul {
5
+ margin: 0px;
6
+ padding: 0px;
7
+ }
8
+ .dialog #existing_vimeo_video_area_content ul li {
9
+ list-style: none;
10
+ padding: 0px;
11
+ margin: 0px 2px 0px 0px;
12
+ float: left;
13
+ height: 114px;
14
+ max-height: 114px;
15
+ width: 114px;
16
+ max-width: 114px;
17
+ overflow: hidden;
18
+ cursor: pointer;
19
+ text-align: center;
20
+ vertical-align: middle;
21
+ }
22
+ .dialog #existing_vimeo_video_area_content ul li img {
23
+ border: 4px solid transparent;
24
+ }
25
+ .dialog #existing_vimeo_video_area_content ul li.selected img {
26
+ border: 4px solid #22A7F2;
27
+ }
28
+ .dialog #existing_vimeo_video_size_area {
29
+ margin-top: 18px;
30
+ }
31
+ .dialog #existing_vimeo_video_size_area ul {
32
+ margin: 0px;
33
+ padding: 10px 0px 0px 0px;
34
+ }
35
+ .dialog #existing_vimeo_video_size_area ul li {
36
+ float: left;
37
+ list-style: none;
38
+ margin: 0px 18px 0px 0px;
39
+ text-align:center;
40
+ }
41
+ .dialog #existing_vimeo_video_size_area ul li.selected {
42
+
43
+ }
44
+ .dialog #existing_vimeo_video_size_area ul li a {
45
+ display: block;
46
+ border: 1px solid #999999;
47
+ font-size: 10px;
48
+ /* The following default values are overridden below */
49
+ height: 90px;
50
+ width: 90px;
51
+ line-height: 90px;
52
+ margin-top:-20px
53
+ }
54
+ .dialog #existing_vimeo_video_size_area ul li.selected a {
55
+ border-color: #22A7F2;
56
+ background: #22A7F2;
57
+ color: white;
58
+ font-weight: bold;
59
+ }
data/readme.md ADDED
@@ -0,0 +1,10 @@
1
+ # Vimeo Videos engine for Refinery CMS.
2
+
3
+ ## How to build this engine as a gem
4
+
5
+ cd vendor/engines/vimeo_videos
6
+ gem build refinerycms-vimeo_videos.gempspec
7
+ gem install refinerycms-vimeo_videos.gem
8
+
9
+ # Sign up for a http://rubygems.org/ account and publish the gem
10
+ gem push refinerycms-vimeo_videos.gem
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe VimeoVideo do
4
+
5
+ def reset_vimeo_video(options = {})
6
+ @valid_attributes = {
7
+ :id => 1,
8
+ :title => "RSpec is great for testing too"
9
+ }
10
+
11
+ @vimeo_video.destroy! if @vimeo_video
12
+ @vimeo_video = VimeoVideo.create!(@valid_attributes.update(options))
13
+ end
14
+
15
+ before(:each) do
16
+ reset_vimeo_video
17
+ end
18
+
19
+ context "validations" do
20
+
21
+ it "rejects empty title" do
22
+ VimeoVideo.new(@valid_attributes.merge(:title => "")).should_not be_valid
23
+ end
24
+
25
+ it "rejects non unique title" do
26
+ # as one gets created before each spec by reset_vimeo_video
27
+ VimeoVideo.new(@valid_attributes).should_not be_valid
28
+ end
29
+
30
+ end
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-vimeo-videos
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
11
+ platform: ruby
12
+ authors:
13
+ - "Marian Andr\xC3\xA9"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-26 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: vimeo
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 27
30
+ segments:
31
+ - 1
32
+ - 3
33
+ - 0
34
+ version: 1.3.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: httparty
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 5
46
+ segments:
47
+ - 0
48
+ - 6
49
+ - 1
50
+ version: 0.6.1
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Ruby on Rails Vimeo Videos engine for Refinery CMS
54
+ email: mail@bitflut.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files: []
60
+
61
+ files:
62
+ - .gitignore
63
+ - app/controllers/admin/vimeo_account_controller.rb
64
+ - app/controllers/admin/vimeo_base_controller.rb
65
+ - app/controllers/admin/vimeo_videos_controller.rb
66
+ - app/models/vimeo_embed_cache.rb
67
+ - app/models/vimeo_meta_cache.rb
68
+ - app/models/vimeo_video.rb
69
+ - app/views/admin/vimeo_videos/_existing_vimeo_video.html.erb
70
+ - app/views/admin/vimeo_videos/_form.html.erb
71
+ - app/views/admin/vimeo_videos/_vimeo_video.html.haml
72
+ - app/views/admin/vimeo_videos/index.js.erb
73
+ - app/views/admin/vimeo_videos/insert.html.erb
74
+ - app/views/shared/admin/_vimeo_picker.html.erb
75
+ - config/locales/en.yml
76
+ - config/locales/lolcat.yml
77
+ - config/locales/nb.yml
78
+ - config/locales/nl.yml
79
+ - config/routes.rb
80
+ - db/migrate/create_vimeo_embed_cache.rb
81
+ - db/migrate/create_vimeo_meta_cache.rb
82
+ - db/migrate/create_vimeo_videos.rb
83
+ - db/seeds/vimeo_videos.rb
84
+ - features/manage_vimeo_videos.feature
85
+ - features/step_definitions/vimeo_video_steps.rb
86
+ - features/support/paths.rb
87
+ - lib/generators/refinerycms_vimeo_videos_generator.rb
88
+ - lib/refinerycms-vimeo-videos.rb
89
+ - lib/tasks/vimeo_videos.rake
90
+ - public/javascripts/refinery/vimeo_videos.js
91
+ - public/stylesheets/admin/vimeo_videos.css
92
+ - readme.md
93
+ - spec/models/vimeo_video_spec.rb
94
+ has_rdoc: true
95
+ homepage: http://bitflut.com
96
+ licenses:
97
+ - MIT
98
+ post_install_message:
99
+ rdoc_options: []
100
+
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ requirements: []
122
+
123
+ rubyforge_project:
124
+ rubygems_version: 1.6.2
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Vimeo Videos engine for Refinery CMS
128
+ test_files: []
129
+