Skip to content

Commit

Permalink
UI: cover art
Browse files Browse the repository at this point in the history
*BETTER: display cover art for ebooks
*FIXES: warning from yaml.loader  closes #304

Signed-off-by: Peter Weber <peter.weber@rero.ch>
  • Loading branch information
rerowep authored and jma committed May 23, 2019
1 parent bed0e48 commit edf7524
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 51 deletions.
2 changes: 1 addition & 1 deletion rero_ils/modules/apiharvester/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand Down
19 changes: 17 additions & 2 deletions rero_ils/modules/documents/static/js/rero_ils/thumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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) {
Expand All @@ -42,6 +56,7 @@ angular.module('reroThumbnails', [])
});
}
}

}])
.directive('iconThumbnail', ['$log', 'gettextCatalog', function($log, gettextCatalog) {
return {
Expand All @@ -55,7 +70,7 @@ angular.module('reroThumbnails', [])
</figure>',
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
);
}
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
{%- block body %}
<header class="row">
<div id="thumbnail" class="col-sm-2 col-md-1 d-flex justify-content-start">
<icon-thumbnail class="thumb"
<icon-thumbnail class="thumb"
{% if record.cover_art %}
thumbnailurl='{{ (record.cover_art) }}'
{% else %}
thumbnailurl=""
{% if record.identifiers %}
identifiers='{{ (record.identifiers or {})|tojson }}'
{% else %}
identifiers=""
{% endif %}
type="{{ record.type }}"
config='{{ {"thumbnail_service_url": config.RERO_ILS_THUMBNAIL_SERVICE_URL} | tojson }}'>
</icon-thumbnail>
{% endif %}
type="{{ record.type }}"
config='{{ {"thumbnail_service_url": config.RERO_ILS_THUMBNAIL_SERVICE_URL} | tojson }}'>
</icon-thumbnail>
</div>
<h1 class="col-sm-10 col-md-11">{{ record.title }}</h1>
</header>
Expand Down
2 changes: 1 addition & 1 deletion rero_ils/modules/ebooks/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit edf7524

Please sign in to comment.