TW5: just a <<search>> search box

871 views
Skip to first unread message

Dave

unread,
Jul 8, 2018, 6:39:18 PM7/8/18
to TiddlyWiki
This is just for reference - I couldn't find a quick answer on this

In TW classic you could add a search box anywhere (say in a tiddler you'll often have open) with "<<search>>"

In TW5 you could do this: {{$:/core/ui/SideBarLists}}, but that gives you not only a search box, but the tabs and tiddler lists underneath.


For just the search box only you can copy the code in that shadow tiddler, put it in another tiddler, say "justSearch" and remove this near the end:
<$macrocall $name="tabs" tabsList="[all[shadows+tiddlers]tag[$:/tags/SideBar]!has[draft.of]]" default={{$:/config/DefaultSidebarTab}} state="$:/state/tab/sidebar" />

And then anywhere you want a search box just put {{justSearch}}, and there it is :)

Or, if you want to just copy that blob of code from here, here it is:

<div class="tc-sidebar-lists">

<$set name="searchTiddler" value="$:/temp/search">
<div class="tc-search">
<$edit-text tiddler="$:/temp/search" type="search" tag="input" focus={{$:/config/Search/AutoFocus}} focusPopup=<
<qualify "$:/state/popup/search-dropdown">> class="tc-popup-handle"/>
<$reveal state="$:/temp/search" type="nomatch" text="">
<$button tooltip={{$:/language/Buttons/AdvancedSearch/Hint}} aria-label={{$:/language/Buttons/AdvancedSearch/Caption}} class="tc-btn-invisible">
<$action-setfield $tiddler="$:/temp/advancedsearch" text={{$:/temp/search}}/>
<$action-setfield $tiddler="$:/temp/search" text=""/>
<$action-navigate $to="$:/AdvancedSearch"/>
{{$:/core/images/advanced-search-button}}
</$button>
<$button class="tc-btn-invisible">
<$action-setfield $tiddler="$:/temp/search" text="" />
{{$:/core/images/close-button}}
</$button>
<$button popup=<
<qualify "$:/state/popup/search-dropdown">> class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
<$list filter="[{$:/temp/search}minlength{$:/config/Search/MinLength}limit[1]]" variable="listItem">
<$set name="resultCount" value="""<$count filter="[!is[system]search{$(searchTiddler)$}]"/>""">
{{$:/language/Search/Matches}}
</$set>
</$list>
</$button>
</$reveal>
<$reveal state="$:/temp/search" type="match" text="">
<$button to="$:/AdvancedSearch" tooltip={{$:/language/Buttons/AdvancedSearch/Hint}} aria-label={{$:/language/Buttons/AdvancedSearch/Caption}} class="tc-btn-invisible">
{{$:/core/images/advanced-search-button}}
</$button>
</$reveal>
</div>

<$reveal tag="div" class="tc-block-dropdown-wrapper" state="$:/temp/search" type="nomatch" text="">

<$reveal tag="div" class="tc-block-dropdown tc-search-drop-down tc-popup-handle" state=<
<qualify "$:/state/popup/search-dropdown">> type="nomatch" text="" default="">

<$list filter="[{$:/temp/search}minlength{$:/config/Search/MinLength}limit[1]]" emptyMessage="""
<div class="tc-search-results">{{$:/language/Search/Search/TooShort}}</div>""" variable="listItem">

{{$:/core/ui/SearchResults}}

</$list>

</$reveal>

</$reveal>

</$set>

</div>




TonyM

unread,
Jul 8, 2018, 7:11:46 PM7/8/18
to TiddlyWiki
Thanks for sharing Dave

Tony

Mohammad

unread,
Jul 8, 2018, 10:55:57 PM7/8/18
to TiddlyWiki
Thanks Dave!
Why the searchbox in the sidebar is synchronized with you code e.g. it seems what you type and what you get also shown in the sidebar searchbox!

/Mohammad

Jed Carty

unread,
Jul 9, 2018, 5:18:49 AM7/9/18
to TiddlyWiki
I made a macro version of this and posted it here: https://www.ooktech.xyz:8443/Public#%24%3A%2Fmacros%2FForums%2FSearchBar

