kaltura_box 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/README.md +35 -30
- data/lib/kaltura_box/entry/class_methods.rb +12 -2
- data/lib/kaltura_box/version.rb +1 -1
- data/lib/kaltura_box/view_helpers.rb +183 -0
- data/spec/entry_spec.rb +17 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d44f8e7050f6616d5a0c25d0f7034d7202626d62
|
4
|
+
data.tar.gz: e59fe2243068728b9834fae5039dede567b0eebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a117d402b73e95d5f80f2fa8b4fb3027c05adea7398d3f776ad9103a47f12d6799e93b9aec67eafd2fd3bc15e4f1ad90760986c52596463eb04f11db325ba4ec
|
7
|
+
data.tar.gz: 91103a76ea91a232a8dff5ddfa1add70b789f28f0c9b4ced07b4ba077d918898b76e876094537cc78d04e431ca14f816d3149784018797f1c90b47f7c1b89555
|
data/README.md
CHANGED
@@ -20,36 +20,41 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
23
|
+
```ruby
|
24
|
+
# For the Entry class
|
25
|
+
class Video < ActiveRecord::Base
|
26
|
+
include KalturaBox::Entry
|
27
|
+
end
|
28
|
+
|
29
|
+
# Category class
|
30
|
+
class Category < ActiveRecord::Base
|
31
|
+
include KalturaBox::Category
|
32
|
+
end
|
33
|
+
|
34
|
+
# Entry listing from Kaltura
|
35
|
+
Video.video_list
|
36
|
+
|
37
|
+
# Search
|
38
|
+
Video.video_list("search string here")
|
39
|
+
|
40
|
+
# Create videos based on Kaltura entries
|
41
|
+
Video.update_all_videos!
|
42
|
+
|
43
|
+
# Retrieve a kaltura entry
|
44
|
+
video = Video.new(entry_id: "0_7ivwzhbh")
|
45
|
+
video.get
|
46
|
+
|
47
|
+
# Tagging
|
48
|
+
video.set_tags = "noodles, food, yummy" # Create a new set of tags
|
49
|
+
video.add_tags = "rice, fruits" # Add more tags to the existing tag list
|
50
|
+
video.add_tag("bacon") # Add a single tag
|
51
|
+
video.get_tags # Retrieve tags
|
52
|
+
|
53
|
+
# Kaltura Metadata
|
54
|
+
video.set(name: "bla", description: "blablabla")
|
55
|
+
video.set_name = "bla"
|
56
|
+
video.set_description = "blablabla"
|
57
|
+
```
|
53
58
|
|
54
59
|
## Contributing
|
55
60
|
|
@@ -22,10 +22,20 @@ module KalturaBox
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def video_list
|
25
|
+
def video_list(keyword = nil)
|
26
26
|
client = KalturaBox::Client.update_session
|
27
27
|
media = Kaltura::KalturaMediaService.new(client)
|
28
|
-
|
28
|
+
|
29
|
+
if keyword
|
30
|
+
filter = Kaltura::KalturaBaseEntryFilter.new
|
31
|
+
filter.free_text = keyword
|
32
|
+
media_list = media.list(filter)
|
33
|
+
else
|
34
|
+
media_list = media.list
|
35
|
+
end
|
36
|
+
|
37
|
+
return nil unless media_list.objects
|
38
|
+
|
29
39
|
media_list.objects.reject { |v| v.media_type != 1 }
|
30
40
|
end
|
31
41
|
|
data/lib/kaltura_box/version.rb
CHANGED
@@ -0,0 +1,183 @@
|
|
1
|
+
module KalturaBox
|
2
|
+
|
3
|
+
##
|
4
|
+
# The ViewHelpers module provides extensions to Rails ActionView class that allow interactions with Kaltura on rails view layer.
|
5
|
+
#
|
6
|
+
# @author Patrick Robertson
|
7
|
+
##
|
8
|
+
module ViewHelpers
|
9
|
+
# default UI Conf ID of the kdp player
|
10
|
+
DEFAULT_KPLAYER = '1339442'
|
11
|
+
# default embedded KDP width
|
12
|
+
PLAYER_WIDTH = '400'
|
13
|
+
# default embedded KDP height
|
14
|
+
PLAYER_HEIGHT = '330'
|
15
|
+
|
16
|
+
##
|
17
|
+
# Convienence to include SWFObject and the required Kaltura upload embed javascripts.
|
18
|
+
##
|
19
|
+
def include_kaltura_fu(*args)
|
20
|
+
content = javascript_include_tag('kaltura_upload')
|
21
|
+
content << javascript_include_tag('//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js')
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Returns the thumbnail of the provided Kaltura Entry.
|
26
|
+
# @param [String] entry_id Kaltura entry_id
|
27
|
+
# @param [Hash] options the options for the thumbnail parameters.
|
28
|
+
# @option options [Array] :size ([]) an array of [width,height]
|
29
|
+
# @option options [String] :second (nil) the second of the Kaltura entry that the thumbnail should be of.
|
30
|
+
#
|
31
|
+
# @return [String] Image tag of the thumbnail resource.
|
32
|
+
##
|
33
|
+
def kaltura_thumbnail(entry_id,options={})
|
34
|
+
options[:size] ||= []
|
35
|
+
size_parameters = ""
|
36
|
+
seconds_parameter = ""
|
37
|
+
|
38
|
+
unless options[:size].empty?
|
39
|
+
size_parameters = "/width/#{options[:size].first}/height/" +
|
40
|
+
"#{options[:size].last}"
|
41
|
+
else
|
42
|
+
# if the thumbnail width and height are defined in the config,
|
43
|
+
# use it, assuming it wasn't locally overriden
|
44
|
+
if KalturaBox.config.thumb_width && KalturaBox.config.thumb_height
|
45
|
+
size_parameters = "/width/#{KalturaBox.config.thumb_width}/height/" +
|
46
|
+
"#{KalturaBox.config.thumb_height}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
unless options[:second].nil?
|
51
|
+
seconds_parameter = "/vid_sec/#{options[:second]}"
|
52
|
+
else
|
53
|
+
seconds_parameter = "/vid_sec/5"
|
54
|
+
end
|
55
|
+
|
56
|
+
image_tag("#{KalturaBox.config.service_url}/p/#{KalturaBox.config.partner_id}" +
|
57
|
+
"/thumbnail/entry_id/#{entry_id}" +
|
58
|
+
seconds_parameter +
|
59
|
+
size_parameters)
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Returns the code needed to embed a KDPv3 player.
|
64
|
+
#
|
65
|
+
# @param [String] entry_id Kaltura entry_id
|
66
|
+
# @param [Hash] options the embed code options.
|
67
|
+
# @option options [String] :div_id ('kplayer') The div element that the flash object will be inserted into.
|
68
|
+
# @option options [Array] :size ([]) The [width,wight] of the player.
|
69
|
+
# @option options [Boolean] :use_url (false) flag to determine whether entry_id is an entry or a URL of a flash file.
|
70
|
+
# @option options [String] :player_conf_id (KalturaBox.config(:player_conf_id)) A UI Conf ID to override the player with.
|
71
|
+
#
|
72
|
+
# @return [String] returns a string representation of the html/javascript necessary to play a Kaltura entry.
|
73
|
+
##
|
74
|
+
def kaltura_player_embed(entry_id,options={})
|
75
|
+
player_conf_parameter = "/uiconf_id/"
|
76
|
+
options[:div_id] ||= "kplayer"
|
77
|
+
options[:size] ||= []
|
78
|
+
options[:use_url] ||= false
|
79
|
+
width = PLAYER_WIDTH
|
80
|
+
height = PLAYER_HEIGHT
|
81
|
+
source_type = "entryId"
|
82
|
+
|
83
|
+
unless options[:size].empty?
|
84
|
+
width = options[:size].first
|
85
|
+
height = options[:size].last
|
86
|
+
end
|
87
|
+
|
88
|
+
if options[:use_url] == true
|
89
|
+
source_type = "url"
|
90
|
+
end
|
91
|
+
|
92
|
+
unless options[:player_conf_id].nil?
|
93
|
+
player_conf_parameter += "#{options[:player_conf_id]}"
|
94
|
+
else
|
95
|
+
unless KalturaBox.config.player_conf_id.nil?
|
96
|
+
player_conf_parameter += "#{KalturaBox.config.player_conf_id}"
|
97
|
+
else
|
98
|
+
player_conf_parameter += "#{DEFAULT_KPLAYER}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
"<div id=\"#{options[:div_id]}\"></div>
|
103
|
+
<script type=\"text/javascript\">
|
104
|
+
var params= {
|
105
|
+
allowscriptaccess: \"always\",
|
106
|
+
allownetworking: \"all\",
|
107
|
+
allowfullscreen: \"true\",
|
108
|
+
wmode: \"opaque\",
|
109
|
+
bgcolor: \"#000000\"
|
110
|
+
};
|
111
|
+
var flashVars = {};
|
112
|
+
flashVars.sourceType = \"#{source_type}\";
|
113
|
+
flashVars.entryId = \"#{entry_id}\";
|
114
|
+
flashVars.emptyF = \"onKdpEmpty\";
|
115
|
+
flashVars.readyF = \"onKdpReady\";
|
116
|
+
|
117
|
+
var attributes = {
|
118
|
+
id: \"#{options[:div_id]}\",
|
119
|
+
name: \"#{options[:div_id]}\"
|
120
|
+
};
|
121
|
+
|
122
|
+
swfobject.embedSWF(\"#{KalturaBox.config.service_url}/kwidget/wid/_#{KalturaBox.config.partner_id}" + player_conf_parameter + "\",\"#{options[:div_id]}\",\"#{width}\",\"#{height}\",\"10.0.0\",\"http://ttv.mit.edu/swfs/expressinstall.swf\",flashVars,params,attributes);
|
123
|
+
</script>".html_safe
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Returns the html/javascript necessary for a KSU widget.
|
128
|
+
#
|
129
|
+
# @param [Hash] options
|
130
|
+
# @option options [String] :div_id ('uploader') div that the flash object will be inserted into.
|
131
|
+
##
|
132
|
+
def kaltura_upload_embed(options={})
|
133
|
+
client = KalturaBox::Client.update_session
|
134
|
+
options[:div_id] ||="uploader"
|
135
|
+
"<div id=\"#{options[:div_id]}\"></div>
|
136
|
+
<script type=\"text/javascript\">
|
137
|
+
|
138
|
+
var params = {
|
139
|
+
allowScriptAccess: \"always\",
|
140
|
+
allowNetworking: \"all\",
|
141
|
+
wmode: \"transparent\"
|
142
|
+
};
|
143
|
+
var attributes = {
|
144
|
+
id: \"uploader\",
|
145
|
+
name: \"KUpload\"
|
146
|
+
};
|
147
|
+
var flashVars = {
|
148
|
+
uid: \"ANONYMOUS\",
|
149
|
+
partnerId: \"#{KalturaBox.config.partner_id}\",
|
150
|
+
subPId: \"#{KalturaBox.config.partner_id}00\",
|
151
|
+
entryId: \"-1\",
|
152
|
+
ks: \"#{client.session_key}\",
|
153
|
+
uiConfId: '4211621',
|
154
|
+
jsDelegate: \"delegate\",
|
155
|
+
maxFileSize: \"999999999\",
|
156
|
+
maxTotalSize: \"999999999\"
|
157
|
+
};
|
158
|
+
|
159
|
+
swfobject.embedSWF(\"#{KalturaBox.config.service_url}/kupload/ui_conf_id/4211621\", \"uploader\", \"160\", \"26\", \"9.0.0\", \"expressInstall.swf\", flashVars, params,attributes);
|
160
|
+
|
161
|
+
</script>".html_safe
|
162
|
+
end
|
163
|
+
|
164
|
+
##
|
165
|
+
# Creates a link_to tag that seeks to a certain time on a KDPv3 player.
|
166
|
+
#
|
167
|
+
# @param [String] content The text in the link tag.
|
168
|
+
# @param [Integer] seek_time The time in seconds to seek the player to.
|
169
|
+
# @param [Hash] options
|
170
|
+
#
|
171
|
+
# @option options [String] :div_id ('kplayer') The div of the KDP player.
|
172
|
+
##
|
173
|
+
def kaltura_seek_link(content,seek_time,options={})
|
174
|
+
options[:div_id] ||= "kplayer"
|
175
|
+
|
176
|
+
options[:onclick] = "$(#{options[:div_id]}).get(0).sendNotification('doSeek',#{seek_time});window.scrollTo(0,0);return false;"
|
177
|
+
options.delete(:div_id)
|
178
|
+
link_to(content,"#", options)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
end
|
data/spec/entry_spec.rb
CHANGED
@@ -15,6 +15,23 @@ describe "KalturaBox::Entry" do
|
|
15
15
|
|
16
16
|
context "video_list" do
|
17
17
|
it { expect(videos.class).to eq Array }
|
18
|
+
|
19
|
+
describe "searching" do
|
20
|
+
|
21
|
+
context "valid search" do
|
22
|
+
it "returns an array" do
|
23
|
+
expect(Video.video_list("education").class).to eq Array
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "invalid search" do
|
28
|
+
it "returns nil" do
|
29
|
+
expect(Video.video_list("blabla")).to be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
18
35
|
end
|
19
36
|
|
20
37
|
context "update all videos" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaltura_box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shinn Chong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kaltura-ruby-client
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/kaltura_box/entry/metadata/class_and_instance_methods.rb
|
125
125
|
- lib/kaltura_box/entry/metadata/class_methods.rb
|
126
126
|
- lib/kaltura_box/version.rb
|
127
|
+
- lib/kaltura_box/view_helpers.rb
|
127
128
|
- spec/api_spec.rb
|
128
129
|
- spec/category_spec.rb
|
129
130
|
- spec/entry_spec.rb
|