Need help with custom export button

I have a JavaScript macro, GenChartFamilyTreeData, that generates a chart/report in HTML based on a few parameters. I want a tiddler that will contain a button to trigger this macro to generate the HTML content, providing an export/download for the user of the resulting HTML file.

Currently, I have a button that copies the HTML content to the clipboard, where I wikify the output of the content from GenChartFamilyTreeData macro for use in the button… something like this:

\define copyfamilytreebutton(proband, folderdepth, direction, theme)
<$wikify name=charting text=<<GenChartFamilyTreeData """$proband$""">> type="text" output=text >
<$button message="tm-copy-to-clipboard" param=<<charting>>>{{$:/core/images/copy-clipboard}} Copy HTML for family chart of $proband$ to clipboard</$button></$wikify>
\end

There are two disadvantages to the current mechanism. 1. Extra work for the user to save the HTML file, and 2. When the tiddler is open or other tiddlers change GenChartFamilyTree runs, which takes a couple of seconds. I only want it to run when the user clicks the button.

So, I want to change my copy to clipboard button to an export button.

Thanks for any help,

Craig

Craig, I don’t have the time for the full answer however two tips;

  • Follow how the existing export tools in tiddlywiki work, see also custom exports
  • The export method basically initiates a download of content appropriately formatted, the format is the output of a “template” tiddler designed to produce the desired output.
    • This somehow sounds different to what you described above.
1 Like

@TW_Tones Thank you. I was attempting to go off in some wild direction with this. Your first point, I suspect, is key. I have been working on a custom GEDCOM file export, where I have a mockup working. I never thought to follow that because of my current implementation approach.

So I created this tiddler to define the export…

Then I was able to export an html chart this way…

Creating this…

Thanks for push in the right direction.

Craig