Skip to content

Commit

Permalink
feat: babeltheque
Browse files Browse the repository at this point in the history
Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Mar 13, 2024
1 parent aa30131 commit c650c4d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
9 changes: 8 additions & 1 deletion rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ def _(x):
'https://www.google-analytics.com',
'https://services.test.rero.ch',
'https://services.rero.ch',
'https://cdn.jsdelivr.net'
'https://cdn.jsdelivr.net',
'https://www.babelio.com'
]
},
'content_security_policy_report_uri': None,
Expand Down Expand Up @@ -3984,3 +3985,9 @@ def search_type(field):
}
},
]

# Babeltheque Configuration
# ========================
RERO_ILS_APP_BABELTHEQUE_CONFIG = {
'enabled_views': ['global', 'vs']
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2019-2023 RERO
Copyright (C) 2019-2024 RERO
Copyright (C) 2019-2023 UCLouvain

This program is free software: you can redistribute it and/or modify
Expand All @@ -20,6 +20,8 @@
{%- extends 'rero_ils/page.html' %}
{% from 'rero_ils/macros/macro.html' import div, dict_values, div_list, dl, dl_row, dl_dict, dl_list, div_json %}

{% set isbn = record|get_first_isbn %}

{%- block css %}
{{ super() }}
{{ node_assets('@rero/rero-ils-ui/dist/public-holdings-items', ['styles.*css'], 'css') }}
Expand Down Expand Up @@ -277,6 +279,15 @@ <h3>
</a>
{% endif %}
</div>
{% if viewcode | babeltheque_enabled_view and isbn is not undefined %}
<!-- BABELTHEQUE -->
<input id="BW_id_isbn" class="d-none" value="{{ isbn }}"></input>
<div class="d-flex w-100 mx-5 mt-3">
<div class="flex-fill" id="BW_etiquettes">ETIQUETTES</div>
<div class="flex-fill" id="BW_suggestions">SUGGESTIONS</div>
<div class="flex-fill" id="BW_citations">CITATIONS</div>
</div>
{% endif %}
</div>

{%- block record_body %}
Expand All @@ -293,6 +304,15 @@ <h3>
<i class="fa fa-bars"></i> {{ _('Description') }}
</a>
</li>
{% if viewcode | babeltheque_enabled_view %}
<li class="nav-item">
<a class="nav-link" href="#documents-more-infos" data-toggle="tab"
id="documents-more-infos-tab" title="{{ _('More infos') }}" role="tab"
aria-controls="documents-description" aria-selected="false">
<i class="fa fa-bars"></i> {{ _('More infos') }}
</a>
</li>
{% endif %}
</ul>
</nav>
</header>
Expand Down Expand Up @@ -322,6 +342,15 @@ <h3>
<i class="fa fa-bars"></i> {{ _('Description') }}
</a>
</li>
{% if viewcode | babeltheque_enabled_view %}
<li class="nav-item">
<a class="nav-link" href="#documents-more-infos" data-toggle="tab"
id="documents-more-infos-tab" title="{{ _('More infos') }}" role="tab"
aria-controls="documents-more-infos" aria-selected="false">
<i class="fa fa-bars"></i> {{ _('More infos') }}
</a>
</li>
{% endif %}
</ul>
</nav>
</header>
Expand All @@ -344,6 +373,17 @@ <h3>
<section class="tab-pane container" id="documents-description" role="tabpanel" aria-labelledby="documents-description-tab">
{% include('rero_ils/_documents_description.html') %}
</section>
{% if viewcode | babeltheque_enabled_view %}
<section class="tab-pane container" id="documents-more-infos" role="tabpanel" aria-labelledby="documents-more-infos-tab">
<div class="d-flex flex-column my-2">
<div id="BW_prix_litt">LITT</div>
<div id="BW_critiques">CRIT</div>
<div id="BW_bio_auteur">AUTEUR</div>
<div id="BW_videos">VIDEO</div>
<div id="BW_podcasts">PODCAST</div>
</div>
</section>
{% endif %}
</article>
{% endif %}
</article>
Expand Down Expand Up @@ -372,4 +412,7 @@ <h5 class="d-inline-block">{{ _('Export Formats') }}:</h5>
{%- block javascript %}
{{ super() }}
{{ node_assets('@rero/rero-ils-ui/dist/public-holdings-items', tags='defer') }}
{% if viewcode | babeltheque_enabled_view %}
<script type="text/javascript" src="https://www.babelio.com/bw_330.js"></script>
{% endif %}
{% endblock javascript %}
18 changes: 18 additions & 0 deletions rero_ils/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from flask_babel import gettext as _
from flask_login import current_user
from invenio_records_ui.signals import record_viewed
from jinja2 import Undefined

from rero_ils.modules.collections.api import CollectionsSearch
from rero_ils.modules.entities.api import Entity
Expand Down Expand Up @@ -117,6 +118,23 @@ def doc_item_view_method(pid, record, template=None, **kwargs):
static_folder='static',
)

@blueprint.app_template_filter()
def babeltheque_enabled_view(view):
"""Check if the view is activated for babeltheque."""
enabled_views = current_app.config.get(
'RERO_ILS_APP_BABELTHEQUE_CONFIG', {}).get('enabled_views', [])
return view in enabled_views

@blueprint.app_template_filter()
def get_first_isbn(record):
"""Get first isbn result."""
# ISBN
isbns = [
identified_by.get('value')
for identified_by in record.get('identifiedBy', [])
if identified_by.get('type') == 'bf:Isbn'
]
return isbns[0] if isbns else Undefined

@blueprint.app_template_filter()
def note_general(notes):
Expand Down

0 comments on commit c650c4d

Please sign in to comment.