Looking for reading material: using javascript libraries in TiddlyWiki

303 views
Skip to first unread message

Charlie Veniot

unread,
Apr 30, 2021, 1:34:06 PM4/30/21
to TiddlyWiki
G'day all,

I'm not having much luck searching the web, and I'm hoping somebody can put me on some kind of "for white belts" reading material.

Say one finds a small javascript library one wants to use with TiddlyWiki, what are the options and the processes involved?

Does one include the libary (if so where?) in TiddlyWiki, then access the libary functions via javascript macros ?

Total newb here with the whole concept, and not particularly knowledgeable about javascript, so please be gentle !

Thanks !

Jeremy Ruston

unread,
May 1, 2021, 5:27:33 AM5/1/21
to tiddl...@googlegroups.com
It depends what the JS library does.

If the library does pure text manipulation (eg an anagram engine), then it should be fairly easy to wrap it up into a JavaScript macro. There are some examples here:


If the library converts markup to HTML, then it can be wrapped to be a parser - see the Markdown parser or the KaTeX parser for an example:


Things get much trickier if the library manipulates the DOM. One fundamental problem is that many libraries are written on the assumption that they will be used on a static page, and don’t automatically cater for dynamic content. In many cases, such libraries are old jQuery libraries that do things that can now be done with plain HTML or wikitext.

The simplest case is a library that produces output in a single DOM node. These can generally be turned into a widget. For example, the CodeMirror widget:


That is not an exhaustive list, what kind of library are you looking at?

Best wishes

Jeremy

Charlie Veniot

unread,
May 1, 2021, 9:13:47 AM5/1/21
to TiddlyWiki
G'day Jeremy, and thank-you !

I have sql.js on the brain, and am not quite sure I really want to even dip a toe into that kind of self-inflicted pain.

Although I was in a soul-searching "should I shouldn't I, could I couldn't I, to be not to be" stretch of waffling over it, I'm pretty sure I've entered an "oh hell no" quick retreat to the safety of a thumb-sucking fetal position.

My loathing of javascript makes it kind of hopeless for this kid.  For all of the great things that can be done with it, as much as I am impressed with capabilities and end products, the language irritates the living daylights out of me.

Silly me: I may have been thinking "throw a wildly interesting project at it, and maybe it will grow on you?"  Not so much.

Thank goodness for the slew of folk with brains wired to work with javascript !

Hans Wobbe

unread,
May 1, 2021, 9:36:52 AM5/1/21
to TiddlyWiki
Happy Saturday, cj.v!

I've read your preceding post several times and I remain unsure which way you are leaning on "sql.jg".

Can you clarify?


Cheers,
Hans

Charlie Veniot

unread,
May 1, 2021, 12:19:59 PM5/1/21
to TiddlyWiki
G'day Hans,

Well, it I wanted basic access from a web page to a Sqlite db file, I'm thinking sql.js would be the way to go.

For really portable (light on infrastructure) TiddlyWiki access to a Sqlite db file via sql.js, I'm thinking that would be the way to go too.  No requirement for node.js or a server of any kind.

I'm finding integration of javascript libraries into TiddlyWiki a non-trivial affair.  Now it could very well be just my deer-in-the-headlights reaction to everything javascript, but I can't help thinking:  if brining sql.js into TiddlyWiki were fairly trivial, surely somebody would have done it by now.

