diff --git a/README.md b/README.md
index e24c2403..037485ff 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
This Gem allows your rails application to access user files from cloud storage.
Currently there are drivers implemented for [Dropbox](http://www.dropbox.com),
[Skydrive](https://skydrive.live.com/), [Google Drive](http://drive.google.com),
-[Box](http://www.box.com), and a server-side directory share.
+[Box](http://www.box.com),[Kaltura](http://www.kaltura.com) and a server-side directory share.
The gem uses [OAuth](http://oauth.net/) to connect to a user's account and
generate a list of single use urls that your application can then use to
@@ -50,7 +50,7 @@ Add `//= require browse_everything` to your application.js
### Adding Providers
In order to connect to a provider like [Dropbox](http://www.dropbox.com),
[Skydrive](https://skydrive.live.com/), [Google Drive](http://drive.google.com), or
-[Box](http://www.box.com), you must provide API keys in _config/browse_everything_providers.yml_. For info on how to edit this file, see [Configuring browse-everything](https://github.com/projecthydra/browse-everything/wiki/Configuring-browse-everything)
+[Box](http://www.box.com), [Kaltura](http://www.kaltura.com), you must provide API keys in _config/browse_everything_providers.yml_. For info on how to edit this file, see [Configuring browse-everything](https://github.com/projecthydra/browse-everything/wiki/Configuring-browse-everything)
### Views
diff --git a/app/controllers/browse_everything_controller.rb b/app/controllers/browse_everything_controller.rb
index c19b7abc..6772d079 100644
--- a/app/controllers/browse_everything_controller.rb
+++ b/app/controllers/browse_everything_controller.rb
@@ -7,6 +7,9 @@ class BrowseEverythingController < ActionController::Base
after_filter {session["#{provider_name}_token"] = provider.token unless provider.nil? }
def index
+ if #{provider_name} == 'kaltura'
+ $current_user = warden.user.email.split("@")[0]
+ end
render :layout => !request.xhr?
end
diff --git a/app/views/browse_everything/_file.html.erb b/app/views/browse_everything/_file.html.erb
index 9620e486..67c07e8a 100644
--- a/app/views/browse_everything/_file.html.erb
+++ b/app/views/browse_everything/_file.html.erb
@@ -26,12 +26,24 @@
<%= check_box_tag(:select_all, "0", false, class: "ev-select-all") if file.container? %>
|
-
- <%= number_to_human_size(file.size).sub(/Bytes/,'bytes') %>
- |
-
- <%= file.type %>
- |
+ <% if provide_name = 'kaltura' %>
+
+ |
+ <% else %>
+
+ <%= number_to_human_size(file.size).sub(/Bytes/,'bytes') %>
+ |
+ <% end %>
+
+ <% if provide_name = 'kaltura' %>
+
+ |
+ <% else %>
+
+ <%= file.type %>
+ |
+ <% end %>
+
<%= file.mtime.strftime('%F %R') %>
|
diff --git a/browse-everything.gemspec b/browse-everything.gemspec
index 32bb7550..50d638b8 100644
--- a/browse-everything.gemspec
+++ b/browse-everything.gemspec
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "bootstrap-sass"
spec.add_dependency "font-awesome-rails"
spec.add_dependency "google-api-client", "~> 0.8.6"
+ spec.add_dependency "kaltura"
spec.add_dependency "httparty"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rspec-rails"
@@ -44,4 +45,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "jasmine", '~> 2.3'
spec.add_development_dependency "coveralls"
spec.add_development_dependency "poltergeist", "~> 1.10"
+ spec.add_development_dependency "rack"
end
diff --git a/lib/browse_everything.rb b/lib/browse_everything.rb
index 92ba0c5d..953a0a72 100644
--- a/lib/browse_everything.rb
+++ b/lib/browse_everything.rb
@@ -15,6 +15,7 @@ module Driver
autoload :SkyDrive, 'browse_everything/driver/sky_drive'
autoload :Box, 'browse_everything/driver/box'
autoload :GoogleDrive, 'browse_everything/driver/google_drive'
+ autoload :Kaltura, 'browse_everything/driver/kaltura'
end
class << self
diff --git a/lib/browse_everything/driver/kaltura.rb b/lib/browse_everything/driver/kaltura.rb
new file mode 100644
index 00000000..a5172aad
--- /dev/null
+++ b/lib/browse_everything/driver/kaltura.rb
@@ -0,0 +1,53 @@
+module BrowseEverything
+ module Driver
+ class Kaltura < Base
+ require 'kaltura'
+
+ def icon
+ 'kaltura'
+ end
+
+ def validate_config
+ unless [:partner_id,:administrator_secret,:service_url].all? { |key| config[key].present? }
+ raise BrowseEverything::InitializationError, "Kaltura driver requires :partner_id, :administrator_secret, and :service_url"
+ end
+ end
+
+ def contents(path='')
+ result = []
+
+ @options = { :filter => { :creatorIdEqual => $current_user } }
+ @session = ::Kaltura::Session.start
+ @@entries = ::Kaltura::MediaEntry.list(@options)
+ @@entries.each do |item|
+ item.location = item.downloadUrl.sub('https:', 'kaltura:')
+ item.mtime = Time.at(item.updatedAt.to_i)
+ result.push(item)
+ end
+ result
+ end
+
+ def link_for(path)
+ correct_path = path.sub('//', 'https://')
+ file_list = @@entries
+ extras = {file_name: ''}
+ file_list.each do |file|
+ if file.downloadUrl == correct_path
+ extras[:file_name] = file.name
+ end
+ end
+ ret = [correct_path, extras]
+ end
+
+ def details(path)
+ byebug
+ contents(path).first
+ end
+
+ def authorized?
+ true
+ end
+
+ end
+ end
+end
diff --git a/lib/generators/browse_everything/templates/browse_everything_providers.yml.example b/lib/generators/browse_everything/templates/browse_everything_providers.yml.example
index 227d5767..3a6d1adc 100644
--- a/lib/generators/browse_everything/templates/browse_everything_providers.yml.example
+++ b/lib/generators/browse_everything/templates/browse_everything_providers.yml.example
@@ -14,3 +14,7 @@
# sky_drive:
# :client_id: YOUR_MS_LIVE_CONNECT_CLIENT_ID
# :client_secret: YOUR_MS_LIVE_CONNECT_CLIENT_SECRET
+# kaltura:
+# :partner_id: YOUR_KLATURA_PARTNER_ID
+# :administrator_secret: YOUR_KALTURA_ADMINSTRATOR_SECRET
+# :service_url: YOUR_SERVICE_URL
diff --git a/spec/fixtures/vcr_cassettes/Kaltura_Session.yml b/spec/fixtures/vcr_cassettes/Kaltura_Session.yml
new file mode 100644
index 00000000..97534763
--- /dev/null
+++ b/spec/fixtures/vcr_cassettes/Kaltura_Session.yml
@@ -0,0 +1,66 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: http://www.kaltura.com/api_v3/?action=start&ks=&partnerId=1&secret=superdupersecret&service=session&type=2
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers: {}
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Date:
+ - Fri, 26 Aug 2011 21:38:40 GMT
+ Server:
+ - Apache
+ Vary:
+ - Accept-Encoding
+ X-Me:
+ - pa-apache3
+ X-Ua-Compatible:
+ - IE=EmulateIE7
+ Content-Length:
+ - '230'
+ Content-Type:
+ - text/xml
+ body:
+ encoding: UTF-8
+ string: thisisavalidsession0.048589944839478
+ http_version: '1.1'
+ recorded_at: Fri, 23 Sep 2016 18:46:02 GMT
+- request:
+ method: get
+ uri: http://www.kaltura.com/api_v3/?action=start&ks=&partnerId=2&secret=superdupersecret&service=session&type=2
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers: {}
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Date:
+ - Fri, 26 Aug 2011 21:38:40 GMT
+ Server:
+ - Apache
+ Vary:
+ - Accept-Encoding
+ X-Me:
+ - pa-apache3
+ X-Ua-Compatible:
+ - IE=EmulateIE7
+ Content-Length:
+ - '227'
+ Content-Type:
+ - text/xml
+ body:
+ encoding: UTF-8
+ string: START_SESSION_ERROR
Error
+ while starting session for partner [2]0.040677070617676
+ http_version: '1.1'
+ recorded_at: Fri, 23 Sep 2016 18:46:02 GMT
+recorded_with: VCR 3.0.3
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 8492c6df..cfb2d959 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -10,6 +10,7 @@
require 'capybara/rspec'
require 'support/rake'
require 'coveralls'
+require 'kaltura'
Coveralls.wear!
EngineCart.load_application!
@@ -64,7 +65,12 @@ def stub_configuration
"sky_drive" => {
client_id: "SkyDriveClientId",
client_secret: "SkyDriveClientSecret"
- }
+ },
+ "kaltura" => {
+ partner_id: "KalturaClientId",
+ administrator_secret: "KalturaAdminSecret",
+ service_url: "KalturaServiceUrl"
+ }
})
end
diff --git a/spec/unit/kaltura_spec.rb b/spec/unit/kaltura_spec.rb
new file mode 100644
index 00000000..333a488f
--- /dev/null
+++ b/spec/unit/kaltura_spec.rb
@@ -0,0 +1,43 @@
+require 'spec_helper'
+
+describe "Kaltura Driver", :vcr => { cassette_name: 'Kaltura_Session', record: :none } do
+
+ context "starting a session", :vcr => { cassette_name: 'Kaltura_Session', record: :none } do
+
+ describe "should properly set and read config values" do
+ before do
+ Kaltura.configure do |config|
+ config.partner_id = 1
+ config.administrator_secret = 'superdupersecret'
+ config.service_url = 'http://www.kaltura.com'
+ end
+ end
+
+ it { Kaltura.config.partner_id.should == 1 }
+ it { Kaltura.config.administrator_secret.should == 'superdupersecret' }
+ it { Kaltura.config.service_url.should == 'http://www.kaltura.com' }
+ end
+
+ describe "should begin a session with proper credentials." do
+ before do
+ Kaltura.configure do |config|
+ config.partner_id = 1
+ config.administrator_secret = 'superdupersecret'
+ config.service_url = 'http://www.kaltura.com'
+ end
+ @session = Kaltura::Session.start
+ end
+
+ it { @session.result.should be_an_instance_of String }
+ it { Kaltura::Session.kaltura_session.should eq(@session.result) }
+ end
+
+ describe "should not begin a session with invalid credentials." do
+ before do
+ Kaltura.configure { |config| config.partner_id = 2 }
+ end
+
+ it { lambda {Kaltura::Session.start}.should raise_error Kaltura::KalturaError }
+ end
+ end
+end