framey 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # The Framey Ruby Gem
2
+
3
+ This gem can be used for easy Rails integration with the Framey video recording service. See http://framey.com for more information.
4
+
5
+ # Dependencies:
6
+
7
+ * httparty (ruby gem)
8
+ * will_paginate (ruby gem)
9
+
10
+ # Installation
11
+
12
+ First, sign up at http://framey.com to get an API key and secret and to set your callback url.
13
+
14
+ If not using bundler, do:
15
+
16
+ `gem install framey`
17
+
18
+ otherwise in your Gemfile:
19
+
20
+ `gem framey`
21
+
22
+ Run the framey generator:
23
+
24
+ `rails generate framey API_KEY API_SECRET`
25
+
26
+ This automatically creates default views, controller and routes for recording and viewing videos, as well as the callback that framey.com pings with the video information:
27
+
28
+ /framey/videos
29
+ /framey/videos/new
30
+ /framey/videos/<video_id>
31
+ /framey/callback
32
+
33
+ Create the supporting database tables:
34
+ rake db:migrate
35
+
36
+ Edit the default configuration options in config/framey.rb:
37
+
38
+ API_HOST = "http://framey.com"
39
+ RUN_ENV = "production"
40
+ API_KEY = "API_KEY_VALUE"
41
+ SECRET = "API_SECRET_VALUE"
42
+ API_TIMEOUT = 15
43
+ MAX_TIME = 30
44
+
45
+ # User / Development Flow
46
+
47
+ * You make a page on your site that displays the Framey flash video recorder
48
+ * Your user visits that page and clicks record
49
+ * If your user likes the video she just recorded, she clicks "Publish"
50
+ * The user's video is processed and stored on the Framey servers.
51
+ * Framey emails you and/or pings your servers at a specified callback url with a url to the video file
52
+ * You can choose to store those urls on your end, or just the id of the Framey video to access it later on Framey via an API call
53
+ * You then display the video to your user using either the Framey video player or your own favorite flash or HTML 5 video player
54
+
55
+ # Usage
56
+
57
+
58
+ To render the Framey video recorder in an ActionView (example assumes ERB) do:
59
+
60
+ <%= javascript_include_tag "swfobject" %>
61
+ <%= render_recorder({
62
+ :id => "myRecorder", # id for the flash embed object (optional, random by default)
63
+ :max_time => 60, # maximum allowed video length in seconds (optional, defaults to 30)
64
+ :session_data => { # custom parameters to be passed along to your app later (optional)
65
+ :user_id => <%= @user.id %> # you may, for example, want to relate this recording to a specific user in your system
66
+ }
67
+ }) %>
68
+
69
+ When your user then views this recorder, records a video, and clicks "Publish", your app receives a POST to the specified callback url with the following parameters:
70
+
71
+ {
72
+ :video => {
73
+ :name => [video name], # this is the video's UUID within the Framey system
74
+ :filesize => [filesize], # the filesize in bytes of the video
75
+ :duration => [duration], # the duration of the video in seconds
76
+ :state => [state], # the state of the video, in this case "uploaded"
77
+ :views => [number of views], # the number of times this video has been viewed, in this case 0
78
+ :data => [the data hash you specified], # this is the exact data you specified in the :session_data hash when rendering the recorder
79
+ :flv_url => [video url], # url to the flash video file on framey that you can feed into a video player later
80
+ :mp4_url => [h.264 video url], # url to the h.264 video file on framey that you can feed into a video player later
81
+ :large_thumbnail_url => [thumbnail url] # url to the large thumbnail image that was generated for this video
82
+ :medium_thumbnail_url => [thumbnail url] # url to the medium thumbnail image that was generated for this video
83
+ :small_thumbnail_url => [thumbnail url] # url to the small thumbnail image that was generated for this video
84
+ }
85
+ }
86
+
87
+ To render the Framey video player in an ActionView (example assumes ERB) do:
88
+
89
+ <%= javascript_include_tag "swfobject" %>
90
+ <%= render_player({
91
+ :id => "myPlayer", # id for the flash embed object (optional, random by default)
92
+ :video_url => "[video url]", # the video url received in the callback (required)
93
+ :thumbnail_url => "[thumbnail url]", # the thumbnail url received in the callback (required)
94
+ :progress_bar_color => "0x123456", # the desired color for the progress bar (optional, defaults to black)
95
+ :volume_bar_color => "0x123456", # the desired color for the volume bar (optional, defaults to black)
96
+ })%>
97
+
98
+ Note that you don't have to use the Framey video player, though, and can use any other flash video player you'd like.
99
+
100
+ To get updated stats information about a given video, do:
101
+
102
+ @video = Framey::Api.get_video("[framey video name]")
103
+
104
+ This returns a simple Framey::Video object, like so:
105
+
106
+ #<Framey::Video:0x1037b4450 @state="uploaded", @filesize=123456, @name="c96323e0-54b1-012e-9d34-7c6d628c53d4", @large_thumbnail_url="http://framey.com/thumbnails/c96323e0-54b1-012e-9d34-7c6d628c53d4.jpg", @medium_thumbnail_url="http://framey.com/thumbnails/c96323e0-54b1-012e-9d34-7c6d628c53d4.jpg", @small_thumbnail_url="http://framey.com/thumbnails/c96323e0-54b1-012e-9d34-7c6d628c53d4.jpg", @data={"user_id" => 1}, @flv_url="http://framey.com/videos/source/c96323e0-54b1-012e-9d34-7c6d628c53d4/source.flv", @mp4_url="http://framey.com/videos/source/c96323e0-54b1-012e-9d34-7c6d628c53d4/source.mp4", @views=12, @duration=15.62>
107
+
108
+ To delete a video on Framey, do:
109
+
110
+ @video.delete!
111
+
112
+ or:
113
+
114
+ Framey::Api.delete_video("[framey video name]")
115
+
116
+ # Other Documentation
117
+
118
+ * http://rubydoc.info/gems/framey/1.2.0/frames
119
+
120
+ # License
121
+
122
+ (The MIT License)
123
+
124
+ Copyright (c) 2011 FIX
125
+
126
+ Permission is hereby granted, free of charge, to any person obtaining
127
+ a copy of this software and associated documentation files (the
128
+ 'Software'), to deal in the Software without restriction, including
129
+ without limitation the rights to use, copy, modify, merge, publish,
130
+ distribute, sublicense, and/or sell copies of the Software, and to
131
+ permit persons to whom the Software is furnished to do so, subject to
132
+ the following conditions:
133
+
134
+ The above copyright notice and this permission notice shall be
135
+ included in all copies or substantial portions of the Software.
136
+
137
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
138
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
139
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
140
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
141
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
142
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
143
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -16,7 +16,7 @@ module Framey
16
16
  timestamp, signature = Framey::Api.sign
17
17
  session_data = (opts[:session_data]||{}).map { |k,v| "#{k.to_s}=#{v.to_s}" }.join(",")
18
18
  run_env = Framey::RUN_ENV
19
- max_time = opts[:max_time] || 30
19
+ max_time = opts[:max_time] || Framey::MAX_TIME
20
20
  divid = "frameyRecorderContainer_#{(rand*999999999).to_i}"
21
21
  objid = opts[:id] || "the#{divid}"
22
22
 
data/config/routes.rb CHANGED
@@ -3,13 +3,11 @@ Rails.application.routes.draw do |map|
3
3
  mount_at = Framey::Engine.config.mount_at
4
4
 
5
5
  match mount_at => 'framey/videos#index'
6
-
6
+
7
7
  map.resources :videos, :only => [ :index, :show, :new],
8
8
  :controller => "framey/videos",
9
9
  :path_prefix => mount_at,
10
10
  :name_prefix => "framey_"
11
11
  post "/framey/callback" => "framey/videos#callback"
12
12
 
13
-
14
-
15
13
  end
data/lib/api.rb CHANGED
@@ -25,7 +25,7 @@ module Framey
25
25
  def self.make_request(method,url,params={})
26
26
  timestamp, signature = self.sign
27
27
 
28
- params = params.merge({:time_stamp => timestamp, :signature => signature, :api_key => Framey.api_key})
28
+ params = params.merge({:time_stamp => timestamp, :signature => signature, :api_key => Framey::API_KEY})
29
29
  res = begin
30
30
  HTTParty.send(method,Framey::API_HOST + url,{:query => params})
31
31
  rescue SocketError => e
data/lib/engine.rb CHANGED
@@ -8,7 +8,7 @@ module Framey
8
8
 
9
9
  # Config defaults
10
10
  config.video_factory_name = "default factory name"
11
- config.mount_at = '/'
11
+ config.mount_at = '/framey'
12
12
 
13
13
  # Load rake tasks
14
14
  rake_tasks do
@@ -2,7 +2,7 @@ module Framey
2
2
  class Engine < Rails::Engine
3
3
 
4
4
  config.mount_at = '/framey'
5
- config.video_factory_name = 'Factory Name'
5
+ config.video_factory_name = 'Framey Factory'
6
6
 
7
7
  end
8
8
 
@@ -11,4 +11,6 @@ module Framey
11
11
  API_KEY = "API_KEY_VALUE"
12
12
  SECRET = "API_SECRET_VALUE"
13
13
  API_TIMEOUT = 15
14
+ MAX_TIME = 30
14
15
  end
16
+
@@ -1,8 +1,4 @@
1
1
  namespace :framey do
2
-
3
- desc "example gem rake task"
4
- task :report => :environment do
5
- puts "you just ran the example gem rake task"
6
- end
2
+
7
3
 