Surely (don't call me Shirley), there are folk out there, with the same star-in-their-eyes admiration of mine for both TiddlyWiki and sql.js , who would have married those two things together a long time ago.

I'd definitely be advertising it, shouting from the mountaintops,  if I had married the two.

So leaning heavily towards great idea, thinking a very messy/costly affair.

Unless somebody knows it would be easy ...

Mark S.

unread,
May 1, 2021, 1:31:35 PM5/1/21
to TiddlyWiki
If I want to learn about javascript or tools made with it, there are reams of documents and tutorials. They are almost all node based.

But if I want to use JS in TW, I'm reduced to maybe two paragraphs of explanatory material. The only documentation I ever found was by (?) Chris Hunt, which pages have now disappeared except on archive. The code examples no longer match existing core.

Trying to clone existing code and hoping that you guess right is like building a ship in a bottle. In the dark.

After 5 years, it would really be great to have a bit of documentation for those of us who understand JS but need some hand-holding for the TW-JS gap.

PMario

unread,
May 1, 2021, 3:16:05 PM5/1/21
to TiddlyWiki
On Saturday, May 1, 2021 at 7:31:35 PM UTC+2 Mark S. wrote:

But if I want to use JS in TW, I'm reduced to maybe two paragraphs of explanatory material. The only documentation I ever found was by (?) Chris Hunt, which pages have now disappeared except on archive. The code examples no longer match existing core.

https://tiddlywiki.com/dev/ is still a very good overview about how TW is built.
 
After 5 years, it would really be great to have a bit of documentation for those of us who understand JS but need some hand-holding for the TW-JS gap.

There are some early TW hangouts, that discuss the internal structure in detail.
Especially No 10 https://www.youtube.com/watch?v=o70TtNIe-L4 which is 2h core design and code only.

have fun!
mario

Brian Theado

unread,
May 1, 2021, 5:15:10 PM5/1/21
to tiddl...@googlegroups.com
https://btheado.github.io/tw-widget-tutorial/ - this is another resource. It is focused specifically on widgets and doesn't cover any of the other integration points mentioned by Jeremy. When I wrote it, I ran out of steam by the time I got to the third-party javascript integration and so there isn't much there to help answer Charlie's original question. But there are a few example libraries integrated there.

For the tutorial, I use the innerwiki widget which makes it into a live playground even for the javascript. You can modify the javascript tiddlers in the outer wiki and see immediate updates in the innerwikis. In fact, I developed the entire tutorial inside the browser. If you learn well by making small modifications to already working code, then it should suit you well.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1bb2059c-4a77-430c-bdb9-e3b052e2b028n%40googlegroups.com.

Anjar

unread,
May 2, 2021, 7:39:53 AM5/2/21
to TiddlyWiki
@cj.v did you see this thread https://groups.google.com/g/tiddlywiki/c/zcgAdcms0zM on php+sqlite? Requires a server though

Best,
Anders

Charlie Veniot

unread,
May 2, 2021, 9:23:08 AM5/2/21
to TiddlyWiki
G'day Anders,

Yup, sure did.  Very cool.

Serverless sql.js would be more my cup of tea, but sqlite solution with server might make for a pretty decent plan B, 

Hans Wobbe

unread,
May 2, 2021, 10:05:35 AM5/2/21
to TiddlyWiki
G'day cj.v:

Do you happen to know if neocities could host such a server?  If so, do we have any Documentation/Knowledge that might help us "make it so"?

Charlie Veniot

unread,
May 2, 2021, 10:54:35 AM5/2/21
to TiddlyWiki
G'day g'day an Happy Sunday!

Neocities if just for hosting static sites.  sql.js would have been a good fit for Neocities.

Charlie Veniot

unread,
May 2, 2021, 11:16:25 AM5/2/21
to TiddlyWiki
Good grief:  Neocities is just for hosting static sites (html, css, javascript and other files.)  sql.js is a good fit for Neocities.

Anjar

unread,
May 2, 2021, 8:06:13 PM5/2/21
to TiddlyWiki
@cj.v Great! You may have read it, but I accidentally came across this: https://phiresky.github.io/blog/2021/hosting-sqlite-databases-on-github-pages/

Best,
Anders

Charlie Veniot

unread,
May 2, 2021, 9:58:39 PM5/2/21
to TiddlyWiki
Thanks Anjar, that's a really good addition to all of the other fine resources in this thread.

Just checking, though:  I don't think that's anything special about github.  I had a Sqlite database on Neocities for a SpiderBasic program I was testing a few years back, and that was working A-1.  Happily, I needed to know nothing about API's, because SpiderBasic handled it all.  Just had to point it to the Sqlite.db file.
  • Ultimately, a sqlite.db file is just another file along with html, js, and css files for a static website on some host.
  • sql.js or whatever api for the static pages to interact with that sqlite.db file, that's the good stuff.
Regardless, that is a really good article about hosting a sqlite.db file on any static site.

Charlie Veniot

unread,
May 2, 2021, 10:35:12 PM5/2/21
to TiddlyWiki
Ugh.  I really ought to read articles a couple of times over.  Says it right under the title:  "(or any static file hoster)"
Reply all
Reply to author
Forward
0 new messages