I am hoping to start using that wiki to put examples made from answers here on the forum. It is on a server running the online version of Bob (I haven't released it yet, I will soon) and hopefully I will be able to give other people editing access to a few public wikis so I won't be the only maintainer of it, if that is ok with the community here.

Dave,

I hope it is ok that I used your example, I listed you as the author and linked to this thread as the motivation in the demo tiddler here: https://www.ooktech.xyz:8443/Public#JustSearch

Mohammad

unread,
Jul 9, 2018, 7:58:04 AM7/9/18
to TiddlyWiki
Jed,
 That is wonderful. While people here are very helpful, but this forum is not good for storing and later searching and finding solution in a clean easy way!
It is very important to have other people contribute to the public wiki you mentioned.

One more important note: create a template for Q&A or forum solution to have a unique standard format for all solution collected in the mentioned multi user wiki.
There is a similar work by Tobias Beer in his A pocket full of tips: http://tobibeer.github.io/tb5/  which collect partially the solution to forum questions. but your wiki is multi user and it is a great improvement to have a sustainable dynamic wiki.



Good luck
Mohammad

David Gifford

unread,
Jul 9, 2018, 8:51:59 AM7/9/18
to TiddlyWiki
Added this macro version to the TiddlyWiki Toolmap under searching tools https://dynalist.io/d/zUP-nIWu2FFoXH-oM7L7d9DM

Ste Wilson

unread,
Jul 9, 2018, 9:39:18 AM7/9/18
to TiddlyWiki
If only there was some sort of existing mechanism where people could subscribe to a wiki, leave comments, automatically receive updates... What would something like that be called..

TonyM

unread,
Jul 9, 2018, 7:44:19 PM7/9/18
to TiddlyWiki
Jed,

Since you recently created this "on demand" search macro, I wonder it it would be a small step for you to devise a search in scope. I will do it eventually if not, it would be nice to provide a search tool a filter which limits the scope to a set of tiddlers then any string provided will searched for in all fields of only the selected tiddlers. I think this could be a common need in larger wikis.

Just a thought.

Tony

Dave

unread,
Jul 9, 2018, 8:10:03 PM7/9/18
to TiddlyWiki
Ha ha, who doesn't like to be "famous" ;)

TonyM

unread,
Jul 9, 2018, 8:39:50 PM7/9/18
to TiddlyWiki
RSS feed?

Ste Wilson

unread,
Jul 10, 2018, 4:53:09 AM7/10/18
to TiddlyWiki
I wears kinda thinking twederation.tiddlyspot.com

It could be leveraged for so much but has dropped off everyone's radar. I think it's in a chicken and egg situation... No one's trying it so Jed's left it so no one's feeding back so..

Jeds new collecting tiddlywiki would seem to be an ideal candidate to be twederated..

Jed Carty

unread,
Jul 10, 2018, 5:17:03 AM7/10/18
to TiddlyWiki
Ste,

Don't worry. Extending TWederation to use this is the next step. Eventually adding a simple websocket component to the twederation plugin so that it can access Bob wikis to improve the network and hopefully speed things up a lot by having optional servers. You could also have real-time syncing to wikis that aren't actually served by a Bob. It is going to be some significant work so it won't happen right away, but it is the plan.

In the shorter term it would probably use http(s) requests to the server with non-realtime updates. This will hopefully help get around the http vs https problems that we kept running into with the twederation network.

The whole development process for Bob has been a long roundabout way to get back to twederation.

Ste Wilson

unread,
Jul 10, 2018, 5:26:30 AM7/10/18
to TiddlyWiki
In Jed we trust!

Pit.W.

unread,
Nov 17, 2018, 5:02:35 AM11/17/18
to tiddl...@googlegroups.com

Mohammed:


replace
        $:/temp/search

with
        $:/temp/search1

and the synchronization stops

Pit.W.
--
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 https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/15889e6c-9791-4b68-839a-43495b88a91d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



_________________________________________________________________
________________________________________________________
Ihre E-Mail-Postfächer sicher & zentral an einem Ort. Jetzt wechseln und alte E-Mail-Adresse mitnehmen! https://www.eclipso.de


Geoff Tothill

unread,
May 17, 2020, 6:49:46 AM5/17/20
to TiddlyWiki
Hi Jed / Dave,

Sorry to resurrect this old thread, but its in regard to your code that allows a search box to be placed in a tiddler, which is very useful.

I have installed your macro and all works as expected except for the number of matches indicator. I'm assuming it takes its value from this filter, but either is not updated or the filter is wrong in my context?:

<$set name="resultCount" value="""<$count filter="[!is[system]search{$(searchTiddler)$}]"/>""">
{{$:/language/Search/Matches}}

Is this something that could be easily fixed?

Cheers and thanks in advance

Geoff.


On my version of TW5 all works as described (using the macro version from 

Mat

unread,
May 17, 2020, 6:58:36 AM5/17/20
to TiddlyWiki
Geoff

Since that was written, new filter ops have been added, including the count[] filter op.
I think the following should work:

<$set name="resultCount" value={{{ [!is[system]search{$(searchTiddler)$}count[]] }}} >

<:-)

Geoff Tothill

unread,
May 17, 2020, 8:03:07 AM5/17/20
to TiddlyWiki
Thanks Matt,

I made the change and this seems to give me 1 as the count despite the number of actual results returned :-(

Thanks for looking that this,

G

Mat

unread,
May 17, 2020, 8:25:18 AM5/17/20
to TiddlyWiki
Geoff Tothill wrote:
I made the change and this seems to give me 1 as the count despite the number of actual results returned :-(

Doing this on tiddlywiki.com I get the result 17:

title: foo
text
: important

title: test
text
:
\define aaa()

<$set name="resultCount" value={{{ [!is[system]search{$(searchTiddler)$}count[]] }}} >
<<resultCount>>
</$set>
\end

<$set name=searchTiddler value=foo>
<<aaa>>
</
$set>


<:-)

Geoff Tothill

unread,
May 17, 2020, 8:32:53 AM5/17/20
to TiddlyWiki
Thanks Matt,

Much appreciated. My mistake somewhere. I will revisit this afternoon.

Have a good afternoon,

Geoff.
Reply all
Reply to author
Forward
0 new messages