Skip to content

Commit

Permalink
Merge pull request #1859 from danskernesdigitalebibliotek/reader-play…
Browse files Browse the repository at this point in the history
…er-feature

Reader / Player
  • Loading branch information
kasperbirch1 authored Jan 22, 2025
2 parents 6a5623b + fe25985 commit 18dfa0c
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 15 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": "2025.4.0",
"version": "0.0.0-dev",
"type": "drupal-library",
"dist": {
"url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/2025.4.0/dist-2025-4-0-851fc5159c4be5f290bdac88e85ad118ebf66698.zip",
"url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/branch-develop/dist-develop.zip",
"type": "zip"
},
"require": {
Expand All @@ -56,9 +56,9 @@
"package": {
"name": "danskernesdigitalebibliotek/dpl-design-system",
"type": "drupal-library",
"version": "2025.4.0",
"version": "0.0.0-dev",
"dist": {
"url": "https://github.com/danskernesdigitalebibliotek/dpl-design-system/releases/download/2025.4.0/dist-2025-4-0-d4f21c986e88e25924a6c2fe87db1a39199ef649.zip",
"url": "https://github.com/danskernesdigitalebibliotek/dpl-design-system/releases/download/branch-develop/dist-develop.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": "2025.4.0",
"danskernesdigitalebibliotek/dpl-react": "2025.4.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.

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public function build() {
"expiration-warning-days-before-config" => $generalSettings->get('expiration_warning_days_before_config') ?? GeneralSettings::EXPIRATION_WARNING_DAYS_BEFORE_CONFIG,

// Urls.
'ereolen-my-page-url' => dpl_react_apps_format_app_url($generalSettings->get('ereolen_my_page_url'), GeneralSettings::EREOLEN_MY_PAGE_URL),
'material-overdue-url' => Url::fromRoute('dpl_loans.list', [], ['absolute' => TRUE])->toString(),

// Texts.
Expand Down
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
2 changes: 1 addition & 1 deletion web/modules/custom/dpl_react_apps/dpl_react_apps.module
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function dpl_react_apps_texts(): array {
'material-by-author' => t("By", [], ['context' => 'Global']),
'material-details-close-modal-aria-label' => t('Close material details modal', [], ['context' => 'Global']),
'material-details-digital-due-date-label' => t("Expires", [], ['context' => 'Global']),
'material-details-go-to-ereolen' => t("Go to eReolen", [], ['context' => 'Global']),
'material-details-go-to-material' => t('Go to material', [], ['context' => 'Global']),
'material-details-link-to-page-with-fees' => t('Read more about fees', [], ['context' => 'Global']),
'material-details-loan-date-label' => t('Loan date', [], ['context' => 'Global']),
'material-details-material-number-label' => t('Material Item Number', [], ['context' => 'Global']),
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 @@ -13,8 +13,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 Down Expand Up @@ -274,6 +276,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 +312,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 @@ -379,7 +383,10 @@ public function work(string $wid): array {
'ok-button-text' => $this->t('Ok', [], ['context' => 'Work Page']),
'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-material-player-text' => $this->t('Listen to @materialType', [], ['context' => 'Work Page']),
'online-material-reader-text' => $this->t('Read @materialType', [], ['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 +412,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 +509,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 18dfa0c

Please sign in to comment.