[TW5] Removing indicies from data tiddlers and using regex to list/search data tiddler indicies

357 views
Skip to first unread message

Jed Carty

unread,
Dec 12, 2014, 3:08:12 PM12/12/14
to tiddl...@googlegroups.com
I am trying to start using data tiddlers more in my wiki and I have set up a collection of acronyms here ( http://inmysocks.tiddlyspot.com/#Dashboard ). I would like to be able to make the search function in that use the regex filter instead of requiring the exact name the way it does now. Is there way to filter the indicies in a data tiddler?

Also, is there a way to delete an index in a data tiddler? I can use action-setfield to remove the content from the index, but I can't find a way to remove it.

Stephan Hradek

unread,
Dec 12, 2014, 8:41:23 PM12/12/14
to tiddl...@googlegroups.com
Try this:

\define thisSearchMacro()
<ol>
<$list filter="[[$:/data/Acronyms]indexes[]regexp:title[(?i)$(thisSearch)$]]">
<li><$transclude tiddler="$:/data/Acronyms" index=<<currentTiddler>>/></li>
</$list>
</
ol>
\end

filter explanation:
1. Get your Acronyms
2. Get its indeces
3. Filter them by your search string
4. For each remaining transclude the content

Jed Carty

unread,
Dec 12, 2014, 11:29:10 PM12/12/14
to tiddl...@googlegroups.com
Thank you! Trying to figure that out has been driving me crazy for a few days.

Jed Carty

unread,
Dec 12, 2014, 11:56:18 PM12/12/14
to tiddl...@googlegroups.com
Do filters get executed in order? I hadn't encountered or noticed it before, but rearranging the filter breaks the output, [indexes[][$:/data/Acronyms]regexp:title[(?i)$(thisSearch)$]] doesn't work. I had assumed that each operation was done independently and then the intersection of the resulting sets (or union for ORing filters) was given as the output.
In most cases this wouldn't have any effect, but it seems to be the case here.

Is that what is happening? If so that may have been why nothing I was trying was working out. It makes sense but either it isn't mentioned in the documentation or I am missing it.

Jeremy Ruston

unread,
Dec 13, 2014, 3:51:28 AM12/13/14
to TiddlyWiki
Hi Jed

>  I hadn't encountered or noticed it before, but rearranging the filter breaks the output

The order does matter for filters that work as "selectors" rather than strict "filters". For example, the "indexes" operator selects all the data indices present in the tiddlers whose titles are in the current list.

Best wishes

Jeremy



--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


--
Jeremy Ruston
mailto:jeremy...@gmail.com

Tobias Beer

unread,
Dec 13, 2014, 4:21:32 AM12/13/14
to tiddl...@googlegroups.com, jeremy...@gmail.com
Hi Jeremy,
 
The order does matter for filters that work as "selectors" rather than strict "filters". For example, the "indexes" operator selects all the data indices present in the tiddlers whose titles are in the current list.

In ...


What exactly is {$:/palette}...

[{$:/palette}indexes[]sort[title]]

interpreted as? ...being a text-reference. I presume it is translated as: take whatever is defined in {$:/palette} as a text-reference to a data-tiddler.

What would happen with a construct like this:

[[tag[foo]indexes[]sort[title]]

...assuming there were multiple data tiddlers tagged foo?

Also, can any field of a tiddler be used as a DataField or does it always have to be the text field? As asked / indicated here, I think it can prove beneficial to store related data entries at the exact tiddler to which they relate, yet not in its text-field.

As for deleting indexes from a DataTiddler, here is one way to do it...


Look at \define deleteSnapshot() and notice how the index is set on button click, however with no setTo value being specified. This results in setting an undefined value, ergo deleting the index from the data.

Best wishes, Tobias.

Jeremy Ruston

unread,
Dec 13, 2014, 4:27:11 AM12/13/14
to Tobias Beer, TiddlyWiki
Hi Tobias

What exactly is {$:/palette}...

[{$:/palette}indexes[]sort[title]]

interpreted as?

The curly braces indicate a transcluded filter operand. The overall action is to take the tiddler title stored in `$:/palette`, get all the indices of the data properties within it, and then sort the indices.

What would happen with a construct like this:

[[tag[foo]indexes[]sort[title]]

...assuming there were multiple data tiddlers tagged foo?

It would take all tiddlers tagged "foo", and accumulate all the indices within them, and then sort the list of indices.
 
Also, can any field of a tiddler be used as a DataField or does it always have to be the text field?

No, the data comprising a data tiddler is always stored in the "text" field.
 
As asked / indicated here, I think it can prove beneficial to store related data entries at the exact tiddler to which they relate, yet not in its text-field.

I'm not so convinced. If we store state within content tiddlers then it makes it harder to share those content tiddlers in a multi-user scenario.

Best wishes

Jeremy.

 
As for deleting indexes from a DataTiddler, here is one way to do it...


Look at \define deleteSnapshot() and notice how the index is set on button click, however with no setTo value being specified. This results in setting an undefined value, ergo deleting the index from the data.

Best wishes, Tobias.

Tobias Beer

unread,
Dec 13, 2014, 7:55:57 AM12/13/14
to tiddl...@googlegroups.com, beert...@gmail.com, jeremy...@gmail.com
Hi Jeremy,
 
I'm not so convinced. If we store state within content tiddlers then it makes it harder to share those content tiddlers in a multi-user scenario.

Please note, I was not at all referring to states.
Rather, I was suggesting data pertaining to an exact tiddler, that are not to "clutter the timeline",
except for per-tiddler lists of related, well, data... of different kinds (see linked discussion).

Think "logs", "comments"... all those kinds of things.

Best wishes, Tobias.

Jed Carty

unread,
Dec 13, 2014, 1:26:51 PM12/13/14
to tiddl...@googlegroups.com
Jeremy,

Thank you, that makes much more sense now and probably makes the filters more powerful. Now I just need to find places where I can take advantage of it.

Tobias,

I would never have thought of removing the indicies like that, thanks!


Think "logs", "comments"... all those kinds of things.

Is that different from just using fields? Fields may get very cluttered I guess, but having a connected data tiddler or something would be equivalent to just using a data tiddler in addition to the original one wouldn't it?
I would think that for logs and the like having the tiddler foo and then storing logs in $:/data/foo/logs and comments in $:/data/foo/comments or some similar setup would be less cluttered than having the information stored in the tiddler foo itself. I think that would make it easier to search and use things like display templates for the data. This would be even better if the system tiddler browser gets implemented ( http://tiddlywiki.com/prerelease/#%24%3A%2Fcore%2Fui%2FMoreSideBar%2FExplore ).

Tobias Beer

unread,
Dec 13, 2014, 3:05:59 PM12/13/14
to tiddl...@googlegroups.com
Hi Jed, 

Think "logs", "comments"... all those kinds of things.

Is that different from just using fields?

Yes and no. A tiddler may have a number of comments or logs attached to it. Implementing that as a number of comment-fields seems difficult and error prone.
 
Fields may get very cluttered I guess, but having a connected data tiddler or something would be equivalent to just using a data tiddler in addition to the original one wouldn't it?

That data tiddler would have to be stuffed into the system tiddler namespace. So, that is one option. Personally, I prefer to keep data at the place to which they pertain, that very tiddler. Other than not wanting to implement that functionality, I don't see why a tiddler itself should not contain complex data anywhere but its body. Whether or not they're easily editable within the current editors is a matter of having accessible editors. 
 
I would think that for logs and the like having the tiddler foo and then storing logs in $:/data/foo/logs and comments in $:/data/foo/comments or some similar setup would be less cluttered than having the information stored in the tiddler foo itself.

What about comments for $:/foo, or even $:/data/foo? I think the complexity gets arbitrarily confusing. I think it is way more natural to simply pack those things into the very tiddler to which they belong. Two different modeling approaches. I don' see a tiddler getting "cluttered" by that, especially nto with tiddler fields being only editable as simple text-inputs.
 
I think that would make it easier to search and use things like display templates for the data. This would be even better if the system tiddler browser gets implemented ( http://tiddlywiki.com/prerelease/#%24%3A%2Fcore%2Fui%2FMoreSideBar%2FExplore ).

I think having comments stored at tiddler-data-fields is by far easier index, search and relate to that very tiddler... using standard filtering procedures, if not a lot easier, than putting these things under some deferred system-namespace. What about renaming a tiddler and similar things? Store fields where they belong, as much as you can. A tiddler is a moveable entity... and should pack with all the things that go with it, is what I think.

But, above all, I see no particular reason why only the text field of a tiddler should be indexable via json. Would there be a technical constraint to doing so?

Best wishes, Tobias.

Stuart Amor

unread,
Jun 10, 2016, 2:41:24 AM6/10/16
to TiddlyWiki
I think I may have missed a fundamental point here. I have followed the above examples and entered:

\define thisSearchMacro()
<ol>
<$list filter="[[$:/data/Entrance]indexes[]regexp:title[(?i)$(thisSearch)$]]">
<li><$transclude tiddler="$:/data/Entrance" index=<<currentTiddler>>/></li>
</$list>
</ol>
\end

<<thisSearchMacro>>

I don't understand how the regexp:title[(?i)$(thisSearch)$] portion of code works, I get the same values if it's there or not...?

magev958

unread,
Nov 17, 2016, 6:46:20 AM11/17/16
to TiddlyWiki
Hi, I looking at your site from time to time and always finds something new and shine :)
This time I liked the macro from "Make data from a dictionary tiddler appear when you hover over something" but I don't seem to make it work in a TW5.1.13, nothing happens, it works fine when I open Your site byt not when I drag the toddlers to my offline 5.1.13?

Jed Carty

unread,
Nov 17, 2016, 6:55:12 AM11/17/16
to TiddlyWiki
That requires the hover widget plugin by Andreas Hahn. His site is somewhere, I don't have the link handy at the moment.

You can get the widget off of the wiki reference wiki here http://inmysocks.tiddlyspot.com/#%24%3A%2Fplugins%2Fahahn%2FhoverWidget

magev958

unread,
Nov 17, 2016, 9:17:49 AM11/17/16
to TiddlyWiki
Ahh, thank You! :)
Reply all
Reply to author
Forward
0 new messages