@Flan: think of plugin as an umbrella term for tiddlers that add functionality to TiddlyWiki. A plugin consists of one or more tiddlers. A javascript tiddler with module-type widget
can define a widget. A plugin can contain one or several such widgets. In this case, one of your plugin tiddlers would be a tiddler that has the javascript code for your widget. For example: If the plugin is $:/plugins/flan/bookinfo, it may contain several tiddlers including for example $:/plugins/flan/bookinfo/widgets/getbookinfo which has the code for your widget. A tiddler defining a widget needs the field *type* with value *application/javascript*, and the field *module-type* with value *widget* On Wednesday, May 20, 2020 at 4:34:41 PM UTC+2, Flan Mou wrote: > > Hi Saq, > > This is very useful, thanks. I'm now a bit confused: it sounds like I want > to create a widget and not a plugin? What's the difference? > > Is there any documentation available along the lines "How to create your > first widget"? > > If not: > - I'm looking at action-createtiddler.js as a reference example. > - If I create an action-getbookinfo as you suggest, where/how do I install > this so that Tiddlers can access the widget? > - Do I put it core/modules/widgets? > - Will it be available for use automatically or do I have to do something > else? > > Thanks for all your help. I'm trying to use the online documentation but > it's not very friendly to someone new to TW. > > On Wednesday, May 20, 2020 at 1:28:33 AM UTC-7, Saq Imtiaz wrote: >> >> Plugin javascript tiddlers need the correct module-type to determine how >> they are made available/run. >> https://tiddlywiki.com/#ModuleType >> >> Here is what I recommend to get you started: >> >> To get the user input of what ISBN to look up, use an edit-text widget >> with a temporary tiddler like $:/myplugin/isbn-search >> https://tiddlywiki.com/#EditTextWidget >> >> Since you want to execute an action on userinput, that is look up the >> isbn, use a button widget to trigger a custom action widget. >> >> You can model your action widget on >> >> https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/widgets/action-setfield.js >> >> For starters, accept a single parameter, the isbn, make the http request >> and in the callback, parse the response and create a tiddler. >> >> For an action widget called action-getbookinfo, it would be invoked like >> this inside the button widget: >> <$action-getbookinfo $isbn={{$:/myplugin/isbn-search}} /> >> >> On Tuesday, May 19, 2020 at 4:57:32 PM UTC+2, Flan Mou wrote: >>> >>> Update: I followed the instructions here: >>> >>> >>> https://tiddlywiki.com/dev/static/How%2520to%2520create%2520plugins%2520in%2520the%2520browser.html >>> >>> And created a plugin which simply contains: >>> >>> (function () { alert("Test alert"); }) >>> >>> Everything got packed and saved, and the plugin appears installed. But >>> when I reload the alert box doesn't appear. I would have expected the code >>> inside an installed plugin to run upon startup. How can I get TW to execute >>> my plugin code? >>> >>> On Tuesday, May 19, 2020 at 7:20:38 AM UTC-7, Flan Mou wrote: >>> >>>> Yes, for example there is the OpenLibrary API: >>>> >>>> https://openlibrary.org/developers/api >>>> >>>> I'm fine with interacting with the API, it's just that I'm not sure how >>>> to build even a very simple request within TW. I was expecting to be able >>>> to create an HTML tiddler, add a <script> tag, and write some Javascript >>>> with XMLHttpRequest() within it. But it seems that's not possible. For >>>> example I created an HTML Tiddler with: >>>> >>>> <script> >>>> alert("Testing"); >>>> </script> >>>> >>>> And that didn't work. >>>> >>>> I guess my question is: is there a way to get TW to execute arbitrary >>>> Javascript within a tiddler? If not, how do I make that happen? Apologies >>>> if this is available in the documentation somewhere but I couldn't find it. >>>> >>>> >>>> On Monday, May 18, 2020 at 11:59:49 PM UTC-7, PMario wrote: >>>>> >>>>> Hi, >>>>> Is there a public service, where you can GET the info? Without an API >>>>> description, it's hard to do. >>>>> -mario >>>>> >>>>> On Tuesday, May 19, 2020 at 6:14:29 AM UTC+2, Flan Mou wrote: >>>>>> >>>>>> Goal: to create a plugin(?) where: you type in an ISBN and it does a >>>>>> few HTTP GETs to get book information and populates a new tiddler with >>>>>> that >>>>>> info. >>>>>> >>>>>> I'm pretty new to TiddlyWiki and I've been trying to make my way >>>>>> through tiddlywiki.com/dev looking for examples I can base things >>>>>> off. I haven't seen anything relevant. >>>>>> >>>>>> I'd be happy for any points in useful directions. >>>>>> >>>>>> Thanks. >>>>>> >>>>> -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/0be57034-f3f2-4954-bf19-aad9ff7c79e7%40googlegroups.com.
