### RDM Instance Development - Initial Setup Source: https://github.com/inveniosoftware/invenio-app-rdm/wiki/Development-Setup Commands to cookiecutter a new RDM instance and install dependencies for local development. ```console $ export FLASK_ENV=development $ invenio-cli install $ invenio-cli services $ invenio-cli demo ``` -------------------------------- ### Invenio React Libraries Development - Clone and Build Source: https://github.com/inveniosoftware/invenio-app-rdm/wiki/Development-Setup Steps to clone a React Invenio module, install its dependencies, and build it. ```console $ git clone git@github.com:inveniosoftware/react-invenio-deposit $ cd react-invenio-deposit $ npm install $ npm run build ``` -------------------------------- ### Boosting Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/help/search.en.html Example of using the boost operator `^` to rank terms by relevance. ```text metadata.title:"open science"^5 metadata.description:"open science" ``` -------------------------------- ### RDM Instance Development - Running the Instance Source: https://github.com/inveniosoftware/invenio-app-rdm/wiki/Development-Setup Command to run the RDM instance after initial setup. ```console $ invenio-cli run ``` -------------------------------- ### Invenio React Libraries Development - Link and Watch Source: https://github.com/inveniosoftware/invenio-app-rdm/wiki/Development-Setup Commands to link the built React module into the instance and start watching for code changes. ```console $ npm run link-dist && npm run watch ``` -------------------------------- ### RDM Instance Development - Webpack Watch Source: https://github.com/inveniosoftware/invenio-app-rdm/wiki/Development-Setup Commands to activate the virtual environment and start the webpack watch process for live asset reloading. ```console $ pipenv shell (my-site)$ export FLASK_ENV=development (my-site)$ invenio webpack run start ``` -------------------------------- ### Invenio React Libraries Development - Restart Instance Source: https://github.com/inveniosoftware/invenio-app-rdm/wiki/Development-Setup Commands to restart the RDM instance with the development environment and webpack watch enabled. ```console $ export FLASK_ENV=development $ invenio webpack run start ``` -------------------------------- ### Fuzziness Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/help/search.en.html Example of using the fuzzy operator `~` to search for terms similar to the search term. ```text oepn~ ``` -------------------------------- ### Invenio React Libraries Development - Global Link Source: https://github.com/inveniosoftware/invenio-app-rdm/wiki/Development-Setup Command to globally link the React module from the instance's node_modules folder. ```console $ npm link react-invenio-deposit ``` -------------------------------- ### Wildcards Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/help/search.en.html Example of using wildcard operators `?` for a single character and `*` for zero or more characters. ```text ope? scien* ``` -------------------------------- ### Install dependencies with uv or pipenv Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/docs/contributing.md Commands to install local copy into a virtual environment using either uv or pipenv. ```console cd invenio-app-rdm/ # with uv $ uv venv $ uv pip install -e ".[tests,opensearch2]" # with pipenv $ pipenv run pip install -e ".[tests,opensearch2]" ``` -------------------------------- ### Metadata Variable Setup Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/details/meta.html Sets up variables for title, description, authors, and files from the record UI data. ```html {%- set meta_title = record_ui["metadata"]["title"]|striptags -%} {%- set meta_description = record_ui["metadata"]["description"]|striptags -%} {%- set meta_authors = record_ui["metadata"]["creators"]|map(attribute='person_or_org')|map(attribute='name') -%} {%- set files = record_ui["files"] %} ``` -------------------------------- ### Missing values search Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/help/search.en.html Examples of searching for records that are missing a value or have a value in a specific field using `_exists_` and `NOT _exists_`. ```text NOT _exists_:metadata.additional_titles ``` ```text _exists_:metadata.creators ``` -------------------------------- ### Proximity searches Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/help/search.en.html Example of a proximity search allowing terms to not be in the exact order and include other terms in between. ```text "open science"~5 ``` -------------------------------- ### Desktop Quick-create Menu Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/header_login.html Renders a 'plus' menu for quick creation actions on desktop view. ```html {%- set plus_menu_items = current_menu.submenu('plus').children %} {%- if plus_menu_items %} {%- for item in plus_menu_items if item.visible %} [{{ item.text|safe }}]({{ item.url }}){%- endfor %} {% endif %} ``` -------------------------------- ### Show Title and Language Detail Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Displays a title, optionally appending the language if provided. ```html {% macro show_title_detail(title, language, value) %} {{ title }} {{ '(' + language + ')' if language }} {{ value }} {%- endmacro %} ``` -------------------------------- ### Show References Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Iterates over a list of references, formatting each reference with its identifier and scheme, and creating a Markdown list. ```html {% macro show_references(references) %} {% for reference in references %} {% set reference_string = reference.reference|default('') %} {% if reference.get('identifier') %} {% if reference.scheme is defined and reference.scheme %} {% set reference_scheme = reference.scheme | get_scheme_label %} {% set reference_string = reference_string ~ ' (' ~ reference_scheme ~ ' - ' ~ reference.identifier ~ ')' %} {% else %} {% set reference_string = reference_string ~ ' (' ~ reference.identifier ~ ')' %} {% endif %} {% endif %} * {{ reference_string | urlize }} {% endfor %} {% endmacro %} ``` -------------------------------- ### Mobile/Tablet Quick-create Menu Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/header_login.html Renders a 'plus' menu for quick creation actions on mobile/tablet view. ```html {{ _("Actions") }} ------------------- {%- for item in plus_menu_items if item.visible %} [{{ item.text|safe }}]({{ item.url }}) {%- endfor %} ``` -------------------------------- ### Show Additional Titles Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Iterates over a list of additional titles, displaying each with its language if available. ```html {% macro show_add_titles(add_titles) %} {% for add_title in add_titles %} {% if add_title.lang %} {{ show_title_detail(add_title.type.title_l10n, add_title.lang.title_l10n, add_title.title) }} {% else %} {{ show_title_detail(add_title.type.title_l10n,None, add_title.title) }} {% endif %} {% endfor %} {% endmacro %} ``` -------------------------------- ### Footer Links Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/footer.html Jinja2 template code defining links for the footer, categorized into 'About InvenioRDM', 'Get involved', and 'Community'. It uses internationalization functions like _() for translatable strings and Markdown-like syntax for links. ```html {# Copyright (C) 2019-2020 CERN. Copyright (C) 2019-2020 Northwestern University. Copyright (C) 2021 Graz University of Technology. Copyright (C) 2024 KTH Royal Institute of Technology. Invenio App RDM is free software; you can redistribute it and/or modify it under the terms of the MIT License; see LICENSE file for more details. #} {%- block footer\_top %} {%- block footer\_top\_left %} {{ \_("About InvenioRDM") }} ---------------------------- [{{ \_("Product page") }}](http://inveniosoftware.org/products/rdm) [{{ \_("Features") }}](https://inveniosoftware.org/products/rdm/#features) [{{ \_("Roadmap") }}](https://inveniosoftware.org/products/rdm/roadmap/) [{{ \_("Demo site") }}](http://inveniordm.web.cern.ch) {{ \_("Get involved") }} ------------------------ [{{ \_("GitHub") }}](https://github.com/inveniosoftware/invenio-app-rdm) [{{ \_("Project Milestones") }}](https://github.com/inveniosoftware/product-rdm) [{{ \_("Documentation") }}](http://inveniordm.docs.cern.ch) {{ \_("Community") }} --------------------- [{{ \_("Chatroom") }}](https://discord.gg/8qatqBC) [{{ \_("Forum") }}](https://invenio-talk.web.cern.ch/c/projects/invenio-rdm) [{{ \_("Events & training") }}](https://inveniosoftware.org/events/) {%- endblock footer\_top\_left %} {%- block footer\_top\_right %} {%- endblock footer\_top\_right %} {%- endblock footer\_top %} ``` -------------------------------- ### Show Additional Descriptions Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Iterates over a list of additional descriptions, displaying type, language, and the description text. Special handling for 'notes' type. ```html {% macro show_add_descriptions(add_descriptions) %} {% for add_description in add_descriptions %} {% set desc_type_defined = add_description.type is defined %} {% set desc_text = add_description.description|default('') %} {{ add_description.type.title_l10n if desc_type_defined else _('Missing description type!') }} {{ '(' ~ add_description.lang.title_l10n ~ ')' if add_description.lang is defined else '' }} --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- {# additional description data is being sanitized by marshmallow in the backend #} {% if desc_type_defined and add_description.type.id == "notes" %} {{ desc_text | safe }} {% else %} {{ desc_text | safe }} {% endif %} {% endfor %} {% endmacro %} ``` -------------------------------- ### List String Values Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Iterates over a list of string values, optionally creating search links for each value. ```html {% macro list_string_values(field, values) %} {% for value in values %} {% set search_url = field | custom_fields_search(value) %} {% if search_url %} [{{ value }}]({{ search_url }}) {{ ", " if not loop.last }} {% else %} {{ value }}{{ ", " if not loop.last }} {% endif %} {% endfor %} {% endmacro %} ``` -------------------------------- ### Show Dates Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Iterates over a list of dates, displaying the date type, date value, and any associated description. ```html {% macro show_dates(dates) %} {% for date in dates %} {% set date_type_title = date.get('type', {}).get('title_l10n', _('Unknown date type')) %} {{ date_type_title }} {{ date.date|default('') }} {{ date.description|default('') }} {% endfor %} {% endmacro %} ``` -------------------------------- ### List Vocabulary Values Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html A macro to list and format vocabulary field values, generating search URLs if applicable. ```html {% macro list_vocabulary_values(field, values, field_cfg) %} {% if values is mapping %} {{ _vocabulary_search_url(field, values, field_cfg) }} {% else %} {% for value in values %} {{ _vocabulary_search_url(field, value, field_cfg) }}{{ ", " if not loop.last }} {% endfor %} {% endif %} {% endmacro %} ``` -------------------------------- ### Show Sanitized Detail Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Similar to show_detail, but sanitizes the value before displaying it, assuming it's safe HTML. ```html {% macro show_sanitized_detail(title, value) %} {{ title }} {{ value | sanitize_html()| safe }} {%- endmacro %} ``` -------------------------------- ### Show Funding Item Macro (Helper) Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Displays a single funding item, including funder name, award details (acronym, title, number, identifiers), and links. ```html {% macro _show_funding_item(item, index) %} {{ item.funder.name if item.funder }} {%- if item.award -%} {% if item.award.acronym %} {{ item.award.acronym }} - {% endif %}{%- if item.award.title_l10n -%} {{ item.award.title_l10n }} {%- endif -%} {%- if item.award.number -%} {{ item.award.number }} {%- endif -%} {%- if item.award.identifiers -%} {% for identifier in item.award.identifiers if 'url' == identifier.scheme %} []({{ identifier.identifier }}){%- endfor -%} {%- endif -%} {%- endif -%} {% endmacro %} ``` -------------------------------- ### Preview File Box Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/files.html This macro renders a box for previewing a file, including its name and a preview link if applicable. It also handles remote files. ```html {%- macro preview_file_box(file, pid, is_preview, record, include_deleted, display_name=None) %} {%- set is_remote_file = file.transfer.type == transfer_types.REMOTE %} {%- if display_name %} {%- set human_readable_file_name = display_name(file) or file.key %} {%- else %} {%- set human_readable_file_name = file.key %} {%- endif %} ### {{ human_readable_file_name }} {%- if is_remote_file %} {{ _('This file cannot be previewed') }} * {{ _('This file is an external reference and not stored directly in this repository. To access its content, please download it and open it locally.') }} {%- else %} {{ preview_file('invenio_app_rdm_records.record_file_preview', pid_value=pid, filename=file.key, is_preview=is_preview, include_deleted=include_deleted) }} {%- endif %} {%- endmacro %} ``` -------------------------------- ### Show Funding Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Iterates over a list of funding items and calls a helper macro to display each item. ```html {% macro show_funding(funding) %} {% for fund in funding %} {{ _show_funding_item(fund, loop.index0) }} {% endfor %} {% endmacro %} ``` -------------------------------- ### Run tests Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/docs/contributing.md Command to run tests, which include test coverage, PEP8, PEP257, flake8, and Sphinx documentation build. ```console (venv) ./run-tests.sh ``` -------------------------------- ### Show Detail Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html A basic macro to display a title and its corresponding value. ```html {# Copyright (C) 2020-2025 CERN. Copyright (C) 2024 Northwestern University. Copyright (C) 2024-2025 KTH Royal Institute of Technology. Invenio RDM Records is free software; you can redistribute it and/or modify it under the terms of the MIT License; see LICENSE file for more details. #} {% macro show_detail(title, value) %} {{ title }} {{ value }} {%- endmacro %} ``` -------------------------------- ### Preview File Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/files.html This macro generates a URL for previewing a file, handling different preview and include_deleted settings. ```html {%- macro preview_file(preview_endpoint, pid_value, filename, is_preview, include_deleted, id='preview-iframe' ) %} {%- set include_deleted_value = 0 -%} {% if include_deleted %} {%- set include_deleted_value = 1 -%} {% endif %} {% if is_preview %} {%- set preview_url = url_for(preview_endpoint, pid_value=pid_value, filename=filename, preview=1, include_deleted=include_deleted_value) -%} {% else %} {%- set preview_url = url_for(preview_endpoint, pid_value=pid_value, filename=filename, include_deleted=include_deleted_value) -%} {% endif %} {%- endmacro %} ``` -------------------------------- ### Jinja2 Macro for License Link Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/details/side_bar/licenses.html A Jinja2 macro that generates a link to more information about a license, prioritizing 'license.link' and falling back to 'license.props.url'. ```html {% macro license_link(license) %} {% if license.link %} [{{ _('Read more') }}]({{ license.link }} "{{ _('Opens in new tab') }}") {% elif license.props and license.props.url %} [{{ _('Read more') }}]({{ license.props.url }} "{{ _('Opens in new tab') }}") {% endif %} {% endmacro %} ``` -------------------------------- ### Show Alternate Identifiers Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html Iterates over a list of alternate identifiers, displaying the scheme and the identifier value (linked if possible). ```html {% macro show_alternate_identifiers(identifiers) %} {% for alt_id in identifiers %} {{ alt_id.scheme | get_scheme_label }} {% set url = alt_id.identifier|pid_url(scheme=alt_id.scheme) %} {% if url %} [{{ alt_id.identifier }}]({{ url }} "{{ _('Opens in new tab') }}") {% else %} {{ alt_id.identifier }} {% endif %} {% endfor %} {% endmacro %} ``` -------------------------------- ### File List Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/files.html This macro generates a list of files with their names, sizes, checksums, and download/preview links. It handles remote files and archive downloads. ```html {%- macro file_list( files, pid, is_preview, include_deleted, record=None, with_preview=true, download_endpoint='invenio_app_rdm_records.record_file_download', preview_endpoint='invenio_app_rdm_records.record_file_preview', is_media=false, permissions=None, display_name=None ) %} {%- set binary_sizes = not config.APP_RDM_DISPLAY_DECIMAL_FILE_SIZES %} {%- set include_deleted_value = 0 -%} {% if include_deleted %} {%- set include_deleted_value = 1 -%} {% endif %} {% for file in files %} {% if not file.access.hidden %} {%- set is_remote_file = file.transfer.type == transfer_types.REMOTE %} {%- if display_name %} {%- set human_readable_file_name = display_name(file) or file.key %} {%- else %} {%- set human_readable_file_name = file.key %} {%- endif %} {% if is_preview %} {%- set file_url_download = url_for(download_endpoint, pid_value=pid, filename=file.key, download=1, preview=1) %} {%- set file_url_preview = url_for(preview_endpoint, pid_value=pid, filename=file.key, preview=1, include_deleted=include_deleted_value) %} {% else %} {%- set file_url_download = url_for(download_endpoint, pid_value=pid, filename=file.key, download=1) %} {%- set file_url_preview = url_for(preview_endpoint, pid_value=pid, filename=file.key, include_deleted=include_deleted_value) %} {% endif %} {%- set file_type = file.key.split('.')[-1] %} {% endif %} {% endfor %} {{"Name"}} {{"Size"}} {%- if config.RDM_ARCHIVE_DOWNLOAD_ENABLED %} {% set archive_download_url = record.links.archive_media if is_media else record.links.archive %} [{{"Download all"}}]({{ archive_download_url }}) {%- endif %} [{{ human_readable_file_name }}]({{ file_url_download }}) {%- if not is_remote_file %} {{ file.checksum or _("Checksum not yet calculated.") }} {%- endif %} {%- if is_remote_file %}{{"N/A (external)"}}{%- else -%}{{ file.size|filesizeformat(binary=binary_sizes) }}{%- endif %} {% if with_preview and file_type|lower is previewable and not is_remote_file %} [{{"Preview"}}]({{ file_url_preview }}) {% endif %} [{{"Download"}}]({{ file_url_download }}) {%- endmacro %} ``` -------------------------------- ### List Languages Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html A macro to list localized titles of languages. ```html {% macro list_languages(languages) %} {% for lang in languages %} {{ lang.title_l10n }}{{ ", " if not loop.last }} {% endfor %} {% endmacro %} ``` -------------------------------- ### Show Section Custom Fields Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html A macro to organize and render custom fields based on their section (e.g., Journal, Imprint, Thesis, Conference). ```html {% macro show_section_custom_fields(custom_fields, section_fields) %} {% set ns = namespace(journal=[], imprint=[], thesis=[], conference=[], other=[]) %} {% for field_cfg in section_fields %} {% set field_value = custom_fields.get(field_cfg.field) %} {% if field_value is not none and field_value != '' %} {% if field_cfg.field.startswith('journal:') %} {% set ns.journal = ns.journal + [field_cfg] %} {% elif field_cfg.field.startswith('imprint:') %} {% set ns.imprint = ns.imprint + [field_cfg] %} {% elif field_cfg.field.startswith('thesis:') %} {% set ns.thesis = ns.thesis + [field_cfg] %} {% elif field_cfg.field.startswith('conference:') %} {% set ns.conference = ns.conference + [field_cfg] %} {% else %} {% set ns.other = ns.other + [field_cfg] %} {% endif %} {% endif %} {% endfor %} {% if ns.journal or ns.imprint or ns.thesis or ns.conference %} {% if ns.journal %} {{ render_custom_field_group(custom_fields, ns.journal, 'Journal') }} {% endif %} {% if ns.imprint %} {{ render_custom_field_group(custom_fields, ns.imprint, 'Imprint') }} {% endif %} {% if ns.thesis %} {{ render_custom_field_group(custom_fields, ns.thesis, 'Thesis') }} {% endif %} {% if ns.conference %} {{ render_custom_field_group(custom_fields, ns.conference, 'Conference') }} {% endif %} {% endif %} {% if ns.other %} {% for field_cfg in ns.other %} {{ render_custom_field_dt_dd(custom_fields, field_cfg) }} {% endfor %} {% endif %} {% endmacro %} ``` -------------------------------- ### File Rendering Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/files.html A Jinja macro that renders system files, access restrictions, and a file list for a record. It includes logic for displaying file sizes, access status, embargo reasons, and a detailed file list with preview and download options. ```html {% macro files(files, pid, is_preview, include_deleted, record, binary_sizes, permissions, display_name) %} {{ _("System files") }} {% if files %} ({{files|sum(attribute='size')|filesizeformat(binary=binary_sizes)}}){% endif %} {% if record.access.record == 'restricted'%} #### {{ record.ui.access_status.title_l10n }} {{ record.ui.access_status.description_l10n }} {% if record.access.embargo.reason %} {{"Reason"}}: {{record.access.embargo.reason}} {% endif%} {% endif %} {{ file_list(files, pid, is_preview, include_deleted, record=record, with_preview=false, download_endpoint="invenio_app_rdm_records.record_media_file_download", is_media=true, permissions=permissions, display_name=display_name) }} {%- endmacro %} ``` -------------------------------- ### Media File List Box Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/files.html This macro is similar to file_list_box but specifically for media files. ```html {%- macro media_file_list_box(files, pid, is_preview, include_deleted, record, permissions, display_name=None) %} {%- set binary_sizes = not config.APP_RDM_DISPLAY_DECIMAL_FILE_SIZES %} ``` -------------------------------- ### List Float Values Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html A macro to format and display float values, with optional search URLs. ```html {% macro list_float_values(field, values) %} {% for value in values %} {% set search_url = field | custom_fields_search(value) %} {% if search_url %} [{{ "%0.2f" | format(value) }}]({{ search_url }}){{ " , " if not loop.last }} {% else %} {{ "%0.2f" | format(value) }}{{ ", " if not loop.last }} {% endif %} {% endfor %} {% endmacro %} ``` -------------------------------- ### Show Version Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/version.html This macro displays the version number, publication date, and DOI. It handles cases where the DOI might not be available. ```html {# Copyright (C) 2020 CERN. Copyright (C) 2024 KTH Royal Institute of Technology. Invenio RDM Records is free software; you can redistribute it and/or modify it under the terms of the MIT License; see LICENSE file for more details. #} {% macro show_version(version, publication_date, doi) %} {{ _("Version") }} {{ version }} {% set doi = doi if doi else _("No DOI available") %} {{ doi }} {{ publication_date }} {%- endmacro %} ``` -------------------------------- ### File Loop and Download URL Generation Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/details/meta.html Iterates through files if the user has read permissions and generates download URLs for each file. ```html {%- if permissions.can_read_files -%} {%- for file_name, file in files.entries.items() or {} -%} {%- set file_url = url_for("invenio\_app_rdm.record_file_download", pid_value=record_ui["id"], filename=file_name, _external=True) %} ``` -------------------------------- ### Thesis Detail Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html A Jinja macro to display thesis details, showing the title and the thesis content itself. ```html {%- macro show_detail_thesis(title, thesis) -%} {{ title }} {{ thesis | safe }} {% endmacro %} ``` -------------------------------- ### Show Detail Conference Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html A macro to display conference-specific details. ```html {% macro show_detail_conference(conference) %} ``` -------------------------------- ### Desktop Account Dropdown Menu Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/header_login.html Displays the user's email and links to settings and admin sections for desktop view. ```html {%- if config.USERPROFILES %} {{ current_user.email|truncate(31,true) }} {%- for item in current_menu.submenu('settings').children if item.visible %} [{{ item.text|safe }}]({{ item.url }}) {%- endfor %} {% set ns = namespace(admin_menu=False) %} {%- for item in current_menu.submenu('profile-admin').children if item.visible %} {% set ns.admin_menu = True %} [{{ item.text|safe }}]({{ item.url }}) {%- endfor %} {% if ns.admin_menu %} {% endif %} [{{ _('Log out') }}]({{ url_for_security('logout') }}) {%- else %} [{{ _('Log out') }}]({{ url_for_security('logout') }}) {%- endif %} ``` -------------------------------- ### File List Box Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/files.html This macro renders a box containing the file list, including total size and access restrictions. ```html {%- macro file_list_box(files, pid, is_preview, include_deleted, record, permissions, display_name=None) %} {%- set binary_sizes = not config.APP_RDM_DISPLAY_DECIMAL_FILE_SIZES %} ### {{ _("Files") }} {% if files %} ({{files|map(attribute='size', default=0)|sum()|filesizeformat(binary=binary_sizes)}}){% endif %} {% if record.access.files == 'restricted' %} #### {{ record.ui.access_status.title_l10n }} {{ record.ui.access_status.description_l10n }} {% if record.access.embargo.reason %} {{"Reason"}}: {{record.access.embargo.reason}} {% endif%} {% endif %} {{ file_list(files, pid, is_preview, include_deleted, record=record,download_endpoint="invenio_app_rdm_records.record_file_download", permissions=permissions, display_name=display_name) }} {%- endmacro %} ``` -------------------------------- ### Clone your fork locally Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/docs/contributing.md Command to clone your forked repository of Invenio App RDM locally. ```console git clone git@github.com:your_name_here/invenio-app-rdm.git ``` -------------------------------- ### Vocabulary Search URL Macro Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html A macro to generate a search URL for a vocabulary field value. ```html {% macro _vocabulary_search_url(field, value, field_cfg) %} {% if field_cfg.landing_page_search_attr and field_cfg.landing_page_search_attr in value %} {% set search_text = value[field_cfg.landing_page_search_attr] %} {% else %} {% set search_text = value.title_l10n %} {% endif %} {% set search_url = field | custom_fields_search(search_text, field_cfg) %} {% if search_url %} [{{ value.title_l10n | safe }}]({{ search_url }}) {% else %} {{ value.title_l10n }} {% endif %} {% endmacro %} ``` -------------------------------- ### Jinja2 Template for Displaying Rights and Copyrights Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/details/side_bar/licenses.html The main Jinja2 template logic for rendering license and copyright information based on the 'rights' and 'copyrights' variables. ```html {% set rights = record_ui["ui"].get('rights', []) %} {% set copyrights = record_ui.get('metadata', {}).get('copyright') %} {% if rights or copyrights %} {{ _('Rights') }} ------------------ {% if rights %} {{ _("License") }} {%- for license in rights -%} {% if license.icon %} {% set iconFile = 'icons/licenses/{}.svg'.format(license.icon) %} ![{{ license.id }} icon]({{ url_for('static', filename=iconFile) }}) {% endif %} {{ license.title_l10n }} {{ license.description_l10n or _('No further description.') }} {{ license_link(license) }} {% endfor %} {% endif %} {% if copyrights %} {{ _("Copyright") }} {{ copyrights }} {% endif %} {% endif %} ``` -------------------------------- ### JavaScript Includes Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/detail.html This block includes necessary JavaScript files for the landing page theme and previewer, conditionally based on a theme template setting. ```html {%- block javascript %} {% if use_theme_basic_template|default(true) %} {{ super() }} {% else %} {% include config.THEME_JAVASCRIPT_TEMPLATE %} {% endif %} {%- block record_jsonld %} {% set jsonld_serialization = record_ui | transform_record('SchemaorgJSONLDSerializer', throws=False) %} {%- if jsonld_serialization %} {{ jsonld_serialization | tojson }} {%- endif %} {%- endblock record_jsonld %} {{ webpack['invenio-app-rdm-landing-page-theme.js'] }} {{ webpack['invenio-app-rdm-landing-page.js'] }} {{ webpack['previewer_theme.js'] }} {%- endblock javascript %} ``` -------------------------------- ### Site Banner Block Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/header.html Includes a banner component if configured. ```html {%- block site_banner %} {% from 'invenio_banners/banner.html' import banner %} {{ banner() }} {%- endblock site_banner %} ``` -------------------------------- ### Mobile/Tablet Account Menu Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/header_login.html Displays user account options for mobile/tablet view. ```html {{ _("My account") }} ---------------------- {%- for item in current_menu.submenu('settings').children if item.visible %} [{{ item.text|safe }}]({{ item.url }}) {%- endfor %} {% set ns = namespace(admin_menu=False) %} {%- for item in current_menu.submenu('profile-admin').children if item.visible %} {% set ns.admin_menu = True %} [{{ item.text|safe }}]({{ item.url }}) {%- endfor %} {% if ns.admin_menu %} {% endif %} [{{ _('Log out') }}]({{ url_for_security('logout') }}) ``` -------------------------------- ### Login/Signup Links Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/header_login.html Displays login and signup links if the user is not authenticated and registration is enabled. ```html {%- if config.ACCOUNTS %} {%- if not current_user.is_authenticated %} [{{ _('Log in') }}]({{ url_for_security('login', next=request.path) }}) {% if security.registerable %} [{{ _('Sign up') }}]({{ url_for_security('register') }}) {% endif %} {%- endif %} {%- endif %} ``` -------------------------------- ### Navbar Navigation Links Source: https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/templates/themes/default/invenio_app_rdm/header.html Iterates through main menu items and action items to render navigation links. ```html {%- block navbar_nav %} {%- for item in current_menu.submenu('main').children|sort(attribute='order') if item.visible recursive %} {%- if item.children %} [{{ item.text|safe }}]({{ item.url }}) {{ loop(item.children|sort(attribute='order')) }} {%- else %} [{{ item.text|safe }}]({{ item.url }}) {%- endif %} {%- endfor %} {% for item in current_menu.submenu('actions').children|sort(attribute='order') if item.visible recursive %} [{{ item.text|safe }}]({{ item.url }}) {% endfor %} {%- endblock navbar_nav %} ```