diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f505f48..b6e261b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,6 +16,24 @@ on: description: 'invenio-override repo branch' required: false default: 'main' + variant: + type: choice + description: Choose the instance variant + options: + - mug + - oer + - basic + - vanilla + required: false + default: mug + recreate: + type: choice + description: Recreate instance (passed to gitlab pipeline) + options: + - true + - false + required: false + default: false jobs: @@ -39,6 +57,7 @@ jobs: pip install uv - name: Install invenio-override + if: ${{ !startsWith( github.ref, 'refs/tags') }} run: | mkdir .venv uv venv .venv @@ -53,10 +72,13 @@ jobs: install_cmd='uv pip install git+https://github.com/sharedRDM/invenio-override@${INVENIO_OVERRIDE_BRANCH}' eval "$install_cmd" - - name: Change pyproject.toml - if: "${{ github.event.inputs.invenio-override-branch != '' }}" + - name: Change pyproject.toml override branch + if: "${{ github.event.inputs.invenio-override-branch != '' && !startsWith( github.ref, 'refs/tags') }}" run: sed -i 's/invenio-override", branch = "main"/invenio-override", branch = "${{ github.event.inputs.invenio-override-branch }}"/g' pyproject.toml + - name: Change pyproject.toml override MUG + run: sed -i 's/-override ~/-override[marc21] ~/g' pyproject.toml + - name: Relock uv run: | source .venv/bin/activate @@ -101,7 +123,176 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - build-and-push-theme: + build-and-push-oer: + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.12' + + - name: Install uv package + run: | + pip install uv + + - name: Install invenio-override + if: ${{ !startsWith( github.ref, 'refs/tags') }} + run: | + mkdir .venv + uv venv .venv + source .venv/bin/activate + + if [[ '${{ github.event.inputs.invenio-override-branch }}' == '' ]]; then + INVENIO_OVERRIDE_BRANCH="main" + else + INVENIO_OVERRIDE_BRANCH="${{ github.event.inputs.invenio-override-branch }}" + fi + + install_cmd='uv pip install git+https://github.com/sharedRDM/invenio-override@${INVENIO_OVERRIDE_BRANCH}' + eval "$install_cmd" + + - name: Change pyproject.toml override branch + if: "${{ github.event.inputs.invenio-override-branch != '' && !startsWith( github.ref, 'refs/tags') }}" + run: sed -i 's/invenio-override", branch = "main"/invenio-override", branch = "${{ github.event.inputs.invenio-override-branch }}"/g' pyproject.toml + + - name: Change pyproject.toml override OER + run: sed -i 's/-override ~/-override[lom] ~/g' pyproject.toml + + - name: Relock uv + run: | + source .venv/bin/activate + uv lock --upgrade + deactivate + rm -rf .venv + + - name: Convert repository name to lowercase + run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Determine Docker tag (from tag or branch) + id: get_tag + run: | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then + TAG_NAME="${GITHUB_REF#refs/tags/}" + else + TAG_NAME="${GITHUB_REF#refs/heads/}" + fi + echo "DOCKER_TAG=$TAG_NAME" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push OER Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + file: Dockerfile.oer + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-oer + labels: ${{ steps.meta.outputs.labels }} + + + build-and-push-basic: + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.12' + + - name: Install uv package + run: | + pip install uv + + - name: Install invenio-override + if: ${{ !startsWith( github.ref, 'refs/tags') }} + run: | + mkdir .venv + uv venv .venv + source .venv/bin/activate + + if [[ '${{ github.event.inputs.invenio-override-branch }}' == '' ]]; then + INVENIO_OVERRIDE_BRANCH="main" + else + INVENIO_OVERRIDE_BRANCH="${{ github.event.inputs.invenio-override-branch }}" + fi + + install_cmd='uv pip install git+https://github.com/sharedRDM/invenio-override@${INVENIO_OVERRIDE_BRANCH}' + eval "$install_cmd" + + - name: Change pyproject.toml override branch + if: "${{ github.event.inputs.invenio-override-branch != '' && !startsWith( github.ref, 'refs/tags') }}" + run: sed -i 's/invenio-override", branch = "main"/invenio-override", branch = "${{ github.event.inputs.invenio-override-branch }}"/g' pyproject.toml + + - name: Relock uv + run: | + source .venv/bin/activate + uv lock --upgrade + deactivate + rm -rf .venv + + - name: Convert repository name to lowercase + run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Determine Docker tag (from tag or branch) + id: get_tag + run: | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then + TAG_NAME="${GITHUB_REF#refs/tags/}" + else + TAG_NAME="${GITHUB_REF#refs/heads/}" + fi + echo "DOCKER_TAG=$TAG_NAME" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Basic Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + file: Dockerfile.basic + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-basic + labels: ${{ steps.meta.outputs.labels }} + + + build-and-push-vanilla: runs-on: ubuntu-22.04 permissions: contents: read @@ -111,6 +302,28 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.12' + + - name: Install uv package + run: | + pip install uv + + - name: Change pyproject.toml no override + run: sed -i 's/"invenio-override ~=0.0.6",//g' pyproject.toml + + - name: Relock uv + run: | + mkdir .venv + uv venv .venv + source .venv/bin/activate + uv pip uninstall invenio-override + uv lock --upgrade + deactivate + rm -rf .venv + - name: Convert repository name to lowercase run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV @@ -137,22 +350,25 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Theme Docker image + - name: Build and push Vanilla Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: context: . - file: Dockerfile.theme + file: Dockerfile.basic push: true tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-theme + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-vanilla labels: ${{ steps.meta.outputs.labels }} + trigger-gitlab-pipeline: name: Trigger GitLab Pipeline runs-on: ubuntu-latest needs: - build-and-push-mug - - build-and-push-theme + - build-and-push-oer + - build-and-push-basic + - build-and-push-vanilla steps: - name: Set Docker tag environment @@ -172,5 +388,5 @@ jobs: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} PROJECT_ID: 45464 REF_NAME: 'main' - PIPELINE_VARIABLES: '{"DOCKER_IMAGE_TAG":"${{ env.DOCKER_TAG }}", "DOCKER_IMAGE_TAG_INSTANCE":"mug"}' + PIPELINE_VARIABLES: '{"DOCKER_IMAGE_TAG":"${{ env.DOCKER_TAG }}", "DOCKER_IMAGE_TAG_INSTANCE":"${{ github.event.inputs.variant }}", "RECREATE_INSTANCE":"${{ github.event.inputs.recreate }}"}' diff --git a/Dockerfile.theme b/Dockerfile.basic similarity index 95% rename from Dockerfile.theme rename to Dockerfile.basic index 5ecd850..c833c18 100644 --- a/Dockerfile.theme +++ b/Dockerfile.basic @@ -33,7 +33,7 @@ COPY --from=builder ${INVENIO_INSTANCE_PATH}/templates ${INVENIO_INSTANCE_PATH}/ WORKDIR ${WORKING_DIR}/src COPY ./docker/uwsgi/ ${INVENIO_INSTANCE_PATH} -COPY ./invenio.cfg ${INVENIO_INSTANCE_PATH} +COPY ./themes/override-basic/invenio.cfg ${INVENIO_INSTANCE_PATH} RUN chown invenio:invenio . USER invenio diff --git a/Dockerfile.oer b/Dockerfile.oer new file mode 100644 index 0000000..3dcf001 --- /dev/null +++ b/Dockerfile.oer @@ -0,0 +1,43 @@ +# STAGE 1 +FROM ghcr.io/tu-graz-library/docker-invenio-base:main-builder AS builder + +COPY pyproject.toml uv.lock ./ + +RUN uv sync --frozen + +# to use rspack +ENV INVENIO_WEBPACKEXT_PROJECT="invenio_assets.webpack:rspack_project" + +COPY ./app_data/ ${INVENIO_INSTANCE_PATH}/app_data/ +COPY ./assets/ ${INVENIO_INSTANCE_PATH}/assets/ +COPY ./static/ ${INVENIO_INSTANCE_PATH}/static/ +COPY ./translations ${INVENIO_INSTANCE_PATH}/translations/ +COPY ./templates ${INVENIO_INSTANCE_PATH}/templates/ + +# Replace variables.less +COPY themes/MUG/variables.less /opt/env/lib/python3.12/site-packages/invenio_override/assets/semantic-ui/less/invenio_override/variables.less + +RUN invenio collect --verbose && invenio webpack create + +WORKDIR ${INVENIO_INSTANCE_PATH}/assets +RUN pnpm install +RUN pnpm run build + +# STAGE 2 +FROM ghcr.io/tu-graz-library/docker-invenio-base:main-frontend AS frontend + +COPY --from=builder ${VIRTUAL_ENV}/lib ${VIRTUAL_ENV}/lib +COPY --from=builder ${VIRTUAL_ENV}/bin ${VIRTUAL_ENV}/bin +COPY --from=builder ${INVENIO_INSTANCE_PATH}/app_data ${INVENIO_INSTANCE_PATH}/app_data +COPY --from=builder ${INVENIO_INSTANCE_PATH}/static ${INVENIO_INSTANCE_PATH}/static +COPY --from=builder ${INVENIO_INSTANCE_PATH}/translations ${INVENIO_INSTANCE_PATH}/translations +COPY --from=builder ${INVENIO_INSTANCE_PATH}/templates ${INVENIO_INSTANCE_PATH}/templates + +WORKDIR ${WORKING_DIR}/src +COPY ./docker/uwsgi/ ${INVENIO_INSTANCE_PATH} +COPY ./themes/override-oer/invenio.cfg ${INVENIO_INSTANCE_PATH} +RUN chown invenio:invenio . + +USER invenio + +ENTRYPOINT [ "bash", "-c"] diff --git a/README.md b/README.md index 0553ba0..add4a06 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,14 @@ For detailed steps on working with UV, check the [Working with UV](./UV-GUIDE.md ## Docker Images +Each image has a correspondent instance _variant_ that a user can choose to deploy. + | Name | Description | |---|---| -| ``Dockerfile`` | Dockerfile used to build base image, without theme. | -| ``Dockerfile.mug`` | Dockerfile used to build MUG image. | -| ``Dockerfile.theme`` | Dockerfile used to build default override theme image. | +| ``Dockerfile`` | Dockerfile used to build base image, without theme. - no variant, used for local testing. | +| ``Dockerfile.mug`` | Dockerfile used to build MUG image. (with Publications) - variant **mug** | +| ``Dockerfile.oer`` | Dockerfile used to build Educational Resources image (OER). - variant **oer** | +| ``Dockerfile.basic`` | Dockerfile used to base invenio-override image (no OER or Publications) and also base invenio theme (without invenio-override) - variants **basic** and **vanilla** | ## CI/CD diff --git a/pyproject.toml b/pyproject.toml index c5d6bd3..f119f27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,11 +10,12 @@ authors = [ dependencies = [ "invenio-app-rdm[opensearch2] ~=13.0.0b3.dev2", + "invenio-rdm-records>=18.11.0,<19.0.0", "invenio-logging[sentry_sdk]>=4.0.0,<5.0.0", "uwsgi >=2.0", "uwsgitop >=0.11", "uwsgi-tools >=1.1.1", - "invenio-override[marc21] ~=0.0.6", + "invenio-override ~=0.0.6", ] [tool.setuptools] diff --git a/themes/override-base/additional.md b/themes/override-base/additional.md new file mode 100644 index 0000000..a4370da --- /dev/null +++ b/themes/override-base/additional.md @@ -0,0 +1 @@ +# Example config for instance installation with invenio-override withour OER and Publications (basic) or completely without invenio-override (vanilla invenioRDM). \ No newline at end of file diff --git a/themes/override-base/invenio.cfg b/themes/override-base/invenio.cfg new file mode 100644 index 0000000..5c0f048 --- /dev/null +++ b/themes/override-base/invenio.cfg @@ -0,0 +1,296 @@ +""" +InvenioRDM settings for instance project. + +This file was automatically generated by 'invenio-cli init'. + +For the full list of settings and their values, see +https://inveniordm.docs.cern.ch/reference/configuration/. +""" + +from datetime import datetime +from invenio_i18n import lazy_gettext as _ + +def _(x): # needed to avoid start time failure with lazy strings + return x + +# Flask +# ===== +# See https://flask.palletsprojects.com/en/1.1.x/config/ + +# Define the value of the cache control header `max-age` returned by the server when serving +# public files. Files will be cached by the browser for the provided number of seconds. +# See flask documentation for more information: +# https://flask.palletsprojects.com/en/2.1.x/config/#SEND_FILE_MAX_AGE_DEFAULT +SEND_FILE_MAX_AGE_DEFAULT = 300 + +# SECURITY WARNING: keep the secret key used in production secret! +# Do not commit it to a source code repository. +# TODO: Set +SECRET_KEY = "CHANGE_ME" + +# Since HAProxy and Nginx route all requests no matter the host header +# provided, the allowed hosts variable is set to localhost. In production it +# should be set to the correct host and it is strongly recommended to only +# route correct hosts to the application. +TRUSTED_HOSTS = ["0.0.0.0", "localhost", "127.0.0.1"] + + +# Flask-SQLAlchemy +# ================ +# See https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/ + +# TODO: Set +SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://instance:instance@localhost/instance" + + +# Invenio-App +# =========== +# See https://invenio-app.readthedocs.io/en/latest/configuration.html + +APP_DEFAULT_SECURE_HEADERS = { + "content_security_policy": { + "default-src": [ + "'self'", + "data:", # for fonts + "'unsafe-inline'", # for inline scripts and styles + "blob:", # for pdf preview + # Add your own policies here (e.g. analytics) + ], + }, + "content_security_policy_report_only": False, + "content_security_policy_report_uri": None, + "force_file_save": False, + "force_https": True, + "force_https_permanent": False, + "frame_options": "sameorigin", + "frame_options_allow_from": None, + "session_cookie_http_only": True, + "session_cookie_secure": True, + "strict_transport_security": True, + "strict_transport_security_include_subdomains": True, + "strict_transport_security_max_age": 31556926, # One year in seconds + "strict_transport_security_preload": False, +} + + +# Flask-Babel +# =========== +# See https://python-babel.github.io/flask-babel/#configuration + +# # Default locale (language) +# BABEL_DEFAULT_LOCALE = 'en' +# # Default time zone +# BABEL_DEFAULT_TIMEZONE = 'Europe/Zurich' + + +# Invenio-I18N +# ============ +# See https://invenio-i18n.readthedocs.io/en/latest/configuration.html + +# Other supported languages (do not include BABEL_DEFAULT_LOCALE in list). +# I18N_LANGUAGES = [ +# # ('de', _('German')), +# # ('tr', _('Turkish')), +# ] + + +# Invenio-Theme +# ============= +# See https://invenio-theme.readthedocs.io/en/latest/configuration.html + +# Name used in header and UI +THEME_SITENAME = "instance" +# Frontpage title +THEME_FRONTPAGE_TITLE = "instance" +# Header logo +# THEME_LOGO = 'images/invenio-rdm.svg' + + +# Invenio-App-RDM +# =============== +# See https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/config.py + +# Instance's theme entrypoint file. Path relative to the ``assets/`` folder. +INSTANCE_THEME_FILE = "./less/theme.less" + +# Email address for administrator emails (like file checksum alerts) +APP_RDM_ADMIN_EMAIL_RECIPIENT = "info@instance.com" + +# Default values for the deposit form +APP_RDM_DEPOSIT_FORM_DEFAULTS = { + "publication_date": lambda: datetime.now().strftime("%Y-%m-%d"), + "rights": [ + { + "id": "cc-by-4.0", + "title": "Creative Commons Attribution 4.0 International", + "description": ( + "The Creative Commons Attribution license allows " + "re-distribution and re-use of a licensed work " + "on the condition that the creator is " + "appropriately credited." + ), + "link": "https://creativecommons.org/licenses/by/4.0/legalcode", + } + ], + "publisher": "instance", +} + +APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES = "search" # "search_only" or "off" + +# Invenio-Records-Resources +# ========================= +# See https://github.com/inveniosoftware/invenio-records-resources/blob/master/invenio_records_resources/config.py + +# TODO: Set with your own hostname when deploying to production +SITE_UI_URL = "https://127.0.0.1" + +SITE_API_URL = "https://127.0.0.1/api" + + +# Invenio-RDM-Records +# =================== +# See https://inveniordm.docs.cern.ch/customize/dois/ +DATACITE_ENABLED = False +DATACITE_USERNAME = "" +DATACITE_PASSWORD = "" +DATACITE_PREFIX = "" +DATACITE_TEST_MODE = True +DATACITE_DATACENTER_SYMBOL = "" + +# Authentication - Invenio-Accounts and Invenio-OAuthclient +# ========================================================= +# See: https://inveniordm.docs.cern.ch/customize/authentication/ + +# Invenio-Accounts +# ---------------- +# See https://github.com/inveniosoftware/invenio-accounts/blob/master/invenio_accounts/config.py +ACCOUNTS_LOCAL_LOGIN_ENABLED = True # enable local login +SECURITY_REGISTERABLE = True # local login: allow users to register +SECURITY_RECOVERABLE = True # local login: allow users to reset the password +SECURITY_CHANGEABLE = True # local login: allow users to change psw +# SECURITY_CONFIRMABLE = True # local login: users can confirm e-mail address +SECURITY_LOGIN_WITHOUT_CONFIRMATION = ( + True # require users to confirm email before being able to login +) + +# Invenio-OAuthclient +# ------------------- +# See https://github.com/inveniosoftware/invenio-oauthclient/blob/master/invenio_oauthclient/config.py + +OAUTHCLIENT_REMOTE_APPS = {} # configure external login providers + +from invenio_oauthclient.views.client import auto_redirect_login + +ACCOUNTS_LOGIN_VIEW_FUNCTION = ( + auto_redirect_login # autoredirect to external login if enabled +) +OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = False # autoredirect to external login + +# Invenio-UserProfiles +# -------------------- +USERPROFILES_READ_ONLY = ( + False # allow users to change profile info (name, email, etc...) +) + +# OAI-PMH +# ======= +# See https://github.com/inveniosoftware/invenio-oaiserver/blob/master/invenio_oaiserver/config.py + +OAISERVER_ID_PREFIX = "instance.com" +"""The prefix that will be applied to the generated OAI-PMH ids.""" +OAISERVER_ADMIN_EMAILS = [ + "info@instance.com", +] + +# Invenio-Search +# -------------- + +SEARCH_INDEX_PREFIX = "instance-" + +# Invenio-Users-Resources +# ----------------------- + +USERS_RESOURCES_ADMINISTRATION_ENABLED = True +"""Enable the user administration""" + +# Invenio-Administration +# ---------------------- + +from invenio_app_rdm import __version__ + +ADMINISTRATION_DISPLAY_VERSIONS = [ + ("invenio-app-rdm", f"v{__version__}"), + ("instance", "v1.0.0"), +] + +# Invenio-I18N +# ============ +# See https://invenio-i18n.readthedocs.io/en/latest/configuration.html +BABEL_DEFAULT_LOCALE = "en" +# Default time zone +BABEL_DEFAULT_TIMEZONE = "Europe/Vienna" +# Other supported languages (do not include BABEL_DEFAULT_LOCALE in list). +I18N_LANGUAGES = [("de", _("German"))] + + +# Extras +# -------------- +# INVENIO_THEME_SHOW_FRONTPAGE_INTRO_SECTION=False +THEME_SHOW_FRONTPAGE_INTRO_SECTION = False +"""Set True for frontpage Intro.""" + +RDM_USER_MODERATION_ENABLED = True +"""User moderation feature enabled.""" + +RDM_SEARCH_SORT_BY_VERIFIED = True +"""Enable the sorting of records by verified.""" + +USERS_RESOURCES_ADMINISTRATION_ENABLED = True +"""Enable user administration.""" + +USERS_RESOURCES_GROUPS_ENABLED = True +"""Config to enable features related to existence of groups.""" + +COMMUNITIES_ADMINISTRATION_DISABLED = False # this enables it +"""Enable communities administration.""" + +APP_RDM_SUBCOMMUNITIES_LABEL = "Projects" +"""Label for subcommunities in communities browse page.""" + +COMMUNITIES_SHOW_BROWSE_MENU_ENTRY = True +"""Toggle to show or hide the 'Browse' menu entry for communities.""" + +JOBS_ADMINISTRATION_ENABLED = True +"""Enable Jobs administration view.""" + +# Invenio-Override +# -------------- + +# # # LOGO +# #INVENIO_OVERRIDE_LOGO=images/MUG.svg +# OVERRIDE_LOGO = "images/MUG.svg" +# """override logo""" + +# #INVENIO_OVERRIDE_FAVICON=mug.ico +# OVERRIDE_FAVICON = "mug.ico" +# """override favicon""" + +# #INVENIO_OVERRIDE_PRODUCTION=True +# OVERRIDE_PRODUCTION = True +# """Enable/Disable notice.""" + +# #INVENIO_OVERRIDE_ICON=images/icon_use.png +# OVERRIDE_ICON = "images/icon_use.png" +# """Icon used in login page""" + +# #INVENIO_OVERRIDE_CONTACT_FORM=False +# OVERRIDE_CONTACT_FORM = False +# """Enable/Disable Contact form.""" + +# #INVENIO_OVERRIDE_SHIBBOLETH=False +# OVERRIDE_SHIBBOLETH = False +# """Set True if SAML is configured""" + +# #INVENIO_OVERRIDE_FRONTPAGE_RIGHT=False +# OVERRIDE_FRONTPAGE_RIGHT = True +# """Frontpage right section""" diff --git a/themes/override-oer/additional.md b/themes/override-oer/additional.md new file mode 100644 index 0000000..7bc3489 --- /dev/null +++ b/themes/override-oer/additional.md @@ -0,0 +1 @@ +# Example config for installation with invenio-override and OER \ No newline at end of file diff --git a/themes/override-oer/invenio.cfg b/themes/override-oer/invenio.cfg new file mode 100644 index 0000000..d0e45af --- /dev/null +++ b/themes/override-oer/invenio.cfg @@ -0,0 +1,325 @@ +""" +InvenioRDM settings for instance project. + +This file was automatically generated by 'invenio-cli init'. + +For the full list of settings and their values, see +https://inveniordm.docs.cern.ch/reference/configuration/. +""" + +from datetime import datetime +from invenio_i18n import lazy_gettext as _ +from invenio_oauthclient.contrib.keycloak import KeycloakSettingsHelper + +def _(x): # needed to avoid start time failure with lazy strings + return x + +# ============================================================================ +# Flask Configuration +# See https://flask.palletsprojects.com/en/1.1.x/config/ +# Define the value of the cache control header `max-age` returned by the server when serving +# public files. Files will be cached by the browser for the provided number of seconds. +# See flask documentation for more information: +# https://flask.palletsprojects.com/en/2.1.x/config/#SEND_FILE_MAX_AGE_DEFAULT +# ============================================================================ +SEND_FILE_MAX_AGE_DEFAULT = 300 + +# SECURITY WARNING: keep the secret key used in production secret! +# Do not commit it to a source code repository. +# TODO: Set +SECRET_KEY="CHANGE_ME" + +# Since HAProxy and Nginx route all requests no matter the host header +# provided, the allowed hosts variable is set to localhost. In production it +# should be set to the correct host and it is strongly recommended to only +# route correct hosts to the application. +TRUSTED_HOSTS = ['0.0.0.0', 'localhost', '127.0.0.1'] + + +# ============================================================================ +# Flask-SQLAlchemy Configuration +# See https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/ +# ============================================================================ +# TODO: Set +SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://instance:instance@localhost/instance" + + +# ============================================================================ +# Invenio-App Configuration +# See https://invenio-app.readthedocs.io/en/latest/configuration.html +# ============================================================================ +APP_DEFAULT_SECURE_HEADERS = { + 'content_security_policy': { + 'default-src': [ + "'self'", + 'data:', # for fonts + "'unsafe-inline'", # for inline scripts and styles + "blob:", # for pdf preview + # Add your own policies here (e.g. analytics) + ], + }, + 'content_security_policy_report_only': False, + 'content_security_policy_report_uri': None, + 'force_file_save': False, + 'force_https': True, + 'force_https_permanent': False, + 'frame_options': 'sameorigin', + 'frame_options_allow_from': None, + 'session_cookie_http_only': True, + 'session_cookie_secure': True, + 'strict_transport_security': True, + 'strict_transport_security_include_subdomains': True, + 'strict_transport_security_max_age': 31556926, # One year in seconds + 'strict_transport_security_preload': False, +} + +# ============================================================================ +# Flask-Babel Configuration +# See https://python-babel.github.io/flask-babel/#configuration +# ============================================================================ +# # Default locale (language) +# BABEL_DEFAULT_LOCALE = 'en' +# # Default time zone +# BABEL_DEFAULT_TIMEZONE = 'Europe/Zurich' + +# ============================================================================ +# Invenio-I18N +# See https://invenio-i18n.readthedocs.io/en/latest/configuration.html +# Other supported languages (do not include BABEL_DEFAULT_LOCALE in list). +# ============================================================================ +# I18N_LANGUAGES = [ +# # ('de', _('German')), +# # ('tr', _('Turkish')), +# ] + + +# ============================================================================ +# Invenio-Theme Configuration +# See https://invenio-theme.readthedocs.io/en/latest/configuration.html +# See https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/config.py +# ============================================================================ +# Name used in header and UI +THEME_SITENAME = "instance" +# Frontpage title +THEME_FRONTPAGE_TITLE = "instance" +# Header logo +# THEME_LOGO = 'images/invenio-rdm.svg' + +# Instance's theme entrypoint file. Path relative to the ``assets/`` folder. +INSTANCE_THEME_FILE = './less/theme.less' + +# Email address for administrator emails (like file checksum alerts) +APP_RDM_ADMIN_EMAIL_RECIPIENT = "info@instance.com" + +# Default values for the deposit form +APP_RDM_DEPOSIT_FORM_DEFAULTS = { + "publication_date": lambda: datetime.now().strftime("%Y-%m-%d"), + "rights": [ + { + "id": "cc-by-4.0", + "title": "Creative Commons Attribution 4.0 International", + "description": ("The Creative Commons Attribution license allows " + "re-distribution and re-use of a licensed work " + "on the condition that the creator is " + "appropriately credited."), + "link": "https://creativecommons.org/licenses/by/4.0/legalcode", + } + ], + "publisher": "instance", +} + +APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES = 'search' # "search_only" or "off" + +# ============================================================================ +# Invenio-Records-Resources +# See https://github.com/inveniosoftware/invenio-records-resources/blob/master/invenio_records_resources/config.py +# ============================================================================ +# TODO: Set with your own hostname when deploying to production +SITE_UI_URL = "https://127.0.0.1" +SITE_API_URL = "https://127.0.0.1/api" + +# ============================================================================ +# Invenio-RDM-Records +# See https://inveniordm.docs.cern.ch/customize/dois/ +# ============================================================================ +DATACITE_ENABLED = False +DATACITE_USERNAME = "" +DATACITE_PASSWORD = "" +DATACITE_PREFIX = "" +DATACITE_TEST_MODE = True +DATACITE_DATACENTER_SYMBOL = "" + +# ========================================================= +# Authentication - Invenio-Accounts and Invenio-OAuthclient +# See: https://inveniordm.docs.cern.ch/customize/authentication/ +# ========================================================= + +# ============================================================================ +# Invenio-Accounts +# ============================================================================ +# See https://github.com/inveniosoftware/invenio-accounts/blob/master/invenio_accounts/config.py +ACCOUNTS_LOCAL_LOGIN_ENABLED = True # enable local login +SECURITY_REGISTERABLE = True # local login: allow users to register +SECURITY_RECOVERABLE = True # local login: allow users to reset the password +SECURITY_CHANGEABLE = True # local login: allow users to change psw +SECURITY_CONFIRMABLE = True # local login: users can confirm e-mail address +SECURITY_LOGIN_WITHOUT_CONFIRMATION = True # require users to confirm email before being able to login + +# ============================================================================ +# Invenio-OAuthclient +# See https://github.com/inveniosoftware/invenio-oauthclient/blob/master/invenio_oauthclient/config.py +# ============================================================================ +OAUTHCLIENT_REMOTE_APPS = {} # configure external login providers + +from invenio_oauthclient.views.client import auto_redirect_login +ACCOUNTS_LOGIN_VIEW_FUNCTION = auto_redirect_login # autoredirect to external login if enabled +OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = False # autoredirect to external login + +# ============================================================================ +# Invenio-UserProfiles +# ============================================================================ +USERPROFILES_READ_ONLY = True # allow users to change profile info (name, email, etc...) + +# ============================================================================ +# OAI-PMH +# See https://github.com/inveniosoftware/invenio-oaiserver/blob/master/invenio_oaiserver/config.py +# ============================================================================ +OAISERVER_ID_PREFIX = "instance.com" +"""The prefix that will be applied to the generated OAI-PMH ids.""" +OAISERVER_ADMIN_EMAILS = [ + "info@instance.com", +] + +# ============================================================================ +# Invenio - Search Configuration +# ============================================================================ +# Prefix for Elasticsearch indexes to avoid conflicts in shared environments. +SEARCH_INDEX_PREFIX = "instance-" + +# ============================================================================ +# Invenio-Users-Resources +# ============================================================================ +USERS_RESOURCES_ADMINISTRATION_ENABLED = True +"""Enable the user administration""" + +# ============================================================================ +# Invenio-Administration +# ============================================================================ +from invenio_app_rdm import __version__ +ADMINISTRATION_DISPLAY_VERSIONS = [ + ("invenio-app-rdm", f"v{__version__}"), + ("instance", "v1.0.0"), +] + +# ============================================================================ +# Invenio-I18N +# ============================================================================ +# See https://invenio-i18n.readthedocs.io/en/latest/configuration.html +BABEL_DEFAULT_LOCALE = "en" +# Default time zone +BABEL_DEFAULT_TIMEZONE = "Europe/Vienna" +# Other supported languages (do not include BABEL_DEFAULT_LOCALE in list). +I18N_LANGUAGES = [] + +# ============================================================================ +# Extras +# ============================================================================ +#INVENIO_THEME_SHOW_FRONTPAGE_INTRO_SECTION=False +THEME_SHOW_FRONTPAGE_INTRO_SECTION = False +"""Set True for frontpage Intro.""" + +RDM_USER_MODERATION_ENABLED = True +"""User moderation feature enabled.""" + +RDM_SEARCH_SORT_BY_VERIFIED = True +"""Enable the sorting of records by verified.""" + +USERS_RESOURCES_ADMINISTRATION_ENABLED = True +"""Enable user administration.""" + +USERS_RESOURCES_GROUPS_ENABLED = True +"""Config to enable features related to existence of groups.""" + +COMMUNITIES_ADMINISTRATION_DISABLED = False # this enables it +"""Enable communities administration.""" + +APP_RDM_SUBCOMMUNITIES_LABEL = "Projects" +"""Label for subcommunities in communities browse page.""" + +COMMUNITIES_SHOW_BROWSE_MENU_ENTRY = True +"""Toggle to show or hide the 'Browse' menu entry for communities.""" + +JOBS_ADMINISTRATION_ENABLED = True +"""Enable Jobs administration view.""" + +# ============================================================================ +# Invenio-override +# Configure theme elements, such as logos, icons, and footer templates. +# ============================================================================ +#INVENIO_OVERRIDE_LOGO=images/MUG.svg +OVERRIDE_LOGO = "images/invenio-rdm.svg" +"""override logo""" + +#INVENIO_OVERRIDE_PRODUCTION=True +OVERRIDE_PRODUCTION = True +"""Enable/Disable notice.""" + +#INVENIO_OVERRIDE_ICON=images/icon_use.png +OVERRIDE_ICON = "images/icon_use.png" +"""Icon used in login page""" + +#INVENIO_OVERRIDE_CONTACT_FORM=False +OVERRIDE_CONTACT_FORM = True +"""Enable/Disable Contact form.""" + +#INVENIO_OVERRIDE_SHIBBOLETH=False +OVERRIDE_SHIBBOLETH = False +"""Set True if SAML is configured""" + +#INVENIO_OVERRIDE_FRONTPAGE_RIGHT=False +OVERRIDE_FRONTPAGE_RIGHT = False +"""Frontpage right section""" + +# Right Section Configuration +# -------------- +OVERRIDE_RIGHT_SECTION_TITLE = True +"""Title for the right section.""" + +OVERRIDE_SHOW_RIGHT_CONTACT_EMAILL = True +"""Contact Email for the right section.""" + +OVERRIDE_RIGHT_SECTION_CONTACT_EMAIL = "rdmsupport@tugraz.at" +"""Contact email displayed in the right section.""" + +# Theme and Templates +# -------------- +OVERRIDE_RESOURCE_OVERVIEW = True +"""Resource overview section""" + +# ============================================================================ +# Invenio-override - Global Search Configuration +# ============================================================================ +OVERRIDE_SHOW_PUBLICATIONS_SEARCH = False +"""Enable or disable the publication global search feature.""" + +OVERRIDE_SHOW_EDUCATIONAL_RESOURCES = True +"""Enable or disable the educational resources global search feature.""" + +USER_DASHBOARD_MENU_OVERRIDES = { + "uploads": { + "text": _("Research Results"), + }, +} +"""Override the Uploads menu title""" + +GLOBAL_SEARCH_SCHEMAS = { + "rdm": { + "schema": "rdm", + "name_l10n": "Research Result", + }, + "marc21": { + "schema": "lom", + "name_l10n": "OER", + }, +} +"""Mapping of original schemas for global search."""