1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-10 11:59:58 +00:00

Add support for custom search result visualisations

This commit is contained in:
Jermolene 2014-10-27 18:38:34 +00:00
parent 91ec164361
commit c13cf94413
5 changed files with 59 additions and 10 deletions

View File

@ -1,5 +1,6 @@
title: $:/language/Search/ title: $:/language/Search/
DefaultResults/Caption: List
Filter/Caption: Filter Filter/Caption: Filter
Filter/Hint: Search via a [[filter expression|http://tiddlywiki.com/static/Filters.html]] Filter/Hint: Search via a [[filter expression|http://tiddlywiki.com/static/Filters.html]]
Filter/Matches: //<small><<resultCount>> matches</small>// Filter/Matches: //<small><<resultCount>> matches</small>//

View File

@ -0,0 +1,14 @@
title: $:/core/ui/DefaultSearchResultList
tags: $:/tags/SearchResults
caption: {{$:/language/Search/DefaultResults/Caption}}
\define searchResultList()
<$set name="resultCount" value="""<$count filter="[!is[system]search{$(searchTiddler)$}]"/>""">
{{$:/language/Search/Matches}}
</$set>
<$list filter="[!is[system]search{$(searchTiddler)$}sort[title]limit[250]]" template="$:/core/ui/ListItemTemplate"/>
\end
<<searchResultList>>

13
core/ui/SearchResults.tid Normal file
View File

@ -0,0 +1,13 @@
title: $:/core/ui/SearchResults
<div class="tc-search-results">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/SearchResults]!has[draft.of]butfirst[]limit[1]]" emptyMessage="""
<$list filter="[all[shadows+tiddlers]tag[$:/tags/SearchResults]!has[draft.of]]">
<$transclude/>
</$list>
""">
<<tabs "[all[shadows+tiddlers]tag[$:/tags/SearchResults]!has[draft.of]]" "$:/core/ui/DefaultSearchResultList">>
</$list>
</div>

View File

@ -15,18 +15,10 @@ title: $:/core/ui/SideBarLists
<$reveal state="$:/temp/search" type="nomatch" text=""> <$reveal state="$:/temp/search" type="nomatch" text="">
<div class="tc-search-results"> <$set name="searchTiddler" value="$:/temp/search">
{{$:/core/ui/SearchResults}}
<$set name="resultCount" value="""<$count filter="[!is[system]search{$:/temp/search}]"/>""">
{{$:/language/Search/Matches}}
</$set> </$set>
<$list filter="[!is[system]search{$:/temp/search}sort[title]limit[250]]" template="$:/core/ui/ListItemTemplate"/>
</div>
</$reveal> </$reveal>
<$reveal state="$:/temp/search" type="match" text=""> <$reveal state="$:/temp/search" type="match" text="">

View File

@ -0,0 +1,29 @@
created: 20141027151552783
modified: 20141027151947305
tags: [[Customise TiddlyWiki]]
title: Customising search results
type: text/vnd.tiddlywiki
By default, the results for the sidebar search box are displayed as a simple list of tiddler titles. The search results can be customised by adding plugin visualisations that show the search results in different ways. (Tabs are shown automatically if an additional search result visualisation is detected).
Search result visualisations are stored in tiddlers tagged [[$:/tags/SearchResults]]. The default search result listing is implemented in the system tiddler [[$:/core/ui/DefaultSearchResultList]].
To create a new search result visualisation:
# Create a new tiddler tagged [[$:/tags/SearchResults]]
# Use the widget variable ''searchTiddler'' to access the title of the tiddler containing the current search term
Here is an example of an alternative visualisation that displays results in reverse chronological order:
```
\define searchResults()
<$set name="resultCount" value="""<$count filter="[!is[system]search{$(searchTiddler)$}]"/>""">
{{$:/language/Search/Matches}}
</$set>
<<timeline subfilter:"!is[system]search{$(searchTiddler)$}">>
\end
<<searchResults>>
```