diff --git a/rero_ils/bundles.py b/rero_ils/bundles.py deleted file mode 100644 index 0bb24ba65c..0000000000 --- a/rero_ils/bundles.py +++ /dev/null @@ -1,105 +0,0 @@ -# -*- coding: utf-8 -*- -# -# RERO ILS -# Copyright (C) 2019 RERO -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -"""JS/CSS bundles for RERO ILS theme.""" - -from __future__ import absolute_import, print_function - -import os - -from invenio_assets import AngularGettextFilter, GlobBundle, NpmBundle -from pkg_resources import resource_filename - -RERO_ILS_UI_VERSION = '0.8.0' - - -def catalog(domain): - """Return glob matching path to tranlated messages for a given domain.""" - return os.path.join( - os.path.abspath(resource_filename('rero_ils', 'translations')), - '*', # language code - 'LC_MESSAGES', - '{0}.po'.format(domain), - ) - - -main_css = NpmBundle( - 'scss/rero_ils/styles.scss', - depends=('scss/rero_ils/*.scss'), - filters='node-scss,cleancssurl', - output='gen/rero_ils_main.%(version)s.css', - npm={ - 'almond': '~0.3.3', - 'bootstrap': '~4.2.1', - 'font-awesome': '~4.7.0', - 'jquery': '~1.9.1', - } -) -"""Main CSS bundle with Bootstrap and Font-Awesome.""" - -i18n = GlobBundle( - catalog('messages'), - filters=AngularGettextFilter(catalog_name='reroilsAppTranslations'), -) - -js = NpmBundle( - 'node_modules/almond/almond.js', - 'js/rero_ils/rero_ils.js', - 'js/rero_ils/rero_keep_tab.js', - filters='requirejs', - npm={ - 'almond': '~0.3.3', - 'angular': '~1.6.9', - 'bootstrap': '~4.2.1', - 'angular-gettext': '~2.3.8', - 'jquery': '~1.9.1', - }, - output='gen/rero_ils.main.%(version)s.js' -) - -admin_ui_js = NpmBundle( - 'node_modules/@rero/rero-ils-ui/dist/admin/runtime.*.js', - 'node_modules/@rero/rero-ils-ui/dist/admin/polyfills.*.js', - 'node_modules/@rero/rero-ils-ui/dist/admin/styles.*.js', - 'node_modules/@rero/rero-ils-ui/dist/admin/scripts.*.js', - 'node_modules/@rero/rero-ils-ui/dist/admin/main.*.js', - output='gen/rero_ils_admin_ui.%(version)s.js', - npm={ - '@rero/rero-ils-ui': '~{version}'.format(version=RERO_ILS_UI_VERSION) - } -) - -public_search_ui_js = NpmBundle( - 'node_modules/@rero/rero-ils-ui/dist/public-search/runtime.*.js', - 'node_modules/@rero/rero-ils-ui/dist/public-search/polyfills.*.js', - 'node_modules/@rero/rero-ils-ui/dist/public-search/styles.*.js', - 'node_modules/@rero/rero-ils-ui/dist/public-search/scripts.*.js', - 'node_modules/@rero/rero-ils-ui/dist/public-search/main.*.js', - output='gen/rero_ils_public-search_ui.%(version)s.js', - npm={ - '@rero/rero-ils-ui': '~{version}'.format(version=RERO_ILS_UI_VERSION) - } -) - -search_bar_ui_js = NpmBundle( - 'node_modules/@rero/rero-ils-ui/dist/search-bar/polyfills.*.js', - 'node_modules/@rero/rero-ils-ui/dist/search-bar/main.*.js', - output='gen/rero_ils_search-bar_ui.%(version)s.js', - npm={ - '@rero/rero-ils-ui': '~{version}'.format(version=RERO_ILS_UI_VERSION) - } -) diff --git a/rero_ils/config.py b/rero_ils/config.py index 332b6d211e..227c9787f4 100644 --- a/rero_ils/config.py +++ b/rero_ils/config.py @@ -154,22 +154,7 @@ def _(x): SECURITY_REGISTER_USER_TEMPLATE = 'rero_ils/register_user.html' SECURITY_FORGOT_PASSWORD_TEMPLATE = 'rero_ils/forgot_password.html' SECURITY_RESET_PASSWORD_TEMPLATE = 'rero_ils/reset_password.html' -#: Template for tombstone page. -RECORDS_UI_TOMBSTONE_TEMPLATE = "rero_ils/tombstone.html" -#: Miscellaneous templates -SEARCH_UI_JSTEMPLATE_RESULTS = ( - 'templates/rero_ils/brief_view_documents.html' -) -SEARCH_UI_SEARCH_TEMPLATE = 'rero_ils/search.html' -SEARCH_UI_JSTEMPLATE_FACETS = 'templates/rero_ils/facets.html' -SEARCH_UI_JSTEMPLATE_RANGE = 'templates/rero_ils/range.html' -SEARCH_UI_JSTEMPLATE_COUNT = 'templates/rero_ils/count.html' -SEARCH_UI_JSTEMPLATE_PAGINATION = 'templates/rero_ils/pagination.html' -SEARCH_UI_SEARCH_MIMETYPE = 'application/rero+json' - -SEARCH_UI_HEADER_TEMPLATE = 'rero_ils/search_header.html' -REROILS_SEARCHBAR_TEMPLATE = 'templates/rero_ils/searchbar.html' -RERO_ILS_EDITOR_TEMPLATE = 'rero_ils/editor.html' +RERO_ILS_SEARCH_TEMPLATE = 'rero_ils/search.html' RERO_ILS_COLLECTIONS_TEMPLATE = 'rero_ils/collections.html' # Theme configuration @@ -197,13 +182,14 @@ def _(x): #: Template for error pages. THEME_ERROR_TEMPLATE = 'rero_ils/page_error.html' #: RERO-ils search endpoint (i.e /search/documents) -RERO_ILS_THEME_SEARCH_ENDPOINT = '/search/documents' +# RERO_ILS_THEME_SEARCH_ENDPOINT = '/search/documents' # External CSS for each organisation customization RERO_ILS_THEME_ORGANISATION_CSS_ENDPOINT = 'https://resources.rero.ch/ils/test/css/' #: Template for including a tracking code for web analytics. THEME_TRACKINGCODE_TEMPLATE = 'rero_ils/trackingcode.html' THEME_JAVASCRIPT_TEMPLATE = 'rero_ils/javascript.html' +# WEBPACKEXT_PROJECT = 'rero_ils.webpack.project' # Logings # ======= #: Sentry level @@ -1486,7 +1472,7 @@ def _(x): ), ) -SEARCH_UI_SEARCH_INDEX = 'documents' +# SEARCH_UI_SEARCH_INDEX = 'documents' # Default view code for all organisations view # TODO: Should be taken into angular @@ -2089,7 +2075,7 @@ def _(x): INDEXER_REPLACE_REFS = True INDEXER_RECORD_TO_INDEX = 'rero_ils.modules.indexer_utils.record_to_index' -SEARCH_UI_SEARCH_API = '/api/documents/' +# SEARCH_UI_SEARCH_API = '/api/documents/' RERO_ILS_APP_URL_SCHEME = 'https' RERO_ILS_APP_HOST = 'ils.rero.ch' diff --git a/rero_ils/filter.py b/rero_ils/filter.py index f21d2d5aea..ec417dae19 100644 --- a/rero_ils/filter.py +++ b/rero_ils/filter.py @@ -19,6 +19,8 @@ import json import re +import glob +import os import dateparser from babel.dates import format_date, format_datetime, format_time @@ -27,6 +29,29 @@ from markupsafe import Markup +def webpack_assets(package, patterns=['runtime*.js', 'polyfills*.js', 'main*.js'], _type='js', tags=''): + package_path = os.path.join(current_app.static_folder, 'node_modules', package) + def transform(value): + value = re.sub(r'(.*?)\/static', '/static', value) + to_return = ''.format( + value=value, + tags=tags + ) + if _type == 'css': + to_return = ''.format( + value=value, + tags=tags + ) + return to_return + output_files = [] + for pattern in patterns: + files = glob.glob(os.path.join(package_path, pattern)) + output_files.extend([transform(v) for v in files]) + class Test: + def __html__(): + return Markup('\n'.join(output_files)) + return Test + def format_date_filter( date_str, date_format='full', time_format='medium', locale=None, delimiter=', ', timezone=None, diff --git a/rero_ils/modules/contributions/bundles.py b/rero_ils/modules/contributions/bundles.py deleted file mode 100644 index 744fe8cd47..0000000000 --- a/rero_ils/modules/contributions/bundles.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# -# RERO ILS -# Copyright (C) 2020 RERO -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -"""JS/CSS bundles for theme.""" - -from __future__ import absolute_import, print_function - -from flask_assets import Bundle -from invenio_assets import NpmBundle - -from ...bundles import i18n - -detailed_js = Bundle( - i18n, - NpmBundle( - 'js/rero_ils/contribution_jq.js', - npm={ - 'jquery': '~1.9.1', - } - ), - filters='jsmin', - output='gen/rero_ils.contribution_detailed.%(version)s.js', -) diff --git a/rero_ils/modules/contributions/static/js/rero_ils/contribution.js b/rero_ils/modules/contributions/static/js/rero_ils/contribution.js deleted file mode 100644 index fc28b2064e..0000000000 --- a/rero_ils/modules/contributions/static/js/rero_ils/contribution.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - -RERO ILS -Copyright (C) 2019 RERO - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -*/ - -angular.module('reroilsPerson', []) - .controller('personController', ['$scope', function($scope) { - - $scope.person = null; - - $scope.$watch("record", function(record) { - $scope.person = extract_source(record, $scope.config); - }); - - function extract_source(record, config) { - var orders = config.persons_label_order; - var language = config.language; - data = record['metadata']; - if (!(language in orders)) { - language = orders['fallback']; - } - order = orders[language]; - order.some(function(source) { - if (source in data) { - dataSource = source; - return true; - } - }) - return data[dataSource]; - } - }]); diff --git a/rero_ils/modules/contributions/static/js/rero_ils/contribution_jq.js b/rero_ils/modules/contributions/static/js/rero_ils/contribution_jq.js deleted file mode 100644 index 2b42983d41..0000000000 --- a/rero_ils/modules/contributions/static/js/rero_ils/contribution_jq.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - -RERO ILS -Copyright (C) 2020 RERO - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -*/ - -$(document).ready(function() { - $('#nav-tab').keeptab({ localeItemName: 'person-tab'}); -}); diff --git a/rero_ils/modules/contributions/views.py b/rero_ils/modules/contributions/views.py index f270753c63..cd48fbc5c0 100644 --- a/rero_ils/modules/contributions/views.py +++ b/rero_ils/modules/contributions/views.py @@ -26,11 +26,11 @@ from invenio_pidstore.models import PersistentIdentifier from invenio_records_ui.signals import record_viewed -from rero_ils.modules.contributions.api import Contribution, ContributionType -from rero_ils.modules.organisations.api import Organisation +from .api import Contribution, ContributionType +from ..organisations.api import Organisation from ..documents.api import DocumentsSearch -from ...views import url_active +from ...theme.views import url_active blueprint = Blueprint( 'contributions', diff --git a/rero_ils/modules/documents/bundles.py b/rero_ils/modules/documents/bundles.py deleted file mode 100644 index 5f0404c1c2..0000000000 --- a/rero_ils/modules/documents/bundles.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -# -# RERO ILS -# Copyright (C) 2019 RERO -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -"""JS/CSS bundles for theme.""" - -from __future__ import absolute_import, print_function - -from flask_assets import Bundle -from invenio_assets import NpmBundle - -from ...bundles import i18n - -detailed_js = Bundle( - i18n, - NpmBundle( - 'js/rero_ils/translations.js', - 'js/rero_ils/thumbnail.js', - 'js/rero_ils/detailed_app.js', - 'js/rero_ils/documents_jq.js', - filters='requirejs', - depends=('node_modules/d3/*'), - npm={ - "almond": "~0.3.1", - 'angular': '~1.4.10', - 'angular-loading-bar': '~0.9.0', - 'd3': '^3.5.17', - 'jquery': '~1.9.1', - } - ), - filters='jsmin', - output='gen/rero_ils.detailed.%(version)s.js', -) diff --git a/rero_ils/modules/documents/static/js/rero_ils/detailed_app.js b/rero_ils/modules/documents/static/js/rero_ils/detailed_app.js deleted file mode 100644 index 11152188f6..0000000000 --- a/rero_ils/modules/documents/static/js/rero_ils/detailed_app.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - -RERO ILS -Copyright (C) 2019 RERO - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -*/ - -require([ - 'node_modules/d3/d3', - 'node_modules/angular/angular', - 'node_modules/angular-loading-bar/build/loading-bar' - ], function() { - // When the DOM is ready bootstrap the `invenio-serach-js` - - angular.element(document).ready(function() { - angular.bootstrap( - document.getElementById("thumbnail"), [ - 'angular-loading-bar', 'reroilsAppTranslations', 'reroThumbnails' - ] - ); - }); - }); diff --git a/rero_ils/modules/documents/static/js/rero_ils/documents.js b/rero_ils/modules/documents/static/js/rero_ils/documents.js deleted file mode 100644 index 4ddaa88c38..0000000000 --- a/rero_ils/modules/documents/static/js/rero_ils/documents.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - -RERO ILS -Copyright (C) 2019 RERO - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -*/ - -angular.module('reroilsUtils', []) - - .controller('exportController', ['$scope', function($scope) { - $scope.csvURL = function() { - return window.location.href.toString().replace('search', 'api/export/documents/csv').replace(/size=\d+/, 'size=19999'); - }; - }]) - - .directive('reroilsExportCsv', function() { - return { - template: '' - }; - }) - - .controller('recordController', ['$scope', function($scope) { - record = $scope.rec; - }]); diff --git a/rero_ils/modules/documents/static/js/rero_ils/documents_jq.js b/rero_ils/modules/documents/static/js/rero_ils/documents_jq.js deleted file mode 100644 index 06e014573c..0000000000 --- a/rero_ils/modules/documents/static/js/rero_ils/documents_jq.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - -RERO ILS -Copyright (C) 2019 RERO - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -*/ - -$(document).ready(function() { - $('.collapse').on('hidden.bs.collapse shown.bs.collapse', function () { - var element = $('#' + $(this).data('holdingId')).find('.availability'); - element.hasClass('d-none') ? - element.removeClass('d-none') : element.addClass('d-none'); - }); - - $('#nav-tab').keeptab({ localeItemName: 'document-tab'}); - }); diff --git a/rero_ils/modules/documents/templates/rero_ils/_documents_get.html b/rero_ils/modules/documents/templates/rero_ils/_documents_get.html index a34404d869..11372409f7 100644 --- a/rero_ils/modules/documents/templates/rero_ils/_documents_get.html +++ b/rero_ils/modules/documents/templates/rero_ils/_documents_get.html @@ -232,8 +232,8 @@ {%- elif reasons %}
- - diff --git a/rero_ils/modules/ext.py b/rero_ils/modules/ext.py index 95f2c79dfb..21bf79186f 100644 --- a/rero_ils/modules/ext.py +++ b/rero_ils/modules/ext.py @@ -49,7 +49,7 @@ from .patrons.listener import create_subscription_patron_transaction, \ enrich_patron_data, update_from_profile from ..filter import empty_data, format_date_filter, jsondumps, text_to_id, \ - to_pretty_json + to_pretty_json, webpack_assets class REROILSAPP(object): @@ -70,6 +70,7 @@ def __init__(self, app=None): # register filters app.add_template_filter(format_date_filter, name='format_date') + app.add_template_global(webpack_assets, name='webpack_assets') app.add_template_filter(to_pretty_json, name='tojson_pretty') app.add_template_filter(text_to_id, name='text_to_id') app.add_template_filter(jsondumps, name='jsondumps') diff --git a/rero_ils/modules/ill_requests/bundles.py b/rero_ils/modules/ill_requests/bundles.py deleted file mode 100644 index 93eed7d28c..0000000000 --- a/rero_ils/modules/ill_requests/bundles.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# -# RERO ILS -# Copyright (C) 2020 RERO -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -"""JS/CSS bundles for theme.""" - -from __future__ import absolute_import, print_function - -from flask_assets import Bundle -from invenio_assets import NpmBundle - -ill_request_form_js = Bundle( - NpmBundle( - 'js/rero_ils/ill_request_form.js', - filters='requirejs', - npm={ - 'jquery': '~1.9.1', - } - ), - filters='jsmin', - output='gen/rero_ils.ill_request_form.%(version)s.js', -) diff --git a/rero_ils/modules/ill_requests/static/js/rero_ils/ill_request_form.js b/rero_ils/modules/ill_requests/static/js/rero_ils/ill_request_form.js deleted file mode 100644 index 4aa54b61d0..0000000000 --- a/rero_ils/modules/ill_requests/static/js/rero_ils/ill_request_form.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - -RERO ILS -Copyright (C) 2020 RERO - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -*/ - -$(document).ready(function() { - - function toggleField(checked) { - var target = $('div').find('[data-form-id="pages"]'); - if (checked == 0) { - target.addClass('d-none'); - } else { - target.removeClass('d-none'); - } - } - $('input:radio[name="request_copy"]').on('change', function() { - toggleField($(this).val()); - }); - $('input:radio[name="request_copy"]:checked').trigger('change'); -}); diff --git a/rero_ils/modules/patrons/static/js/rero_ils/patron_fees_toogle.js b/rero_ils/modules/patrons/static/js/rero_ils/patron_fees_toogle.js deleted file mode 100644 index c20b873b0f..0000000000 --- a/rero_ils/modules/patrons/static/js/rero_ils/patron_fees_toogle.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - -RERO ILS -Copyright (C) 2020 RERO - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -*/ - -$(document).ready(function() { - // Toogle - $('.btn-toogle').on('click', function() { - toogle($(this), 'target-id'); - }); - - /** - * Toogle element - * @param object element - * @param string elementId - */ - function toogle(element, elementId) { - var target = $('#' + element.data(elementId)); - var iCaret = element.find('i'); - if(iCaret.hasClass('fa-caret-right')) { - iCaret - .removeClass('fa-caret-right') - .addClass('fa-caret-down'); - } else { - iCaret - .removeClass('fa-caret-down') - .addClass('fa-caret-right'); - } - if (target.hasClass('d-none')) { - target - .removeClass('d-none') - .addClass('d-block'); - } else { - target - .removeClass('d-block') - .addClass('d-none'); - } - } -}); diff --git a/rero_ils/static/scss/rero_ils/cover.scss b/rero_ils/static/scss/rero_ils/cover.scss deleted file mode 100644 index 4d5ca1afe5..0000000000 --- a/rero_ils/static/scss/rero_ils/cover.scss +++ /dev/null @@ -1,22 +0,0 @@ -/* - - RERO ILS - Copyright (C) 2019 RERO - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, version 3 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - - */ - -.rero-ils-cover-logo { - width: 10em; -} diff --git a/rero_ils/static/templates/rero_ils/count.html b/rero_ils/static/templates/rero_ils/count.html deleted file mode 100644 index 735d5d5edb..0000000000 --- a/rero_ils/static/templates/rero_ils/count.html +++ /dev/null @@ -1,25 +0,0 @@ - -
-
-
Found {{$count}} result.
-
No results found.
-
-
diff --git a/rero_ils/static/templates/rero_ils/facets.html b/rero_ils/static/templates/rero_ils/facets.html deleted file mode 100644 index 166ef2bea4..0000000000 --- a/rero_ils/static/templates/rero_ils/facets.html +++ /dev/null @@ -1,64 +0,0 @@ - -
-
- -
-
{{ aggr.key | translate }}
-
-
-
-
    -
  • - - - - - {{ (tree[item.key]) ? '-' : '+' }} - - -
    -
    -
      -
    • - - {{ subFacets.name | translate }} - {{ subFacets.key | translate }} - ({{ subFacets.doc_count }}) -
    • -
    -
    -
    -
  • -
