New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview plugin #1632

Merged
merged 6 commits into from Apr 30, 2018

Conversation

Projects
None yet
2 participants
@noirbizarre
Member

noirbizarre commented Apr 30, 2018

This PR makes Resource.preview_url a property relying udata.preview entrypoint plugins.

For security considerations, the preview_url is not user writable and rely on udata.preview plugins providing (or not) a preview URL.

Preview plugins should inherit from udata.core.dataset.preview:PreviewPlugin and implement both can_preview(resource) and preview_url(resource) methods.

To resolve cases where multiple plugins match, we introduced 2 levels of preview plugins. When the default attribute is set to True on a PreviewPlugin, this plugin will match only if none of the non-default plugin matched.
In case of multiple non default match or multiple default match, the preview_url will be any of the candidates.

@noirbizarre noirbizarre added this to the 1.4.0 milestone Apr 30, 2018

@noirbizarre noirbizarre self-assigned this Apr 30, 2018

@noirbizarre noirbizarre requested a review from opendatateam/etalab Apr 30, 2018

Show outdated Hide outdated docs/extending.md Outdated
Show outdated Hide outdated docs/extending.md Outdated
Show outdated Hide outdated docs/extending.md Outdated
Show outdated Hide outdated docs/extending.md Outdated
Show outdated Hide outdated docs/extending.md Outdated
Show outdated Hide outdated udata/core/dataset/preview.py Outdated
Show outdated Hide outdated udata/core/dataset/preview.py Outdated
candidates = (p.preview_url(resource)
for p in get_enabled_plugins()
if p.can_preview(resource))
return next(iter(candidates), None)

This comment has been minimized.

@abulte

abulte Apr 30, 2018

Member

👌

@abulte

abulte Apr 30, 2018

Member

👌

@abulte

abulte approved these changes Apr 30, 2018

Show outdated Hide outdated udata/core/dataset/preview.py Outdated

@noirbizarre noirbizarre merged commit 42b72f4 into opendatateam:master Apr 30, 2018

3 checks passed

ci/circleci: assets Your tests passed on CircleCI!
Details
ci/circleci: dist Your tests passed on CircleCI!
Details
ci/circleci: python Your tests passed on CircleCI!
Details

@noirbizarre noirbizarre deleted the noirbizarre:preview-plugin branch Apr 30, 2018

@noirbizarre noirbizarre referenced this pull request Apr 30, 2018

Merged

Preview plugin #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment