[twdev] Re: ANN: widget tutorial

2019-02-17 Thread TonyM
Brian,

In this thread 
, Bimlas 
may get to follow up on a solution to use IntenceDebate as a comment 
plugin. I thought I would mention it because it may be one of the simpler 
examples of integrating because its primary model is inclusion of 
javascript but no libraries. It may be a good example for others to follow 
your instructions and integrate other solutions out there of this simpler 
nature.

Regards
Tony


On Monday, 4 February 2019 00:14:15 UTC+11, Brian Theado wrote:
>
> I have a work in progress tutorial for writing TW widgets at 
> https://btheado.github.io/tw-widget-tutorial/. It starts with the 
> simplest widget I could think of and builds from there. I will be adding 
> more over the coming days and weeks.
>
> It uses the innerwiki plugin to provide an interactive playground for the 
> javascript code. In fact I developed it all using a single file tiddlywiki. 
> The immediate feedback provided by the innerwiki widget was most helpful.
>
> Any feedback appreciated, especially if I've misrepresented anything.
>
> Brian
>

-- 
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 tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/5b158be3-9be7-4869-85c1-e501be0c2a3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [twdev] Re: ANN: widget tutorial

2019-02-17 Thread stefano franchi
On Sun, Feb 17, 2019 at 1:25 PM Brian Theado  wrote:

>
>
> On Sun, Feb 17, 2019 at 10:25 AM stefano franchi <
> stefano.fran...@gmail.com> wrote:
> [...]
>
>> In particular, there is an issue I have not been able to solve yet, and I
>> hope you may help---where do I look to find examples of a callback function
>> that would allow the calling code to tell the external library  to save its
>> data?
>>
>
> This is backwards from the way I've implemented it and seen it implemented
> in other widgets. I think the expectation is that the external library
> provides a way to register a callback will will be called by the library
> every time anything changes. The widget can register a callback in which
> the code will ask the library to serialize its data. The resulting data is
> saved to some tiddler field in order to persist. In this way, the data is
> always in sync with the tiddler field. The widget does not get notified it
> is about to be destroyed (that I know of), so having the data always in
> sync is required.
>
> I think in a previous exchange you suggested to take a look at the
>> Codemirror plugin, but I could not find where the mechanism is implemented.
>> I guess it is because I am not really sure what I am looking for.
>>
>
>
> This is the code I had in mind
> https://github.com/Jermolene/TiddlyWiki5/blob/master/plugins/tiddlywiki/codemirror/engine.js#L121
>
> // Set up a change event handler
> this.cm.on("change",function() {
> self.widget.saveChanges(self.getText());
> });
>
> [...]
>
> /*
> Get the text of the engine
> */
> CodeMirrorEngine.prototype.getText = function() {
> return this.cm.getValue();
> };
>
>
> Here's an example I wrote, but it is much more complicated WRT the
> persisting of data:
> https://github.com/btheado/tweve/blob/master/src/plugins/btheado/tweve/files/eve-widget.js#L61
>
> Here's another one I wrote, but not well commented and probably not a good
> example to follow:
> https://github.com/btheado/jsoneditor/blob/master/jsoneditor-widget.js#L60
>
>
Hi Brian,

thanks for the pointers---all very useful. I had indeed missed that bit of
the codemirror code, which makes perfect sense now that I see it.


>
>> Your tutorial on the refresh mechanism does a great job of explaining how
>> a widget manages to keep itself in sync with the underlying tiddler. It is
>> the reverse procedure that is still baffling to me. In particular, is
>> complete sync the only option---sending back a call from the widget back to
>> the tiddler after every single update? That may not be feasible in case the
>> external library works on on  its own internal representation of the
>> underlying tiddler data and it may be expensive to convert back and forth
>> (as it is in my case). I am thinking a simpler "updateTiddlerOnExit" method
>> to call before the widget is destroyed would be more appropriate, but I
>> haven't found out how to manage this kind of tiddler-->widget communication.
>>
>
> See this related discussion, I don't think TW currently supports what you
> are after: https://github.com/Jermolene/TiddlyWiki5/issues/1784
>
>
I see, thanks for saving me hours of digging! That's exactly what I was
after. Too bad it's not supported yet.

So in your case you are saying the conversion back and forth is too
> expensive to always keep in sync? Have you already tried it and found it to
> be too slow?
>

I did and it is borderline. I will keep looking for solutions. But thanks a
lot for the help!

Cheers,

S.

-- 
__
Stefano Franchi

stefano.fran...@gmail.com 
http://stefano.cleinias.org

-- 
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 tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/CAJODLwYKocDJKN2cqmPzHkOcCGiQzU6CSO_X0Dm8fmq7%3DPDdaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [twdev] Re: ANN: widget tutorial

2019-02-17 Thread Brian Theado
On Sun, Feb 17, 2019 at 10:25 AM stefano franchi 
wrote:
[...]

> In particular, there is an issue I have not been able to solve yet, and I
> hope you may help---where do I look to find examples of a callback function
> that would allow the calling code to tell the external library  to save its
> data?
>

This is backwards from the way I've implemented it and seen it implemented
in other widgets. I think the expectation is that the external library
provides a way to register a callback will will be called by the library
every time anything changes. The widget can register a callback in which
the code will ask the library to serialize its data. The resulting data is
saved to some tiddler field in order to persist. In this way, the data is
always in sync with the tiddler field. The widget does not get notified it
is about to be destroyed (that I know of), so having the data always in
sync is required.

I think in a previous exchange you suggested to take a look at the
> Codemirror plugin, but I could not find where the mechanism is implemented.
> I guess it is because I am not really sure what I am looking for.
>


This is the code I had in mind
https://github.com/Jermolene/TiddlyWiki5/blob/master/plugins/tiddlywiki/codemirror/engine.js#L121

// Set up a change event handler
this.cm.on("change",function() {
self.widget.saveChanges(self.getText());
});

[...]

/*
Get the text of the engine
*/
CodeMirrorEngine.prototype.getText = function() {
return this.cm.getValue();
};


Here's an example I wrote, but it is much more complicated WRT the
persisting of data:
https://github.com/btheado/tweve/blob/master/src/plugins/btheado/tweve/files/eve-widget.js#L61

Here's another one I wrote, but not well commented and probably not a good
example to follow:
https://github.com/btheado/jsoneditor/blob/master/jsoneditor-widget.js#L60



> Your tutorial on the refresh mechanism does a great job of explaining how
> a widget manages to keep itself in sync with the underlying tiddler. It is
> the reverse procedure that is still baffling to me. In particular, is
> complete sync the only option---sending back a call from the widget back to
> the tiddler after every single update? That may not be feasible in case the
> external library works on on  its own internal representation of the
> underlying tiddler data and it may be expensive to convert back and forth
> (as it is in my case). I am thinking a simpler "updateTiddlerOnExit" method
> to call before the widget is destroyed would be more appropriate, but I
> haven't found out how to manage this kind of tiddler-->widget communication.
>

See this related discussion, I don't think TW currently supports what you
are after: https://github.com/Jermolene/TiddlyWiki5/issues/1784

So in your case you are saying the conversion back and forth is too
expensive to always keep in sync? Have you already tried it and found it to
be too slow?

Brian

-- 
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 tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/CAO5X8CyZ2%3DnOgYfd-EKxiGUpmUa3LssRj5N%3Dy7r1tnbpTkrkYg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[twdev] Re: Problem with TW5.1.19 and Tinka plugin

2019-02-17 Thread Ton Gerner
Hi Mohammad,

I read it.

Cheers,

Ton

-- 
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 tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/77a9d3e9-32d2-46e0-9bae-1ada175a35c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[twdev] Re: Problem with TW5.1.19 and Tinka plugin

2019-02-17 Thread Mohammad Rahmani
Hi Ton,

Referring to Andreas Hahn the author of Tinka at


https://groups.google.com/d/msg/tiddlywiki/Wcz36PF2a6M/R7NIHrMVBAAJ

The Tinka plugin works with TW5.1.20pre and the issue is from TW5.1.19 side.

Best
Mohammad




On Friday, January 4, 2019 at 12:18:50 AM UTC+3:30, Ton Gerner wrote:
>
> Hi all,
>
> I tried to make a plugin with TW5.1.19 and the Tinka plugin, but got a red 
> Javascript error with the text: "TypeError: tiddler is undefined".
>
> When I do the same with TW5.1.17, the plugin is made without error.
>
> When I import the plugin made in TW5.1.17 in a TW5.1.19 and repack the 
> plugin I get the same error: "TypeError: tiddler is undefined".
>
> Up to now I never had problems with making plugins using Tinka.
>
> Has anybody else seen this behaviour?
>
> Cheers,
>
> Ton
>
>

-- 
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 tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/5140aec5-7115-4d18-a732-5617424c8507%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [twdev] Re: ANN: widget tutorial

2019-02-17 Thread stefano franchi
On Sun, Feb 17, 2019 at 8:22 AM Brian Theado  wrote:

> I have been making slow progress with this.
>
> I wrote additional sections:
>
> Widget attributes tutorial part II
> 3rd party library tutorial part I
> 3rd party library tutorial part II
>
> I also improved some of the examples of the previous sections.
>
> I still haven't written about child widgets. I also haven't covered the
> difficult topic of how to get the 3rd party library code suitable for
> loading into Tiddlywiki. I plan to add a few examples from my experience,
> but it won't be comprehensive as it is a large topic.
>
> See the update at https://btheado.github.io/tw-widget-tutorial/
>
> Stefano,
>
> > great work and greatly needed. Can't wait to read the 3rd party library
> tutorial!
>
> I would guess based on your other threads that you are already past the
> point where the 3rd party library tutorials would help you. Also based on
> those threads, I doubt what I've written so far would have helped you much.
> One difficulty you faced was how to get 3rd party code suitable for loading
> and I haven't written anything on that yet. Another difficulty was related
> to arranging files on the file system such that node.js would pick them up
> as plugins. This topic I don't plan to cover at all as I see that topic
> being orthogonal to writing widget code.
>
>

Hi Brian,

thanks for the tutorials, I have already learned a few things from them I
didn't know before. You are right that I am almost done with my external
library widget plugin, and I am working on a write-up of the process that
led me there, but that does not make less of a newbie to this fascinating
TW world.

In particular, there is an issue I have not been able to solve yet, and I
hope you may help---where do I look to find examples of a callback function
that would allow the calling code to tell the external library  to save its
data?
I think in a previous exchange you suggested to take a look at the
Codemirror plugin, but I could not find where the mechanism is implemented.
I guess it is because I am not really sure what I am looking for. Your
tutorial on the refresh mechanism does a great job of explaining how a
widget manages to keep itself in sync with the underlying tiddler. It is
the reverse procedure that is still baffling to me. In particular, is
complete sync the only option---sending back a call from the widget back to
the tiddler after every single update? That may not be feasible in case the
external library works on on  its own internal representation of the
underlying tiddler data and it may be expensive to convert back and forth
(as it is in my case). I am thinking a simpler "updateTiddlerOnExit" method
to call before the widget is destroyed would be more appropriate, but I
haven't found out how to manage this kind of tiddler-->widget communication.


Cheers,

Stefano



>
>
-- 
__
Stefano Franchi

stefano.fran...@gmail.com 
http://stefano.cleinias.org

-- 
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 tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/CAJODLwYdoH0_K%3Dwn7DfxDRN%2ByrnvPxMsW2bnJppTxyocaab-iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [twdev] Re: ANN: widget tutorial

2019-02-17 Thread Brian Theado
I have been making slow progress with this.

I wrote additional sections:

Widget attributes tutorial part II
3rd party library tutorial part I
3rd party library tutorial part II

I also improved some of the examples of the previous sections.

I still haven't written about child widgets. I also haven't covered the
difficult topic of how to get the 3rd party library code suitable for
loading into Tiddlywiki. I plan to add a few examples from my experience,
but it won't be comprehensive as it is a large topic.

See the update at https://btheado.github.io/tw-widget-tutorial/

Stefano,

> great work and greatly needed. Can't wait to read the 3rd party library
tutorial!

I would guess based on your other threads that you are already past the
point where the 3rd party library tutorials would help you. Also based on
those threads, I doubt what I've written so far would have helped you much.
One difficulty you faced was how to get 3rd party code suitable for loading
and I haven't written anything on that yet. Another difficulty was related
to arranging files on the file system such that node.js would pick them up
as plugins. This topic I don't plan to cover at all as I see that topic
being orthogonal to writing widget code.

Brian

On Sun, Feb 3, 2019 at 11:14 PM stefano franchi 
wrote:

> Brian,
>
> great work and greatly needed. Can't wait to read the 3rd party library
> tutorial!
>
> Cheers,
> Stefano
>
> On Sun, Feb 3, 2019 at 9:35 PM Brian Theado 
> wrote:
>
>> Tony and Mohammad, thanks for the feedback.
>>
>> I just added "Widget attributes tutorial part I".
>>
>> So now these sections are written:
>>
>> Undefined widget tutorial
>> Do nothing widget tutorial
>> Hello World widget tutorial
>> Widget refresh tutorial part I
>> Widget refresh tutorial part II
>> Widget refresh tutorial part III
>> Widget attributes tutorial part I
>>
>>
>> With these still left to write:
>>
>> Widget attributes tutorial part II
>> 3rd party library tutorial part I
>> 3rd party library tutorial part II
>> Child widgets tutorial
>>
>>
>> Brian
>>
>> On Sun, Feb 3, 2019 at 8:14 AM Brian Theado 
>> wrote:
>>
>>> I have a work in progress tutorial for writing TW widgets at
>>> https://btheado.github.io/tw-widget-tutorial/. It starts with the
>>> simplest widget I could think of and builds from there. I will be adding
>>> more over the coming days and weeks.
>>>
>>> It uses the innerwiki plugin to provide an interactive playground for
>>> the javascript code. In fact I developed it all using a single file
>>> tiddlywiki. The immediate feedback provided by the innerwiki widget was
>>> most helpful.
>>>
>>> Any feedback appreciated, especially if I've misrepresented anything.
>>>
>>> Brian
>>>
>> --
>> 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 tiddlywikidev+unsubscr...@googlegroups.com.
>> To post to this group, send email to tiddlywikidev@googlegroups.com.
>> Visit this group at https://groups.google.com/group/tiddlywikidev.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/tiddlywikidev/CAO5X8CzUa3%3D50x2fFUW-EvMPzmUsDsrPW98ESLigEFp8zT8YmA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> __
> Stefano Franchi
>
> stefano.fran...@gmail.com 
> http://stefano.cleinias.org
>
> --
> 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 tiddlywikidev+unsubscr...@googlegroups.com.
> To post to this group, send email to tiddlywikidev@googlegroups.com.
> Visit this group at https://groups.google.com/group/tiddlywikidev.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywikidev/CAJODLwZ3RqwhEvEZc%2BMx%3DPpKP6h19Z%3D_Ve%3D6-2pY4zsF4RmrfA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/CAO5X8CzXoYyY8jdSFKkxQMo%3DOTm-CnCtp9Se3ix6a%3DC%3DUSu-gA%40mail.gmail.com.
For more options, visit