Added vue handling the information from lubimy czytac to fetch information about the books and fill in the form automatically.
This commit is contained in:
@@ -9,9 +9,12 @@ use App\Repository\BookRepository;
|
||||
use App\Repository\FileRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Techtube\Bookinfo\BookFinder;
|
||||
use Techtube\Bookinfo\DataParser;
|
||||
|
||||
#[Route('/book')]
|
||||
class BookController extends AbstractController
|
||||
@@ -34,12 +37,20 @@ class BookController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$bookRepository->add($book, true);
|
||||
|
||||
$cover = $request->files->get('book')['cover'];
|
||||
if ($cover) {
|
||||
$cover->move(
|
||||
$this->getParameter('book_covers'),
|
||||
'cover_' . $book->getId() . '.' . $cover->guessClientExtension()
|
||||
$bookRequest = $request->request->all('book');
|
||||
if (!empty($bookRequest['cover_url'])) {
|
||||
file_put_contents(
|
||||
$this->getParameter('book_covers') . 'cover_' . $book->getId() . '.jpg',
|
||||
file_get_contents($bookRequest['cover_url'])
|
||||
);
|
||||
} else {
|
||||
$cover = $request->files->get('book')['cover'];
|
||||
if ($cover) {
|
||||
$cover->move(
|
||||
$this->getParameter('book_covers'),
|
||||
'cover_' . $book->getId() . '.' . $cover->guessClientExtension()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$ebook = $request->files->get('book')['ebook'];
|
||||
@@ -59,6 +70,20 @@ class BookController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/search/{phrase}', name: 'app_book_search', methods: ['GET'])]
|
||||
public function search(string $phrase): JsonResponse
|
||||
{
|
||||
$bookFinder = new BookFinder();
|
||||
return new JsonResponse($bookFinder->search($phrase));
|
||||
}
|
||||
|
||||
#[Route('/info/{urlInBase64}', name: 'app_book_info', methods: ['GET'])]
|
||||
public function info(string $urlInBase64): JsonResponse
|
||||
{
|
||||
$bookFinder = new BookFinder();
|
||||
return new JsonResponse($bookFinder->byUrl(base64_decode($urlInBase64)));
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_book_show', methods: ['GET'])]
|
||||
public function show(Book $book): Response
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user