Skip to content

Commit

Permalink
Remove Delicious from Canvas
Browse files Browse the repository at this point in the history
refs AE-142
flag=none

test plan:
- mutating allowed_services via UI still works
- mutating user services via UI still works

Change-Id: I2231b76c2dc9443ea94ecf0afbdfc842ecc8c497
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/313727
Reviewed-by: Aaron Ogata <[email protected]>
Reviewed-by: Jacob Burroughs <[email protected]>
Tested-by: Service Cloud Jenkins <[email protected]>
Migration-Review: Jacob Burroughs <[email protected]>
QA-Review: Isaac Moore <[email protected]>
Product-Review: Isaac Moore <[email protected]>
  • Loading branch information
rmsy committed Mar 22, 2023
1 parent cddc38a commit e1b397c
Show file tree
Hide file tree
Showing 18 changed files with 119 additions and 218 deletions.
3 changes: 0 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
#
#
class UsersController < ApplicationController
include Delicious
include SearchHelper
include SectionTabHelper
include I18nUtilities
Expand Down Expand Up @@ -1280,8 +1279,6 @@ def create_user_service
password = params[:user_service][:password]
service = ServiceCredentials.new(user_name, password)
case params[:user_service][:service]
when "delicious"
delicious_get_last_posted(service)
when "diigo"
Diigo::Connection.diigo_get_bookmarks(service)
when "skype"
Expand Down
29 changes: 5 additions & 24 deletions app/models/bookmark_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
require "nokogiri"

class BookmarkService < UserService
include Delicious

def post_bookmark(opts)
url = opts[:url]
return unless url
Expand All @@ -32,10 +30,10 @@ def post_bookmark(opts)
tags = opts[:tags] || ["instructure"]
begin
case service
when "delicious"
delicious_post_bookmark(self, url, title, description, tags)
when "diigo"
Diigo::Connection.diigo_post_bookmark(self, url, title, description, tags)
else
raise "Unknown bookmark service: #{service}"
end
rescue
# Should probably save the data to try again if it fails... at least one more try
Expand All @@ -54,7 +52,7 @@ def find_bookmarks(query)
bookmark_search(self, query)
end

def bookmark_search(service, query)
def bookmark_search(service, _query)
bookmarks = []
case service.service
when "diigo"
Expand All @@ -71,25 +69,8 @@ def bookmark_search(service, query)
else
bookmarks
end
when "delicious"
# This needs to be rewritten with new API and moved into a gem. (Currently not working and no way to test without updating the API.)
url = "https://api.del.icio.us/v1/posts/all?tag=#{query}"
http, request = delicious_generate_request(url, "GET", service.service_user_name, service.decrypted_password)
response = http.request(request)
case response
when Net::HTTPSuccess
document = Nokogiri::XML(response.body)
document.search("/posts/post").each do |post|
bookmarks << {
title: post["description"],
url: post["href"],
description: post["description"],
tags: post["tags"]
}
end
else
response.error!
end
else
raise "Unknown bookmark service: #{service}"
end
bookmarks
end
Expand Down
16 changes: 1 addition & 15 deletions app/models/user_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ def self.register_from_params(user, params = {})
opts[:secret] = nil
opts[:service] = params[:service]
case opts[:service]
when "delicious"
opts[:service_domain] = "delicious.com"
opts[:protocol] = "http-auth"
opts[:service_user_id] = params[:user_name]
opts[:service_user_name] = params[:user_name]
opts[:password] = params[:password]
when "diigo"
opts[:service_domain] = "diigo.com"
opts[:protocol] = "http-auth"
Expand Down Expand Up @@ -164,8 +158,6 @@ def self.sort_position(type)
3
when CommunicationChannel::TYPE_TWITTER
4
when "delicious"
7
when "diigo"
8
else
Expand All @@ -179,8 +171,6 @@ def self.short_description(type)
t "#user_service.descriptions.google_drive", "Students can use Google Drive to collaborate on group projects. Google Drive allows for real-time collaborative editing of documents, spreadsheets and presentations."
when CommunicationChannel::TYPE_TWITTER
t "#user_service.descriptions.twitter", "Twitter is a great resource for out-of-class communication."
when "delicious"
t "#user_service.descriptions.delicious", "Delicious is a collaborative link-sharing tool. You can tag any page on the Internet for later reference. You can also link to other users' Delicious accounts to share links of similar interest."
when "diigo"
t "#user_service.descriptions.diigo", "Diigo is a collaborative link-sharing tool. You can tag any page on the Internet for later reference. You can also link to other users' Diigo accounts to share links of similar interest."
when "skype"
Expand All @@ -198,8 +188,6 @@ def self.registration_url(type)
"http://calendar.google.com"
when CommunicationChannel::TYPE_TWITTER
"http://twitter.com/signup"
when "delicious"
"http://delicious.com/"
when "diigo"
"https://www.diigo.com/sign-up"
when "skype"
Expand All @@ -217,8 +205,6 @@ def service_user_link
"http://calendar.google.com"
when CommunicationChannel::TYPE_TWITTER
"http://www.twitter.com/#{service_user_name}"
when "delicious"
"http://www.delicious.com/#{service_user_name}"
when "diigo"
"http://www.diigo.com/user/#{service_user_name}"
when "skype"
Expand All @@ -232,7 +218,7 @@ def self.service_type(type)
case type
when "google_docs", "google_drive"
"DocumentService"
when "delicious", "diigo"
when "diigo"
"BookmarkService"
else
"UserService"
Expand Down
7 changes: 0 additions & 7 deletions app/stylesheets/bundles/profile_show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,6 @@
}
}

.delicious {
background-position: -129px 0;
&:hover {
background-position: -129px -32px;
}
}

.diigo {
background-position: -160px 0;
&:hover {
Expand Down
34 changes: 0 additions & 34 deletions app/views/profile/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -362,40 +362,6 @@ TEXT
</div>
</div>
</li>
<li id="unregistered_service_delicious" class="service" style="<%= hidden if services.include?("delicious") || !service_enabled?(:delicious) %>">
<a href="#" class="btn btn-small"><%= image_tag "delicious_icon.png", :alt => '' %> <%= t('links.delicious', "Delicious") %></a>
<div style="display: none; text-align: <%= direction('left') %>;" class="content" title="<%= t('titles.delicious_login', "Delicious Login") %>" id="unregistered_service_delicious_dialog">
<div>
<%= image_tag "delicious.png", :style => "float: #{direction('left')}; padding-#{ direction('right') }: 5px;", :alt => '' %>
<div style="font-size: 1.2em; font-weight: bold;"><%= t('headers.delicious_login', "Delicious Login") %></div>
<%= t(:delicious_description, <<~TEXT)
Delicious is a tool that lets you store and share your bookmarks with others.
Canvas's rich content editor will let you search your Delicious tags
to easily link from within Canvas to other resources you find useful.
TEXT
%>
<div class="clear"></div>
</div>
<div style="font-size: 1.0em; margin-top: 10px;">
<%= form_for :user_service, :url => profile_create_user_service_url, :html => {:class => "create_user_service_form"}, :namespace => "delicious" do |f| %>
<%= f.hidden_field :service, :value => "delicious" %>
<table role="presentation" class="formtable">
<tr>
<td><%= f.blabel :user_name, :en => "User Name" %></td>
<td><%= f.text_field :user_name, :style => "width: 150px;" %></td>
</tr><tr>
<td><%= f.blabel :password, :en => "Password" %></td>
<td><%= f.password_field :password, :style => "width: 150px;" %></td>
</tr><tr>
<td colspan="2">
<button type="submit" class="btn btn-primary"><%= t('buttons.save_login', "Save Login") %></button>
</td>
</tr>
</table>
<% end %>
</div>
</div>
</li>
<li id="unregistered_service_diigo" class="service" style="<%= hidden if services.include?("diigo") || !feature_and_service_enabled?(:diigo) %>">
<a href="#" class="btn btn-small"><%= image_tag "diigo_icon.png", :alt => '' %> <%= t('links.diigo', "Diigo") %></a>
<div style="display: none; text-align: <%= direction('left') %>;" class="content" title="<%= t('titles.diigo_login', "Diigo Login") %>" id="unregistered_service_diigo_dialog">
Expand Down
27 changes: 27 additions & 0 deletions db/migrate/20230321155031_remove_delicious.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

#
# Copyright (C) 2023 - present 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 RemoveDelicious < ActiveRecord::Migration[7.0]
tag :predeploy

def up
DataFixup::RemoveDelicious.run
end
end
5 changes: 0 additions & 5 deletions lib/account_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ def self.allowable_services
description: "",
expose_to_ui: :service
},
delicious: {
name: I18n.t("Delicious"),
description: "",
expose_to_ui: :service
},
diigo: {
name: I18n.t("Diigo"),
description: "",
Expand Down
30 changes: 30 additions & 0 deletions lib/data_fixup/remove_delicious.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

#
# Copyright (C) 2023 - present 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/>.

module DataFixup::RemoveDelicious
def self.run
# Remove delicious from allowed services
Account.where("allowed_services LIKE ?", "%delicious%")
.in_batches
.update_all("allowed_services = regexp_replace(allowed_services, '(^[+-]?delicious,)|(,[+-]?delicious)', '', 'g')")

# Delete delicious user service configurations
UserService.where(service: "delicious").in_batches.delete_all
end
end
72 changes: 0 additions & 72 deletions lib/delicious.rb

This file was deleted.

Binary file removed public/images/delicious.48px.gif
Binary file not shown.
Binary file removed public/images/delicious.png
Binary file not shown.
Binary file removed public/images/delicious_icon.png
Binary file not shown.
Binary file removed public/images/delicious_small_icon.png
Binary file not shown.
54 changes: 54 additions & 0 deletions spec/lib/data_fixup/remove_delicious_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

# Copyright (C) 2023 - present 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/>.

describe DataFixup::RemoveDelicious do
it "removes delicious when it is at the start" do
account = account_model(allowed_services: "+delicious,-skype")
described_class.run

expect(account.reload.allowed_services).to eq "-skype"
end

it "removes delicious when it is at the end" do
account = account_model(allowed_services: "+skype,-delicious")
described_class.run

expect(account.reload.allowed_services).to eq "+skype"
end

it "removes delicious when it is in the middle" do
account = account_model(allowed_services: "+skype,-delicious,+diigo")
described_class.run

expect(account.reload.allowed_services).to eq "+skype,+diigo"
end

it "removes delicious when it is present multiple times" do
account = account_model(allowed_services: "+delicious,+skype,-delicious,+diigo,+delicious")
described_class.run

expect(account.reload.allowed_services).to eq "+skype,+diigo"
end

it "deletes any configured delicious user services" do
user_service = user_service_model(service: "delicious")
described_class.run

expect { user_service.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end
Loading

0 comments on commit e1b397c

Please sign in to comment.