Could vanilla TW5 wikify a file?

63 views
Skip to first unread message

Mat

unread,
Apr 28, 2015, 1:13:20 PM4/28/15
to tiddly...@googlegroups.com
It feels like I've dealt with this before but never actually asked it explicitly:

Is there any way to make TW5 (not node.js version) read and process (is the word "wikify"?) a file, e.g a json file with tiddlers?

Must it take a manual drag-n-drop to import e.g a json file, couldn't it be done in some more automatic way?

What if the file is stored fully locally, even in same folder as the TW?


In reading articles like the following (and understanding a fraction) it really feels like it should be possible after all...

Reading files in JavaScript using file APIs, including among other things a demo where you can slice out parts from a TW.

HTML imports. Assumes CORS but I think a great part of reading file needs is for locally stored files. (And if you store your TW in a sky folder that even others could put stuff into then...)



Partly inspired from the articles, here are some arbitrary synaptic snapshots from a happy non-coder:
  • A hard coded "port" in TW core (or a plugin), with a transclusion-like interface that takes some file address. The TW file is processed from top and reaches the transclusion...takes sidestep to run through the transcluded file.. then stepping back in again to continue in the TW file...
  • The external file name sneakily contains the content. In trying to call "Foo*.*" the OS or browser answers that "no you cannot read FooHereisreallythecontentofthefile.txt as it is an external file" to which TW says thank you.
  • A hardcoded div(?) that is really a permanent address+filename so that any filed saved with that name is accepted (..somehow)

Reversing the omelet, looking instead at the file to be imported.
  • The exploding bottom technique; the file cointains the content but also the "end of a TW file"  (</body></html> ?). Part of the process to insert it into the TW is to delete the TW file ending and replace it (append) the external file."
  • The file thinks he is the center of the universe and imports the TW around himself. It reads the TW code down to a marker, copies this to above its own content, and then under the content applies a copy of the rest of the TW code. He then makes coffee for you and fetches your slippers.

<:-)

Jeremy Ruston

unread,
Apr 30, 2015, 12:19:01 PM4/30/15
to TiddlyWikiDev
Hi Mat

To try to answer your first question, it would be possible to construct a variant of TW that on startup used XMLHttpRequest to load the tiddlers from a tiddlers.json file stored in the same directory.

> A hard coded "port" in TW core (or a plugin), with a transclusion-like interface that takes some file address. The TW file is processed from top and reaches the transclusion...takes sidestep to run through the transcluded file.. then stepping back in again to continue in the TW file...

I think that would be possible. It would need  CORS, and I think it wouldn't work from a file:// URI in Firefox. And of course there's currently no notion for the idea of sidestepping through the transcluded file. I think the best we could do is use a list widget that brings in the transcluded tiddlers.

> The external file name sneakily contains the content. In trying to call "Foo*.*" the OS or browser answers that "no you cannot read FooHereisreallythecontentofthefile.txt as it is an external file" to which TW says thank you.

Not quite sure what you mean here

> A hardcoded div(?) that is really a permanent address+filename so that any filed saved with that name is accepted (..somehow)

Similarly lost I'm afraid!

> Reversing the omelet, looking instead at the file to be imported. 
> The exploding bottom technique; the file cointains the content but also the "end of a TW file"  (</body></html> ?). Part of the process to insert it into 
the TW is to delete the TW file ending and replace it (append) the external file."

I'm not sure what you're trying to do here?

> The file thinks he is the center of the universe and imports the TW around himself. It reads the TW code down to a marker, copies this to above its own content, and then under the content applies a copy of the rest of the TW code. He then makes coffee for you and fetches your slippers.

A TW file wouldn't modify itself, in the sense of splicing new content into the raw HTML. Rather it would import some or all of the individual tiddlers  from the HTML file.

Best wishes

Jeremy




--
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 tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/cfd0cbb8-a26c-445a-99af-8a5c3fffc823%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com
Reply all
Reply to author
Forward
0 new messages