feat: allow handlers to claim individual files via canHandle matcher - #1
Open
R0Wi wants to merge 2 commits into
Open
feat: allow handlers to claim individual files via canHandle matcher#1R0Wi wants to merge 2 commits into
R0Wi wants to merge 2 commits into
Conversation
Handlers can now provide an optional canHandle(fileInfo) callback. Such handlers do not own their mime types exclusively: they claim individual files at opening time, taking precedence over the handler the mime type is registered to. This allows apps to provide a specialised view for a subset of files sharing a generic mime type, e.g. 360° photospheres within image/jpeg (nextcloud/files_photospheres#27). Per-file matching is applied when opening a file as well as when navigating through a slideshow (previous/next/compare), so the viewer switches components per file. Custom WebDAV properties registered via registerDavProperty are available on the file info passed to the matcher (camelCased). Also exposes the new handler property through the @nextcloud/viewer api package (bumped to 1.1.0) including documentation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ARx3GZy5CQBsWUCPEp7mrL
Moves the photosphere functionality of the files_photospheres app (nextcloud/files_photospheres#27) directly into the viewer, so that 360° media works out of the box. Recognition: a Sabre plugin scans the first bytes of jpeg files for Google Photo Sphere XMP metadata (GPano, incl. VR180) and serves the result — cached via ICacheFactory — as the WebDAV property {http://nextcloud.org/ns}viewer-photosphere-metadata, which is requested with every files PROPFIND via registerDavProperty. The built-in 'photospheres' handler claims exactly those image/jpeg files whose metadata marks them as photospheres through the per-file canHandle() matcher, so regular images keep using the image handler and slideshow navigation switches seamlessly between flat images and panoramas. Cropping/pose data (panoData) is honored. Rendering is based on photo-sphere-viewer (lazy-loaded chunk) with gyroscope, stereo and autorotate support. 360° videos have no detectable server-side metadata, so they are opened explicitly through a new "View in 360°" file action using an equirectangular video adapter. The feature is optional: administrators can disable it under Settings -> Administration -> Additional settings (app config value photospheres_enabled, enabled by default). When disabled, the Sabre plugin, the DAV property registration, the handlers and the file action are all inactive. Includes a cypress e2e test with a real photosphere fixture, psalm stubs for the sabre/OCA\DAV classes, and the PHP metadata reader was verified against the complete files_photospheres test corpus. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ARx3GZy5CQBsWUCPEp7mrL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handlers can now provide an optional canHandle(fileInfo) callback. Such
handlers do not own their mime types exclusively: they claim individual
files at opening time, taking precedence over the handler the mime type
is registered to. This allows apps to provide a specialised view for a
subset of files sharing a generic mime type, e.g. 360° photospheres
within image/jpeg (nextcloud/files_photospheres#27).
Per-file matching is applied when opening a file as well as when
navigating through a slideshow (previous/next/compare), so the viewer
switches components per file. Custom WebDAV properties registered via
registerDavProperty are available on the file info passed to the
matcher (camelCased).
Also exposes the new handler property through the @nextcloud/viewer api
package (bumped to 1.1.0) including documentation.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01ARx3GZy5CQBsWUCPEp7mrL