Skip to content

Documented HTML hooks for JavaScript plugin authors #987

Open

Description

@simonw

In #981 I added data-column= attributes to the <th> on the table page. These should become part of Datasette's documented API so JavaScript plugin authors can use them to derive things about the tables shown on a page (`datasette-cluster-map uses them as-of simonw/datasette-cluster-map#18).

Activity

  1. simonw commented on Oct 1, 2020

    @simonw
    OwnerAuthor

    <th class="col-{{ column.name|to_css_class }}" scope="col" data-column="{{ column.name }}" data-is-pk="{% if column.is_pk %}1{% else %}0{% endif %}">

  2. simonw commented on Oct 1, 2020

    @simonw
    OwnerAuthor

    This should be a new page in the documentation, which will be expanded later on to cover things like the proposed JavaScript plugin hooks system from #983.

  3. added this to the Datasette 0.52 milestone on Nov 1, 2020
  4. simonw commented on Dec 30, 2020

    @simonw
    OwnerAuthor

    More generally, I need to document certain areas of the page that JavaScript plugins are invited to append their content to - such that plugin authors can use them and feel confident that future changes to the Datasette templates won't break their plugins.

  5. simonw commented on Dec 30, 2020

    @simonw
    OwnerAuthor

    Related problem: right now if you're writing custom template it's not at all obvious how to write them such that visualization plugins like datasette-cluster-map will continue to work.

  6. changed the title [-]Documentation on hooks for JavaScript plugin authors[/-] [+]Documented HTML hooks for JavaScript plugin authors[/+] on Dec 30, 2020
  7. simonw commented on Dec 30, 2020

    @simonw
    OwnerAuthor

    In terms of "places to put your plugin content", the simplest solution I can think of is something like this:

    <div id="plugin-content-pre-table"></div>

    Alternative designs:

    • A documented JavaScript function that returns the CSS selector where plugins should put their content
    • A documented JavaScript function that returns a DOM node where plugins should put their content. This would allow the JavaScript to create the element if it does not already exist (though it wouldn't be obvious WHERE that element should be created)
    • Documented JavaScript functions for things like "append this node/HTML to the place-where-plugins-go"

    I think the original option - an empty <div> with a known id attribute - is the right one to go with here. It's the simplest, it's very easy for custom template authors to understand and it acknowledges that plugins may have all kinds of extra crazy stuff they want to do - like checking in that div to see if another plugin has written to it already, for example.

  8. simonw commented on Dec 31, 2020

    @simonw
    OwnerAuthor

    I'm going to use class="plugin-content-pre-table" rather than id= - just because I still want to be able to display all of this stuff on the single https://latest.datasette.io/-/patterns page so duplicate IDs are best avoided.

  9. simonw commented on Jan 25, 2021

    @simonw
    OwnerAuthor

    This is joined with #1191 now, which I've bumped from 0.54.

  10. removed this from the Datasette 0.54 milestone on Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions