Skip to content
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

Pass columns to extra CSS/JS/etc plugin hooks #938

Closed
simonw opened this issue Aug 16, 2020 · 3 comments
Closed

Pass columns to extra CSS/JS/etc plugin hooks #938

simonw opened this issue Aug 16, 2020 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Aug 16, 2020

I'd like datasette-cluster-map to only add links to JavaScript on pages that have tables with latitude and longitude columns.

Passing the names of the columns to the plugin hook can support this and will be backwards compatible thanks to pluggy.

@simonw
Copy link
Owner Author

simonw commented Aug 16, 2020

Four plugin hooks need this extra columns argument:

  • extra_css_urls(template, database, table, datasette)
  • extra_js_urls(template, database, table, datasette)
  • extra_body_script(template, database, table, view_name, datasette)
  • extra_template_vars(template, database, table, view_name, request, datasette)

It's weird that these take different arguments. I should fix that too.

@simonw
Copy link
Owner Author

simonw commented Aug 16, 2020

extra_tenplate_vars should he documented first and should be the only one to document the arguments and the async return feature. Others should refer back to it rather than duplicating that.

@simonw simonw closed this as completed in 3a4c8ed Aug 16, 2020
simonw added a commit that referenced this issue Aug 16, 2020
simonw added a commit to simonw/datasette-cluster-map that referenced this issue Aug 16, 2020
simonw added a commit to simonw/datasette-cluster-map that referenced this issue Aug 16, 2020
* Only include JavaScript on pages with latitude/longitude columns
* Depend on Datasette >= 0.48

Refs #15, refs simonw/datasette#938
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant