chili_videos 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data.tar.gz.sig +1 -0
  2. data/.autotest +5 -0
  3. data/Gemfile +13 -0
  4. data/Gemfile.lock +33 -0
  5. data/History.txt +4 -0
  6. data/LICENSE +20 -0
  7. data/Manifest.txt +63 -0
  8. data/README.md +169 -0
  9. data/Rakefile +45 -0
  10. data/app/controllers/videos_controller.rb +72 -0
  11. data/app/helpers/videos_helper.rb +34 -0
  12. data/app/models/assembly.rb +62 -0
  13. data/app/models/assembly_observer.rb +6 -0
  14. data/app/models/assembly_processor.rb +16 -0
  15. data/app/models/video.rb +24 -0
  16. data/app/views/settings/_settings.html.erb +13 -0
  17. data/app/views/videos/edit.html.erb +32 -0
  18. data/app/views/videos/index.html.erb +37 -0
  19. data/app/views/videos/new.html.erb +41 -0
  20. data/app/views/videos/plugin_not_configured.html.erb +6 -0
  21. data/app/views/videos/show.html.erb +40 -0
  22. data/app/views/videos/upload_complete.html.erb +7 -0
  23. data/assets/player.swf +0 -0
  24. data/assets/readme.html +84 -0
  25. data/assets/stylesheets/forms.css +7 -0
  26. data/assets/stylesheets/videos.css +76 -0
  27. data/assets/swfobject.js +8 -0
  28. data/assets/yt.swf +0 -0
  29. data/autotest/discover.rb +4 -0
  30. data/bin/delayed_job +23 -0
  31. data/config/locales/en.yml +15 -0
  32. data/config/routes.rb +3 -0
  33. data/db/migrate/20110301025054_create_videos.rb +15 -0
  34. data/db/migrate/20110309060901_create_assemblies.rb +14 -0
  35. data/db/migrate/20110314022354_create_delayed_jobs.rb +21 -0
  36. data/db/migrate/20110402043115_create_slugs.rb +18 -0
  37. data/db/migrate/20110402053931_add_slug_cache_to_videos.rb +11 -0
  38. data/init.rb +63 -0
  39. data/lang/en.yml +16 -0
  40. data/lib/chili_videos.rb +18 -0
  41. data/lib/chili_videos/config.rb +40 -0
  42. data/lib/chili_videos/error.rb +5 -0
  43. data/lib/tasks/chili_videos_tasks.rb +112 -0
  44. data/lib/tasks/contributor_tasks.rb +64 -0
  45. data/lib/tasks/delayed_job.rake +6 -0
  46. data/lib/tasks/friendly_id.rake +19 -0
  47. data/lib/video_project_patch.rb +10 -0
  48. data/lib/video_user_patch.rb +10 -0
  49. data/lib/video_version_patch.rb +9 -0
  50. data/rails/delayed_job +25 -0
  51. data/rails/init.rb +1 -0
  52. data/test/fixtures/incomplete_assembly.json +9 -0
  53. data/test/fixtures/single_video_processed_assembly.json +9 -0
  54. data/test/fixtures/standard_transloadit_response.json +6 -0
  55. data/test/functional/videos_controller_test.rb +232 -0
  56. data/test/integration/project_video_list_test.rb +104 -0
  57. data/test/integration/project_video_uploading_test.rb +56 -0
  58. data/test/integration/viewing_project_video_test.rb +74 -0
  59. data/test/test_helper.rb +77 -0
  60. data/test/unit/assembly_processor_test.rb +57 -0
  61. data/test/unit/assembly_test.rb +95 -0
  62. data/test/unit/chili_video_plugin/config_test.rb +49 -0
  63. data/test/unit/chili_video_plugin_test.rb +30 -0
  64. data/test/unit/video_test.rb +26 -0
  65. metadata +279 -0
  66. metadata.gz.sig +0 -0
