Skip to main content

oarepo-previewer

OARepo module delivering contrib previewers to invenio-previewer for custom file extensions.

Installation

pip install oarepo-previewer

The Flask app extension (registered via the invenio_base.apps entry point) inserts the previewers listed in OAREPO_PREVIEWER_ENABLED at the front of invenio-previewer's PREVIEWER_PREFERENCE.

Shipped previewers

Molecular Viewer (mol)

A unified molecular structure previewer powered by Molstar, supporting a wide range of molecular and crystallographic file formats:

Extension Format
.mvsj MolViewSpec JSON description
.mvsx MolViewSpec ZIP container
.pdb Protein Data Bank
.ent PDB legacy format
.cif Crystallographic Information File
.bcif Binary CIF (compressed)
.mcif Magnetic CIF
.mmcif Macro-molecular CIF
.mol / .sdf / .sd MDL Molfile
.mol2 Tripos Mol2
.gro GROMACS structure
.xyz XYZ coordinate format
.pdbqt PDBQT (AutoDock)

The previewer leverages Molstar's native support for these formats, providing 3D visualization directly in the browser. Configuration is handled via the template which loads Molstar and initializes the viewer with the file URI.

Configuration

# invenio.cfg
OAREPO_PREVIEWER_ENABLED = ["mol"]  # default
OAREPO_PREVIEWER_MOL_MAX_FILE_SIZE_BYTES = 200 * 1024 * 1024

Set OAREPO_PREVIEWER_ENABLED = [] to manage PREVIEWER_PREFERENCE manually.

Content Security Policy (Molstar)

Molstar may issue fetch calls to external databases when a previewed file (e.g. an .mvsj/.mvsx MolViewSpec description) contains URLs pointing to remote resources. If your app sets APP_DEFAULT_SECURE_HEADERS, the default Content Security Policy will block these requests, so the policy needs to be relaxed for the molecular viewer to work.

invenio.cfg settings could be for instance:

# invenio.cfg
APP_DEFAULT_SECURE_HEADERS = {
    "content_security_policy": {
        "default-src": [
            "'self'",
            "fonts.googleapis.com",
            "*.gstatic.com",
            "data:",
            "'unsafe-inline'",
            "blob:",
            "http://127.0.0.1:9000/",  # Development S3 server
            "https://licensebuttons.net/",
        ],
        "script-src": [
            "'self'",
            "blob:",
            "'wasm-unsafe-eval'",
        ],
        "connect-src": [
            "'self'",
            "http://127.0.0.1:9000",  # Development S3 server
            "https://*.rcsb.org",  # RCSB PDB (Protein Data Bank)
            "https://*.ebi.ac.uk",  # EBI (European Bioinformatics Institute)
            "https://*.pdbj.org",  # PDBj (Protein Data Bank Japan)
            "https://modelarchive.org",  # ModelArchive
            "https://*.expasy.org",  # ExPASy
            "https://pubchem.ncbi.nlm.nih.gov",  # PubChem
        ],
    }
}

The connect-src database entries are actually only needed if previewed files reference remote resources — Molstar fetches them from the databases above. If your records never contain such references, you can omit them (or add more if needed). Keep the development S3 entries (127.0.0.1:9000) out of production deployments and replace them with your actual file storage origin.

Adding a contrib previewer

  1. Create a module in oarepo_previewer/previewers/ exposing previewable_extensions (list of extensions without a dot) and the can_preview(file) / preview(file) functions — see (invenio_previewer/extensions/json_prismjs.py) for the contract. Templates go to oarepo_previewer/templates/semantic-ui/oarepo_previewer/.

  2. Register it in pyproject.toml:

    [project.entry-points."invenio_previewer.previewers"]
    mol = "oarepo_previewer.previewers.mol "
    
  3. Add its name to the default OAREPO_PREVIEWER_ENABLED in oarepo_previewer/config.py.

Development

./run.sh --help   # oarepo library runner (tests, linting, ...)
./run.sh tests

License

MIT — Copyright (C) 2026 CESNET z.s.p.o. See the LICENSE file.

Metadata

Release files for oarepo-previewer 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oarepo-previewer 1.0.2
File Size Uploaded Provenance Actions
oarepo_previewer-1.0.2.tar.gz 13.3 kB Without provenance Details for oarepo_previewer-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oarepo-previewer 1.0.2
File Interpreter ABI Platform Actions
oarepo_previewer-1.0.2-py3-none-any.whl Python 3 none any Details for oarepo_previewer-1.0.2-py3-none-any.whl

Total release size: 34.6 kB

Release files / oarepo_previewer-1.0.2.tar.gz

Download URL oarepo_previewer-1.0.2.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bb819e19d7b86ea558a909fd5bb6561cd032c2cf754f40ec45261be648be1a6d
BLAKE2b-256 checksum
How to use checksums
9558d69541ef04a2621e41f97fd92ac6922633bb6ac2c5ddb64a09211222db19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / oarepo_previewer-1.0.2-py3-none-any.whl

Download URL oarepo_previewer-1.0.2-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68f8037e7f8106aca606d01a3271547cf8e8c97e372e3bbd96487bbd0855a2ad
BLAKE2b-256 checksum
How to use checksums
bdccad5de832f690e2a653abf8bfc5ddd6758abaf788587c2e30603dfbf36b7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for oarepo-previewer 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page