8
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: framey
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-06 00:00:00.000000000Z
12
+ date: 2011-09-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &2156150860 !ruby/object:Gem::Requirement
16
+ requirement: &2161364280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156150860
24
+ version_requirements: *2161364280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: will_paginate
27
- requirement: &2156148300 !ruby/object:Gem::Requirement
27
+ requirement: &2161362860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156148300
35
+ version_requirements: *2161362860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &2156147600 !ruby/object:Gem::Requirement
38
+ requirement: &2161361840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,13 +43,13 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2156147600
46
+ version_requirements: *2161361840
47
47
  description: TO DO
48
48
  email: david@qlabs.com
49
49
  executables: []
50
50
  extensions: []
51
51
  extra_rdoc_files:
52
- - README.rdoc
52
+ - README.md
53
53
  files:
54
54
  - app/controllers/framey/videos_controller.rb
55
55
  - app/helpers/application_helper.rb
@@ -77,7 +77,7 @@ files:
77
77
  - public/player.swf
78
78
  - public/recorder.swf
79
79
  - public/stylesheets/framey.css
80
- - README.rdoc
80
+ - README.md
81
81
  homepage: http://framey.com
82
82
  licenses: []
83
83
  post_install_message:
data/README.rdoc DELETED
@@ -1,56 +0,0 @@
1
- == Overview
2
-
3
- One of the things I was most looking forward to in rails 3 was the plugin / engine architecture. Recently, I sat down to figure out how to create my first engine and package it up as a gem and it took me awhile of time just to get the structure of the engine setup. It's missing a lot of the "rails" you get in a normal rails app.
4
-
5
- In it's simplest form engines are quite easy, however for a full-featured engine (such as creating a forum) there are a lot of extras that you're going to want. These are the things I spent time figuring out that I've packaged up into an easy starting point:
6
-
7
- * Namespacing models & controllers so they don't collide with those in the main app
8
- * Creating a global layout within your engine that gets nested within your application layout
9
- * Generating migrations from your engine
10
- * Creating an "acts_as_[plugin]" declaration for use inside your main app's models
11
- * Easy plugin configuration file editable from main app directory
12
- * Rake tasks within engine
13
- * Writing tests for models complete with fixtures
14
- * Serving static assets within engine
15
- * Packaging and distributing as a gem
16
- * Code is here - I've created an engine stub that has all the things setup for you already. I want to see a lot more rails 3 engines get created, I hope this helps! I'd love to hear feedback from you if you try it out.
17
-
18
- Here’s how you get ready to create your first gem by using this starting point:
19
-
20
- * git clone http://github.com/krschacht/rails_3_engine_demo.git
21
- * cd rails_3_engine_demo
22
- * [edit test/database.yml]
23
- * rake test (this will initialize your test database and run the basic test suite)
24
-
25
- Now, create a plain rails app and set it up to use your engine. FYI: even though the engine's directory is 'rails_3_engine_demo', internally the engine is named 'cheese'
26
-
27
- * cd .. [ this is to take you outside the 'rails_3_engine_demo' directory that was created above' ]
28
- * rails new demo_app_to_use_gem -d mysql
29
- * cd demo_app_to_use_gem
30
- * [edit config/database.yml]
31
- * [edit Gemfile, add line: ] gem ‘cheese’, :path => "../rails_3_engine_demo"
32
- * rails generate cheese
33
- * [examine config/initializers/cheese.rb to see basic config parameters]
34
- * rake db:create
35
- * rake db:migrate (one of the migrations that you'll see run came from the engine)
36
-
37
- You have now setup a empty rails app that utilizes your engine. To test out the functionality, startup the demo app’s webserver:
38
-
39
- * rails server
40
- * Then visit: http://localhost:3000/cheese (this is a controller included within the engine)
41
- * Watch the server logs as you're viewing this page and you'll see some output which is coming from an application before_filter which is executing from inside the engine (in lib/application_controller.rb)
42
- * rake cheese:report (this is a a rake task that is included inside the engine)
43
-
44
- Lastly, let's package up your engine as a real gem. You’ll need Jeweler installed for this:
45
-
46
- * cd rails_3_engine_demo
47
- * sudo gem install jeweler
48
- * rake gemspec
49
- * rake build
50
- * rake install (you have now installed your engine as a gem locally)
51
- * [ At this point if you wanted your demo app to use your installed gem, edit the Gemfile in your demo app and remove the 'path' option from your gem line. It should look like this: ] gem ‘cheese’
52
- * rake gemcutter:release (this pushes your gem up to Gemcutter, a public gem repository)
53
-
54
- Now you’re ready to start customizing this engine for your own purposes. Do a global find in your engine directory and replace every instance of "cheese" and "Cheese" with your engine name (be sure to preserve capitalization). Likewise, rename every directory and file that’s named "cheese" with your engine name. I should really automate this but I haven’t figured out how to create a rake task that I can run from within the engine directory itself.
55
-
56
- P.S. Special thanks to Chrispy for helping figure out the application_controller includes!