From edf75246aee9c0bf6e9d53c1ad5fda4fb19e8fad Mon Sep 17 00:00:00 2001 From: Peter Weber Date: Fri, 17 May 2019 11:07:36 +0200 Subject: [PATCH] UI: cover art *BETTER: display cover art for ebooks *FIXES: warning from yaml.loader closes #304 Signed-off-by: Peter Weber --- rero_ils/modules/apiharvester/cli.py | 2 +- .../documents/static/js/rero_ils/thumbnail.js | 19 ++++++++- .../rero_ils/brief_view_documents.html | 42 ------------------- .../rero_ils/detailed_view_documents.html | 13 ++++-- rero_ils/modules/ebooks/cli.py | 2 +- .../public-documents-brief-view.component.ts | 4 +- 6 files changed, 31 insertions(+), 51 deletions(-) delete mode 100644 rero_ils/modules/documents/static/templates/rero_ils/brief_view_documents.html diff --git a/rero_ils/modules/apiharvester/cli.py b/rero_ils/modules/apiharvester/cli.py index 400ebebb64..a3467d5f1d 100644 --- a/rero_ils/modules/apiharvester/cli.py +++ b/rero_ils/modules/apiharvester/cli.py @@ -77,7 +77,7 @@ def api_source_config(name, url, mimetype, size, comment, update): @with_appcontext def api_source_config_from_file(configfile, update): """Add or update ApiHarvestConfigs from file.""" - configs = yaml.load(configfile) + configs = yaml.load(configfile, Loader=yaml.FullLoader) for name, values in sorted(configs.items()): url = values.get('url', '') mimetype = values.get('mimetype', '') diff --git a/rero_ils/modules/documents/static/js/rero_ils/thumbnail.js b/rero_ils/modules/documents/static/js/rero_ils/thumbnail.js index 8ff3222fb6..012c67b2f1 100644 --- a/rero_ils/modules/documents/static/js/rero_ils/thumbnail.js +++ b/rero_ils/modules/documents/static/js/rero_ils/thumbnail.js @@ -7,13 +7,16 @@ angular.module('reroThumbnails', []) }; $scope.thumbnail_service_url = undefined; + $scope.$on('thumbnail.init', thumbnailInit); - function thumbnailInit(init, identifiers, type, config) { + function thumbnailInit(init, thumbnailurl, identifiers, type, config) { var thumbnail_service_url = angular.fromJson(config).thumbnail_service_url; $scope.thumbnail_service_url = $sce.trustAsResourceUrl(thumbnail_service_url); $scope.type = type; $scope.identifiers = angular.fromJson(identifiers); + $scope.thumbnail_url = thumbnailurl }; + $scope.$watch( "identifiers", function handleIdentifiers( identifiers ) { @@ -23,6 +26,17 @@ angular.module('reroThumbnails', []) }, true ); + + $scope.$watch( + "thumbnailurl", + function handleThumbnailUrl( thumbnailurl ) { + if(thumbnailurl) { + $scope.thumbnail_url = thumbnailurl; + } + }, + true + ); + function getThumbnailUrl(identifiers) { var isbn = identifiers.isbn; if(isbn) { @@ -42,6 +56,7 @@ angular.module('reroThumbnails', []) }); } } + }]) .directive('iconThumbnail', ['$log', 'gettextCatalog', function($log, gettextCatalog) { return { @@ -55,7 +70,7 @@ angular.module('reroThumbnails', []) ', link: function (scope, element, attrs) { scope.$broadcast( - 'thumbnail.init', attrs.identifiers, attrs.type, attrs.config + 'thumbnail.init', attrs.thumbnailurl, attrs.identifiers, attrs.type, attrs.config ); } }; diff --git a/rero_ils/modules/documents/static/templates/rero_ils/brief_view_documents.html b/rero_ils/modules/documents/static/templates/rero_ils/brief_view_documents.html deleted file mode 100644 index c208884eb7..0000000000 --- a/rero_ils/modules/documents/static/templates/rero_ils/brief_view_documents.html +++ /dev/null @@ -1,42 +0,0 @@ -
- - -
-

{{ record.metadata.title }}

-
- -
    -
  • - {{ author.name }} - {{ author.qualifier ? author.qualifier : '' }} - {{ author.date ? author.date : '' }} - {{ $last ? '' : '; ' }} -
  • -
  • ; …
  • -
- - - {{ record.metadata.is_part_of }} - - -
    -
  • - {{ publisher.place.join(', ') }}: - {{ publisher.name.join(', ') }} - {{ $last ? '' : '; ' }} -
  • -
- - - {{ record.metadata.publicationYear }} - {{ record.metadata.freeFormedPublicationDate }} -
- - {{ status|translate }} -
-
-
-
diff --git a/rero_ils/modules/documents/templates/rero_ils/detailed_view_documents.html b/rero_ils/modules/documents/templates/rero_ils/detailed_view_documents.html index 9aa0740216..dcd3065589 100644 --- a/rero_ils/modules/documents/templates/rero_ils/detailed_view_documents.html +++ b/rero_ils/modules/documents/templates/rero_ils/detailed_view_documents.html @@ -14,15 +14,20 @@ {%- block body %}
- - + {% endif %} + type="{{ record.type }}" + config='{{ {"thumbnail_service_url": config.RERO_ILS_THUMBNAIL_SERVICE_URL} | tojson }}'> +

{{ record.title }}

diff --git a/rero_ils/modules/ebooks/cli.py b/rero_ils/modules/ebooks/cli.py index c7bd25fcc9..eb4b9e9c12 100644 --- a/rero_ils/modules/ebooks/cli.py +++ b/rero_ils/modules/ebooks/cli.py @@ -71,7 +71,7 @@ def add_oai_source_config(name, baseurl, metadataprefix, setspecs, comment, @with_appcontext def init_oai_harvest_config(configfile, update): """Init OAIHarvestConfig.""" - configs = yaml.load(configfile) + configs = yaml.load(configfile, Loader=yaml.FullLoader) for name, values in sorted(configs.items()): baseurl = values['baseurl'] metadataprefix = values.get('metadataprefix', 'marc21') diff --git a/ui/src/app/records/search/brief-view/public-documents-brief-view.component.ts b/ui/src/app/records/search/brief-view/public-documents-brief-view.component.ts index 2d5ec981ec..f0b03a5419 100644 --- a/ui/src/app/records/search/brief-view/public-documents-brief-view.component.ts +++ b/ui/src/app/records/search/brief-view/public-documents-brief-view.component.ts @@ -84,7 +84,9 @@ export class PublicDocumentsBriefViewComponent implements BriefView { if (value !== undefined) { this._record = value; this.coverUrl = `/static/images/icon_${value.metadata.type}.png`; - if (value.metadata.identifiers) { + if (value.metadata.cover_art) { + this.coverUrl = value.metadata.cover_art; + } else if (value.metadata.identifiers) { const isbn = value.metadata.identifiers.isbn; if (isbn) { this.getCover(isbn);