remove embedly
this was used by collections (which no longer exist) Test plan: make sure there are no references to embedly on the account settings page Change-Id: Ia599877523a26560392ca554a2e760930f65deb6 Reviewed-on: https://gerrit.instructure.com/30148 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Cody Cutrer <cody@instructure.com> Product-Review: Cameron Matheson <cameron@instructure.com> QA-Review: Cameron Matheson <cameron@instructure.com>
This commit is contained in:
parent
ae814421e0
commit
62c292fb7b
7
Gemfile
7
Gemfile
|
@ -275,13 +275,6 @@ group :cassandra do
|
|||
gem "canvas_cassandra", path: "gems/canvas_cassandra"
|
||||
end
|
||||
|
||||
group :embedly do
|
||||
gem 'embedly', '1.5.5'
|
||||
gem 'oauth', '0.4.7'
|
||||
gem 'querystring', '0.1.0'
|
||||
gem 'typhoeus', '0.3.3'
|
||||
end
|
||||
|
||||
group :statsd do
|
||||
gem 'statsd-ruby', '1.0.0', :require => 'statsd'
|
||||
end
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<%= fields_for :settings, OpenObject.new(settings) do |f| %>
|
||||
<table style="width: 500px;" class="formtable">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<p><%= t :description, "This plugin integrates with the Embedly service to pre-fill information on collection items. The paid plan returns extra information over the free plan: you can select from multiple images on the page, and it returns the embed information for in-line previewing (playing youtube videos, etc)." %></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= f.blabel :api_key, :en => "Embedly API Key" %></td>
|
||||
<td><%= f.text_field :api_key %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= f.blabel :plan_type, :en => "Embedly plan type" %></td>
|
||||
<td><%= f.select :plan_type, [["Free Plan", "free"], ["Paid Plan", "paid"]] %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2012 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
class Canvas::Embedly < Struct.new(:title, :description, :images, :object_html, :data_type)
|
||||
|
||||
class Image < Struct.new(:url)
|
||||
def as_json(*a)
|
||||
{ 'url' => self.url }
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(url)
|
||||
self.images = []
|
||||
# if embedly returns any kind of error, we return a valid object with
|
||||
# all fields set to null
|
||||
get_data_for(url)
|
||||
end
|
||||
|
||||
MAXWIDTH = 922
|
||||
|
||||
def as_json(*a)
|
||||
{ 'title' => self.title, 'description' => self.description, 'images' => self.images.map { |i| i.as_json(*a) }, 'object_html' => self.object_html, 'data_type' => self.data_type }
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def get_data_for(url)
|
||||
data = get_embedly_data(url)
|
||||
|
||||
return unless data
|
||||
if data.type == "error"
|
||||
ErrorReport.log_error :embedly, :message => "Error from embedly: #{data.inspect}"
|
||||
return
|
||||
end
|
||||
|
||||
self.data_type = data.type
|
||||
self.title = data.title
|
||||
self.description = data.description
|
||||
if data.images
|
||||
self.images = data.images.map { |i| Image.new(i['url']) }
|
||||
elsif data.object && data.object.url
|
||||
self.images = [Image.new(data.url)]
|
||||
elsif data.thumbnail_url
|
||||
self.images = [Image.new(data.thumbnail_url)]
|
||||
end
|
||||
|
||||
if data.object && data.object.html
|
||||
self.object_html = data.object.html
|
||||
elsif data.html
|
||||
self.object_html = data.html
|
||||
end
|
||||
|
||||
# reject non-iframe html embeds
|
||||
if self.object_html.present?
|
||||
doc = Nokogiri::HTML::DocumentFragment.parse(self.object_html)
|
||||
if doc.children.map { |c| c.name.downcase } != ['iframe']
|
||||
self.object_html = nil
|
||||
end
|
||||
end
|
||||
|
||||
@raw_response = data
|
||||
end
|
||||
|
||||
def get_embedly_data(url)
|
||||
return unless settings
|
||||
Bundler.require "embedly"
|
||||
|
||||
data = Canvas.timeout_protection("embedly") do
|
||||
embedly_api = ::Embedly::API.new(:key => settings[:api_key])
|
||||
api_method = settings[:plan_type] == "paid" ? :preview : :oembed
|
||||
embedly_api.send(api_method, {
|
||||
:url => url,
|
||||
:maxwidth => MAXWIDTH,
|
||||
:autoplay => true
|
||||
}).first
|
||||
end
|
||||
end
|
||||
|
||||
def settings
|
||||
@settings ||= PluginSetting.settings_for_plugin(:embedly)
|
||||
end
|
||||
|
||||
def embedly_timeout
|
||||
Setting.get('embedly_request_timeout', 15.seconds.to_s).to_f
|
||||
end
|
||||
end
|
|
@ -224,16 +224,6 @@ Canvas::Plugin.register('assignment_freezer', nil, {
|
|||
:settings => nil
|
||||
})
|
||||
|
||||
Canvas::Plugin.register('embedly', nil, {
|
||||
:name => lambda{ t :name, 'Embedly Integration' },
|
||||
:description => lambda{ t :description, 'Pull Embedly info for Collections' },
|
||||
:website => 'http://embed.ly/',
|
||||
:author => 'Instructure',
|
||||
:author_website => 'http://www.instructure.com',
|
||||
:version => '1.0.0',
|
||||
:settings_partial => 'plugins/embedly_settings',
|
||||
:settings => nil
|
||||
})
|
||||
Canvas::Plugin.register('crocodoc', :previews, {
|
||||
:name => lambda { t :name, 'Crocodoc' },
|
||||
:description => lambda { t :description, 'Enabled Crocodoc as a document preview option' },
|
||||
|
|
Loading…
Reference in New Issue