Skip to content

Commit

Permalink
Merge pull request #1779 from danskernesdigitalebibliotek/DDFBRA-183-…
Browse files Browse the repository at this point in the history
…anonymous-and-logged-in-user-can-try-ebook

DDFBRA-183 - Anonymous and logged in user can try ebook + audiobook
  • Loading branch information
kasperbirch1 authored Dec 12, 2024
2 parents 988f59f + 8b80f8f commit 04b75ef
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 13 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"type": "package",
"package": {
"name": "danskernesdigitalebibliotek/dpl-react",
"version": "2024.50.0",
"version": "0.0.0-dev",
"type": "drupal-library",
"dist": {
"url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/2024.50.0/dist-2024-50-0-971e7c3cbc30ed2ea65d95655b798d67a6aa9d75.zip",
"url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/branch-DDFBRA-183-anonymous-and-logged-in-user-can-try-ebook/dist-ddfbra-183-anonymous-and-logged-in-user-can-try-ebook.zip",
"type": "zip"
},
"require": {
Expand All @@ -56,9 +56,9 @@
"package": {
"name": "danskernesdigitalebibliotek/dpl-design-system",
"type": "drupal-library",
"version": "2024.50.0",
"version": "0.0.0-dev",
"dist": {
"url": "https://github.com/danskernesdigitalebibliotek/dpl-design-system/releases/download/2024.50.0/dist-2024-50-0-fbcaaf96dce9df6ceb2537705578a0f3e882fe08.zip",
"url": "https://github.com/danskernesdigitalebibliotek/dpl-design-system/releases/download/branch-DDFBRA-184-anonymous-and-logged-in-user-can-try-audiobook/dist-ddfbra-184-anonymous-and-logged-in-user-can-try-audiobook.zip",
"type": "zip"
}
}
Expand Down Expand Up @@ -90,8 +90,8 @@
"composer/installers": "1.12.0",
"cweagans/composer-patches": "1.7.3",
"danskernesdigitalebibliotek/cms-api": "*",
"danskernesdigitalebibliotek/dpl-design-system": "2024.50.0",
"danskernesdigitalebibliotek/dpl-react": "2024.50.0",
"danskernesdigitalebibliotek/dpl-design-system": "0.0.0-dev",
"danskernesdigitalebibliotek/dpl-react": "0.0.0-dev",
"danskernesdigitalebibliotek/fbs-client": "*",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"deoliveiralucas/array-keys-case-transform": "^1.1",
Expand Down
12 changes: 7 additions & 5 deletions composer.lock

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

12 changes: 12 additions & 0 deletions web/modules/custom/dpl_react/dpl_react.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ recommendation:
- dpl_react/base
- dpl_react/handler

reader:
remote: https://github.com/danskernesdigitalebibliotek/dpl-react
license:
name: GNU AFFERO
url: https://github.com/danskernesdigitalebibliotek/dpl-react/blob/master/LICENSE
gpl-compatible: true
js:
/libraries/dpl-react/Reader.js: {}
dependencies:
- dpl_react/base
- dpl_react/handler

opening-hours:
remote: https://github.com/danskernesdigitalebibliotek/dpl-react
license:
Expand Down
9 changes: 9 additions & 0 deletions web/modules/custom/dpl_react_apps/dpl_react_apps.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ dpl_react_apps.work:
_controller: '\Drupal\dpl_react_apps\Controller\DplReactAppsController::work'
requirements:
_permission: 'access content'

dpl_react_apps.reader:
path: '/reader'
defaults:
_controller: '\Drupal\dpl_react_apps\Controller\DplReactAppsController::reader'
requirements:
_permission: 'access content'
options:
no_cache: true
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\dpl_react_apps\Controller;

use Drupal\Core\Block\BlockManagerInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Render\RendererInterface;
use Drupal\dpl_fbs\Form\FbsSettingsForm;
Expand All @@ -13,8 +14,10 @@
use Drupal\dpl_library_agency\GeneralSettings;
use Drupal\dpl_library_agency\ReservationSettings;
use Symfony\Component\DependencyInjection\ContainerInterface;
use function Safe\json_encode as json_encode;
use function Safe\preg_replace as preg_replace;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use function Safe\json_encode;
use function Safe\preg_replace;

/**
* Controller for rendering full page DPL React apps.
Expand All @@ -31,6 +34,7 @@ public function __construct(
protected BranchRepositoryInterface $branchRepository,
protected DplInstantLoanSettings $instantLoanSettings,
protected GeneralSettings $generalSettings,
protected BlockManagerInterface $blockManager,
) {}

/**
Expand All @@ -49,6 +53,7 @@ public static function create(ContainerInterface $container) {
$container->get('dpl_library_agency.branch.repository'),
$container->get('dpl_instant_loan.settings'),
$container->get('dpl_library_agency.general_settings'),
$container->get('plugin.manager.block'),
);
}

Expand Down Expand Up @@ -274,6 +279,7 @@ public function work(string $wid): array {
'already-reserved-text' => $this->t('Already reserved', [], ['context' => 'Work Page']),
'approve-reservation-text' => $this->t('Approve reservation', [], ['context' => 'Work Page']),
'audience-text' => $this->t('Audience', [], ['context' => 'Work Page']),
'audiobook-text' => $this->t('Audiobook', [], ['context' => 'Work Page']),
'blocked-button-text' => $this->t('Blocked', [], ['context' => 'Work Page']),
'cannot-see-review-text' => $this->t('The review is not accessible', [], ['context' => 'Work Page']),
'cant-reserve-text' => $this->t("Can't be reserved", [], ['context' => 'Work Page']),
Expand Down Expand Up @@ -309,6 +315,7 @@ public function work(string $wid): array {
'details-list-parts-text' => $this->t('Contents', [], ['context' => 'Work Page']),
'details-of-the-material-text' => $this->t('Details of the material', [], ['context' => 'Work Page']),
'details-text' => $this->t('Details', [], ['context' => 'Work Page']),
'ebook-text' => $this->t('Ebook', [], ['context' => 'Work Page']),
'edition-text' => $this->t('Edition', [], ['context' => 'Work Page']),
'editions-text' => $this->t('Editions', [], ['context' => 'Work Page']),
'expand-more-text' => $this->t('Expand more', [], ['context' => 'Work Page']),
Expand Down Expand Up @@ -380,6 +387,7 @@ public function work(string $wid): array {
'online-limit-month-audiobook-info-text' => $this->t('You have borrowed @count out of @limit possible audio-books this month', [], ['context' => 'Work Page']),
'online-limit-month-ebook-info-text' => $this->t('You have borrowed @count out of @limit possible e-books this month', [], ['context' => 'Work Page']),
'online-limit-month-info-text' => $this->t('You have borrowed @count out of @limit possible e-books this month', [], ['context' => 'Work Page']),
'online-material-teaser-text' => $this->t('Try @materialType', [], ['context' => 'Work Page']),
'open-order-not-owned-ill-loc-text' => $this->t('Your material has been ordered from another library', [], ['context' => 'Work Page']),
'open-order-owned-own-catalogue-text' => $this->t('Item available, order through the librarys catalogue', [], ['context' => 'Work Page']),
'open-order-owned-wrong-mediumtype-text' => $this->t('Item available but medium type not accepted', [], ['context' => 'Work Page']),
Expand All @@ -405,6 +413,8 @@ public function work(string $wid): array {
'order-digital-copy-title-text' => $this->t('Order digital copy', [], ['context' => 'Work Page']),
'original-title-text' => $this->t('Original title', [], ['context' => 'Work Page']),
'periodical-select-edition-text' => $this->t('Edition', [], ['context' => 'Work Page']),
'player-modal-close-button-text' => $this->t('Close', [], ['context' => 'Work Page']),
'player-modal-description-text' => $this->t('Modal for player', [], ['context' => 'Work Page']),
'periodical-select-year-text' => $this->t('Year', [], ['context' => 'Work Page']),
'periodikum-select-week-text' => $this->t('Week', [], ['context' => 'Work Page']),
'periodikum-select-year-text' => $this->t('Year', [], ['context' => 'Work Page']),
Expand Down Expand Up @@ -500,4 +510,38 @@ public static function externalApiBaseUrls(): array {
return $urls;
}

/**
* Render the Reader React app.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The HTTP request containing query parameters.
*
* @return mixed[]
* Render array with the Reader app block.
*
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*/
public function reader(Request $request): array {
$identifier = $request->query->get('identifier');
$orderid = $request->query->get('orderid');

if (!$identifier && !$orderid) {
throw new BadRequestHttpException('Either identifier or orderid must be provided.');
}

$data = [
'identifier' => $identifier ?? NULL,
'orderid' => $orderid ?? NULL,
];

$app = [
'#theme' => 'dpl_react_app',
'#name' => 'reader',
'#data' => $data,
];

return $app;

}

}
26 changes: 26 additions & 0 deletions web/themes/custom/novel/templates/layout/page--reader.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{#
/**
* @file
* Theme override to display a /reader page.
*
* This template is a variant of the page.html.twig template used for rendering
* the user registration page. As we don't want the user accessing things outside
* of the registration form, we have removed the header and footer regions for this
* page.
*
* Available variables:
*
* General utility variables:
* - base_path: The base URL path of the Drupal installation. Will usually be
* "/" unless you have installed Drupal in a sub-directory.
* - is_front: A flag indicating if the current page is the front page.
* - logged_in: A flag indicating if the user is registered and signed in.
* - is_admin: A flag indicating if the user has permission to access
* administration pages.
*
*/
#}

<main id="main-content" role="main">
{{ page.content }}
</main>

0 comments on commit 04b75ef

Please sign in to comment.