From 68ce7115b2d97d2f98d169342fe734a589960c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Marie=CC=81thoz?= Date: Wed, 2 Dec 2020 13:30:26 +0100 Subject: [PATCH] assets: move to webpack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Removes npm utils from the bootstrap script. * Removes angularjs translations extraction. * Moves all theme related files into a specific directory. * Removes all bundles files. * Removes useless INVENIO_SEARCH_UI configuration variables. * Includes the angular application with a custom manner: it does not make sense to use `invenio-assets` for an already optimized bundle. * Removes js to store the last visited html tab, closes #1394. * Removes angularjs dependency. * Use simple code to generate thumbnails in the document detailed view. * Reduces the docker image size by cleaning several cache files. * Closes #713. Signed-off-by: Johnny Mariéthoz --- Dockerfile.base | 1 - babel.ini | 5 - docs/api.rst | 2 +- poetry.lock | 91 ++++--- pyproject.toml | 1 - rero_ils/bundles.py | 105 -------- rero_ils/config.py | 23 +- rero_ils/filter.py | 37 +++ rero_ils/modules/contributions/bundles.py | 37 --- .../static/js/rero_ils/contribution.js | 45 ---- .../rero_ils/detailed_view_contribution.html | 2 +- rero_ils/modules/contributions/views.py | 7 +- rero_ils/modules/documents/bundles.py | 46 ---- .../static/js/rero_ils/detailed_app.js | 34 --- .../documents/static/js/rero_ils/documents.js | 36 --- .../static/js/rero_ils/documents_jq.js | 28 --- .../documents/static/js/rero_ils/thumbnail.js | 96 -------- .../templates/rero_ils/_documents_get.html | 4 +- .../rero_ils/detailed_view_documents.html | 31 +-- rero_ils/modules/documents/utils.py | 19 ++ rero_ils/modules/documents/views.py | 19 +- rero_ils/modules/ext.py | 5 +- rero_ils/modules/ill_requests/bundles.py | 35 --- .../static/js/rero_ils/ill_request_form.js | 34 --- .../static/js/rero_ils/patron_fees_toogle.js | 53 ---- .../templates/rero_ils/patron_profile.html | 2 +- rero_ils/static/js/rero_ils/invenio_config.js | 38 --- rero_ils/static/js/rero_ils/rero_ils.js | 94 ------- rero_ils/static/js/rero_ils/rero_keep_tab.js | 49 ---- rero_ils/static/js/rero_ils/search_app.js | 41 ---- rero_ils/static/js/rero_ils/translations.js | 23 -- rero_ils/static/scss/rero_ils/cover.scss | 22 -- rero_ils/static/templates/rero_ils/count.html | 25 -- .../static/templates/rero_ils/facets.html | 64 ----- .../static/templates/rero_ils/pagination.html | 52 ---- .../static/templates/rero_ils/searchbar.html | 34 --- .../patrons/bundles.py => theme/__init__.py} | 19 +- rero_ils/theme/assets/js/reroils/login.js | 59 +++++ .../assets/js/reroils/public.js} | 8 +- .../assets/js/reroils/toast.js} | 9 +- rero_ils/theme/assets/js/reroils/toggle.js | 77 ++++++ .../assets/js/reroils/tooltip.js} | 6 +- .../rero_ils/contributions/detailed.scss} | 0 .../scss/rero_ils/documents/detailed.scss} | 0 .../assets}/scss/rero_ils/footer.scss | 0 .../assets}/scss/rero_ils/frontpage.scss | 0 .../assets}/scss/rero_ils/header.scss | 0 .../assets}/scss/rero_ils/page.scss | 0 .../scss/rero_ils/patrons/profile.scss} | 0 .../assets}/scss/rero_ils/search.scss | 0 .../assets}/scss/rero_ils/styles.scss | 29 ++- .../assets}/scss/rero_ils/thumbnail.scss | 10 +- .../assets}/scss/rero_ils/variables.scss | 2 +- .../apple-touch-icon-144-precomposed.png | Bin .../{ => theme}/static/apple-touch-icon.png | Bin .../{ => theme}/static/css/rero_ils/wiki.css | 0 rero_ils/{ => theme}/static/favicon.ico | Bin .../static/images/GitHub-Mark-120px-plus.png | Bin .../static/images/Twitter_Logo_Blue.png | Bin .../static/images/homepage_image_bleu.jpg | Bin .../static/images/logo-taiga-color.png | Bin .../static/images/logo_explore_height_119.png | Bin .../static/images/logo_rero_21_inline.png | Bin .../static/images/logo_rero_ils.png | Bin .../static/images/logo_rerodoc_height_119.png | Bin rero_ils/{ => theme}/static/images/rero21.svg | 0 rero_ils/{ => theme}/templates/__init__.py | 0 .../rero_ils/_editor_button_actions.html | 0 .../templates/rero_ils/_info_pilot.html | 0 .../templates/rero_ils/_info_test.html | 0 .../templates/rero_ils/breadcrumbs.html | 0 .../templates/rero_ils/collections.html | 0 .../templates/rero_ils/footer.html | 0 .../templates/rero_ils/forgot_password.html | 0 .../templates/rero_ils/frontpage.html | 0 .../templates/rero_ils/header.html | 0 .../templates/rero_ils/header_frontpage.html | 0 .../templates/rero_ils/javascript.html | 13 +- .../templates/rero_ils/login_user.html | 0 .../rero_ils/macros/header_menus.html | 0 .../templates/rero_ils/macros/macro.html | 0 .../templates/rero_ils/macros/messages.html | 0 .../{ => theme}/templates/rero_ils/page.html | 5 +- .../templates/rero_ils/page_cover.html | 8 +- .../templates/rero_ils/page_error.html | 0 .../templates/rero_ils/page_settings.html | 0 .../templates/rero_ils/page_wiki.html | 0 .../templates/rero_ils/professional.html | 7 +- .../templates/rero_ils/register_user.html | 0 .../templates/rero_ils/reset_password.html | 0 .../templates/rero_ils/search.html | 10 +- .../templates/rero_ils/tombstone.html | 0 .../templates/rero_ils/trackingcode.html | 0 .../security/email/reset_instructions.html | 0 .../security/email/reset_instructions.txt | 0 rero_ils/{ => theme}/views.py | 4 +- rero_ils/{ => theme}/webpack.py | 21 +- rero_ils/utils.py | 1 + rero_ils/webpack_assets/.babelrc | 6 - .../webpack_assets/build/webpack.config.js | 230 ------------------ rero_ils/webpack_assets/package.json | 86 ------- scripts/bootstrap | 41 ++-- scripts/russian_dolls | 2 +- setup.py | 23 +- tests/ui/test_views.py | 2 +- 105 files changed, 358 insertions(+), 1560 deletions(-) delete mode 100644 rero_ils/bundles.py delete mode 100644 rero_ils/modules/contributions/bundles.py delete mode 100644 rero_ils/modules/contributions/static/js/rero_ils/contribution.js delete mode 100644 rero_ils/modules/documents/bundles.py delete mode 100644 rero_ils/modules/documents/static/js/rero_ils/detailed_app.js delete mode 100644 rero_ils/modules/documents/static/js/rero_ils/documents.js delete mode 100644 rero_ils/modules/documents/static/js/rero_ils/documents_jq.js delete mode 100644 rero_ils/modules/documents/static/js/rero_ils/thumbnail.js delete mode 100644 rero_ils/modules/ill_requests/bundles.py delete mode 100644 rero_ils/modules/ill_requests/static/js/rero_ils/ill_request_form.js delete mode 100644 rero_ils/modules/patrons/static/js/rero_ils/patron_fees_toogle.js delete mode 100644 rero_ils/static/js/rero_ils/invenio_config.js delete mode 100644 rero_ils/static/js/rero_ils/rero_ils.js delete mode 100644 rero_ils/static/js/rero_ils/rero_keep_tab.js delete mode 100644 rero_ils/static/js/rero_ils/search_app.js delete mode 100644 rero_ils/static/js/rero_ils/translations.js delete mode 100644 rero_ils/static/scss/rero_ils/cover.scss delete mode 100644 rero_ils/static/templates/rero_ils/count.html delete mode 100644 rero_ils/static/templates/rero_ils/facets.html delete mode 100644 rero_ils/static/templates/rero_ils/pagination.html delete mode 100644 rero_ils/static/templates/rero_ils/searchbar.html rename rero_ils/{modules/patrons/bundles.py => theme/__init__.py} (61%) create mode 100644 rero_ils/theme/assets/js/reroils/login.js rename rero_ils/{assets/js/admin_ui.js => theme/assets/js/reroils/public.js} (80%) rename rero_ils/{assets/js/public-search_ui.js => theme/assets/js/reroils/toast.js} (78%) create mode 100644 rero_ils/theme/assets/js/reroils/toggle.js rename rero_ils/{modules/contributions/static/js/rero_ils/contribution_jq.js => theme/assets/js/reroils/tooltip.js} (87%) rename rero_ils/{modules/contributions/static/scss/rero_ils/person.scss => theme/assets/scss/rero_ils/contributions/detailed.scss} (100%) rename rero_ils/{modules/documents/static/scss/rero_ils/item_detail.scss => theme/assets/scss/rero_ils/documents/detailed.scss} (100%) rename rero_ils/{static => theme/assets}/scss/rero_ils/footer.scss (100%) rename rero_ils/{static => theme/assets}/scss/rero_ils/frontpage.scss (100%) rename rero_ils/{static => theme/assets}/scss/rero_ils/header.scss (100%) rename rero_ils/{static => theme/assets}/scss/rero_ils/page.scss (100%) rename rero_ils/{modules/patrons/static/scss/rero_ils/patrons_profile.scss => theme/assets/scss/rero_ils/patrons/profile.scss} (100%) rename rero_ils/{static => theme/assets}/scss/rero_ils/search.scss (100%) rename rero_ils/{static => theme/assets}/scss/rero_ils/styles.scss (84%) rename rero_ils/{modules/documents/static => theme/assets}/scss/rero_ils/thumbnail.scss (89%) rename rero_ils/{static => theme/assets}/scss/rero_ils/variables.scss (95%) rename rero_ils/{ => theme}/static/apple-touch-icon-144-precomposed.png (100%) rename rero_ils/{ => theme}/static/apple-touch-icon.png (100%) rename rero_ils/{ => theme}/static/css/rero_ils/wiki.css (100%) rename rero_ils/{ => theme}/static/favicon.ico (100%) rename rero_ils/{ => theme}/static/images/GitHub-Mark-120px-plus.png (100%) rename rero_ils/{ => theme}/static/images/Twitter_Logo_Blue.png (100%) rename rero_ils/{ => theme}/static/images/homepage_image_bleu.jpg (100%) rename rero_ils/{ => theme}/static/images/logo-taiga-color.png (100%) rename rero_ils/{ => theme}/static/images/logo_explore_height_119.png (100%) rename rero_ils/{ => theme}/static/images/logo_rero_21_inline.png (100%) rename rero_ils/{ => theme}/static/images/logo_rero_ils.png (100%) rename rero_ils/{ => theme}/static/images/logo_rerodoc_height_119.png (100%) rename rero_ils/{ => theme}/static/images/rero21.svg (100%) rename rero_ils/{ => theme}/templates/__init__.py (100%) rename rero_ils/{ => theme}/templates/rero_ils/_editor_button_actions.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/_info_pilot.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/_info_test.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/breadcrumbs.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/collections.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/footer.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/forgot_password.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/frontpage.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/header.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/header_frontpage.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/javascript.html (67%) rename rero_ils/{ => theme}/templates/rero_ils/login_user.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/macros/header_menus.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/macros/macro.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/macros/messages.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/page.html (95%) rename rero_ils/{ => theme}/templates/rero_ils/page_cover.html (92%) rename rero_ils/{ => theme}/templates/rero_ils/page_error.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/page_settings.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/page_wiki.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/professional.html (62%) rename rero_ils/{ => theme}/templates/rero_ils/register_user.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/reset_password.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/search.html (81%) rename rero_ils/{ => theme}/templates/rero_ils/tombstone.html (100%) rename rero_ils/{ => theme}/templates/rero_ils/trackingcode.html (100%) rename rero_ils/{ => theme}/templates/security/email/reset_instructions.html (100%) rename rero_ils/{ => theme}/templates/security/email/reset_instructions.txt (100%) rename rero_ils/{ => theme}/views.py (99%) rename rero_ils/{ => theme}/webpack.py (67%) delete mode 100644 rero_ils/webpack_assets/.babelrc delete mode 100644 rero_ils/webpack_assets/build/webpack.config.js delete mode 100644 rero_ils/webpack_assets/package.json diff --git a/Dockerfile.base b/Dockerfile.base index 147f400dd2..dda9514ce6 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -27,7 +27,6 @@ RUN pip install --upgrade setuptools wheel pip "poetry<1.1.0" # Install Node RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - RUN apt-get install --no-install-recommends -y nodejs && rm -rf /var/lib/apt/lists/* -RUN npm install --silent node-sass@4.14.1 clean-css-cli@4.3.0 uglify-js@3.9.4 requirejs@2.3.6 # RUN npm update diff --git a/babel.ini b/babel.ini index 9d07427b41..96c7096865 100644 --- a/babel.ini +++ b/babel.ini @@ -21,9 +21,6 @@ encoding = utf-8 [python: **/manual_translations.txt] encoding = utf-8 -# Extraction from Angular templates -[angular_gettext: **/static/templates/**/**.html] - # Extraction from Jinja2 templates [jinja2: **/templates/**.html] encoding = utf-8 @@ -32,12 +29,10 @@ silent=false # Extraction from JavaScript files [ignore: static/js/rero_ils/admin/**] -[ignore: **/webpack_assets/**/**.js] [javascript: **.js] encoding = utf-8 extract_messages = $._, jQuery._ # Extraction from json files (schema, form) -[ignore: **/webpack_assets/**/**.json] [json: **.json] keys_to_translate = ['^title$', '^label$', 'description', 'placeholder', 'name', 'add', '403', '.*Message'] diff --git a/docs/api.rst b/docs/api.rst index 07ea2b7c22..e903c4f8ba 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -20,5 +20,5 @@ API Docs Views ----- -.. automodule:: rero_ils.views +.. automodule:: rero_ils.theme.views :members: diff --git a/poetry.lock b/poetry.lock index 1c5ec3cb00..c103dc0806 100644 --- a/poetry.lock +++ b/poetry.lock @@ -31,21 +31,6 @@ version = "5.0.2" [package.dependencies] vine = "5.0.0" -[[package]] -category = "main" -description = "A plugin for babel to work with angular-gettext templates" -name = "angular-gettext-babel" -optional = false -python-versions = "*" -version = "0.3" - -[package.dependencies] -babel = "*" - -[package.extras] -dev = ["check-manifest"] -test = ["coverage"] - [[package]] category = "dev" description = "apipkg: namespace control and lazy-import mechanism" @@ -56,11 +41,11 @@ version = "1.5" [[package]] category = "main" -description = "Disable App Nap on OS X 10.9" +description = "Disable App Nap on macOS >= 10.9" name = "appnope" optional = false python-versions = "*" -version = "0.1.0" +version = "0.1.2" [[package]] category = "main" @@ -993,17 +978,18 @@ version = "1.2.0" [[package]] category = "main" description = "Read metadata from Python packages" +marker = "python_version < \"3.8\" or python_version >= \"3.7\" and python_version < \"3.8\"" name = "importlib-metadata" optional = false python-versions = ">=3.6" -version = "3.1.0" +version = "3.1.1" [package.dependencies] zipp = ">=0.5" [package.extras] -docs = ["sphinx", "rst.linker"] -testing = ["packaging", "pep517", "unittest2", "importlib-resources (>=1.3)"] +docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] +testing = ["pytest (>=3.5,<3.7.3 || >3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "jaraco.test (>=3.2.0)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] [[package]] category = "main" @@ -2026,7 +2012,7 @@ description = "Apply JSON-Patches (RFC 6902)" name = "jsonpatch" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "1.27" +version = "1.28" [package.dependencies] jsonpointer = ">=1.9" @@ -2036,16 +2022,8 @@ category = "main" description = "Python library for serializing any arbitrary object graph into JSON" name = "jsonpickle" optional = false -python-versions = ">=2.7" -version = "1.4.1" - -[package.dependencies] -importlib-metadata = "*" - -[package.extras] -docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] -testing = ["coverage (<5)", "pytest (>=3.5,<3.7.3 || >3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-black-multipy", "pytest-cov", "ecdsa", "feedparser", "numpy", "pandas", "pymongo", "sqlalchemy", "enum34", "jsonlib"] -"testing.libs" = ["demjson", "simplejson", "ujson", "yajl"] +python-versions = "*" +version = "1.2" [[package]] category = "main" @@ -2323,11 +2301,10 @@ description = "Core utilities for Python packages" name = "packaging" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "20.4" +version = "20.7" [package.dependencies] pyparsing = ">=2.0.2" -six = "*" [[package]] category = "main" @@ -2824,7 +2801,10 @@ description = "Redis Scheduler For Celery, Support Add Task Dynamic" name = "redisbeat" optional = false python-versions = "*" -version = "1.2.2" +version = "1.2.4" + +[package.dependencies] +jsonpickle = "1.2" [[package]] category = "main" @@ -3424,6 +3404,7 @@ version = "0.12.0" [[package]] category = "main" description = "Backport of pathlib-compatible object wrapper for zip files" +marker = "python_version < \"3.8\" or python_version >= \"3.7\" and python_version < \"3.8\" or python_version >= \"3.7\" and python_version < \"3.8\" and (python_version < \"3.8\" or python_version >= \"3.7\" and python_version < \"3.8\")" name = "zipp" optional = false python-versions = ">=3.6" @@ -3437,7 +3418,8 @@ testing = ["pytest (>=3.5,<3.7.3 || >3.7.3)", "pytest-checkdocs (>=1.2.3)", "pyt sip2 = ["invenio-sip2"] [metadata] -content-hash = "ec46c48e22530940ef31b24f461fbf544e89d020b5e3e5d18f4b63ddb456c84c" +content-hash = "0973b1b2a75191f71f3c5b075b95c25350e07777a5efbf2ab93ceb88e9e46081" +lock-version = "1.0" python-versions = ">= 3.6, < 3.8" [metadata.files] @@ -3453,16 +3435,13 @@ amqp = [ {file = "amqp-5.0.2-py3-none-any.whl", hash = "sha256:5b9062d5c0812335c75434bf17ce33d7a20ecfedaa0733faec7379868eb4068a"}, {file = "amqp-5.0.2.tar.gz", hash = "sha256:fcd5b3baeeb7fc19b3486ff6d10543099d40ae1f5c9196eae695d1cde1b2f784"}, ] -angular-gettext-babel = [ - {file = "angular_gettext_babel-0.3-py2.py3-none-any.whl", hash = "sha256:9ff197829501e994ac962c0b22aba99459dcf7b0018bf6514a0de15796ba37d9"}, -] apipkg = [ {file = "apipkg-1.5-py2.py3-none-any.whl", hash = "sha256:58587dd4dc3daefad0487f6d9ae32b4542b185e1c36db6993290e7c41ca2b47c"}, {file = "apipkg-1.5.tar.gz", hash = "sha256:37228cda29411948b422fae072f57e31d3396d2ee1c9783775980ee9c9990af6"}, ] appnope = [ - {file = "appnope-0.1.0-py2.py3-none-any.whl", hash = "sha256:5b26757dc6f79a3b7dc9fab95359328d5747fcb2409d331ea66d0272b90ab2a0"}, - {file = "appnope-0.1.0.tar.gz", hash = "sha256:8b995ffe925347a2138d7ac0fe77155e4311a0ea6d6da4f5128fe4b3cbe5ed71"}, + {file = "appnope-0.1.2-py2.py3-none-any.whl", hash = "sha256:93aa393e9d6c54c5cd570ccadd8edad61ea0c4b9ea7a01409020c9aa019eb442"}, + {file = "appnope-0.1.2.tar.gz", hash = "sha256:dd83cd4b5b460958838f6eb3000c660b1f9caf2a5b1de4264e941512f603258a"}, ] arrow = [ {file = "arrow-0.17.0-py2.py3-none-any.whl", hash = "sha256:e098abbd9af3665aea81bdd6c869e93af4feb078e98468dd351c383af187aac5"}, @@ -3804,8 +3783,8 @@ imagesize = [ {file = "imagesize-1.2.0.tar.gz", hash = "sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1"}, ] importlib-metadata = [ - {file = "importlib_metadata-3.1.0-py2.py3-none-any.whl", hash = "sha256:590690d61efdd716ff82c39ca9a9d4209252adfe288a4b5721181050acbd4175"}, - {file = "importlib_metadata-3.1.0.tar.gz", hash = "sha256:d9b8a46a0885337627a6430db287176970fff18ad421becec1d64cfc763c2099"}, + {file = "importlib_metadata-3.1.1-py3-none-any.whl", hash = "sha256:6112e21359ef8f344e7178aa5b72dc6e62b38b0d008e6d3cb212c5b84df72013"}, + {file = "importlib_metadata-3.1.1.tar.gz", hash = "sha256:b0c2d3b226157ae4517d9625decf63591461c66b3a808c2666d538946519d170"}, ] infinity = [ {file = "infinity-1.5.tar.gz", hash = "sha256:8daa7c15ce2100fdccfde212337e0cd5cf085869f54dc2634b6c30d61461ecda"}, @@ -3958,12 +3937,12 @@ jsmin = [ {file = "jsmin-2.2.2.tar.gz", hash = "sha256:b6df99b2cd1c75d9d342e4335b535789b8da9107ec748212706ef7bbe5c2553b"}, ] jsonpatch = [ - {file = "jsonpatch-1.27-py2.py3-none-any.whl", hash = "sha256:86eaaccfac8891c6a09ab48aec13fb5921ff32c838e7a19981f0d2b94915f668"}, - {file = "jsonpatch-1.27.tar.gz", hash = "sha256:4d08af10d71723b5b2924da6ba90f273a4d1a5c6accfb605eb970cb2f9b29cf9"}, + {file = "jsonpatch-1.28-py2.py3-none-any.whl", hash = "sha256:da3831be60919e8c98564acfc1fa918cb96e7c9750b0428388483f04d0d1c5a7"}, + {file = "jsonpatch-1.28.tar.gz", hash = "sha256:e930adc932e4d36087dbbf0f22e1ded32185dfb20662f2e3dd848677a5295a14"}, ] jsonpickle = [ - {file = "jsonpickle-1.4.1-py2.py3-none-any.whl", hash = "sha256:8919c166bac0574e3d74425c7559434062002d9dfc0ac2afa6dc746ba4a19439"}, - {file = "jsonpickle-1.4.1.tar.gz", hash = "sha256:e8d4b7cd0bd6826001a74377df1079a76ad8bae0f909282de2554164c837c8ba"}, + {file = "jsonpickle-1.2-py2.py3-none-any.whl", hash = "sha256:d0c5a4e6cb4e58f6d5406bdded44365c2bcf9c836c4f52910cc9ba7245a59dc2"}, + {file = "jsonpickle-1.2.tar.gz", hash = "sha256:d3e922d781b1d0096df2dad89a2e1f47177d7969b596aea806a9d91b4626b29b"}, ] jsonpointer = [ {file = "jsonpointer-2.0-py2.py3-none-any.whl", hash = "sha256:ff379fa021d1b81ab539f5ec467c7745beb1a5671463f9dcc2b2d458bd361c1e"}, @@ -4148,8 +4127,8 @@ oauthlib = [ {file = "oauthlib-2.1.0.tar.gz", hash = "sha256:ac35665a61c1685c56336bda97d5eefa246f1202618a1d6f34fccb1bdd404162"}, ] packaging = [ - {file = "packaging-20.4-py2.py3-none-any.whl", hash = "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"}, - {file = "packaging-20.4.tar.gz", hash = "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8"}, + {file = "packaging-20.7-py2.py3-none-any.whl", hash = "sha256:eb41423378682dadb7166144a4926e443093863024de508ca5c9737d6bc08376"}, + {file = "packaging-20.7.tar.gz", hash = "sha256:05af3bb85d320377db281cf254ab050e1a7ebcbf5410685a9a407e18a1f81236"}, ] parso = [ {file = "parso-0.7.1-py2.py3-none-any.whl", hash = "sha256:97218d9159b2520ff45eb78028ba8b50d2bc61dcc062a9682666f2dc4bd331ea"}, @@ -4220,8 +4199,11 @@ psycopg2-binary = [ {file = "psycopg2_binary-2.8.6-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:2dac98e85565d5688e8ab7bdea5446674a83a3945a8f416ad0110018d1501b94"}, {file = "psycopg2_binary-2.8.6-cp38-cp38-win32.whl", hash = "sha256:bd1be66dde2b82f80afb9459fc618216753f67109b859a361cf7def5c7968729"}, {file = "psycopg2_binary-2.8.6-cp38-cp38-win_amd64.whl", hash = "sha256:8cd0fb36c7412996859cb4606a35969dd01f4ea34d9812a141cd920c3b18be77"}, + {file = "psycopg2_binary-2.8.6-cp39-cp39-macosx_10_9_x86_64.macosx_10_9_intel.macosx_10_10_intel.macosx_10_10_x86_64.whl", hash = "sha256:89705f45ce07b2dfa806ee84439ec67c5d9a0ef20154e0e475e2b2ed392a5b83"}, {file = "psycopg2_binary-2.8.6-cp39-cp39-manylinux1_i686.whl", hash = "sha256:42ec1035841b389e8cc3692277a0bd81cdfe0b65d575a2c8862cec7a80e62e52"}, {file = "psycopg2_binary-2.8.6-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:7312e931b90fe14f925729cde58022f5d034241918a5c4f9797cac62f6b3a9dd"}, + {file = "psycopg2_binary-2.8.6-cp39-cp39-win32.whl", hash = "sha256:6422f2ff0919fd720195f64ffd8f924c1395d30f9a495f31e2392c2efafb5056"}, + {file = "psycopg2_binary-2.8.6-cp39-cp39-win_amd64.whl", hash = "sha256:15978a1fbd225583dd8cdaf37e67ccc278b5abecb4caf6b2d6b8e2b948e953f6"}, ] ptyprocess = [ {file = "ptyprocess-0.6.0-py2.py3-none-any.whl", hash = "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f"}, @@ -4341,6 +4323,8 @@ pyyaml = [ {file = "PyYAML-5.3.1-cp37-cp37m-win_amd64.whl", hash = "sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf"}, {file = "PyYAML-5.3.1-cp38-cp38-win32.whl", hash = "sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97"}, {file = "PyYAML-5.3.1-cp38-cp38-win_amd64.whl", hash = "sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee"}, + {file = "PyYAML-5.3.1-cp39-cp39-win32.whl", hash = "sha256:ad9c67312c84def58f3c04504727ca879cb0013b2517c85a9a253f0cb6380c0a"}, + {file = "PyYAML-5.3.1-cp39-cp39-win_amd64.whl", hash = "sha256:6034f55dab5fea9e53f436aa68fa3ace2634918e8b5994d82f3621c04ff5ed2e"}, {file = "PyYAML-5.3.1.tar.gz", hash = "sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"}, ] raven = [ @@ -4352,7 +4336,7 @@ redis = [ {file = "redis-3.5.3.tar.gz", hash = "sha256:0e7e0cfca8660dea8b7d5cd8c4f6c5e29e11f31158c0b0ae91a397f00e5a05a2"}, ] redisbeat = [ - {file = "redisbeat-1.2.2.tar.gz", hash = "sha256:59b7e9984cb9cde9eaea21093ca2b953f83995a64b6c240e4c36f1b2e9ed1e38"}, + {file = "redisbeat-1.2.4.tar.gz", hash = "sha256:0b800c6c20168780442b575d583d82d83d7e9326831ffe35f763289ebcd8b4f6"}, ] regex = [ {file = "regex-2020.11.13-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:8b882a78c320478b12ff024e81dc7d43c1462aa4a3341c754ee65d857a521f85"}, @@ -4577,19 +4561,28 @@ typed-ast = [ {file = "typed_ast-1.4.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:269151951236b0f9a6f04015a9004084a5ab0d5f19b57de779f908621e7d8b75"}, {file = "typed_ast-1.4.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:24995c843eb0ad11a4527b026b4dde3da70e1f2d8806c99b7b4a7cf491612652"}, {file = "typed_ast-1.4.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:fe460b922ec15dd205595c9b5b99e2f056fd98ae8f9f56b888e7a17dc2b757e7"}, + {file = "typed_ast-1.4.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:fcf135e17cc74dbfbc05894ebca928ffeb23d9790b3167a674921db19082401f"}, {file = "typed_ast-1.4.1-cp36-cp36m-win32.whl", hash = "sha256:4e3e5da80ccbebfff202a67bf900d081906c358ccc3d5e3c8aea42fdfdfd51c1"}, {file = "typed_ast-1.4.1-cp36-cp36m-win_amd64.whl", hash = "sha256:249862707802d40f7f29f6e1aad8d84b5aa9e44552d2cc17384b209f091276aa"}, {file = "typed_ast-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8ce678dbaf790dbdb3eba24056d5364fb45944f33553dd5869b7580cdbb83614"}, {file = "typed_ast-1.4.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:c9e348e02e4d2b4a8b2eedb48210430658df6951fa484e59de33ff773fbd4b41"}, {file = "typed_ast-1.4.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:bcd3b13b56ea479b3650b82cabd6b5343a625b0ced5429e4ccad28a8973f301b"}, + {file = "typed_ast-1.4.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:f208eb7aff048f6bea9586e61af041ddf7f9ade7caed625742af423f6bae3298"}, {file = "typed_ast-1.4.1-cp37-cp37m-win32.whl", hash = "sha256:d5d33e9e7af3b34a40dc05f498939f0ebf187f07c385fd58d591c533ad8562fe"}, {file = "typed_ast-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:0666aa36131496aed8f7be0410ff974562ab7eeac11ef351def9ea6fa28f6355"}, {file = "typed_ast-1.4.1-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:d205b1b46085271b4e15f670058ce182bd1199e56b317bf2ec004b6a44f911f6"}, {file = "typed_ast-1.4.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:6daac9731f172c2a22ade6ed0c00197ee7cc1221aa84cfdf9c31defeb059a907"}, {file = "typed_ast-1.4.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d"}, + {file = "typed_ast-1.4.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:7e4c9d7658aaa1fc80018593abdf8598bf91325af6af5cce4ce7c73bc45ea53d"}, {file = "typed_ast-1.4.1-cp38-cp38-win32.whl", hash = "sha256:715ff2f2df46121071622063fc7543d9b1fd19ebfc4f5c8895af64a77a8c852c"}, {file = "typed_ast-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:fc0fea399acb12edbf8a628ba8d2312f583bdbdb3335635db062fa98cf71fca4"}, {file = "typed_ast-1.4.1-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:d43943ef777f9a1c42bf4e552ba23ac77a6351de620aa9acf64ad54933ad4d34"}, + {file = "typed_ast-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:92c325624e304ebf0e025d1224b77dd4e6393f18aab8d829b5b7e04afe9b7a2c"}, + {file = "typed_ast-1.4.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:d648b8e3bf2fe648745c8ffcee3db3ff903d0817a01a12dd6a6ea7a8f4889072"}, + {file = "typed_ast-1.4.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:fac11badff8313e23717f3dada86a15389d0708275bddf766cca67a84ead3e91"}, + {file = "typed_ast-1.4.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:0d8110d78a5736e16e26213114a38ca35cb15b6515d535413b090bd50951556d"}, + {file = "typed_ast-1.4.1-cp39-cp39-win32.whl", hash = "sha256:b52ccf7cfe4ce2a1064b18594381bccf4179c2ecf7f513134ec2f993dd4ab395"}, + {file = "typed_ast-1.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:3742b32cf1c6ef124d57f95be609c473d7ec4c14d0090e5a5e05a15269fb4d0c"}, {file = "typed_ast-1.4.1.tar.gz", hash = "sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b"}, ] tzlocal = [ diff --git a/pyproject.toml b/pyproject.toml index 9a067c5c24..ce0b6f6e72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,6 @@ redisbeat = "*" jsonpickle = "*" ciso8601 = "*" # TODO: to be removed when the thumbnail will be refactored -angular-gettext-babel= ">=0.1" invenio-userprofiles = {git = "https://github.com/rero/invenio-userprofiles.git", tag = "reroprofile"} ## Additionnal constraints on python modules 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..df6dab6247 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 @@ -196,14 +181,13 @@ def _(x): THEME_SETTINGS_TEMPLATE = SETTINGS_TEMPLATE #: 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' # 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 +1470,6 @@ def _(x): ), ) -SEARCH_UI_SEARCH_INDEX = 'documents' # Default view code for all organisations view # TODO: Should be taken into angular @@ -2089,8 +2072,6 @@ def _(x): INDEXER_REPLACE_REFS = True INDEXER_RECORD_TO_INDEX = 'rero_ils.modules.indexer_utils.record_to_index' -SEARCH_UI_SEARCH_API = '/api/documents/' - RERO_ILS_APP_URL_SCHEME = 'https' RERO_ILS_APP_HOST = 'ils.rero.ch' #: Actual URL used to construct links in notifications for example diff --git a/rero_ils/filter.py b/rero_ils/filter.py index f21d2d5aea..d8cb129de7 100644 --- a/rero_ils/filter.py +++ b/rero_ils/filter.py @@ -17,7 +17,9 @@ """Jinja filters.""" +import glob import json +import os import re import dateparser @@ -27,6 +29,41 @@ from markupsafe import Markup +def node_assets(package, patterns=[ + 'runtime*.js', 'polyfills*.js', 'main*.js'], _type='js', tags=''): + """Generate the node assets html code. + + :param package: The node package path relative to node_modules. + :param patters: list of glob bash like partterns. + "param _type: string one of ['js', 'css']. + "param tags: additional script, link, html tags such as 'defer', etc. + "return" html link, script code + """ + package_path = os.path.join( + current_app.static_folder, 'node_modules', package) + + def to_html(value): + value = re.sub(r'(.*?)\/static', '/static', value) + # default: js + html_code = '' + # styles + if _type == 'css': + html_code = '' + return html_code.format( + value=value, + tags=tags + ) + output_files = [] + for pattern in patterns: + files = glob.glob(os.path.join(package_path, pattern)) + output_files.extend([to_html(v) for v in files]) + + class HTMLSafe: + def __html__(): + return Markup('\n'.join(output_files)) + return HTMLSafe + + 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/templates/rero_ils/detailed_view_contribution.html b/rero_ils/modules/contributions/templates/rero_ils/detailed_view_contribution.html index 22212ac5c6..b6d40cf492 100644 --- a/rero_ils/modules/contributions/templates/rero_ils/detailed_view_contribution.html +++ b/rero_ils/modules/contributions/templates/rero_ils/detailed_view_contribution.html @@ -36,7 +36,7 @@

