After some experimentation, I’ve found that it is not so simple to build place list index tiddlers from wikitext scripting “on-the-fly” (i.e, within the TiddlyTools Location code).
However, I did come up with a strategy for using wikitext scripting to define a separate $button
that can assemble place list index tiddlers from separate tiddlers.
Let’s suppose you have some tiddlers tagged with TTPlace
, where each tiddler’s title is the description (“address”) of the place, and the tiddler’s text field contains latitude,longitude
values. You can then create a tiddler (e.g., “MakeMyPlacesList”) that gathers all the separate TTPlace
tiddlers into a single JSON index tiddler, like this:
<$let tid="$:/config/TiddlyTools/Places/MyPlacesList">
<$button> make MyPlacesList index from separate places
<$list filter="[tag[TTPlace]]">
<$action-setfield $tiddler=<<tid>> $index={{!!title}} $value={{!!text}}/>
</$list>
</$button>
Then, after running this wikiscript, you can optionally delete the individual TTPlace
tiddlers, since all the needed information is now collected in a single JSON index tiddler.
Also, while investigating this strategy, I realized that the CURRENT TiddlyTools Location “place list” code can work with a mix of JSON index tiddlers and/or dictionary index tiddlers (which use a simpler syntax that is easier to type). While JSON index tiddlers look like this:
{
"index":"value",
"index":"value",
"index":"value"
}
dictionary index tiddlers look like this:
index: value
index: value
index: value
i.e., you can omit the enclosing curly brackets, the quotes around index
and value
, and the trailing comma at the end of each line. The only limitation of the dictionary index format is that the index
text cannot contain any colon (:
) characters, as the index
is not enclosed in quotes and the colon is used as the separator (aka, “delimiter”) between the index
and value
on each line.
To generate a dictionary index tiddler instead of a JSON index tiddler, all you need to do is to set the target tiddler’s type
field to application/x-tiddler-dictionary
before writing the list of index/value output, like this:
<$let tid="$:/config/TiddlyTools/Places/MyPlacesList">
<$button> make <<tid>> index from separate places
<$action-setfield $tiddler=<<tid>> type="application/x-tiddler-dictionary"/>
<$list filter="[tag[TTPlace]]">
<$action-setfield $tiddler=<<tid>> $index={{!!title}} $value={{!!text}}/>
</$list>
</$button>
Hopefully, the above gives you some more ideas for implementing your own strategy for defining “places”.
Let me know how it goes…
enjoy,
-e