Help wanted from Developer with Core knowledge - new operators

Folks, Please see this discussion What is in a tiddler? tiddler types and how we handle them. I am looking at a Proof of concept for the introduction or a types field that behaves similarly to the tags field.

  • I can most likely construct all the user interface elements I need
  • I am posting here for help with the filter operators
  • Unless I have underestimated something, I believe someone with the requisite knowledge and skill may be able to assist without much time and effort.

I have looked at cloning and modifying the following core modules filter tiddlers;

So far I have reached the limit of my JavaScript and TiddlyWiki development skills including;

  • The function getTiddlersWithTags defined in $:/core/modules/wiki.js
    also needs to be used to create a getTiddlersWithType
    • A filter operator with this undefined function named abends the wiki
    • Then this raises the issue that tags are indexed for performance so there is additional code relating to that
  • There is other javascript code I am not sure how to safely manipulate such as tiddler.fields.tags and length=tiddler.fields.tags.length

If anyone can help I will post a demo/dev wiki in tiddlyhost with as much work done as I can to keep the effort to a minimum.

Hi @TW_Tones I think this kind of experiment will be much easier once the parameterised transclusion PR is merged. You’d be able to write custom operators that use filters to implement the required functionality. In the meantime, this would require a fair bit of JavaScript development so it would be a matter of persuading somebody to write the code for you.

I’m sure you already know this, so maybe this is nothing more than a refresher for anyone who is looking for similar information.

There already are filter operators that work very similar to the tagging operators, but on arbitrary fields (I’m using types for the examples):

  • tag[<tag>]types[<type>] or field:types[<type>]
  • tagging[]listed[types]
  • tags[]get[types]enlist-input[]
  • untagged[]!has[types]

So maybe it’s just a matter of creating aliases for these if you really need the types operator names?

As far as I know, field lookups are cached like tags, so these should be (mostly) just as fast…?

Have a nice day
Yaisog

2 Likes

Nice list. I was trying to construct the same. I think the above would only work on tiddlers with a single tag. I think this is closer:

tag[<tag>]contains:types[<type>]

Thanks for letting me know, my initial review of the Javascript and other operators people have introduced suggested it was almost trivial. I will take you on your word that is is not.

  • Yes thanks, I was aware of this but I was exploring making this a much easier to use fundamental solution, especially for novices. But thanks for restating it.
  • Can you suggest how to do this?
  • That is reassuring, any solution needs to retain this.

For the record:

Filter operators that work like the tagging operators, but on arbitrary fields (I’m using types for the examples):

  • tag[<tag>]contains:types[<type>] @btheado mod’
  • tagging[]listed[types]
  • tags[]get[types]enlist-input[]
  • untagged[]!has[types] btheado

The easiest way will probably be via parameterized transclusions, as Jeremy stated earlier.

Maybe it would be useful to make this a TWTalk Wiki entry?

I took a stab at this. I was unsuccessful, but perhaps someone with more experience can explain where it went wrong. It’s at https://crosseye.github.io/TW5-demos/2023-01-30a/.