@@ -0,0 +1 @@
1
+ ��y���&@f͊�&��ОC�p
@@ -0,0 +1,5 @@
1
+ Autotest.add_hook :initialize do |autotest|
2
+ %w{.git .svn .hg .DS_Store ._* vendor tmp log doc}.each do |exception|
3
+ autotest.add_exception(exception)
4
+ end
5
+ end
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'httparty', '~> 0.7.4'
4
+ gem 'delayed_job', '~> 2.0.4'
5
+ gem 'hashie', '~> 1.0.0'
6
+ gem 'friendly_id', '~> 3.2.1'
7
+
8
+ group :development do
9
+ gem 'autotest-rails', '~> 4.1.0'
10
+ gem 'fakeweb'
11
+ gem 'hoe', '~> 2.8.0'
12
+ gem 'ZenTest'
13
+ end
@@ -0,0 +1,33 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ZenTest (4.5.0)
5
+ autotest-rails (4.1.0)
6
+ ZenTest
7
+ babosa (0.3.2)
8
+ crack (0.1.8)
9
+ daemons (1.1.0)
10
+ delayed_job (2.0.4)
11
+ daemons
12
+ fakeweb (1.3.0)
13
+ friendly_id (3.2.1.1)
14
+ babosa (~> 0.3.0)
15
+ hashie (1.0.0)
16
+ hoe (2.8.0)
17
+ rake (>= 0.8.7)
18
+ httparty (0.7.4)
19
+ crack (= 0.1.8)
20
+ rake (0.8.7)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ ZenTest
27
+ autotest-rails (~> 4.1.0)
28
+ delayed_job (~> 2.0.4)
29
+ fakeweb
30
+ friendly_id (~> 3.2.1)
31
+ hashie (~> 1.0.0)
32
+ hoe (~> 2.8.0)
33
+ httparty (~> 0.7.4)
@@ -0,0 +1,4 @@
1
+ == 0.1.0 2011-04-21
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Tom Kersten
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 NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ .autotest
2
+ Gemfile
3
+ Gemfile.lock
4
+ History.txt
5
+ LICENSE
6
+ Manifest.txt
7
+ README.md
8
+ Rakefile
9
+ app/controllers/videos_controller.rb
10
+ app/helpers/videos_helper.rb
11
+ app/models/assembly.rb
12
+ app/models/assembly_observer.rb
13
+ app/models/assembly_processor.rb
14
+ app/models/video.rb
15
+ app/views/settings/_settings.html.erb
16
+ app/views/videos/edit.html.erb
17
+ app/views/videos/index.html.erb
18
+ app/views/videos/new.html.erb
19
+ app/views/videos/plugin_not_configured.html.erb
20
+ app/views/videos/show.html.erb
21
+ app/views/videos/upload_complete.html.erb
22
+ assets/player.swf
23
+ assets/readme.html
24
+ assets/stylesheets/forms.css
25
+ assets/stylesheets/videos.css
26
+ assets/swfobject.js
27
+ assets/yt.swf
28
+ autotest/discover.rb
29
+ bin/delayed_job
30
+ config/locales/en.yml
31
+ config/routes.rb
32
+ db/migrate/20110301025054_create_videos.rb
33
+ db/migrate/20110309060901_create_assemblies.rb
34
+ db/migrate/20110314022354_create_delayed_jobs.rb
35
+ db/migrate/20110402043115_create_slugs.rb
36
+ db/migrate/20110402053931_add_slug_cache_to_videos.rb
37
+ init.rb
38
+ lang/en.yml
39
+ lib/chili_videos.rb
40
+ lib/chili_videos/config.rb
41
+ lib/chili_videos/error.rb
42
+ lib/tasks/chili_videos_tasks.rb
43
+ lib/tasks/contributor_tasks.rb
44
+ lib/tasks/delayed_job.rake
45
+ lib/tasks/friendly_id.rake
46
+ lib/video_project_patch.rb
47
+ lib/video_user_patch.rb
48
+ lib/video_version_patch.rb
49
+ rails/delayed_job
50
+ rails/init.rb
51
+ test/fixtures/incomplete_assembly.json
52
+ test/fixtures/single_video_processed_assembly.json
53
+ test/fixtures/standard_transloadit_response.json
54
+ test/functional/videos_controller_test.rb
55
+ test/integration/project_video_list_test.rb
56
+ test/integration/project_video_uploading_test.rb
57
+ test/integration/viewing_project_video_test.rb
58
+ test/test_helper.rb
59
+ test/unit/assembly_processor_test.rb
60
+ test/unit/assembly_test.rb
61
+ test/unit/chili_video_plugin/config_test.rb
62
+ test/unit/chili_video_plugin_test.rb
63
+ test/unit/video_test.rb
@@ -0,0 +1,169 @@
1
+ # ChiliVideos Plugin - A "private Youtube" for ChiliProject (or Redmine) installations
2
+
3
+ * http://github.com/tomkersten/chili_videos
4
+
5
+ ## DESCRIPTION:
6
+
7
+ ChiliProject/Redmine plugin which integrates with [Transload.it](http://transload.it)
8
+ to offer a private "YouTube-like" setup to your project site.
9
+
10
+ Notable items to consider before installing:
11
+
12
+ 1. This plugin is distributed as a gem, but does
13
+ ship with migrations and asset files (stylesheets, etc). Therefore,
14
+ the installation procedure is not the standard process.
15
+ 1. The processing of "Assemblies" from the Transload.it service is
16
+ handled in the background (via `delayed_job`), so there is an
17
+ additional daemon process which you will have to monitor and/or
18
+ manage with your installation.
19
+
20
+ ## FEATURES:
21
+
22
+ 1. Makes it dead simple upload, store, and embed videos to your own
23
+ ChiliProject/Redmine (CP/RM) installation.
24
+ - **Note:** Videos are stored wherever you have Transload.it send them,
25
+ Amazon's S3 service being a popular option.
26
+ 1. Allows you to link videos to specific "versions" in the CP/RM
27
+ project
28
+ 1. Adds a "video" wiki macro which can be used to embed any video in
29
+ wiki's, news items, et cetera. (taken from the `redmine_video_embed`
30
+ plugin)
31
+
32
+ ## SCREENSHOTS:
33
+
34
+ You can find a few screenshots [here](http://www.flickr.com/photos/62017377@N04/sets/72157626425517743/).
35
+
36
+ ## PROBLEMS:
37
+
38
+ 1. Does not support authenticated requests to Transload.it yet. You
39
+ probably don't want to use this on "public" CP/RM installations
40
+ quite yet. This will be implementd soon...
41
+ 1. If users click the "submit" button multiple times on the upload
42
+ form, they may get duplicate video transcodings.
43
+ 1. There is not currently support for a default "still" thumbnail image
44
+ to be displayed when the video has not been started yet. All videos
45
+ are just a "black box" until you click "play" at this point.
46
+
47
+ ## SYNOPSIS:
48
+
49
+ 1. Install the plugin
50
+ 1. Fire up the delayed\_job daemon
51
+ 1. Add your Transload.it account credentials & template ID on the
52
+ 'ChiliVideos' plugin settings page.
53
+ 1. Enable the "Videos" module in a project
54
+
55
+ A "Videos" tab will show up in your project. Click the "Add Video" link
56
+ in the contextual menu and use the form to send a video through the
57
+ Transload.it workflow you specified in your plugin settings. The
58
+ delayed\_job daemon will grab the information about your video when
59
+ it is done being processed an the video will show up on the "Videos" tab.
60
+
61
+ ## REQUIREMENTS:
62
+
63
+ * A Transload.it API key and workflow template ID
64
+ * Gems:
65
+ - httparty (v0.7.4)
66
+ - daemon-spawn (v0.4.2)
67
+ - delayed\_job (v2.0.4)
68
+ - friendly\_id (v3.2.1.1)
69
+ - hashie (v1.0.0)
70
+
71
+ ## INSTALL:
72
+
73
+ ```
74
+ gem install chili_videos
75
+ ```
76
+
77
+ ### Manual steps after gem installation
78
+
79
+ In your 'config/environment.rb', add:
80
+
81
+ ``` ruby
82
+ config.gem 'chili_videos'
83
+ ```
84
+
85
+ In your 'Rakefile', add:
86
+
87
+ ``` ruby
88
+ require 'chili_videos'
89
+ require 'tasks/chili_videos_tasks'
90
+ ChiliVideosTasks.new"
91
+ ```
92
+
93
+ Run the installation rake task (runs migrations & installs assets)
94
+
95
+ ```
96
+ RAILS_ENV=production rake chili_videos:install
97
+ ```
98
+
99
+ Cycle your application server (mongrel, unicorn, etc)
100
+
101
+ Start the delayed\_job daemon
102
+
103
+ ```
104
+ RAILS_ENV=production rake chili_videos:delayed_job ACTION=start
105
+ ```
106
+
107
+ ## UNINSTALL:
108
+
109
+ Stop the delayed\_job daemon
110
+
111
+ ```
112
+ RAILS_ENV=production rake chili_videos:delayed_job ACTION=stop
113
+ ```
114
+
115
+ Run the uninstall rake task (reverts migrations & uninstalls assets)
116
+
117
+ ```
118
+ RAILS_ENV=production rake chili_videos:uninstall
119
+ ```
120
+
121
+ In your 'Rakefile', remove:
122
+
123
+ ``` ruby
124
+ require 'chili_videos'
125
+ require 'tasks/chili_videos_tasks'
126
+ ChiliVideosTasks.new"
127
+ ```
128
+
129
+ In your 'config/environment.rb', remove:
130
+
131
+ ``` ruby
132
+ config.gem 'chili_videos'
133
+ ```
134
+
135
+ Cycle your application server (mongrel, unicorn, whatevs)...
136
+
137
+ Then, uninstall the chili_videos gem:
138
+
139
+ ```
140
+ gem uninstall chili_videos
141
+ ```
142
+
143
+ Done.
144
+
145
+ ## CONTRIBUTING AND/OR SUPPORT:
146
+
147
+ ### Found a bug? Have a feature request?
148
+
149
+ Please file a ticket on the '[Issues](https://github.com/tomkersten/chili_videos/issues)'
150
+ page of the Github project site
151
+
152
+ You can also drop me a message on Twitter [@tomkersten](http://twitter.com/tomkersten).
153
+ ### Want to contribute?
154
+
155
+ (Better instructions coming soon)
156
+
157
+ 1. Fork the project
158
+ 1. Create a feature branch and implement your idea (preferably with
159
+ tests)
160
+ 1. Update the History.txt file in the 'Next Release' section (at the top)
161
+ 1. Send a pull request
162
+
163
+ ## LICENSE:
164
+
165
+ Refer to the [LICENSE](https://github.com/tomkersten/chili_videos/blob/master/LICENSE) file
166
+
167
+ ## Contributors (sorted alphabetically)
168
+
169
+ * Roy Kolak
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift('lib')
3
+ require 'redmine_plugin_support'
4
+ require 'chili_videos'
5
+ require 'tasks/contributor_tasks'
6
+ require 'tasks/chili_videos_tasks'
7
+
8
+ RedminePluginSupport::Base.setup do |plugin|
9
+ plugin.project_name = 'redmine_chili_videos'
10
+ plugin.default_task = [:test]
11
+ plugin.tasks = [:db, :doc, :release, :clean, :test]
12
+ plugin.redmine_root = File.expand_path(File.dirname(__FILE__) + '/../../../')
13
+ end
14
+
15
+ Dir["/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
16
+
17
+ task :default => [:test]
18
+
19
+ ChiliVideosTasks.new
20
+
21
+ begin
22
+ require 'hoe'
23
+ Hoe.plugin :git
24
+
25
+ $hoe = Hoe.spec('chili_videos') do
26
+ self.readme_file = 'README.md'
27
+ self.version = ChiliVideos::VERSION
28
+ self.extra_rdoc_files = FileList['README.md', 'LICENSE', 'History.txt']
29
+ self.summary = "ChiliProject (/Redmine) plugin which adds self-hosted videos transcoded using the Transload.it service. The plugin a 'Video' tab to a project site which contains any associated videos."
30
+ self.extra_deps = [
31
+ ['httparty', '0.7.4'],
32
+ ['daemon-spawn', '0.4.2'],
33
+ ['delayed_job', '2.0.4'],
34
+ ['friendly_id', '3.2.1.1'],
35
+ ['hashie', '1.0.0']
36
+ ]
37
+ self.extra_dev_deps = [['fakeweb', '1.3.0']]
38
+ developer('Tom Kersten', 'tom@whitespur.com')
39
+ end
40
+
41
+ ContributorTasks.new
42
+ rescue LoadError
43
+ puts "You are missing the 'hoe' gem, which is used for gem packaging & release management."
44
+ puts "Install using 'gem install hoe' if you need packaging & release rake tasks."
45
+ end
@@ -0,0 +1,72 @@
1
+ class VideosController < ApplicationController
2
+ unloadable
3
+
4
+ before_filter :verify_plugin_configured, :find_project_by_project_id, :authorize
5
+
6
+ def index
7
+ @videos = @project.videos
8
+
9
+ unless @project.assemblies.unprocessed.empty?
10
+ flash[:notice] = "There are #{Assembly.unprocessed.count} videos being processed right now. Hang tight..."
11
+ end
12
+ end
13
+
14
+ def new
15
+ @api_key = ChiliVideos::Config.api_key
16
+ @workflow = ChiliVideos::Config.workflow
17
+ @versions = @project.versions.open
18
+ end
19
+
20
+ def upload_complete
21
+ @project.assemblies.create!(assembly_params)
22
+ end
23
+
24
+ def show
25
+ if video.blank?
26
+ flash[:error] = "The requested video does not exist. Please verify the link or send the project owner a message."
27
+ redirect_to(project_videos_path(@project))
28
+ end
29
+ end
30
+
31
+ def destroy
32
+ video && video.destroy
33
+ flash[:notice] = l(:video_deleted_message)
34
+ redirect_to project_videos_path(@project)
35
+ end
36
+
37
+ def edit
38
+ if video.blank?
39
+ flash[:error] = "The requested video does not exist. Please verify the link or send the project owner a message."
40
+ redirect_to(project_videos_path(@project))
41
+ else
42
+ @versions = @project.versions.open.push(video.version).compact.sort.uniq
43
+ end
44
+ end
45
+
46
+ def update
47
+ if video.blank?
48
+ flash[:error] = "Hmmm....we couldn't find the video you were editing. Someone may have deleted it while you were performing your edits. You may want to send an email to the project owner to find out who has permissions to administer the project videos."
49
+ redirect_to(project_videos_path(@project))
50
+ else
51
+ video.update_attributes(params[:video])
52
+ redirect_to project_video_path(@project, video)
53
+ end
54
+ end
55
+
56
+ private
57
+ def assembly_params
58
+ { :assembly_id => params[:assembly_id],
59
+ :assembly_url => params[:assembly_url],
60
+ :user_id => User.current.id,
61
+ :processed => false
62
+ }
63
+ end
64
+
65
+ def verify_plugin_configured
66
+ render(:template => 'videos/plugin_not_configured') unless ChiliVideos.configured?
67
+ end
68
+
69
+ def video
70
+ @video ||= @project.videos.find_by_cached_slug(params[:id])
71
+ end
72
+ end
@@ -0,0 +1,34 @@
1
+ module VideosHelper
2
+ extend self
3
+
4
+ def video_embed_macro_markup(video)
5
+ "{{video(#{video.permalink})}}"
6
+ end
7
+
8
+ def gravatar_enabled?
9
+ Setting['gravatar_enabled'] == '1'
10
+ end
11
+
12
+ def video_embed_code(video, size = :standard)
13
+ width = size == :large ? 640 : 560
14
+ height = size == :large ? 390 : 349
15
+
16
+ "<script type='text/javascript' src='#{swf_object_file_url}'></script>\n" + \
17
+ "<script type='text/javascript'>\n" + \
18
+ " var s1 = new SWFObject('#{swf_player_file_url}', 'player', '#{width}','#{height}','9');\n" + \
19
+ " s1.addParam('allowfullscreen','true');\n" + \
20
+ " s1.addParam('allowscriptaccess','always');\n" + \
21
+ " s1.addParam('flashvars','file=#{video.url}');\n" + \
22
+ " s1.write('video_#{video.permalink}');\n" + \
23
+ "</script>\n"
24
+ end
25
+
26
+ private
27
+ def swf_object_file_url
28
+ "/plugin_assets/chili_videos/swfobject.js"
29
+ end
30
+
31
+ def swf_player_file_url
32
+ "/plugin_assets/chili_videos/player.swf"
33
+ end
34
+ end