4cf3564d28
- There is a new standalone script (metadata.js) which requests a new controller to get bookmark metadata and fill the form async - This feature is enabled with the new setting: general.enable_async_metadata (enabled by default) - general.retrieve_description is now enabled by default - A small rotating loader animation has a been added to bookmark inputs when metadata is being retrieved (default template) - Custom JS htmlentities has been removed and mathiasbynens/he library is used instead Fixes #1563
29 lines
798 B
PHP
29 lines
798 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shaarli\Front\Controller\Admin;
|
|
|
|
use Slim\Http\Request;
|
|
use Slim\Http\Response;
|
|
|
|
/**
|
|
* Controller used to retrieve/update bookmark's metadata.
|
|
*/
|
|
class MetadataController extends ShaarliAdminController
|
|
{
|
|
/**
|
|
* GET /admin/metadata/{url} - Attempt to retrieve the bookmark title from provided URL.
|
|
*/
|
|
public function ajaxRetrieveTitle(Request $request, Response $response): Response
|
|
{
|
|
$url = $request->getParam('url');
|
|
|
|
// Only try to extract metadata from URL with HTTP(s) scheme
|
|
if (!empty($url) && strpos(get_url_scheme($url) ?: '', 'http') !== false) {
|
|
return $response->withJson($this->container->metadataRetriever->retrieve($url));
|
|
}
|
|
|
|
return $response->withJson([]);
|
|
}
|
|
}
|