diff --git a/core/language/en-GB/Search.multids b/core/language/en-GB/Search.multids index 4f2bf186a..d8d7ae3d7 100644 --- a/core/language/en-GB/Search.multids +++ b/core/language/en-GB/Search.multids @@ -1,5 +1,6 @@ title: $:/language/Search/ +DefaultResults/Caption: List Filter/Caption: Filter Filter/Hint: Search via a [[filter expression|http://tiddlywiki.com/static/Filters.html]] Filter/Matches: //<> matches// diff --git a/core/ui/DefaultSearchResultList.tid b/core/ui/DefaultSearchResultList.tid new file mode 100644 index 000000000..e5972af8f --- /dev/null +++ b/core/ui/DefaultSearchResultList.tid @@ -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}} + + + +<$list filter="[!is[system]search{$(searchTiddler)$}sort[title]limit[250]]" template="$:/core/ui/ListItemTemplate"/> +\end +<> diff --git a/core/ui/SearchResults.tid b/core/ui/SearchResults.tid new file mode 100644 index 000000000..93acc607c --- /dev/null +++ b/core/ui/SearchResults.tid @@ -0,0 +1,13 @@ +title: $:/core/ui/SearchResults + +
+ +<$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/> + +"""> +<> + + +
diff --git a/core/ui/SideBarLists.tid b/core/ui/SideBarLists.tid index afbbd02e3..4522b1b41 100644 --- a/core/ui/SideBarLists.tid +++ b/core/ui/SideBarLists.tid @@ -15,18 +15,10 @@ title: $:/core/ui/SideBarLists <$reveal state="$:/temp/search" type="nomatch" text=""> -
- -<$set name="resultCount" value="""<$count filter="[!is[system]search{$:/temp/search}]"/>"""> - -{{$:/language/Search/Matches}} - +<$set name="searchTiddler" value="$:/temp/search"> +{{$:/core/ui/SearchResults}} -<$list filter="[!is[system]search{$:/temp/search}sort[title]limit[250]]" template="$:/core/ui/ListItemTemplate"/> - -
- <$reveal state="$:/temp/search" type="match" text=""> diff --git a/editions/prerelease/tiddlers/Customising search results.tid b/editions/prerelease/tiddlers/Customising search results.tid new file mode 100644 index 000000000..0816c7061 --- /dev/null +++ b/editions/prerelease/tiddlers/Customising search results.tid @@ -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}} + + +<> +\end +<> +``` +