[TW5] Help for Search customization (filter work)

75 views
Skip to first unread message

François Godard

unread,
Mar 15, 2017, 3:56:32 PM3/15/17
to TiddlyWiki
Hi guys !

I realize I have a very specific request. But hopefully challenging/interesting enough for you guys.
I put some background info, so you understand where I am coming from but I guess you can skip the paragraph, till the issue bit

Background : I have migrated a chm file that document an internal database, into TW5 of course. The migration is done with a Vim script that converts the html into tiddlers. The files are then imported nicely in TW. This works great. The purpose of this is to allow me and colleagues to add notes to the documentation. Documentation is never complete and you always want to write down a SQL query and share it. So you can add some tiddlers to the tiddlywiki (not easily done with chm). Point is the DB evolves and new chm come up from time to time. So to keep the notes and allow for refreshed tiddlers, I came up with this :
  • The migrated tiddlers are named by database object typically table name. I'll use tableA in the examples
  • These have embedded a button at the top that will create a relative tiddler to their name : TableA+ (just add the "+" suffix)
  • They transclude this relative tiddler (basically  the migrated tiddler include {{TableA+}} even if it does not exist yet.
  • So if a comment was made , the TableA+ is created and kept , and TableA is updated at the new migration.
  • I apply the same idea for a bottom comment with suffix "+b" , that creates TableA+b, and to create comment for each field of the table, so TableA.field1+ can be created
This again works very nicely. Now comes the point. I want to search through Table documentation and my notes at the same time. and the default search can come up with many entry for the same table (TableA, TableA+, TableA.fieldn+, TableA+b). What I want is to get only one result back from the search (nicer, more compact result set)

Here is my issue
The tiddlywiki is full of comment tiddlers that have suffix "+", "+b" and ".fieldn+". 
These comments refers to the a main tiddler named "TableA". 

I want to be able to search through all of these, but only offer a link to the main tiddler . So if my search string is found in "TableA+", I want the search to return TableA
This can be done for the "+" and "+b" suffix, using removesuffix operator

in the macro that customize the search, i will use the following to change the link to remove from the tiddlers the "+b" suffix

[!is[system]search{$(searchTiddler)$}!regexp[\..*\+]] +[removesuffix[+b]]

I do the same with "+" suffix, add the tiddlers corresponding to the table (removesuffix does filter out the tiddlers without suffix) , do the union of the lot, and sort it back.

<$list filter="[!is[system]search{$(searchTiddler)$}!regexp[\..*\+]] +[removesuffix[+]] [!is[system]search{$(searchTiddler)$}!regexp[\..*\+]] +[removesuffix[+b]] [!is[system]search{$(searchTiddler)$}!suffix[+]!suffix[+b]] [!is[system]search{$(searchTiddler)$}regexp[\..*\+]] +[sort[]]">

The code above include the regexp operator to include or exclude the tiddlers with the ".field1+" or ".field67+" suffix. But for them I don't know how to remove the suffix. removesuffix does not work with regular expressions

So in short
is there a way to remove a suffix that you can identify through regular expressions ?

I guess variables could help, but I would not know where to start. Can you provide clues ?
Also I am not fully confortable on how to customize the search, is there any example around of customized searchs appart from the timeline in tiddlywiki.com ? where is the code for the default search ?

Many thanks for your help. Sorry for the long post




Mark S.

unread,
Mar 15, 2017, 6:41:21 PM3/15/17
to TiddlyWiki
Just a thought. Instead of a system based on enforced naming conventions, why not have each of the comment tiddlers tagged with the name of the original TableA (etc.) tiddler. Then extracting the matching tiddlers (as tags) would be much easier and wouldn't require extraordinary measures ??

Good luck,
Mark

François Godard

unread,
Mar 16, 2017, 4:47:40 AM3/16/17
to TiddlyWiki
Looks like the way to go. So I'll create my comments with these buttons

<$button> <$action-sendmessage $message="tm-new-tiddler" title="TableA.Field+" tags="TableA"/>edit</$button>

And my customized search will be

[!is[system]search{$(searchTiddler)$}each[tags]get[tags]] +[sort[]]

Thanks a lot Mark !
Reply all
Reply to author
Forward
0 new messages