Query -- One click import of JSON file at an exact address?

99 views
Skip to first unread message

@TiddlyTweeter

unread,
Oct 20, 2018, 3:01:21 PM10/20/18
to TiddlyWiki
The import mechanism allows browsing to find a file to import.

Is it possible to specify an exact address of a file (preferably with relative addressing) so you can just click a button and activate import? I'm not clear if its possible or how to do it if it is.

Any help appreciated.

Best wishes
Josiah

Eric Shulman

unread,
Oct 20, 2018, 5:06:21 PM10/20/18
to TiddlyWiki
On Saturday, October 20, 2018 at 12:01:21 PM UTC-7, @TiddlyTweeter wrote:
The import mechanism allows browsing to find a file to import.

Is it possible to specify an exact address of a file (preferably with relative addressing) so you can just click a button and activate import? I'm not clear if its possible or how to do it if it is.

It's no longer possible, due to increases in browser security.  

If you could access an "exact address of a file" without going through the system interface, then it would be possible to trick people into clicking a button that reads system data without them knowing it.

Basically, the system file I/O dialog box is limited by the browser so it can be used to select a file, but the data *returned* by that box only includes the filename, extension, and file *content*... but NOT the path to the file, as that could be used to probe your local directory structure to look for vulnerabilities (at least... that's the theory).

-e

TonyM

unread,
Oct 20, 2018, 7:23:04 PM10/20/18
to TiddlyWiki
Josiah,

An idea

This may be possible to a degree if you can serve your file to the browser, such as the link to the file is changed into an online file with a url address. If this is done only on the local host no one else can see it, and while the browser can see them, its only what you choose. I will look into it.

Tiddlyserver can do this to some extent, the 5.1.18prerelease also speaks of serving files.

Tony

@TiddlyTweeter

unread,
Oct 21, 2018, 6:21:46 AM10/21/18
to TiddlyWiki
Eric

Thanks for the detailed clarification. I sort of suspected it was so but wanted to be really sure.

Best wishes
Josiah



@TiddlyTweeter wrote:
The import mechanism allows browsing to find a file to import.

Is it possible to specify an exact address of a file (preferably with relative addressing) so you can just click a button and activate import? I'm not clear if its possible or how to do it if it is.


Eric Shulman replied:

@TiddlyTweeter

unread,
Oct 21, 2018, 6:39:30 AM10/21/18
to tiddl...@googlegroups.com
TonyM wrote:

This may be possible to a degree if you can serve your file to the browser, such as the link to the file is changed into an online file with a url address.


Thanks, that sounds hopeful.


If this is done only on the local host no one else can see it, and while the browser can see them, its only what you choose. I will look into it.

Just so you know, here is the use case ...

-- Its ultimately for "Bob" wiki system.

-- It purely local, as an aid to being able to assemble Wiki without having to search all over the shop to get bits, tweaks and plugins needed.

Background: Bob has superb tools like internalFetch (i.e. inter-wiki relations that can copy Tiddlers from one to another) editions, and, more recently, easy access to a plugin library. Powerful and useful. But its not quite the same as using JSON.

In reality: I already do most of needed customisation through JSON files. I prefer them as they will work with individual TW as well as a server based system, are easy to maintain through PMario's Bundler and highly portable. AND, most important, they can be very precisely honed sets of exactly what components I want to include in a wiki.

The problem is: having an easier way to cope with the numbers I have. They need better organising and, the ISSUE here, easier to find and invoke.
 

If this is done only on the local host no one else can see it, and while the browser can see them, its only what you choose. I will look into it.

Tiddlyserver can do this to some extent, the 5.1.18prerelease also speaks of serving files.


Best wishes
Josiah

Jed Carty

unread,
Oct 21, 2018, 6:49:49 AM10/21/18
to TiddlyWiki
If I understand your original question this is very possible. But I am getting a very different question from it than Eric, because everything he said is correct about being able to determine the path to a file from the browser.

You can supply a file path to the browser and have it import a file, that is no problem. The problem is getting the file path from a supplied file, not getting a file from a supplied file path.

So if you are saying that there is some file '/home/me/tiddlywiki/something.json' and it's location is both known and won't change and I want to import it, there is nothing preventing the browser from doing that.

@TiddlyTweeter

unread,
Oct 21, 2018, 7:43:44 AM10/21/18
to tiddl...@googlegroups.com

That is exactly it. It won't change. The JSON files are in one directory with invariable addresses.

FYI, the purpose is in Bob, to complement internalFetch, editions & plugins with highly-specific JSON imports. I prefer JSON as it will also work with singular wiki--so I don't need to maintain two systems.

All I want to do is understand how to, on button click, invoke a specific JSON import, if possible.

Jeremy Ruston

unread,
Oct 21, 2018, 10:14:51 AM10/21/18
to tiddl...@googlegroups.com


On 21 Oct 2018, at 11:49, Jed Carty <inmy...@gmail.com> wrote:

So if you are saying that there is some file '/home/me/tiddlywiki/something.json' and it's location is both known and won't change and I want to import it, there is nothing preventing the browser from doing that.

Are you thinking of using XMLHttpRequest()? Sadly, for the last several years all major browsers prevent pages loaded from a file:// from reading other file:// URI locations, for fairly obvious security reasons.

As far as I know, the best we can do to achieve the OP is to use JSONP — in other words, have JS code dynamically add a <script> tag that points to a file that contains the data as a function call. I don’t think it could be done with a plain JSON file.

Best wishes

Jeremy.
Reply all
Reply to author
Forward
0 new messages