-
-
-
diff --git a/rero_ils/static/templates/rero_ils/pagination.html b/rero_ils/static/templates/rero_ils/pagination.html deleted file mode 100644 index 84cd5a7f5d..0000000000 --- a/rero_ils/static/templates/rero_ils/pagination.html +++ /dev/null @@ -1,52 +0,0 @@ - - diff --git a/rero_ils/static/templates/rero_ils/searchbar.html b/rero_ils/static/templates/rero_ils/searchbar.html deleted file mode 100644 index c86e929a3c..0000000000 --- a/rero_ils/static/templates/rero_ils/searchbar.html +++ /dev/null @@ -1,34 +0,0 @@ - - diff --git a/rero_ils/modules/patrons/bundles.py b/rero_ils/theme/__init__.py similarity index 59% rename from rero_ils/modules/patrons/bundles.py rename to rero_ils/theme/__init__.py index c6a559acaa..c9be00c264 100644 --- a/rero_ils/modules/patrons/bundles.py +++ b/rero_ils/theme/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # RERO ILS -# Copyright (C) 2020 RERO +# Copyright (C) 2019 RERO # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -15,21 +15,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -"""JS/CSS bundles for theme.""" - -from __future__ import absolute_import, print_function - -from flask_assets import Bundle -from invenio_assets import NpmBundle - -patron_profile_js = Bundle( - NpmBundle( - 'js/rero_ils/patron_fees_toogle.js', - filters='requirejs', - npm={ - 'jquery': '~1.9.1', - } - ), - filters='jsmin', - output='gen/rero_ils.patron_profile.%(version)s.js', -) +"""RERO ILS theme module.""" diff --git a/rero_ils/assets/js/admin_ui.js b/rero_ils/theme/assets/js/admin_ui.js similarity index 100% rename from rero_ils/assets/js/admin_ui.js rename to rero_ils/theme/assets/js/admin_ui.js diff --git a/rero_ils/assets/js/public-search_ui.js b/rero_ils/theme/assets/js/public-search_ui.js similarity index 100% rename from rero_ils/assets/js/public-search_ui.js rename to rero_ils/theme/assets/js/public-search_ui.js diff --git a/rero_ils/theme/assets/js/reroils/login.js b/rero_ils/theme/assets/js/reroils/login.js new file mode 100644 index 0000000000..3621090540 --- /dev/null +++ b/rero_ils/theme/assets/js/reroils/login.js @@ -0,0 +1,40 @@ +import $ from 'jquery'; + +$("#login-user").submit(function (e) { + + e.preventDefault(); // avoid to execute the actual submit of the form. + + var form = $(this); + var url = form.attr('data-action'); + + $.ajax({ + type: "POST", + url: url, + data: form.serialize(), // serializes the form's elements. + success: function (data) { + var next = getUrlParameter('next'); + window.location.replace(next ? next : '/'); + }, + error: function (data) { + var response = $.parseJSON(data.responseText); + var alert = $("#js-alert"); + var msg = $("#js-alert span.msg").html(response.errors[0].message); + alert.show(); + } + }); +}); + +var getUrlParameter = function getUrlParameter(sParam) { + var sPageURL = window.location.search.substring(1), + sURLVariables = sPageURL.split('&'), + sParameterName, + i; + + for (i = 0; i < sURLVariables.length; i++) { + sParameterName = sURLVariables[i].split('='); + + if (sParameterName[0] === sParam) { + return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); + } + } +}; diff --git a/rero_ils/theme/assets/js/reroils/public.js b/rero_ils/theme/assets/js/reroils/public.js new file mode 100644 index 0000000000..bc5c101bd4 --- /dev/null +++ b/rero_ils/theme/assets/js/reroils/public.js @@ -0,0 +1,6 @@ +import 'bootstrap'; +import './tooltip'; +import './toast'; +import './login'; +import './tab'; +import './toggle'; diff --git a/rero_ils/theme/assets/js/reroils/tab.js b/rero_ils/theme/assets/js/reroils/tab.js new file mode 100644 index 0000000000..78c61b6c79 --- /dev/null +++ b/rero_ils/theme/assets/js/reroils/tab.js @@ -0,0 +1,34 @@ +import $ from 'jquery'; + +// contribution + +$.fn.keeptab = function( options ) { + + var opts = $.extend( { + tabsName: '.nav-tabs', + localeItemName: 'navkeeptab', + selector: '.nav-link' + }, options ); + + $(opts.tabsName).find(opts.selector).on('click', function() { + var elementId = undefined; + if ($(this).attr('id')) { + elementId = '#' + $(this).attr('id'); + } else if ($(this).attr('href')) { + elementId = $(this).attr('href') + } else { + window.console.log('Missing id or href.'); + } + if (elementId) { + localStorage.setItem(opts.localeItemName, elementId); + } + }); + + var activeTab = localStorage.getItem(opts.localeItemName); + if (activeTab && $(activeTab).length) { + $(activeTab).tab('show'); + } + return this; +}; + +$('#nav-tab').keeptab({ localeItemName: 'person-tab'}); diff --git a/rero_ils/theme/assets/js/reroils/toast.js b/rero_ils/theme/assets/js/reroils/toast.js new file mode 100644 index 0000000000..12c9ccbad4 --- /dev/null +++ b/rero_ils/theme/assets/js/reroils/toast.js @@ -0,0 +1,6 @@ +import $ from 'jquery'; + +// flash messages +$('.toast-container .toast').toast({ + delay: 5000 +}).toast('show'); diff --git a/rero_ils/theme/assets/js/reroils/toggle.js b/rero_ils/theme/assets/js/reroils/toggle.js new file mode 100644 index 0000000000..98808fe544 --- /dev/null +++ b/rero_ils/theme/assets/js/reroils/toggle.js @@ -0,0 +1,60 @@ +import $ from 'jquery'; + +// Documents +$('.collapse').on('hidden.bs.collapse shown.bs.collapse', function () { + var element = $('#' + $(this).data('holdingId')).find('.availability'); + element.hasClass('d-none') ? + element.removeClass('d-none') : element.addClass('d-none'); +}); + +$('#nav-tab').keeptab({ localeItemName: 'document-tab'}); + +// Patrons +$('.btn-toogle').on('click', function () { + toogle($(this), 'target-id'); +}); + +// ILLRequest +$('input:radio[name="request_copy"]').on('change', function () { + toggleField($(this).val()); +}); +$('input:radio[name="request_copy"]:checked').trigger('change') + +/** + * Toogle element + * @param object element + * @param string elementId + */ +function toogle(element, elementId) { + var target = $('#' + element.data(elementId)); + var iCaret = element.find('i'); + if (iCaret.hasClass('fa-caret-right')) { + iCaret + .removeClass('fa-caret-right') + .addClass('fa-caret-down'); + } else { + iCaret + .removeClass('fa-caret-down') + .addClass('fa-caret-right'); + } + if (target.hasClass('d-none')) { + target + .removeClass('d-none') + .addClass('d-block'); + } else { + target + .removeClass('d-block') + .addClass('d-none'); + } +} + +function toggleField(checked) { + var target = $('div').find('[data-form-id="pages"]'); + if (checked == 0) { + target.addClass('d-none'); + } else { + target.removeClass('d-none'); + } +} + + diff --git a/rero_ils/theme/assets/js/reroils/tooltip.js b/rero_ils/theme/assets/js/reroils/tooltip.js new file mode 100644 index 0000000000..860ad600d2 --- /dev/null +++ b/rero_ils/theme/assets/js/reroils/tooltip.js @@ -0,0 +1,3 @@ +import $ from 'jquery'; + +$('[data-toggle="tooltip"]').tooltip(); diff --git a/rero_ils/modules/contributions/static/scss/rero_ils/person.scss b/rero_ils/theme/assets/scss/rero_ils/contributions/detailed.scss similarity index 100% rename from rero_ils/modules/contributions/static/scss/rero_ils/person.scss rename to rero_ils/theme/assets/scss/rero_ils/contributions/detailed.scss diff --git a/rero_ils/modules/documents/static/scss/rero_ils/item_detail.scss b/rero_ils/theme/assets/scss/rero_ils/documents/detailed.scss similarity index 100% rename from rero_ils/modules/documents/static/scss/rero_ils/item_detail.scss rename to rero_ils/theme/assets/scss/rero_ils/documents/detailed.scss diff --git a/rero_ils/static/scss/rero_ils/footer.scss b/rero_ils/theme/assets/scss/rero_ils/footer.scss similarity index 100% rename from rero_ils/static/scss/rero_ils/footer.scss rename to rero_ils/theme/assets/scss/rero_ils/footer.scss diff --git a/rero_ils/static/scss/rero_ils/frontpage.scss b/rero_ils/theme/assets/scss/rero_ils/frontpage.scss similarity index 100% rename from rero_ils/static/scss/rero_ils/frontpage.scss rename to rero_ils/theme/assets/scss/rero_ils/frontpage.scss diff --git a/rero_ils/static/scss/rero_ils/header.scss b/rero_ils/theme/assets/scss/rero_ils/header.scss similarity index 100% rename from rero_ils/static/scss/rero_ils/header.scss rename to rero_ils/theme/assets/scss/rero_ils/header.scss diff --git a/rero_ils/static/scss/rero_ils/page.scss b/rero_ils/theme/assets/scss/rero_ils/page.scss similarity index 100% rename from rero_ils/static/scss/rero_ils/page.scss rename to rero_ils/theme/assets/scss/rero_ils/page.scss diff --git a/rero_ils/modules/patrons/static/scss/rero_ils/patrons_profile.scss b/rero_ils/theme/assets/scss/rero_ils/patrons/profile.scss similarity index 100% rename from rero_ils/modules/patrons/static/scss/rero_ils/patrons_profile.scss rename to rero_ils/theme/assets/scss/rero_ils/patrons/profile.scss diff --git a/rero_ils/static/scss/rero_ils/search.scss b/rero_ils/theme/assets/scss/rero_ils/search.scss similarity index 100% rename from rero_ils/static/scss/rero_ils/search.scss rename to rero_ils/theme/assets/scss/rero_ils/search.scss diff --git a/rero_ils/static/scss/rero_ils/styles.scss b/rero_ils/theme/assets/scss/rero_ils/styles.scss similarity index 84% rename from rero_ils/static/scss/rero_ils/styles.scss rename to rero_ils/theme/assets/scss/rero_ils/styles.scss index 43fac8b351..f3b817f92c 100644 --- a/rero_ils/static/scss/rero_ils/styles.scss +++ b/rero_ils/theme/assets/scss/rero_ils/styles.scss @@ -21,21 +21,28 @@ @import "variables"; // Setting the path to fonts files. -$fa-font-path: "/static/node_modules/font-awesome/fonts"; -$icon-font-path: "/static/node_modules/bootstrap-sass/assets/fonts/bootstrap/"; -@import "../../node_modules/bootstrap/scss/bootstrap"; -@import "../../node_modules/font-awesome/scss/font-awesome"; +$fa-font-path: "~font-awesome/fonts"; +$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/"; +@import '~bootstrap/scss/bootstrap'; +@import "~font-awesome/scss/font-awesome"; +// general styles @import "page"; @import "header"; @import "footer"; @import "search"; -@import "thumbnail"; -@import "person"; @import "frontpage"; -@import "patrons_profile"; -@import "cover"; -@import "item_detail"; +// @import "thumbnail"; + +// modules +@import "contributions/detailed"; +@import "patrons/profile"; +@import "documents/detailed"; + +// cover +.rero-ils-cover-logo { + width: 10em; +} // CSS code to allow `ng-csp="no-inline-css"` [ng\:cloak], @@ -92,8 +99,8 @@ html [type=button] { color: $secondary; } -button:disabled:hover { - cursor: not-allowed; +button:disabled { + pointer-events: none; } div.tooltip div.tooltip-inner{ diff --git a/rero_ils/static/scss/rero_ils/variables.scss b/rero_ils/theme/assets/scss/rero_ils/variables.scss similarity index 95% rename from rero_ils/static/scss/rero_ils/variables.scss rename to rero_ils/theme/assets/scss/rero_ils/variables.scss index 0c564ba334..f5aaabe71f 100644 --- a/rero_ils/static/scss/rero_ils/variables.scss +++ b/rero_ils/theme/assets/scss/rero_ils/variables.scss @@ -32,7 +32,7 @@ $footer-height: 50px; $form-check-input-margin-y: .2rem !default; // controls the checkbox vertical alignement -$static-images: "/static/images"; +$static-images: "../../../static/images"; /* diff --git a/rero_ils/static/apple-touch-icon-144-precomposed.png b/rero_ils/theme/static/apple-touch-icon-144-precomposed.png similarity index 100% rename from rero_ils/static/apple-touch-icon-144-precomposed.png rename to rero_ils/theme/static/apple-touch-icon-144-precomposed.png diff --git a/rero_ils/static/apple-touch-icon.png b/rero_ils/theme/static/apple-touch-icon.png similarity index 100% rename from rero_ils/static/apple-touch-icon.png rename to rero_ils/theme/static/apple-touch-icon.png diff --git a/rero_ils/static/css/rero_ils/wiki.css b/rero_ils/theme/static/css/rero_ils/wiki.css similarity index 100% rename from rero_ils/static/css/rero_ils/wiki.css rename to rero_ils/theme/static/css/rero_ils/wiki.css diff --git a/rero_ils/static/favicon.ico b/rero_ils/theme/static/favicon.ico similarity index 100% rename from rero_ils/static/favicon.ico rename to rero_ils/theme/static/favicon.ico diff --git a/rero_ils/static/images/GitHub-Mark-120px-plus.png b/rero_ils/theme/static/images/GitHub-Mark-120px-plus.png similarity index 100% rename from rero_ils/static/images/GitHub-Mark-120px-plus.png rename to rero_ils/theme/static/images/GitHub-Mark-120px-plus.png diff --git a/rero_ils/static/images/Twitter_Logo_Blue.png b/rero_ils/theme/static/images/Twitter_Logo_Blue.png similarity index 100% rename from rero_ils/static/images/Twitter_Logo_Blue.png rename to rero_ils/theme/static/images/Twitter_Logo_Blue.png diff --git a/rero_ils/static/images/homepage_image_bleu.jpg b/rero_ils/theme/static/images/homepage_image_bleu.jpg similarity index 100% rename from rero_ils/static/images/homepage_image_bleu.jpg rename to rero_ils/theme/static/images/homepage_image_bleu.jpg diff --git a/rero_ils/static/images/logo-taiga-color.png b/rero_ils/theme/static/images/logo-taiga-color.png similarity index 100% rename from rero_ils/static/images/logo-taiga-color.png rename to rero_ils/theme/static/images/logo-taiga-color.png diff --git a/rero_ils/static/images/logo_explore_height_119.png b/rero_ils/theme/static/images/logo_explore_height_119.png similarity index 100% rename from rero_ils/static/images/logo_explore_height_119.png rename to rero_ils/theme/static/images/logo_explore_height_119.png diff --git a/rero_ils/static/images/logo_rero_21_inline.png b/rero_ils/theme/static/images/logo_rero_21_inline.png similarity index 100% rename from rero_ils/static/images/logo_rero_21_inline.png rename to rero_ils/theme/static/images/logo_rero_21_inline.png diff --git a/rero_ils/static/images/logo_rero_ils.png b/rero_ils/theme/static/images/logo_rero_ils.png similarity index 100% rename from rero_ils/static/images/logo_rero_ils.png rename to rero_ils/theme/static/images/logo_rero_ils.png diff --git a/rero_ils/static/images/logo_rerodoc_height_119.png b/rero_ils/theme/static/images/logo_rerodoc_height_119.png similarity index 100% rename from rero_ils/static/images/logo_rerodoc_height_119.png rename to rero_ils/theme/static/images/logo_rerodoc_height_119.png diff --git a/rero_ils/static/images/rero21.svg b/rero_ils/theme/static/images/rero21.svg similarity index 100% rename from rero_ils/static/images/rero21.svg rename to rero_ils/theme/static/images/rero21.svg diff --git a/rero_ils/static/js/rero_ils/invenio_config.js b/rero_ils/theme/static/js/rero_ils/invenio_config.js similarity index 100% rename from rero_ils/static/js/rero_ils/invenio_config.js rename to rero_ils/theme/static/js/rero_ils/invenio_config.js diff --git a/rero_ils/static/js/rero_ils/rero_ils.js b/rero_ils/theme/static/js/rero_ils/rero_ils.js similarity index 98% rename from rero_ils/static/js/rero_ils/rero_ils.js rename to rero_ils/theme/static/js/rero_ils/rero_ils.js index 2da42e1404..95d6b1e69f 100644 --- a/rero_ils/static/js/rero_ils/rero_ils.js +++ b/rero_ils/theme/static/js/rero_ils/rero_ils.js @@ -29,7 +29,7 @@ require([ $(document).ready(function () { - $('[data-toggle="tooltip"]').tooltip(); + // $('[data-toggle="tooltip"]').tooltip(); // flash messages $('.toast-container .toast').toast({ diff --git a/rero_ils/static/js/rero_ils/rero_keep_tab.js b/rero_ils/theme/static/js/rero_ils/rero_keep_tab.js similarity index 100% rename from rero_ils/static/js/rero_ils/rero_keep_tab.js rename to rero_ils/theme/static/js/rero_ils/rero_keep_tab.js diff --git a/rero_ils/static/js/rero_ils/search_app.js b/rero_ils/theme/static/js/rero_ils/search_app.js similarity index 100% rename from rero_ils/static/js/rero_ils/search_app.js rename to rero_ils/theme/static/js/rero_ils/search_app.js diff --git a/rero_ils/static/js/rero_ils/translations.js b/rero_ils/theme/static/js/rero_ils/translations.js similarity index 100% rename from rero_ils/static/js/rero_ils/translations.js rename to rero_ils/theme/static/js/rero_ils/translations.js diff --git a/rero_ils/templates/__init__.py b/rero_ils/theme/templates/__init__.py similarity index 100% rename from rero_ils/templates/__init__.py rename to rero_ils/theme/templates/__init__.py diff --git a/rero_ils/templates/rero_ils/_editor_button_actions.html b/rero_ils/theme/templates/rero_ils/_editor_button_actions.html similarity index 100% rename from rero_ils/templates/rero_ils/_editor_button_actions.html rename to rero_ils/theme/templates/rero_ils/_editor_button_actions.html diff --git a/rero_ils/templates/rero_ils/_info_pilot.html b/rero_ils/theme/templates/rero_ils/_info_pilot.html similarity index 100% rename from rero_ils/templates/rero_ils/_info_pilot.html rename to rero_ils/theme/templates/rero_ils/_info_pilot.html diff --git a/rero_ils/templates/rero_ils/_info_test.html b/rero_ils/theme/templates/rero_ils/_info_test.html similarity index 100% rename from rero_ils/templates/rero_ils/_info_test.html rename to rero_ils/theme/templates/rero_ils/_info_test.html diff --git a/rero_ils/templates/rero_ils/breadcrumbs.html b/rero_ils/theme/templates/rero_ils/breadcrumbs.html similarity index 100% rename from rero_ils/templates/rero_ils/breadcrumbs.html rename to rero_ils/theme/templates/rero_ils/breadcrumbs.html diff --git a/rero_ils/templates/rero_ils/collections.html b/rero_ils/theme/templates/rero_ils/collections.html similarity index 100% rename from rero_ils/templates/rero_ils/collections.html rename to rero_ils/theme/templates/rero_ils/collections.html diff --git a/rero_ils/templates/rero_ils/footer.html b/rero_ils/theme/templates/rero_ils/footer.html similarity index 100% rename from rero_ils/templates/rero_ils/footer.html rename to rero_ils/theme/templates/rero_ils/footer.html diff --git a/rero_ils/templates/rero_ils/forgot_password.html b/rero_ils/theme/templates/rero_ils/forgot_password.html similarity index 100% rename from rero_ils/templates/rero_ils/forgot_password.html rename to rero_ils/theme/templates/rero_ils/forgot_password.html diff --git a/rero_ils/templates/rero_ils/frontpage.html b/rero_ils/theme/templates/rero_ils/frontpage.html similarity index 100% rename from rero_ils/templates/rero_ils/frontpage.html rename to rero_ils/theme/templates/rero_ils/frontpage.html diff --git a/rero_ils/templates/rero_ils/header.html b/rero_ils/theme/templates/rero_ils/header.html similarity index 100% rename from rero_ils/templates/rero_ils/header.html rename to rero_ils/theme/templates/rero_ils/header.html diff --git a/rero_ils/templates/rero_ils/header_frontpage.html b/rero_ils/theme/templates/rero_ils/header_frontpage.html similarity index 100% rename from rero_ils/templates/rero_ils/header_frontpage.html rename to rero_ils/theme/templates/rero_ils/header_frontpage.html diff --git a/rero_ils/templates/rero_ils/javascript.html b/rero_ils/theme/templates/rero_ils/javascript.html similarity index 67% rename from rero_ils/templates/rero_ils/javascript.html rename to rero_ils/theme/templates/rero_ils/javascript.html index 9247e35f6c..f61384e13f 100644 --- a/rero_ils/templates/rero_ils/javascript.html +++ b/rero_ils/theme/templates/rero_ils/javascript.html @@ -17,12 +17,9 @@ #} {%- block javascript %} -{% assets "rero_ils_main_js" %} - -{% endassets %} - -{% assets "rero_ils_search_bar_ui_js" %} - -{% endassets %} - +{{ webpack['manifest.js']}} +{{ webpack['vendor.js']}} +{{ webpack['reroils_public.js']}} +{{ webpack_assets('@rero/rero-ils-ui/dist/search-bar', patterns=['polyfills-es5*.js','main-es5*.js'], tags='nomodule defer') }} +{{ webpack_assets('@rero/rero-ils-ui/dist/search-bar', patterns=['polyfills-es2015*.js','main-es2015*.js'], tags='type="module"') }} {%- endblock javascript %} diff --git a/rero_ils/templates/rero_ils/login_user.html b/rero_ils/theme/templates/rero_ils/login_user.html similarity index 100% rename from rero_ils/templates/rero_ils/login_user.html rename to rero_ils/theme/templates/rero_ils/login_user.html diff --git a/rero_ils/templates/rero_ils/macros/header_menus.html b/rero_ils/theme/templates/rero_ils/macros/header_menus.html similarity index 100% rename from rero_ils/templates/rero_ils/macros/header_menus.html rename to rero_ils/theme/templates/rero_ils/macros/header_menus.html diff --git a/rero_ils/templates/rero_ils/macros/macro.html b/rero_ils/theme/templates/rero_ils/macros/macro.html similarity index 100% rename from rero_ils/templates/rero_ils/macros/macro.html rename to rero_ils/theme/templates/rero_ils/macros/macro.html diff --git a/rero_ils/templates/rero_ils/macros/messages.html b/rero_ils/theme/templates/rero_ils/macros/messages.html similarity index 100% rename from rero_ils/templates/rero_ils/macros/messages.html rename to rero_ils/theme/templates/rero_ils/macros/messages.html diff --git a/rero_ils/templates/rero_ils/page.html b/rero_ils/theme/templates/rero_ils/page.html similarity index 94% rename from rero_ils/templates/rero_ils/page.html rename to rero_ils/theme/templates/rero_ils/page.html index 199a8068b8..5af8cea85f 100644 --- a/rero_ils/templates/rero_ils/page.html +++ b/rero_ils/theme/templates/rero_ils/page.html @@ -71,10 +71,7 @@ {%- endblock head_links %} {%- block header %}{% endblock header %} {%- block css %} - {% assets "rero_ils_main_css" %} - {% endassets %} - + {{ webpack['global.css'] }} {%- endblock css %} {%- endblock head %} diff --git a/rero_ils/templates/rero_ils/page_cover.html b/rero_ils/theme/templates/rero_ils/page_cover.html similarity index 92% rename from rero_ils/templates/rero_ils/page_cover.html rename to rero_ils/theme/templates/rero_ils/page_cover.html index 40c630e74b..bbea618f9f 100644 --- a/rero_ils/templates/rero_ils/page_cover.html +++ b/rero_ils/theme/templates/rero_ils/page_cover.html @@ -57,6 +57,10 @@ {% block page_footer %} {% endblock page_footer %}
- {%- block javascript %}{% endblock javascript %} - {%- block trackingcode %}{% include config.THEME_TRACKINGCODE_TEMPLATE %}{% endblock %} +{%- block javascript %} +{% include 'rero_ils/javascript.html' %} +{%- endblock javascript %} +{%- block trackingcode %} +{% include 'rero_ils/trackingcode.html' %} +{%- endblock %} {%- endblock outer_body %} diff --git a/rero_ils/templates/rero_ils/page_error.html b/rero_ils/theme/templates/rero_ils/page_error.html similarity index 100% rename from rero_ils/templates/rero_ils/page_error.html rename to rero_ils/theme/templates/rero_ils/page_error.html diff --git a/rero_ils/templates/rero_ils/page_settings.html b/rero_ils/theme/templates/rero_ils/page_settings.html similarity index 100% rename from rero_ils/templates/rero_ils/page_settings.html rename to rero_ils/theme/templates/rero_ils/page_settings.html diff --git a/rero_ils/templates/rero_ils/page_wiki.html b/rero_ils/theme/templates/rero_ils/page_wiki.html similarity index 100% rename from rero_ils/templates/rero_ils/page_wiki.html rename to rero_ils/theme/templates/rero_ils/page_wiki.html diff --git a/rero_ils/templates/rero_ils/professional.html b/rero_ils/theme/templates/rero_ils/professional.html similarity index 62% rename from rero_ils/templates/rero_ils/professional.html rename to rero_ils/theme/templates/rero_ils/professional.html index e487c1e426..76364c5ee6 100644 --- a/rero_ils/templates/rero_ils/professional.html +++ b/rero_ils/theme/templates/rero_ils/professional.html @@ -25,15 +25,12 @@ Admin - - + {{ webpack_assets('@rero/rero-ils-ui/dist/admin', ['styles.*css'], 'css') }} - {% assets "rero_ils_admin_ui_js" %} - - {% endassets %} + {{ webpack_assets('@rero/rero-ils-ui/dist/admin') }} diff --git a/rero_ils/templates/rero_ils/register_user.html b/rero_ils/theme/templates/rero_ils/register_user.html similarity index 100% rename from rero_ils/templates/rero_ils/register_user.html rename to rero_ils/theme/templates/rero_ils/register_user.html diff --git a/rero_ils/templates/rero_ils/reset_password.html b/rero_ils/theme/templates/rero_ils/reset_password.html similarity index 100% rename from rero_ils/templates/rero_ils/reset_password.html rename to rero_ils/theme/templates/rero_ils/reset_password.html diff --git a/rero_ils/templates/rero_ils/search.html b/rero_ils/theme/templates/rero_ils/search.html similarity index 81% rename from rero_ils/templates/rero_ils/search.html rename to rero_ils/theme/templates/rero_ils/search.html index c3a9efb83f..16e02f622d 100644 --- a/rero_ils/templates/rero_ils/search.html +++ b/rero_ils/theme/templates/rero_ils/search.html @@ -27,11 +27,8 @@ {%- endblock page_body -%} {%- block javascript %} - {% assets "rero_ils_main_js" %} - - {% endassets %} - - {% assets "rero_ils_public_search_ui_js" %} - - {% endassets %} +{{ webpack['manifest.js']}} +{{ webpack['vendor.js']}} +{{ webpack['reroils_public.js']}} +{{ webpack_assets('@rero/rero-ils-ui/dist/public-search', tags='defer') }}} {%- endblock javascript %} diff --git a/rero_ils/templates/rero_ils/tombstone.html b/rero_ils/theme/templates/rero_ils/tombstone.html similarity index 100% rename from rero_ils/templates/rero_ils/tombstone.html rename to rero_ils/theme/templates/rero_ils/tombstone.html diff --git a/rero_ils/templates/rero_ils/trackingcode.html b/rero_ils/theme/templates/rero_ils/trackingcode.html similarity index 100% rename from rero_ils/templates/rero_ils/trackingcode.html rename to rero_ils/theme/templates/rero_ils/trackingcode.html diff --git a/rero_ils/templates/security/email/reset_instructions.html b/rero_ils/theme/templates/security/email/reset_instructions.html similarity index 100% rename from rero_ils/templates/security/email/reset_instructions.html rename to rero_ils/theme/templates/security/email/reset_instructions.html diff --git a/rero_ils/templates/security/email/reset_instructions.txt b/rero_ils/theme/templates/security/email/reset_instructions.txt similarity index 100% rename from rero_ils/templates/security/email/reset_instructions.txt rename to rero_ils/theme/templates/security/email/reset_instructions.txt diff --git a/rero_ils/views.py b/rero_ils/theme/views.py similarity index 99% rename from rero_ils/views.py rename to rero_ils/theme/views.py index 98aaaa6c6d..c80386da42 100644 --- a/rero_ils/views.py +++ b/rero_ils/theme/views.py @@ -36,7 +36,7 @@ from rero_ils.modules.patrons.api import Patron, current_patron from rero_ils.permissions import can_access_professional_view -from .version import __version__ +from ..version import __version__ blueprint = Blueprint( 'rero_ils', @@ -391,7 +391,7 @@ def set_language(): @check_organisation_viewcode def search(viewcode, recordType): """Search page ui.""" - return render_template(current_app.config.get('SEARCH_UI_SEARCH_TEMPLATE'), + return render_template(current_app.config.get('RERO_ILS_SEARCH_TEMPLATE'), viewcode=viewcode) diff --git a/rero_ils/webpack.py b/rero_ils/theme/webpack.py similarity index 71% rename from rero_ils/webpack.py rename to rero_ils/theme/webpack.py index b62071dd4d..e61ce391ab 100644 --- a/rero_ils/webpack.py +++ b/rero_ils/theme/webpack.py @@ -26,21 +26,24 @@ from flask_webpackext import WebpackBundle, WebpackBundleProject from pywebpack import bundles_from_entry_point -project = WebpackBundleProject( - 'rero_ils', - project_folder='webpack_assets', - config_path='build/config.json', - bundles=bundles_from_entry_point('invenio_assets.webpack'), -) -admin = WebpackBundle( +# project = WebpackBundleProject( +# 'rero_ils', +# project_folder='webpack_assets', +# config_path='build/config.json', +# bundles=bundles_from_entry_point('invenio_assets.webpack'), +# ) + +theme = WebpackBundle( __name__, 'assets', entry={ - 'admin_ui': './js/admin_ui.js', - 'public-search_ui': './js/public-search_ui.js' + 'global': './scss/rero_ils/styles.scss', + 'reroils_public': './js/reroils/public.js' }, dependencies={ - '@rero/rero-ils-ui': '^0.0.1', + 'popper.js': '1.16.1', + 'jquery': '~3.2.1', + 'bootstrap': '~4.5.3', } ) diff --git a/rero_ils/webpack_assets/.babelrc b/rero_ils/theme/webpack_assets/.babelrc similarity index 100% rename from rero_ils/webpack_assets/.babelrc rename to rero_ils/theme/webpack_assets/.babelrc diff --git a/rero_ils/webpack_assets/build/webpack.config.js b/rero_ils/theme/webpack_assets/build/webpack.config.js similarity index 54% rename from rero_ils/webpack_assets/build/webpack.config.js rename to rero_ils/theme/webpack_assets/build/webpack.config.js index fd22c489a5..c81539bd4e 100644 --- a/rero_ils/webpack_assets/build/webpack.config.js +++ b/rero_ils/theme/webpack_assets/build/webpack.config.js @@ -1,42 +1,44 @@ /* + * This file is part of Invenio. + * Copyright (C) 2017-2018 CERN. + * + * Invenio is free software; you can redistribute it and/or modify it + * under the terms of the MIT License; see LICENSE file for more details. + */ -RERO ILS -Copyright (C) 2019 RERO +const path = require("path"); +const { CleanWebpackPlugin } = require("clean-webpack-plugin"); +const config = require("./config"); +const BundleTracker = require("webpack-bundle-tracker"); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); +const safePostCssParser = require("postcss-safe-parser"); +const TerserPlugin = require("terser-webpack-plugin"); +const webpack = require("webpack"); -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -*/ - -const CleanWebpackPlugin = require('clean-webpack-plugin'); -const config = require('./config'); -const ManifestPlugin = require('webpack-manifest-plugin'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); -const safePostCssParser = require('postcss-safe-parser'); -const TerserPlugin = require('terser-webpack-plugin'); -const webpack = require('webpack'); +// Load aliases from config and resolve their full path +let aliases = {}; +if (config.aliases) { + aliases = Object.fromEntries( + Object.entries(config.aliases).map( + ([alias, alias_path]) => [alias, path.resolve(config.build.context, alias_path)] + ) + ) +} var webpackConfig = { + mode: process.env.NODE_ENV, entry: config.entry, context: config.build.context, resolve: { - extensions: ['*', '.js', '.jsx'], - symlinks: false + extensions: ["*", ".js", ".jsx"], + symlinks: false, + alias: aliases, }, output: { path: config.build.assetsPath, - filename: 'js/[name].[chunkhash].js', - chunkFilename: 'js/[id].[chunkhash].js', + filename: "js/[name].[chunkhash].js", + chunkFilename: "js/[id].[chunkhash].js", publicPath: config.build.assetsURL }, optimization: { @@ -89,32 +91,26 @@ var webpackConfig = { }) ], splitChunks: { - cacheGroups: { - commons: { - test: /[\\/]node_modules[\\/]/, - name: "vendor", - chunks: "initial", - }, - }, - chunks: 'all', + chunks: "all" }, // Extract webpack runtime and module manifest to its own file in order to // prevent vendor hash from being updated whenever app bundle is updated. runtimeChunk: { - name: 'manifest' + name: "manifest" } }, module: { rules: [ { - test: require.resolve('jquery'), - use: [{ - loader: 'expose-loader', - options: 'jQuery' - },{ - loader: 'expose-loader', - options: '$' - }] + test: require.resolve("jquery"), + use: [ + { + loader: "expose-loader", + options: { + exposes: ["$", "jQuery"] + } + }, + ] }, { test: /\.(js|jsx)$/, @@ -124,7 +120,10 @@ var webpackConfig = { loader: "babel-loader", options: { presets: ["@babel/preset-env", "@babel/preset-react"], - plugins: ["@babel/plugin-proposal-class-properties", "@babel/plugin-transform-runtime"] + plugins: [ + "@babel/plugin-proposal-class-properties", + "@babel/plugin-transform-runtime" + ] } } ] @@ -138,93 +137,89 @@ var webpackConfig = { options: { emitWarning: true, quiet: true, - formatter: require('eslint-friendly-formatter'), - eslintPath: require.resolve('eslint'), + formatter: require("eslint-friendly-formatter"), + eslintPath: require.resolve("eslint") }, - loader: require.resolve('eslint-loader'), + loader: require.resolve("eslint-loader") } ] }, { test: /\.(scss|css)$/, - use: [ - MiniCssExtractPlugin.loader, - { - loader: "css-loader", - options: { - minimize: { - safe: true - } - } - }, - { - loader: "sass-loader", - options: {} - } - ] + use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"] + }, + { + test: /\.(less)$/, + use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"] }, // Inline images smaller than 10k { - test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, + test: /\.(png|cur|jpe?g|gif|svg)(\?.*)?$/, use: [ { - loader: require.resolve('url-loader'), + loader: require.resolve("url-loader"), options: { limit: 10000, - name: 'img/[name].[hash:7].[ext]' + name: "img/[name].[hash:7].[ext]" } } - ], + ] }, // Inline webfonts smaller than 10k { test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, use: [ { - loader: require.resolve('file-loader'), + loader: require.resolve("file-loader"), options: { limit: 10000, - name: 'fonts/[name].[hash:7].[ext]' + name: "fonts/[name].[hash:7].[ext]" } } - ], + ] } ] }, - // devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'cheap-source-map', + devtool: process.env.NODE_ENV === 'production' ? 'source-ma' : 'inline-source-map', plugins: [ // Pragmas new webpack.DefinePlugin({ - 'process.env': process.env.NODE_ENV + "process.env": process.env.NODE_ENV }), new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output // both options are optional filename: "css/[name].[contenthash].css", - chunkFilename: "css/[name].[contenthash].css", + chunkFilename: "css/[name].[contenthash].css" }), // Removes the dist folder before each run. - new CleanWebpackPlugin(config.build.assetsPath, {allowExternal: true}), + new CleanWebpackPlugin({ dangerouslyAllowCleanPatternsOutsideProject: true }), // Automatically inject jquery new webpack.ProvidePlugin({ - jQuery: 'jquery/src/jquery', - $: 'jquery/src/jquery', - jquery: 'jquery/src/jquery', - 'window.jQuery': 'jquery/src/jquery' + jQuery: "jquery", + $: "jquery", + jquery: "jquery", + "window.jQuery": "jquery" }), // Write manifest file which Python will read. - new ManifestPlugin({ - fileName: 'manifest.json', - stripSrc: true, - publicPath: config.build.assetsURL - }) + new BundleTracker({ + path: config.build.assetsPath, + filename: './manifest.json', + publicPath: config.build.assetsURL, + }), ], performance: { hints: false } -} +}; if (process.env.npm_config_report) { - var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin - webpackConfig.plugins.push(new BundleAnalyzerPlugin()) + var BundleAnalyzerPlugin = require("webpack-bundle-analyzer") + .BundleAnalyzerPlugin; + webpackConfig.plugins.push(new BundleAnalyzerPlugin()); +} + +if (process.env.NODE_ENV === "development") { + const LiveReloadPlugin = require("webpack-livereload-plugin"); + webpackConfig.plugins.push(new LiveReloadPlugin()); } -module.exports = webpackConfig +module.exports = webpackConfig; diff --git a/rero_ils/theme/webpack_assets/package.json b/rero_ils/theme/webpack_assets/package.json new file mode 100644 index 0000000000..42ebcdc7a7 --- /dev/null +++ b/rero_ils/theme/webpack_assets/package.json @@ -0,0 +1,94 @@ +{ + "author": { + "email": "software@rero.ch", + "name": "RERO" + }, + "dependencies": { + "admin-lte": "~2.4.8", + "angular": "~1.4.9", + "angular-gettext": "~2.3.8", + "bootstrap": "~4.5.3", + "bootstrap-sass": "~3.3.5", + "font-awesome": "~4.4.0", + "jquery": "~3.2.1", + "moment": "~2.23.0", + "popper.js": "1.16.1", + "select2": "~4.0.2" + }, + "description": "RERO ILS assets", + "devDependencies": { + "@babel/core": "^7.2.0", + "@babel/plugin-proposal-class-properties": "^7.2.1", + "@babel/plugin-transform-runtime": "^7.2.0", + "@babel/preset-env": "^7.2.0", + "@babel/preset-react": "^7.0.0", + "@babel/runtime": "^7.2.0", + "autoprefixer": "^9.8.6", + "babel-eslint": "^10.1.0", + "babel-loader": "^8.0.4", + "babel-register": "^6.26.0", + "chalk": "^4.1.0", + "clean-webpack-plugin": "^3.0.0", + "css-loader": "^4.2.1", + "eslint": "^7.7.0", + "eslint-config-prettier": "6.11.0", + "eslint-config-react-app": "^5.2.1", + "eslint-config-standard": "^14.1.1", + "eslint-friendly-formatter": "^4.0.1", + "eslint-loader": "^4.0.2", + "eslint-plugin-flowtype": "^5.2.0", + "eslint-plugin-import": "2.22.0", + "eslint-plugin-jsx-a11y": "6.3.1", + "eslint-plugin-node": ">=7.0.0", + "eslint-plugin-prettier": "3.1.4", + "eslint-plugin-promise": "^4.0.1", + "eslint-plugin-react": "7.20.6", + "eslint-plugin-react-hooks": "^4.1.0", + "eslint-plugin-standard": "^4.0.0", + "eventsource-polyfill": "^0.9.6", + "expose-loader": "^1.0.0", + "file-loader": "^6.0.0", + "friendly-errors-webpack-plugin": "^1.7.0", + "function-bind": "^1.1.1", + "less": "^3.12.2", + "less-loader": "6.2.0", + "mini-css-extract-plugin": "0.10.0", + "node-sass": "^4.12.0", + "optimize-css-assets-webpack-plugin": "5.0.3", + "ora": "^5.0.0", + "patch-package": "^6.2.2", + "postcss-flexbugs-fixes": "^4.1.0", + "postcss-loader": "^3.0.0", + "postcss-preset-env": "^6.4.0", + "postcss-safe-parser": "^4.0.1", + "prettier": "2.0.5", + "rimraf": "^3.0.2", + "sass-loader": "^9.0.3", + "semver": "^7.3.2", + "style-loader": "^1.2.1", + "terser-webpack-plugin": "^4.1.0", + "url-loader": "^4.1.0", + "webpack": "^4.27.1", + "webpack-bundle-analyzer": "^3.0.3", + "webpack-bundle-tracker": "^1.0.0-alpha.1", + "webpack-cli": "^3.1.2", + "webpack-dev-middleware": "^3.4.0", + "webpack-hot-middleware": "^2.24.3", + "webpack-livereload-plugin": "^2.2.0", + "webpack-merge": "^5.1.2", + "webpack-yam-plugin": "^1.0.1" + }, + "engines": { + "node": ">= 12", + "npm": ">= 6" + }, + "name": "reroils-assets", + "peerDependencies": {}, + "private": true, + "scripts": { + "build": "NODE_PRESERVE_SYMLINKS=1 NODE_ENV=production webpack --config ./build/webpack.config.js", + "postinstall": "patch-package", + "start": "NODE_PRESERVE_SYMLINKS=1 NODE_ENV=development webpack --watch --progress --config ./build/webpack.config.js" + }, + "version": "1.0.0" +} diff --git a/rero_ils/webpack_assets/package.json b/rero_ils/webpack_assets/package.json deleted file mode 100644 index 47e727bbb4..0000000000 --- a/rero_ils/webpack_assets/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "author": { - "email": "software@rero.ch", - "name": "RERO" - }, - "dependencies": { - "admin-lte": "~2.4.8", - "angular": "~1.4.9", - "angular-gettext": "~2.3.8", - "bootstrap-sass": "~3.3.5", - "font-awesome": "~4.4.0", - "jquery": "~3.2.1", - "moment": "~2.23.0", - "select2": "~4.0.2" - }, - "description": "Invenio assets", - "devDependencies": { - "@babel/core": "^7.2.0", - "@babel/plugin-proposal-class-properties": "^7.2.1", - "@babel/plugin-transform-runtime": "^7.2.0", - "@babel/preset-env": "^7.2.0", - "@babel/preset-react": "^7.0.0", - "@babel/runtime": "^7.2.0", - "autoprefixer": "^6.7.2", - "babel-eslint": "^9.0.0", - "babel-loader": "^8.0.4", - "babel-register": "^6.26.0", - "chalk": "^2.4.1", - "clean-webpack-plugin": "^1.0.0", - "css-loader": "^0.26.1", - "eslint": "^5.10.0", - "eslint-config-prettier": "3.3.0", - "eslint-config-react-app": "^3.0.5", - "eslint-config-standard": "^12.0.0", - "eslint-friendly-formatter": "^4.0.1", - "eslint-loader": "^2.1.1", - "eslint-plugin-flowtype": "^2.0.0", - "eslint-plugin-import": "2.14.0", - "eslint-plugin-jsx-a11y": "6.1.2", - "eslint-plugin-node": ">=7.0.0", - "eslint-plugin-prettier": "3.0.0", - "eslint-plugin-promise": "^4.0.1", - "eslint-plugin-react": "7.11.1", - "eslint-plugin-standard": "^4.0.0", - "eventsource-polyfill": "^0.9.6", - "expose-loader": "^0.7.5", - "file-loader": "^2.0.0", - "friendly-errors-webpack-plugin": "^1.7.0", - "function-bind": "^1.1.1", - "mini-css-extract-plugin": "0.5.0", - "node-sass": "^4.11.0", - "optimize-css-assets-webpack-plugin": "5.0.1", - "ora": "^3.0.0", - "postcss-flexbugs-fixes": "^4.1.0", - "postcss-loader": "^3.0.0", - "postcss-preset-env": "^6.4.0", - "postcss-safe-parser": "^4.0.1", - "prettier": "1.15.3", - "rimraf": "^2.6.2", - "sass-loader": "^7.1.0", - "semver": "^5.6.0", - "style-loader": "^0.23.1", - "terser-webpack-plugin": "^1.1.0", - "url-loader": "^1.1.2", - "webpack": "^4.27.1", - "webpack-bundle-analyzer": "^3.0.3", - "webpack-cli": "^3.1.2", - "webpack-dev-middleware": "^3.4.0", - "webpack-hot-middleware": "^2.24.3", - "webpack-manifest-plugin": "2.0.4", - "webpack-merge": "^4.1.5", - "webpack-yam-plugin": "^1.0.1" - }, - "engines": { - "node": ">= 4.0.0", - "npm": ">= 3.0.0" - }, - "name": "invenio-assets", - "peerDependencies": {}, - "private": true, - "scripts": { - "build": "webpack --mode production --config ./build/webpack.config.js", - "start": "webpack --watch --config ./build/webpack.config.js" - }, - "version": "1.0.0" -} diff --git a/scripts/bootstrap b/scripts/bootstrap index 86a624c094..bbc242984c 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -131,38 +131,44 @@ if ! $deploy ; then fi # install assets utils -virtualenv_path=`poetry env info -p` -info_msg "Install npm assets utils in: ${virtualenv_path}" -npm install npm@latest -g --prefix "${virtualenv_path}" \ - && success_msg "Latest NPM: installed." \ - || error_msg+exit "Failed to install latest NPM." -npm install --prefix "${virtualenv_path}" --silent --force -g node-sass@4.14.1 clean-css-cli@4.3.0 uglify-js@3.9.4 requirejs@2.3.6 \ - && success_msg "NPM assets utils: installed." \ - || error_msg+exit "NPM assets utils installation failed." +# virtualenv_path=`poetry env info -p` +# info_msg "Install npm assets utils in: ${virtualenv_path}" +# npm install npm@latest -g --prefix "${virtualenv_path}" \ +# && success_msg "Latest NPM: installed." \ +# || error_msg+exit "Failed to install latest NPM." # collect static files and compile html/css assets # ------------------------------------------------ # install the npm dependencies info_msg "Install npm dependencies" -invenio npm +# invenio npm info_msg "Search static folder location" static_folder=$(poetry run invenio shell --no-term-title -c "print('static_folder:%s' % app.static_folder)"|grep static_folder| cut -d: -f2-) info_msg "Install static folder npm dependencies in: ${static_folder}" -npm install --prefix "${static_folder}" +# npm install --prefix "${static_folder}" if [[ -f "${tgz_file}" ]] then info_msg "Install RERO-ILS-UI from tgz: ${tgz_file}" - npm install "${tgz_file}" --prefix "${static_folder}" + npm install --no-save --only=prod --no-fund --no-audit "${tgz_file}" --prefix "${static_folder}" +else + npm install --no-save --only=prod --no-fund --no-audit @rero/rero-ils-ui --prefix "${static_folder}" fi # build the web assets info_msg "Build web assets: collect" -invenio collect -v -info_msg "Build web assets: check (build command)" -invenio assets build +invenio collect +# info_msg "Build web assets: check (build command)" +# invenio assets build info_msg "Build web assets: using webpack for invenio-admin" invenio webpack buildall +if $deploy ; then + if ! $ci ; then + info_msg "Clean web asssets" + invenio webpack clean + fi +fi + success_msg "${PROGRAM} finished!" exit 0 diff --git a/setup.py b/setup.py index b70788b63f..5fd3bd6d31 100644 --- a/setup.py +++ b/setup.py @@ -95,7 +95,7 @@ def run(self): 'libraries = rero_ils.modules.libraries.views:blueprint', 'notifications = rero_ils.modules.notifications.views:blueprint', 'patrons = rero_ils.modules.patrons.views:blueprint', - 'rero_ils = rero_ils.views:blueprint', + 'rero_ils = rero_ils.theme.views:blueprint', 'templates = rero_ils.modules.templates.views:blueprint', ], 'invenio_base.api_blueprints': [ @@ -118,21 +118,8 @@ def run(self): 'messages = rero_ils', 'messages_wiki = flask_wiki', ], - 'invenio_assets.bundles': [ - 'rero_ils_main_css = rero_ils.bundles:main_css', - 'rero_ils_main_js = rero_ils.bundles:js', - 'rero_ils_documents_detailed_js = \ - rero_ils.modules.documents.bundles:detailed_js', - 'rero_ils_admin_ui_js = rero_ils.bundles:admin_ui_js', - 'rero_ils_search_bar_ui_js = rero_ils.bundles:search_bar_ui_js', - 'rero_ils_public_search_ui_js = \ - rero_ils.bundles:public_search_ui_js', - 'rero_ils_persons_detailed_js = \ - rero_ils.modules.contributions.bundles:detailed_js', - 'rero_ils_patron_profile_js = \ - rero_ils.modules.patrons.bundles:patron_profile_js', - 'rero_ils_ill_request_form_js = \ - rero_ils.modules.ill_requests.bundles:ill_request_form_js' + 'invenio_assets.webpack': [ + 'reroils_theme = rero_ils.theme.webpack:theme' ], 'dojson.cli': [ 'reverse = rero_ils.dojson.cli:reverse',