Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader / Player #1859

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
988f59f
This branch will consolidate all features related to Reader/Player fu…
kasperbirch1 Dec 12, 2024
c1530a6
Add translations for `Reader`
kasperbirch1 Nov 20, 2024
eabab18
Implement `Reader` App on Route "/reader"
kasperbirch1 Nov 22, 2024
c6c0a38
Add translations (`Player`)
kasperbirch1 Nov 26, 2024
3f8ddf8
Rename `orderid` to lowercase
kasperbirch1 Nov 27, 2024
663b7d3
Clean up translations + Fix typos
kasperbirch1 Dec 5, 2024
96f95ff
### Clean up `page--reader`
kasperbirch1 Dec 5, 2024
d1e04b0
Clean up `Reader` react app
kasperbirch1 Dec 6, 2024
212424a
Use `BadRequestHttpException` for `Reader` app
kasperbirch1 Dec 6, 2024
8b80f8f
Delete this commit (Only for demo purposes)
kasperbirch1 Dec 6, 2024
04b75ef
Merge pull request #1779 from danskernesdigitalebibliotek/DDFBRA-183-…
kasperbirch1 Dec 12, 2024
7aaad2c
Corrected translation from 'Go to eReolen' to 'Go to Material'
kasperbirch1 Dec 2, 2024
f212ac2
Delete this commit (Only for demo purposes)
kasperbirch1 Dec 6, 2024
9fa7ede
Merge pull request #1814 from danskernesdigitalebibliotek/DDFBRA-236-…
kasperbirch1 Dec 12, 2024
5fab43d
Add translations as part of PR #1573
kasperbirch1 Dec 11, 2024
a9cfed1
Delete this commit (Only for demo purposes)
kasperbirch1 Dec 11, 2024
b8bada9
Merge pull request #1854 from danskernesdigitalebibliotek/DDFBRA-251-…
kasperbirch1 Dec 12, 2024
4e0beea
Cleanup leftovers from when `reader` route was a block
kasperbirch1 Dec 13, 2024
1f3fbaf
Delete this commit (Only for demo purposes)
kasperbirch1 Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-reader-player-feature/dist-reader-player-feature.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-reader-player-feature/dist-reader-player-feature.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.

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>
Loading