How to load external data when TiddlyWiki startup?

How to load external data when TiddlyWiki startup?

like this:

The data.json file is a JSON format exported by TiddlyWiki.

It is updated automatically every day.

Currently, I need to import the data.json file into TiddlyWiki manually every day.

I would like to request a feature that would allow me to load the external data directly when TiddlyWiki starts.

I found the plugins:
https://saqimtiaz.github.io/tw5-plugins-sandbox/#ExternalContent

and use the test code:

\procedure loadMyWiki()
\import [[$:/plugins/sq/ExternalContent/loadWikiActions]]
<$transclude
    $variable="loadWikiActions"
    wikiURL="https://simon.tiddlyhost.com/tiddlers.json"
    contentFilter="[!is[system]]"
    deseralizer="text/html"
    />
\end

<$button actions=<<loadMyWiki>> > load content </$button>

but the plugin is not working

Is there any way to load external data?

You need to get json data and save it into tiddlywiki. There are many methods, such as writing a plugin, using fetch, or using tm-https-request.

This is an example of get an external readme markdown file. It involves some js knowledge

Hi @ricky,

I believe you are running in to two different problems.

  1. there was a bug specific to the handling of TiddlyHost files that is now resolved, get the new plugin version.
  2. If you are importing JSON, the deserializer you need to use is application/json

This plugin should do the trick for you as long as the server hosting the JSON file supports CORS.

After update the plugin version and spectify the deserializer to “application/json”
the test code is working.

but when the wikiURL change to “data.json”, it could not working again.

wikiURL="data.json"

maybe ExternalContent Plugin not support to reader local json files?

Are there any other plugins that support local json files?

As specified above, the JSON needs to be hosted on a server (that supports CORS). Your best option might be to setup a small local server to host the JSON file if you really want automated loading of tiddlers from an external file.

1 Like

because CORS not allow to directly to load local json files.

still need the plugin “ExternalContent”
https://saqimtiaz.github.io/tw5-plugins-sandbox/#ExternalContent

and local server to host the json files.

the finally solution like this:

All problems are solve, thanks for all.