{{ record | contribution_label(current_i18n.language) }}

- {% if record | get_cover_art%} - - - - - {% else %}
- - +
+ +
{{ _(record.type) }}
+
- {% endif %}

{{ record.title | create_title_text }} @@ -132,7 +117,7 @@

{% if accesses|length < 1 and not holdings %}

- {%- 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..4cda12eed7 100644 --- a/rero_ils/templates/rero_ils/professional.html +++ b/rero_ils/theme/templates/rero_ils/professional.html @@ -25,15 +25,12 @@ Admin - - + {{ node_assets('@rero/rero-ils-ui/dist/admin', ['styles.*css'], 'css') }} - {% assets "rero_ils_admin_ui_js" %} - - {% endassets %} + {{ node_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..89f4bae837 100644 --- a/rero_ils/templates/rero_ils/search.html +++ b/rero_ils/theme/templates/rero_ils/search.html @@ -27,11 +27,7 @@ {%- endblock page_body -%} {%- block javascript %} - {% assets "rero_ils_main_js" %} - - {% endassets %} - - {% assets "rero_ils_public_search_ui_js" %} - - {% endassets %} +{{ webpack['vendor.js']}} +{{ webpack['reroils_public.js']}} +{{ node_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 67% rename from rero_ils/webpack.py rename to rero_ils/theme/webpack.py index b62071dd4d..03c5e94208 100644 --- a/rero_ils/webpack.py +++ b/rero_ils/theme/webpack.py @@ -23,24 +23,19 @@ {{ webpack['base.js']}} """ -from flask_webpackext import WebpackBundle, WebpackBundleProject -from pywebpack import bundles_from_entry_point +from flask_webpackext import WebpackBundle -project = WebpackBundleProject( - 'rero_ils', - project_folder='webpack_assets', - config_path='build/config.json', - bundles=bundles_from_entry_point('invenio_assets.webpack'), -) - -admin = WebpackBundle( +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', + 'font-awesome': '~4.7.0' } ) diff --git a/rero_ils/utils.py b/rero_ils/utils.py index 1629d25d54..e82a603d50 100644 --- a/rero_ils/utils.py +++ b/rero_ils/utils.py @@ -17,6 +17,7 @@ """Utilities functions for rero-ils.""" + from flask import current_app from invenio_i18n.ext import current_i18n diff --git a/rero_ils/webpack_assets/.babelrc b/rero_ils/webpack_assets/.babelrc deleted file mode 100644 index fd6b16f520..0000000000 --- a/rero_ils/webpack_assets/.babelrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "presets": [ - "@babel/preset-env", - "@babel/preset-react" - ] -} diff --git a/rero_ils/webpack_assets/build/webpack.config.js b/rero_ils/webpack_assets/build/webpack.config.js deleted file mode 100644 index fd22c489a5..0000000000 --- a/rero_ils/webpack_assets/build/webpack.config.js +++ /dev/null @@ -1,230 +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 . - -*/ - -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'); - -var webpackConfig = { - entry: config.entry, - context: config.build.context, - resolve: { - extensions: ['*', '.js', '.jsx'], - symlinks: false - }, - output: { - path: config.build.assetsPath, - filename: 'js/[name].[chunkhash].js', - chunkFilename: 'js/[id].[chunkhash].js', - publicPath: config.build.assetsURL - }, - optimization: { - minimizer: [ - new TerserPlugin({ - terserOptions: { - parse: { - // we want terser to parse ecma 8 code. However, we don't want it - // to apply any minfication steps that turns valid ecma 5 code - // into invalid ecma 5 code. This is why the 'compress' and 'output' - // sections only apply transformations that are ecma 5 safe - // https://github.com/facebook/create-react-app/pull/4234 - ecma: 8 - }, - compress: { - ecma: 5, - warnings: false, - // Disabled because of an issue with Uglify breaking seemingly valid code: - // https://github.com/facebook/create-react-app/issues/2376 - // Pending further investigation: - // https://github.com/mishoo/UglifyJS2/issues/2011 - comparisons: false, - // Disabled because of an issue with Terser breaking valid code: - // https://github.com/facebook/create-react-app/issues/5250 - // Pending further investigation: - // https://github.com/terser-js/terser/issues/120 - inline: 2 - }, - mangle: { - safari10: true - }, - output: { - ecma: 5, - comments: false, - // Turned on because emoji and regex is not minified properly using default - // https://github.com/facebook/create-react-app/issues/2488 - ascii_only: true - } - }, - // Use multi-process parallel running to improve the build speed - // Default number of concurrent runs: os.cpus().length - 1 - parallel: true, - cache: true - }), - new OptimizeCSSAssetsPlugin({ - cssProcessorOptions: { - parser: safePostCssParser, - map: false - } - }) - ], - splitChunks: { - cacheGroups: { - commons: { - test: /[\\/]node_modules[\\/]/, - name: "vendor", - chunks: "initial", - }, - }, - 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' - } - }, - module: { - rules: [ - { - test: require.resolve('jquery'), - use: [{ - loader: 'expose-loader', - options: 'jQuery' - },{ - loader: 'expose-loader', - options: '$' - }] - }, - { - test: /\.(js|jsx)$/, - exclude: [/node_modules/, /@babel(?:\/|\\{1,2})runtime/], - use: [ - { - loader: "babel-loader", - options: { - presets: ["@babel/preset-env", "@babel/preset-react"], - plugins: ["@babel/plugin-proposal-class-properties", "@babel/plugin-transform-runtime"] - } - } - ] - }, - { - test: /\.(js|jsx)$/, - enforce: "pre", - exclude: /node_modules/, - use: [ - { - options: { - emitWarning: true, - quiet: true, - formatter: require('eslint-friendly-formatter'), - eslintPath: require.resolve('eslint'), - }, - loader: require.resolve('eslint-loader'), - } - ] - }, - { - test: /\.(scss|css)$/, - use: [ - MiniCssExtractPlugin.loader, - { - loader: "css-loader", - options: { - minimize: { - safe: true - } - } - }, - { - loader: "sass-loader", - options: {} - } - ] - }, - // Inline images smaller than 10k - { - test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, - use: [ - { - loader: require.resolve('url-loader'), - options: { - limit: 10000, - name: 'img/[name].[hash:7].[ext]' - } - } - ], - }, - // Inline webfonts smaller than 10k - { - test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, - use: [ - { - loader: require.resolve('file-loader'), - options: { - limit: 10000, - name: 'fonts/[name].[hash:7].[ext]' - } - } - ], - } - ] - }, - // devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'cheap-source-map', - plugins: [ - // Pragmas - new webpack.DefinePlugin({ - '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", - }), - // Removes the dist folder before each run. - new CleanWebpackPlugin(config.build.assetsPath, {allowExternal: true}), - // Automatically inject jquery - new webpack.ProvidePlugin({ - jQuery: 'jquery/src/jquery', - $: 'jquery/src/jquery', - jquery: 'jquery/src/jquery', - 'window.jQuery': 'jquery/src/jquery' - }), - // Write manifest file which Python will read. - new ManifestPlugin({ - fileName: 'manifest.json', - stripSrc: true, - 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()) -} - -module.exports = webpackConfig 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..035a792cab 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -97,6 +97,7 @@ do shift done + # Poetry is a mandatory condition to launch this program! if [[ -z "${VIRTUAL_ENV}" ]]; then error_msg+exit "Error - Launch this script via poetry command:\n\tpoetry run ${PROGRAM}" @@ -118,6 +119,10 @@ if $sip2 ; then flags+=("--extras sip2") fi +# create virtualenv and upgrade pip +info_msg "Upgrade pip" +poetry run pip install --upgrade pip + # BOOTSTRAP START # install the application and all the dependencies info_msg "Install with command: ${cmd} ${flags[@]}" @@ -130,39 +135,41 @@ if ! $deploy ; then fi 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." - # collect static files and compile html/css assets # ------------------------------------------------ # install the npm dependencies -info_msg "Install npm dependencies" -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-) + +# install rero-ils-ui info_msg "Install static folder npm dependencies in: ${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: using webpack for invenio-admin" invenio webpack buildall +if $deploy ; then + if ! $ci ; then + info_msg "Clean web assets" + invenio webpack clean + + info_msg "Clean npm cache" + npm cache clean --force + + info_msg "Clean pip cache" + pip cache purge + fi +fi + success_msg "${PROGRAM} finished!" exit 0 diff --git a/scripts/russian_dolls b/scripts/russian_dolls index 7046c187f4..902d11a73e 100755 --- a/scripts/russian_dolls +++ b/scripts/russian_dolls @@ -110,7 +110,7 @@ get_version "${NG_DIR}" NG_PACKAGE="${NG_DIR}/${PACKAGE_NAME}" # fetch rero-ils-ui version get_version "${FRONTEND_DIR}" -FRONTEND_PACKAGE="${FRONTEND_DIR}/${PACKAGE_NAME}" +FRONTEND_PACKAGE="${FRONTEND_DIR}/build/${PACKAGE_NAME}" # packages ng-core info_msg "NG-CORE ❯ packaging…" diff --git a/setup.py b/setup.py index b70788b63f..65d70808e3 100644 --- a/setup.py +++ b/setup.py @@ -73,9 +73,7 @@ def run(self): 'rero-ils = invenio_app.cli:cli', ], 'babel.extractors': [ - 'json = rero_ils.modules.babel_extractors:extract_json', - # TODO: remove once the thumbnail are done in angular - 'angular_gettext = angular_gettext_babel.extract:extract_angular' + 'json = rero_ils.modules.babel_extractors:extract_json' ], 'invenio_base.apps': [ # 'flask_debugtoolbar = flask_debugtoolbar:DebugToolbarExtension', @@ -95,7 +93,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 +116,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', diff --git a/tests/ui/test_views.py b/tests/ui/test_views.py index 9e3600f93a..b37cd36daa 100644 --- a/tests/ui/test_views.py +++ b/tests/ui/test_views.py @@ -23,7 +23,7 @@ from flask import session, url_for from utils import postdata -from rero_ils.views import nl2br +from rero_ils.theme.views import nl2br def test_nl2br():