From f9bd43f3a11d8e53fc5277df62c2e1cf1be77dcd Mon Sep 17 00:00:00 2001 From: jrcastro2 Date: Tue, 25 Aug 2020 15:30:17 +0200 Subject: [PATCH] theme: adds customizable segments --- .travis.yml | 5 ++++- {{cookiecutter.project_shortname}}/Dockerfile | 3 +++ .../MANIFEST.in | 4 ++++ {{cookiecutter.project_shortname}}/Pipfile | 4 ++-- .../run-tests.sh | 2 +- .../scripts/bootstrap | 20 +++++++++++-------- .../tests/e2e/test_front_page.py | 4 ++-- .../records/webpack.py | 3 ++- .../theme.config | 3 +-- .../frontpage.html | 2 +- .../theme/webpack.py | 2 +- 11 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 42f3533..85d9a9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,13 +48,16 @@ python: - "3.6" before_install: + # Upgrade Travis `numpy` version: default is vulnerable and pipenv check will fail otherwise + - pip uninstall numpy -y + - pip install --ignore-installed "numpy>=1.18" # Stop the services running by default on travis - "sudo service mysql stop" - "sudo service postgresql stop" # Chrome webdriver for Selenium - "PATH=$PATH:$HOME/webdrivers" - "if [ ${E2E} == 'yes' ] && [ ! -f $HOME/webdrivers/chromedriver ]; then wget https://chromedriver.storage.googleapis.com/2.31/chromedriver_linux64.zip -P $HOME/webdrivers; unzip -d $HOME/webdrivers $HOME/webdrivers/chromedriver_linux64.zip; fi" - - "nvm install 6; nvm use 6" + - "nvm install 14.0.0; nvm use 14.0.0" - "travis_retry pip install --upgrade pip setuptools py pipenv" - "travis_retry pip install cookiecutter twine wheel coveralls sphinx" diff --git a/{{cookiecutter.project_shortname}}/Dockerfile b/{{cookiecutter.project_shortname}}/Dockerfile index 58735e1..663bf2a 100644 --- a/{{cookiecutter.project_shortname}}/Dockerfile +++ b/{{cookiecutter.project_shortname}}/Dockerfile @@ -17,6 +17,9 @@ COPY ./docker/uwsgi/ ${INVENIO_INSTANCE_PATH} RUN pip install . && \ invenio collect -v && \ + # Dirty solution to create templates folder (Needed) + mkdir /opt/invenio/var/instance/assets && \ + mkdir /opt/invenio/var/instance/assets/templates && \ invenio webpack create && \ # --unsafe needed because we are running as root invenio webpack install --unsafe && \ diff --git a/{{cookiecutter.project_shortname}}/MANIFEST.in b/{{cookiecutter.project_shortname}}/MANIFEST.in index 18b8621..233bf92 100644 --- a/{{cookiecutter.project_shortname}}/MANIFEST.in +++ b/{{cookiecutter.project_shortname}}/MANIFEST.in @@ -35,6 +35,10 @@ recursive-include docs *.py recursive-include docs *.rst recursive-include docs *.txt recursive-include docs Makefile +recursive-include {{ cookiecutter.package_name }} *.config +recursive-include {{ cookiecutter.package_name }} *.less +recursive-include {{ cookiecutter.package_name }} *.overrides +recursive-include {{ cookiecutter.package_name }} *.variables recursive-include {{ cookiecutter.package_name }} *.gitkeep recursive-include {{ cookiecutter.package_name }} *.po *.pot *.mo recursive-include {{ cookiecutter.package_name }} *.json *.html *.js *.scss diff --git a/{{cookiecutter.project_shortname}}/Pipfile b/{{cookiecutter.project_shortname}}/Pipfile index 5b0dbdf..16ed813 100644 --- a/{{cookiecutter.project_shortname}}/Pipfile +++ b/{{cookiecutter.project_shortname}}/Pipfile @@ -7,7 +7,7 @@ name = "pypi" Babel = ">=2.4.0" Flask-BabelEx = ">=0.9.3" invenio = { version = ">=3.4.0a1,<3.5.0", extras = ["base", "auth", "metadata", "files", "{{ cookiecutter.database }}", "elasticsearch{{ cookiecutter.elasticsearch }}" ]} -lxml = ">=3.5.0,<4.2.6" +lxml = ">=4.3.0,<5.0.0" marshmallow = ">=3.0.0,<4.0.0" uwsgi = ">=2.0" uwsgi-tools = ">=1.1.1" @@ -20,7 +20,7 @@ Flask-Debugtoolbar = ">=0.10.1" isort = ">=4.3" mock = ">=2.0.0" pydocstyle = ">=2.0.0" -pytest = ">=3.3.1" +pytest = ">=3.3.1, <6.0.0" pytest-cov = ">=2.5.1" pytest-invenio = ">=1.2.1,<1.3.0" pytest-mock = ">=1.6.0" diff --git a/{{cookiecutter.project_shortname}}/run-tests.sh b/{{cookiecutter.project_shortname}}/run-tests.sh index 1d96219..b58a3e5 100755 --- a/{{cookiecutter.project_shortname}}/run-tests.sh +++ b/{{cookiecutter.project_shortname}}/run-tests.sh @@ -3,7 +3,7 @@ pipenv check && \ pipenv run pydocstyle {{ cookiecutter.package_name }} tests docs && \ -pipenv run isort -rc -c -df && \ +pipenv run isort . --check-only --diff && \ pipenv run check-manifest --ignore ".travis-*,docs/_build*" && \ pipenv run sphinx-build -qnNW docs docs/_build/html && \ pipenv run test diff --git a/{{cookiecutter.project_shortname}}/scripts/bootstrap b/{{cookiecutter.project_shortname}}/scripts/bootstrap index c5e395f..7f82248 100755 --- a/{{cookiecutter.project_shortname}}/scripts/bootstrap +++ b/{{cookiecutter.project_shortname}}/scripts/bootstrap @@ -2,28 +2,32 @@ {% include 'misc/header.py' %} set -e + {% raw %} script_path=$(dirname "$0") pipfile_lock_path="$script_path/../Pipfile.lock" # START: PUT ME BACK -# if [ ! -f $pipfile_lock_path ]; then -# echo "'Pipfile.lock' not found. Generating via 'pipenv lock --dev'..." -# pipenv lock --dev -# fi +if [ ! -f $pipfile_lock_path ]; then + echo "'Pipfile.lock' not found. Generating via 'pipenv lock --dev'..." + pipenv lock --dev --pre +fi -# # Installs all packages specified in Pipfile.lock -# pipenv sync --dev +# Installs all packages specified in Pipfile.lock +pipenv sync --dev # /END: PUT ME BACK # START: REMOVE ME -pipenv run pip install -e git+https://github.com/inveniosoftware/invenio.git#egg=invenio["base","auth","metadata","files","postgresql","elasticsearch7"] +# pipenv run pip install -e git+https://github.com/inveniosoftware/invenio.git#egg=invenio["base","auth","metadata","files","postgresql","elasticsearch7"] # /END: REMOVE ME - # Install application code and entrypoints from 'setup.py' pipenv run pip install -e $script_path/.. + # Build assets pipenv run invenio collect -v +# Dirty solution to create templates folder (Needed) +mkdir $(pipenv --venv)/var/instance/assets/ +mkdir $(pipenv --venv)/var/instance/assets/templates pipenv run invenio webpack buildall {% endraw %} diff --git a/{{cookiecutter.project_shortname}}/tests/e2e/test_front_page.py b/{{cookiecutter.project_shortname}}/tests/e2e/test_front_page.py index 2e17d2f..3d51307 100644 --- a/{{cookiecutter.project_shortname}}/tests/e2e/test_front_page.py +++ b/{{cookiecutter.project_shortname}}/tests/e2e/test_front_page.py @@ -6,5 +6,5 @@ def test_frontpage(live_server, browser): """Test retrieval of front page.""" browser.get(url_for('invenio_theme_frontpage.index', _external=True)) - assert "Welcome to {{cookiecutter.project_name}}." == browser.find_element_by_class_name( - 'marketing').find_element_by_tag_name('h1').text + assert "Welcome to {{cookiecutter.project_name}}." == browser.find_element_by_id( + 'frontpage-h1').text diff --git a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/webpack.py b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/webpack.py index 4632022..f69a971 100644 --- a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/webpack.py +++ b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/records/webpack.py @@ -10,7 +10,8 @@ themes={ 'semantic-ui': dict( entry={ - '{{ cookiecutter.project_shortname }}-search-app': './js/{{ cookiecutter.package_name }}_records/search_app_customizations.js', + '{{ cookiecutter.project_shortname }}-search-app': + './js/{{ cookiecutter.package_name }}_records/search_app_customizations.js', }, dependencies={ "react": "^16.9.0", diff --git a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/assets/semantic-ui/less/{{cookiecutter.package_name}}/theme.config b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/assets/semantic-ui/less/{{cookiecutter.package_name}}/theme.config index 6fe0745..bdae38a 100644 --- a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/assets/semantic-ui/less/{{cookiecutter.package_name}}/theme.config +++ b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/assets/semantic-ui/less/{{cookiecutter.package_name}}/theme.config @@ -38,7 +38,7 @@ @placeholder : 'default'; @rail : 'default'; @reveal : 'default'; -@segment : 'default'; +@segment : 'invenio'; @step : 'default'; /* Collections */ @@ -85,7 +85,6 @@ /* Path to site override folder */ @siteFolder : '../../less/{{ cookiecutter.package_name }}/site'; - /******************************* Import Theme *******************************/ diff --git a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/templates/semantic-ui/{{cookiecutter.package_name}}/frontpage.html b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/templates/semantic-ui/{{cookiecutter.package_name}}/frontpage.html index 6543f97..e8cf05d 100644 --- a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/templates/semantic-ui/{{cookiecutter.package_name}}/frontpage.html +++ b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/templates/semantic-ui/{{cookiecutter.package_name}}/frontpage.html @@ -7,7 +7,7 @@
{%- endraw -%} -

Welcome to {{cookiecutter.project_name}}.

+

Welcome to {{cookiecutter.project_name}}.

{%- raw -%}
diff --git a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/webpack.py b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/webpack.py index e18dc56..86ff2b6 100644 --- a/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/webpack.py +++ b/{{cookiecutter.project_shortname}}/{{cookiecutter.package_name}}/theme/webpack.py @@ -10,7 +10,7 @@ themes={ 'semantic-ui': dict( entry={ - # CHANGE ME TO LESS '{{ cookiecutter.project_shortname }}-theme': './less/{{ cookiecutter.package_name }}/theme.less', + '{{ cookiecutter.project_shortname }}-theme': './less/{{ cookiecutter.package_name }}/theme.less', '{{ cookiecutter.project_shortname }}-preview': './js/{{ cookiecutter.package_name }}/previewer.js', }, dependencies={