From b25632ebc40d61000561508257be3cac89189e9e Mon Sep 17 00:00:00 2001 From: Miguel Dantas Date: Sat, 6 Jul 2019 17:26:15 +0100 Subject: [PATCH] [PLUGINS] Fixed oEmbed dependents to use Embed --- plugins/Bookmark/README | 2 +- plugins/Bookmark/actions/bookmarkforurl.php | 8 ++++---- plugins/Embed/actions/oembed.php | 7 ++++--- plugins/Embed/lib/embedhelper.php | 6 +++--- plugins/LinkPreview/LinkPreviewPlugin.php | 2 +- plugins/LinkPreview/README | 4 ++-- plugins/LinkPreview/actions/oembedproxy.php | 12 ++++++------ plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php | 2 +- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/plugins/Bookmark/README b/plugins/Bookmark/README index e853760544..c77cba9c0a 100644 --- a/plugins/Bookmark/README +++ b/plugins/Bookmark/README @@ -1 +1 @@ -Depends on the oEmbed plugin (Oembed). +Depends on the Embed plugin. diff --git a/plugins/Bookmark/actions/bookmarkforurl.php b/plugins/Bookmark/actions/bookmarkforurl.php index f4393dd193..d6027991da 100644 --- a/plugins/Bookmark/actions/bookmarkforurl.php +++ b/plugins/Bookmark/actions/bookmarkforurl.php @@ -48,7 +48,7 @@ if (!defined('STATUSNET')) { class BookmarkforurlAction extends Action { protected $url = null; - protected $oembed = null; + protected $embed = null; protected $thumbnail = null; protected $title = null; @@ -89,9 +89,9 @@ class BookmarkforurlAction extends Action if ($f instanceof File) { // FIXME: Use some File metadata Event instead - $this->oembed = File_oembed::getKV('file_id', $f->id); - if ($this->oembed instanceof File_oembed) { - $this->title = $this->oembed->title; + $this->embed = File_embed::getKV('file_id', $f->id); + if ($this->embed instanceof File_embed) { + $this->title = $this->embed->title; } $this->thumbnail = File_thumbnail::getKV('file_id', $f->id); } diff --git a/plugins/Embed/actions/oembed.php b/plugins/Embed/actions/oembed.php index 1d4276a325..14a8a51a5f 100644 --- a/plugins/Embed/actions/oembed.php +++ b/plugins/Embed/actions/oembed.php @@ -36,7 +36,7 @@ defined('GNUSOCIAL') || die(); * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class EmbedAction extends Action +class OEmbedAction extends Action { protected function handle() { @@ -48,7 +48,7 @@ class EmbedAction extends Action if (substr(strtolower($url), 0, mb_strlen($root_url)) !== strtolower($root_url)) { // TRANS: Error message displaying attachments. %s is the site's base URL. - throw new ClientException(sprintf(_('oEmbed data will only be provided for %s URLs.'), $root_url)); + throw new ClientException(sprintf(_('Embed data will only be provided for %s URLs.'), $root_url)); } $path = substr($url, strlen($root_url)); @@ -87,7 +87,8 @@ class EmbedAction extends Action // maybe add thumbnail foreach ($notice->attachments() as $attachment) { if (!$attachment instanceof File) { - common_debug('ATTACHMENTS array entry from notice id=='._ve($notice->getID()).' is something else than a File dataobject: '._ve($attachment)); + common_debug('ATTACHMENTS array entry from notice id=='._ve($notice->getID()). + ' is something else than a File dataobject: '._ve($attachment)); continue; } try { diff --git a/plugins/Embed/lib/embedhelper.php b/plugins/Embed/lib/embedhelper.php index 2d56f4bab2..683b9ad6ce 100644 --- a/plugins/Embed/lib/embedhelper.php +++ b/plugins/Embed/lib/embedhelper.php @@ -28,12 +28,12 @@ defined('GNUSOCIAL') || die(); /** - * Utility class to wrap basic oEmbed lookups. + * Utility class to wrap basic embed lookups. * * Blacklisted hosts will use an alternate lookup method: * - Twitpic * - * Whitelisted hosts will use known oEmbed API endpoints: + * Whitelisted hosts will use known embed API endpoints: * - Flickr, YFrog * * Sites that provide discovery links will use them directly; a bug @@ -46,7 +46,7 @@ defined('GNUSOCIAL') || die(); * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class oEmbedHelper +class EmbedHelper { protected static $apiMap = array( 'flickr.com' => 'https://www.flickr.com/services/oembed/', diff --git a/plugins/LinkPreview/LinkPreviewPlugin.php b/plugins/LinkPreview/LinkPreviewPlugin.php index 1e735cab8e..0ef43c9e9b 100644 --- a/plugins/LinkPreview/LinkPreviewPlugin.php +++ b/plugins/LinkPreview/LinkPreviewPlugin.php @@ -56,7 +56,7 @@ class LinkPreviewPlugin extends Plugin if ($user && common_config('attachments', 'process_links')) { $action->script($this->path('js/linkpreview.js')); $data = json_encode(array( - 'api' => common_local_url('oembedproxy'), + 'api' => common_local_url('embedproxy'), 'width' => common_config('attachments', 'thumbwidth'), 'height' => common_config('attachments', 'thumbheight'), )); diff --git a/plugins/LinkPreview/README b/plugins/LinkPreview/README index e15c67a1a3..6969d0ba00 100644 --- a/plugins/LinkPreview/README +++ b/plugins/LinkPreview/README @@ -1,6 +1,6 @@ The LinkPreview plugin adds a UI for previewing thumbnails from links. -Note: This plugin depends on the "Oembed" plugin. +Note: This plugin depends on the "Embed" plugin. Installation ============ @@ -15,7 +15,7 @@ thumbheight: The height of the link preview Example ======= -addPlugin('Oembed'); // Dependency +addPlugin('Embed'); // Dependency $config['attachments']['process_links'] = true; $config['attachments']['thumbwidth'] = 42; $config['attachments']['thumbheight'] = 42; diff --git a/plugins/LinkPreview/actions/oembedproxy.php b/plugins/LinkPreview/actions/oembedproxy.php index e36239216a..c313e1d611 100644 --- a/plugins/LinkPreview/actions/oembedproxy.php +++ b/plugins/LinkPreview/actions/oembedproxy.php @@ -31,27 +31,27 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { } /** - * Oembed proxy implementation + * Embed proxy implementation * * This class provides an interface for our JS-side code to pull info on - * links from other sites, using either native oEmbed, our own custom + * links from other sites, using either native embed, our own custom * handlers, or the noembed.com offsite proxy service as configured. * - * @category oEmbed + * @category embed * @package StatusNet * @author Brion Vibber * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ -class OembedproxyAction extends OembedAction +class OEmbedproxyAction extends OEmbedAction { function handle() { // Trigger short error responses; not a human-readable web page. GNUsocial::setApi(true); - // We're not a general oEmbed proxy service; limit to valid sessions. + // We're not a general embed proxy service; limit to valid sessions. $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. @@ -79,7 +79,7 @@ class OembedproxyAction extends OembedAction $params['maxheight'] = $this->arg('maxheight'); } - $data = oEmbedHelper::getObject($url, $params); + $data = EmbedHelper::getObject($url, $params); $this->init_document('json'); print json_encode($data); diff --git a/plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php b/plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php index 582fc5f4e0..7bcb3f3f1b 100644 --- a/plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php +++ b/plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php @@ -8,7 +8,7 @@ class StoreRemoteMediaPlugin extends Plugin { const PLUGIN_VERSION = '2.0.0'; - // settings which can be set in config.php with addPlugin('Oembed', array('param'=>'value', ...)); + // settings which can be set in config.php with addPlugin('Embed', array('param'=>'value', ...)); // WARNING, these are _regexps_ (slashes added later). Always escape your dots and end your strings public $domain_whitelist = [ // hostname => service provider