aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front/controller/admin/MetadataController.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-11-12 13:11:07 +0100
committerArthurHoaro <arthur@hoa.ro>2020-11-12 13:11:07 +0100
commitaf50eba28a7bd286de4c8c9ee6dc5216b915d149 (patch)
treeffa30a9358e82d27be75d8fc5e57f3c8820dc6d3 /application/front/controller/admin/MetadataController.php
parentb6f678a5a1d15acf284ebcec16c905e976671ce1 (diff)
parent1409f1c89a7ca01456ae2dcd6357d296e2b99f5a (diff)
downloadShaarli-af50eba28a7bd286de4c8c9ee6dc5216b915d149.tar.gz
Shaarli-af50eba28a7bd286de4c8c9ee6dc5216b915d149.tar.zst
Shaarli-af50eba28a7bd286de4c8c9ee6dc5216b915d149.zip
Merge tag 'v0.12.1' into latestlatest
v0.12.1
Diffstat (limited to 'application/front/controller/admin/MetadataController.php')
-rw-r--r--application/front/controller/admin/MetadataController.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/application/front/controller/admin/MetadataController.php b/application/front/controller/admin/MetadataController.php
new file mode 100644
index 00000000..ff845944
--- /dev/null
+++ b/application/front/controller/admin/MetadataController.php
@@ -0,0 +1,29 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Front\Controller\Admin;
6
7use Slim\Http\Request;
8use Slim\Http\Response;
9
10/**
11 * Controller used to retrieve/update bookmark's metadata.
12 */
13class MetadataController extends ShaarliAdminController
14{
15 /**
16 * GET /admin/metadata/{url} - Attempt to retrieve the bookmark title from provided URL.
17 */
18 public function ajaxRetrieveTitle(Request $request, Response $response): Response
19 {
20 $url = $request->getParam('url');
21
22 // Only try to extract metadata from URL with HTTP(s) scheme
23 if (!empty($url) && strpos(get_url_scheme($url) ?: '', 'http') !== false) {
24 return $response->withJson($this->container->metadataRetriever->retrieve($url));
25 }
26
27 return $response->withJson([]);
28 }
29}