From fad316151c282b2383fae751f7ca45373f1f26ed Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 24 Aug 2015 12:27:17 +0200 Subject: Integrate graby --- src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 11 ++++++++--- src/Wallabag/ApiBundle/Resources/config/services.yml | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 02a6de64..d5579de4 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -147,11 +147,16 @@ class WallabagRestController extends Controller { $url = $request->request->get('url'); - $content = Extractor::extract($url); + $content = $this->get('wallabag_core.graby')->fetchContent($url); + $entry = new Entry($this->getUser()); $entry->setUrl($url); - $entry->setTitle($request->request->get('title') ?: $content->getTitle()); - $entry->setContent($content->getBody()); + $entry->setTitle($request->request->get('title') ?: $content['title']); + $entry->setContent($content['html']); + $entry->setMimetype($content['content_type']); + if (isset($content['open_graph']['og_image'])) { + $entry->setPreviewPicture($content['open_graph']['og_image']); + } $tags = $request->request->get('tags', ''); if (!empty($tags)) { diff --git a/src/Wallabag/ApiBundle/Resources/config/services.yml b/src/Wallabag/ApiBundle/Resources/config/services.yml index 6854a444..9ab4f3d1 100644 --- a/src/Wallabag/ApiBundle/Resources/config/services.yml +++ b/src/Wallabag/ApiBundle/Resources/config/services.yml @@ -10,3 +10,6 @@ services: tags: - { name: monolog.logger, channel: wsse } arguments: ['@security.context', '@security.authentication.manager', '@logger'] + + wallabag_core.graby: + class: Graby\Graby -- cgit v1.2.3 From a1413a3da9e845a0f2e00e73069f5363864367bd Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 24 Aug 2015 12:35:02 +0200 Subject: CS --- src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index d5579de4..9ca008bf 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -8,7 +8,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; -use Wallabag\CoreBundle\Service\Extractor; use Hateoas\Configuration\Route; use Hateoas\Representation\Factory\PagerfantaFactory; -- cgit v1.2.3 From d13de40db6fe5a006eb050908450b7adf3fcbf6c Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 24 Aug 2015 19:52:31 +0200 Subject: Update url from graby --- src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 9ca008bf..7452c82a 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -149,7 +149,7 @@ class WallabagRestController extends Controller $content = $this->get('wallabag_core.graby')->fetchContent($url); $entry = new Entry($this->getUser()); - $entry->setUrl($url); + $entry->setUrl($content['url'] ?: $url); $entry->setTitle($request->request->get('title') ?: $content['title']); $entry->setContent($content['html']); $entry->setMimetype($content['content_type']); -- cgit v1.2.3 From 558d9aabab7e01c2e2b506aa362c70a568b953aa Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 10 Sep 2015 21:57:25 +0200 Subject: Move fetching content in a separate class --- .../ApiBundle/Controller/WallabagRestController.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 7452c82a..349229f3 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -146,16 +146,10 @@ class WallabagRestController extends Controller { $url = $request->request->get('url'); - $content = $this->get('wallabag_core.graby')->fetchContent($url); - - $entry = new Entry($this->getUser()); - $entry->setUrl($content['url'] ?: $url); - $entry->setTitle($request->request->get('title') ?: $content['title']); - $entry->setContent($content['html']); - $entry->setMimetype($content['content_type']); - if (isset($content['open_graph']['og_image'])) { - $entry->setPreviewPicture($content['open_graph']['og_image']); - } + $entry = $this->get('wallabag_core.content_proxy')->updateEntry( + new Entry($this->getUser()), + $url + ); $tags = $request->request->get('tags', ''); if (!empty($tags)) { -- cgit v1.2.3 From f1e29e69cb0ba5a0f05190c62e7a4afd43d03436 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 10 Sep 2015 22:00:53 +0200 Subject: CS --- src/Wallabag/ApiBundle/Resources/config/services.yml | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Resources/config/services.yml b/src/Wallabag/ApiBundle/Resources/config/services.yml index 9ab4f3d1..6854a444 100644 --- a/src/Wallabag/ApiBundle/Resources/config/services.yml +++ b/src/Wallabag/ApiBundle/Resources/config/services.yml @@ -10,6 +10,3 @@ services: tags: - { name: monolog.logger, channel: wsse } arguments: ['@security.context', '@security.authentication.manager', '@logger'] - - wallabag_core.graby: - class: Graby\Graby -- cgit v1.2.3