TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.09k stars 1.19k forks source link

Add support for importing via URL #8490

Open Jermolene opened 3 months ago

Jermolene commented 3 months ago

TiddlyWiki Classic's import mechanism works differently than TW5. There is no drag and drop, and the only way to import from another wiki is to enter the URL of the wiki and click a button to have TWC load the wiki file, extract the tiddlers and offer them for import.

By about 2010 the TWC approach to importing was proving problematic because of the adoption of CORS by modern browsers, a security mechanism that prevents websites from reading data from other websites without special configuration required of both parties.

The situation has changed somewhat in the more recent past as CORS has become more widely implemented by popular sharing sites. In particular, now both GitHub Pages and TiddlyHost support CORS.

That means that it would now be practical to replicate the TWC import mechanism within TW5. One approach would be for the empty $:/Import tiddler to carry a text area and button for entering a URL. Using it would have the same effect as downloading the file identified by the URL and dragging it into a TiddlyWiki browser window.

The exciting thing about this approach is that unlike drag and drop or importing a local file, it doesn't require any user intervention. Thus it would be possible to create a wiki that on startup downloads the latest data from a particular wiki or wikis on tiddlyhost.com. This means that it could serve as the basis for a simple serverless implementation of federation.

twMat commented 3 months ago

If implemented, I'd say this is the biggest step TW has taken since TW5 was introduced; TWs that can interact!

click a button to have TWC load the wiki file, extract the tiddlers and offer them for import.

Does this mean it would be possible to extract/import only a subset of tiddlers from the full wiki file?

Does this method differ, or somehow use, the recent tm-https-request message?

Is the method necessarily limited to importing tiddlywikis? Or could it, for example, extract specified "divs" from other sites?

Is it a difficult thing to implement?

kookma commented 3 months ago

Does this mean it would be possible to extract/import only a subset of tiddlers from the full wiki file?

This would be great to read/download a filtered list of tiddlers.

kookma commented 3 months ago

Thus it would be possible to create a wiki that on startup downloads the latest data from a particular wiki or wikis on tiddlyhost.com. This means that it could serve as the basis for a simple serverless implementation of federation.

This is exciting features. Also, if serve on WebDAV one can have a central TiddlyWiki that loads all notes/data from other TiddlyWikis. This way one can search and have all notes in one place.

saqimtiaz commented 3 months ago

Note that for anyone interested in exploring such features, they are all possible today via wikitext without the need for any core changes.

See:

michaeljmcd commented 4 days ago

Would there be a way to keep some sort of link back to the original wiki on imported tiddlers? A sort of offline friendly step towards FedWiki like behavior?

Jermolene commented 3 days ago

Would there be a way to keep some sort of link back to the original wiki on imported tiddlers? A sort of offline friendly step towards FedWiki like behavior?

Yes that would be possible. As @saqimtiaz points out, all the pieces are in place for experimenting on this in pure wikitext, particularly now that Tiddlyhost supports a JSON API (see https://github.com/tiddlyhost/tiddlyhost-com/wiki/Accessing-Tiddlyhost-data-as-JSON)