[TW5] Some strange $:/tags/RawMarkup behavior

107 views
Skip to first unread message

Jed Carty

unread,
Dec 25, 2015, 8:04:32 AM12/25/15
to TiddlyWiki
I have run into a weird problem when using $:/tags/RawMarkup. The SnapSVG plugin I made adds a full page SVG surface to work with, if you import the plugin, save and reload it tells you that Snap isn't defined, but if you import the plugin, edit the tiddler containing the library so it isn't a shadow tiddler anymore then save and reload everything works as expected. After that you can delete the modified tiddler and there aren't any further problems.

Somehow the library isn't being added before the surface is created, but only if you haven't ever loaded the wiki with the library in a non-shadow tiddler and after loading the wiki once with the library in a non-shadow tiddler it can go back to being in a shadow tiddler and not cause any problems.
I think I had the same problem with the twitter button plugin I made but I never found a solution to it. I think that if I make some setting that you need to change to enable the plugin it will take care of the problem but I would like to find a better solution because I don't know any way to tell the user that they need to do something other than save and reload to use the plugin after they import it.

Tobias Beer

unread,
Dec 25, 2015, 8:28:40 AM12/25/15
to tiddl...@googlegroups.com
Hi Jed, where could we find some specific code-bits to look at?

Best wishes,

Tobias.

Jed Carty

unread,
Dec 25, 2015, 9:15:14 AM12/25/15
to TiddlyWiki
I don't know what a minimal example for this would be, but you can get the error if you take an empty wiki, and import both the tiddler SVGImage1 and the plugin from the demo, set the default tiddler to SVGImage1 and then reload the wiki. From what I can tell the tiddler is rendered before the script is loaded. I don't know how to make sure that the script is loaded before the widget does anything.

Tobias Beer

unread,
Dec 25, 2015, 5:20:09 PM12/25/15
to TiddlyWiki
Sounds like a caching issue. How (and from where) is the library loaded? Synchronously or asynchronously? Smells like once the lib is cached (b the browser) the problem is gone.

Best wishes,

Tobias. 

BJ

unread,
Dec 25, 2015, 8:10:49 PM12/25/15
to TiddlyWiki

hi Jed,
some libraries provide an 'I'm ready' event to listen for, but I cannot see one for snap. When a  lib is loaded in the header It will be compiled before the window.onload event fires. I think that the core should listen for this event and set a variable ie

window.onload=function() {
$tw.savetiddler tittle =$:/core/windowready etc
}

This would allow widgets to listen for this tiddler in their refresh function and not render until this tiddler is set.

maybe this would solve your problem.

all the best
BJ

BJ

unread,
Dec 26, 2015, 6:31:30 AM12/26/15
to TiddlyWiki

There is one thing to note when using $:/tags/RawMarkup - this tag is used to insert a tiddlers text in the the head area of the html of the tiddlywiki which happen when the tiddlywiki is saved. But plugin tiddlers are not visible (to this filter) until unpacked, so  they will not be available to be inserted into the head until unpacked from plugins. This means you plugin will need to be saved twice before it will work.

I will open an issue about this. (I have a solution in mind).

BJ

Jed Carty

unread,
Dec 26, 2015, 7:11:00 AM12/26/15
to TiddlyWiki
Tobias,

I just took the text of the script and added <script> and </script> in a tiddler tagged with $:/tags/RawMarkup, past that I don't know. I should probably look up how these things work at some point.

BJ,

That would be lovely. I keep thinking that I have somehow fixed the problem but from your reply it sounds like it is just that the problem doesn't come up when the wiki is built with the plugin included. Things should be far less confusing now, thank you.

BJ

unread,
Dec 28, 2015, 10:37:59 AM12/28/15
to TiddlyWiki
It wouldn't be a problem when runing on node as the tiddlywiki is constructed twice (once on the server and once for the browser). - I have opened an issue.
Reply all
Reply to author
Forward
0 new messages