Skip to content

Commit

Permalink
Merge pull request #229 from biblioverse/opds
Browse files Browse the repository at this point in the history
OPDS Server
  • Loading branch information
SergioMendolia authored Dec 10, 2024
2 parents c03ce41 + 34a6ffd commit 268a1c8
Showing 27 changed files with 1,018 additions and 99 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
"guzzlehttp/guzzle": "^7.8",
"jms/serializer": "^3.30",
"kiwilan/php-ebook": "^3.0",
"kiwilan/php-opds": "^2.1",
"knplabs/knp-menu-bundle": "^3.2",
"knplabs/knp-paginator-bundle": "^6.2",
"liip/imagine-bundle": "^2.10",
136 changes: 135 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/packages/acseo_typesense.yaml
Original file line number Diff line number Diff line change
@@ -51,5 +51,5 @@ acseo_typesense:
books_autocomplete:
finder_parameters:
query_by: title,serie,extension,authors,tags,summary
limit: 16
limit: 100
num_typos: 2
7 changes: 7 additions & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
@@ -23,6 +23,13 @@ security:
pattern: ^/kobo
custom_authenticators:
- App\Security\KoboAccessTokenAuthenticator
opds:
lazy: true
stateless: true
pattern: ^/opds/
access_token:
token_handler: App\Security\OpdsTokenHandler
token_extractors: App\Security\OpdsTokenExtractor
main:
lazy: true
remember_me:
6 changes: 3 additions & 3 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -82,10 +82,10 @@ services:
app.display_mode_subscriber:
class: App\EventSubscriber\DisplayModeSubscriber

App\Controller\OPDS\OpdsController:
arguments:
$bookFinder: '@typesense.specificfinder.books.books_autocomplete'

App\Service\BookSearch:
arguments:
$autocompleteBookFinder: '@typesense.specificfinder.books.books_autocomplete'

App\Twig\Components\Search:
arguments:
33 changes: 33 additions & 0 deletions migrations/Version20241208200901.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241208200901 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add opds access tokens';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE opds_access (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, token VARCHAR(255) NOT NULL, INDEX IDX_1F8403F8A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE opds_access ADD CONSTRAINT FK_1F8403F8A76ED395 FOREIGN KEY (user_id) REFERENCES `user` (id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE opds_access DROP FOREIGN KEY FK_1F8403F8A76ED395');
$this->addSql('DROP TABLE opds_access');
}
}
8 changes: 4 additions & 4 deletions src/Controller/Kobo/KoboDeviceController.php
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public function index(KoboDeviceRepository $koboDeviceRepository): Response
}

return $this->render('kobodevice_user/index.html.twig', [
'kobos' => $koboDeviceRepository->findAllByUser($this->getUser()),
'kobos' => $koboDeviceRepository->findAll(),
]);
}

@@ -59,7 +59,7 @@ public function new(Request $request, EntityManagerInterface $entityManager): Re
$entityManager->persist($koboDevice);
$entityManager->flush();

return $this->redirectToRoute('app_kobodevice_user_index', [], Response::HTTP_SEE_OTHER);
return $this->redirect($request->headers->get('referer') ?? '/');
}

return $this->render('kobodevice_user/new.html.twig', [
@@ -81,7 +81,7 @@ public function edit(Request $request, KoboDevice $koboDevice, EntityManagerInte
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();

return $this->redirectToRoute('app_kobodevice_user_index', [], Response::HTTP_SEE_OTHER);
return $this->redirect($request->headers->get('referer') ?? '/');
}

return $this->render('kobodevice_user/edit.html.twig', [
@@ -102,7 +102,7 @@ public function delete(Request $request, KoboDevice $koboDevice, EntityManagerIn
$entityManager->flush();
}

return $this->redirectToRoute('app_kobodevice_user_index', [], Response::HTTP_SEE_OTHER);
return $this->redirectToRoute('app_dashboard', [], Response::HTTP_SEE_OTHER);
}

#[Route('/logs', name: 'app_kobodevice_user_logs', methods: ['GET'])]
Loading

0 comments on commit 268a1c8

Please sign in to comment.