Skip to main content

splent_feature_media

The media feature of a SPLENT product line: a media library to upload and manage files, the analogue of WordPress's Media Library, with a public gallery the product may show or keep to itself.

A SPLENT feature is a Python package that a product composes with others: its models, routes, services, templates and hooks are registered when the product starts. What this feature provides and requires is listed in the [tool.splent.contract] section of pyproject.toml, which splent feature:contract --write keeps in sync with the source. What it reads from the environment, and its defaults, is [tool.splent.config].

Use it in a product

splent feature:add splent_feature_media

Configuration

Declared in [tool.splent.config], with their types in [tool.splent.config_schema]. The runtime ones are also fields of the settings panel (register_settings("media", "Media", ...)), stored as media_<field> (media_public_gallery for MEDIA_PUBLIC_GALLERY), and the panel wins; param('media', 'MEDIA_PUBLIC_GALLERY') reads whichever is in force.

Key Type Bind Default What it does
MEDIA_PUBLIC_GALLERY bool runtime true The gallery page at /media, browsable by anyone. Off answers 404, so visitors cannot enumerate the library
MEDIA_NAV_LABEL text derivation empty The main-nav label of the gallery. Empty keeps it out of the nav. Not in the panel: the nav entry is registered at start, so a panel value would change nothing until a restart
MEDIA_HOME_COUNT int, at least 0 runtime 0 The latest public photos the home page shows, in its home.section slot (order 40). Zero hides the section
MEDIA_GALLERY_VIEW enum: grid, mosaic runtime grid How the gallery opens. A visitor may switch, and the browser remembers it
MEDIA_GALLERY_PAGE_SIZE int, at least 1 runtime 48 Photos loaded at once as the visitor scrolls
MEDIA_SLIDESHOW_SECONDS int, at least 1 runtime 4 Seconds per photo in the slideshow
MEDIA_UPLOAD_IN_GALLERY bool runtime true Whether the upload form ticks "show in the public gallery"
MEDIA_MAX_UPLOAD_SIZE size deploy 100M The largest file the library takes, as 100M, 1G or a number of bytes. 0 means no limit
PROTECTED_UPLOADS_DIR str deploy empty Where files that are not public live. Empty is the framework's default; in production, the mount target of a named volume
PROTECTED_FILES_ACCEL_PREFIX str, /.+ deploy empty The internal nginx prefix a protected file is handed over with (X-Accel-Redirect). Empty streams it through Python, which is right without a proxy in front

A library takes files bigger than a form (slides, recordings, scanned course material), so media raises the framework's request cap, MAX_CONTENT_LENGTH, to MEDIA_MAX_UPLOAD_SIZE, and never lowers it. It does so in init_feature, from the resolved app.config, not in inject_config from the environment: the product's value beats a docker/.env merged before the product changed it, and a cap raised from the environment could let through files far bigger than the limit the product set.

The gallery opens its photos in the theme's lightbox, and appends the next page as a slideshow reaches the end (splent:lightbox:end). A product without media can still show a few static images on its home with the theme's SITE_GALLERY.

Frontend

The library's image editor, on an image's detail page (media/admin_detail.html), is Cropper.js: crop, rotate and reset over the preview, and the crop saved as a new media item. Its script is assets/js/cropper.js, which imports Cropper.js and its stylesheet; cropperjs 1.6.2 is an npm dependency in frontend/package.json, locked in frontend/package-lock.json, and nothing of it is vendored. The SPLENT toolchain builds the entry cropper into assets/dist/cropper.bundle.js and assets/dist/cropper.css, which the page loads, and only that page: Cropper's .cropper-* classes are global. The message the editor shows when a crop cannot be saved reaches the script in a data-* attribute, in the page's language. The markup uses the shell's Bootstrap CSS, declared in splent.shell, so product:validate checks the product provides it.

The public gallery's own script and stylesheet (assets/js/gallery.js, assets/css/gallery.css) and the picker's (assets/css/picker.css) are the feature's own code, without a build, served as they are and registered with register_asset.

splent feature:compile media            # build it once, in development mode
splent feature:compile media --watch    # again on every change
splent feature:compile media --verify   # the files match assets/meta/manifest.json
splent feature:npm media outdated       # a newer Cropper.js?

Develop

splent feature:test splent_feature_media
splent feature:contract splent_feature_media

Release

splent feature:release splent_feature_media --dry-run --bump minor
splent feature:release splent_feature_media

The first command rehearses the release, its frontend gates included (the production build, the licences of what the bundle ships and npm audit), and changes nothing. The second publishes it to the git forge and to PyPI, and a PyPI version is permanent.

Metadata

Release files for splent-feature-media 0.12.0

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

Source distribution (sdist)

Source distribution for splent-feature-media 0.12.0
File Size Uploaded Provenance Actions
splent_feature_media-0.12.0.tar.gz 67.7 kB Without provenance Details for splent_feature_media-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for splent-feature-media 0.12.0
File Interpreter ABI Platform Actions
splent_feature_media-0.12.0-py3-none-any.whl Python 3 none any Details for splent_feature_media-0.12.0-py3-none-any.whl

Total release size: 149.3 kB

Release files / splent_feature_media-0.12.0.tar.gz

Download URL splent_feature_media-0.12.0.tar.gz
Size 67.7 kB
Tags Source
SHA-256 checksum
How to use checksums
989be8ac138ae12e9f2cdd085d5092fec457b9a21c37632e34dca34491dc6ed8
BLAKE2b-256 checksum
How to use checksums
a8c1c0e774ee826c483a2a29350989a014e6ad696c781fba6edd07100f4a58cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.16

Release files / splent_feature_media-0.12.0-py3-none-any.whl

Download URL splent_feature_media-0.12.0-py3-none-any.whl
Size 81.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e68b8833f210a36ae4355634bc3b2042fcf0136eb281f1dfc54d9d3a49723f7
BLAKE2b-256 checksum
How to use checksums
4c61bb6c045fe347bf23ea5a20369c30f48f6f198499fa8a9252b79f59bf1e5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.16

Security for splent-feature-media 0.12.0

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