You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documented HTML hooks for JavaScript plugin authors #987
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).
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.
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.
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.
In terms of "places to put your plugin content", the simplest solution I can think of is something like this:
<divid="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.
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.
Activity
simonw commentedon Oct 1, 2020
datasette/datasette/templates/_table.html
Line 6 in 1415446
simonw commentedon Oct 1, 2020
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.
simonw commentedon Dec 30, 2020
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.
simonw commentedon Dec 30, 2020
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-mapwill continue to work.[-]Documentation on hooks for JavaScript plugin authors[/-][+]Documented HTML hooks for JavaScript plugin authors[/+]simonw commentedon Dec 30, 2020
In terms of "places to put your plugin content", the simplest solution I can think of is something like this:
Alternative designs:
I think the original option - an empty
<div>with a knownidattribute - 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.simonw commentedon Dec 31, 2020
I'm going to use
class="plugin-content-pre-table"rather thanid=- 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.simonw commentedon Jan 25, 2021
This is joined with #1191 now, which I've bumped from 0.54.