[PLUGINS] Fixed oEmbed dependents to use Embed

This commit is contained in:
Miguel Dantas 2019-07-06 17:26:15 +01:00 committed by Diogo Cordeiro
parent 2a2b3f72fb
commit b25632ebc4
8 changed files with 22 additions and 21 deletions

View File

@ -1 +1 @@
Depends on the oEmbed plugin (Oembed). Depends on the Embed plugin.

View File

@ -48,7 +48,7 @@ if (!defined('STATUSNET')) {
class BookmarkforurlAction extends Action class BookmarkforurlAction extends Action
{ {
protected $url = null; protected $url = null;
protected $oembed = null; protected $embed = null;
protected $thumbnail = null; protected $thumbnail = null;
protected $title = null; protected $title = null;
@ -89,9 +89,9 @@ class BookmarkforurlAction extends Action
if ($f instanceof File) { if ($f instanceof File) {
// FIXME: Use some File metadata Event instead // FIXME: Use some File metadata Event instead
$this->oembed = File_oembed::getKV('file_id', $f->id); $this->embed = File_embed::getKV('file_id', $f->id);
if ($this->oembed instanceof File_oembed) { if ($this->embed instanceof File_embed) {
$this->title = $this->oembed->title; $this->title = $this->embed->title;
} }
$this->thumbnail = File_thumbnail::getKV('file_id', $f->id); $this->thumbnail = File_thumbnail::getKV('file_id', $f->id);
} }

View File

@ -36,7 +36,7 @@ defined('GNUSOCIAL') || die();
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class EmbedAction extends Action class OEmbedAction extends Action
{ {
protected function handle() protected function handle()
{ {
@ -48,7 +48,7 @@ class EmbedAction extends Action
if (substr(strtolower($url), 0, mb_strlen($root_url)) !== strtolower($root_url)) { if (substr(strtolower($url), 0, mb_strlen($root_url)) !== strtolower($root_url)) {
// TRANS: Error message displaying attachments. %s is the site's base 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)); $path = substr($url, strlen($root_url));
@ -87,7 +87,8 @@ class EmbedAction extends Action
// maybe add thumbnail // maybe add thumbnail
foreach ($notice->attachments() as $attachment) { foreach ($notice->attachments() as $attachment) {
if (!$attachment instanceof File) { 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; continue;
} }
try { try {

View File

@ -28,12 +28,12 @@
defined('GNUSOCIAL') || die(); 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: * Blacklisted hosts will use an alternate lookup method:
* - Twitpic * - Twitpic
* *
* Whitelisted hosts will use known oEmbed API endpoints: * Whitelisted hosts will use known embed API endpoints:
* - Flickr, YFrog * - Flickr, YFrog
* *
* Sites that provide discovery links will use them directly; a bug * 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 * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class oEmbedHelper class EmbedHelper
{ {
protected static $apiMap = array( protected static $apiMap = array(
'flickr.com' => 'https://www.flickr.com/services/oembed/', 'flickr.com' => 'https://www.flickr.com/services/oembed/',

View File

@ -56,7 +56,7 @@ class LinkPreviewPlugin extends Plugin
if ($user && common_config('attachments', 'process_links')) { if ($user && common_config('attachments', 'process_links')) {
$action->script($this->path('js/linkpreview.js')); $action->script($this->path('js/linkpreview.js'));
$data = json_encode(array( $data = json_encode(array(
'api' => common_local_url('oembedproxy'), 'api' => common_local_url('embedproxy'),
'width' => common_config('attachments', 'thumbwidth'), 'width' => common_config('attachments', 'thumbwidth'),
'height' => common_config('attachments', 'thumbheight'), 'height' => common_config('attachments', 'thumbheight'),
)); ));

View File

@ -1,6 +1,6 @@
The LinkPreview plugin adds a UI for previewing thumbnails from links. 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 Installation
============ ============
@ -15,7 +15,7 @@ thumbheight: The height of the link preview
Example Example
======= =======
addPlugin('Oembed'); // Dependency addPlugin('Embed'); // Dependency
$config['attachments']['process_links'] = true; $config['attachments']['process_links'] = true;
$config['attachments']['thumbwidth'] = 42; $config['attachments']['thumbwidth'] = 42;
$config['attachments']['thumbheight'] = 42; $config['attachments']['thumbheight'] = 42;

View File

@ -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 * 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. * handlers, or the noembed.com offsite proxy service as configured.
* *
* @category oEmbed * @category embed
* @package StatusNet * @package StatusNet
* @author Brion Vibber <brion@status.net> * @author Brion Vibber <brion@status.net>
* @copyright 2010 StatusNet, Inc. * @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
*/ */
class OembedproxyAction extends OembedAction class OEmbedproxyAction extends OEmbedAction
{ {
function handle() function handle()
{ {
// Trigger short error responses; not a human-readable web page. // Trigger short error responses; not a human-readable web page.
GNUsocial::setApi(true); 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'); $token = $this->trimmed('token');
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given. // 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'); $params['maxheight'] = $this->arg('maxheight');
} }
$data = oEmbedHelper::getObject($url, $params); $data = EmbedHelper::getObject($url, $params);
$this->init_document('json'); $this->init_document('json');
print json_encode($data); print json_encode($data);

View File

@ -8,7 +8,7 @@ class StoreRemoteMediaPlugin extends Plugin
{ {
const PLUGIN_VERSION = '2.0.0'; 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 // WARNING, these are _regexps_ (slashes added later). Always escape your dots and end your strings
public $domain_whitelist = [ public $domain_whitelist = [
// hostname => service provider // hostname => service provider