/*** |Name|TwHelpSearchPlugin| |Source|http://twhelp.tiddlyspot.com/#TwHelpSearchPlugin| |Documentation|http://twhelp.tiddlyspot.com/#TWHelpSearchDoc| |Version|1.0.8| |Author|Morris Gray| |License|http://www.TiddlyTools.com/#LegalStatements <br>and [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]| |~CoreVersion|2.0 - 2.4| |Type|plugin| |Requires|[[SearchOptionsPlugin|http://www.TiddlyTools.com/#SearchOptionsPlugin]] [[TableSortingPlugin|http://tw.lewcid.org/#TableSortingPlugin]] (only for sorting option)| |Overrides|SearchOptionsPlugin's search results| |Description|Extends the search results from SearchOptionsPlugin to a sortable table showing title, size and tags.| ''Demo search:'' |>|>|>|<<search>> | |>|>| look for in |>|>|>| | <<option chkSearchTitles>> | <<option chkSearchText>> | <<option chkSearchTags>> | <<option chkHoldSearches>> | | titles | text | tags | hold | ''A Plugin Tweak for:'' SearchOptionsPlugin !!!!!Description <<< This plugin defines an alternative format for the SearchResults tiddler that is generated by the SearchOptionsPlugin . It presents the search results in tabular form numbering the rows; and showing the tiddler title, the size in bytes, and the tags. It is ready to be used with the [[TableSortingPlugin|http://tw.lewcid.org/#TableSortingPlugin]] (check versions) so any column can be sorted; such as size in ascending or descending order. <<< !!!!!Installation <<< Import (or copy/paste) the following tiddlers into your ~TiddlyWiki: * http://twhelp.tiddlyspot.com/#TwHelpSearchPlugin *SearchOptionsPlugin from http://www.tiddlytools.com/#SearchOptionsPlugin * Get more documentation here [[TWHelpSearchDoc]] or here: * http://twhelp.tiddlyspot.com/#TwHelpSearchDoc <<< !!!!!Revision History <<< ''2009.02.18 [1.0.8]'' Added modified column. ''2009.02.18 [1.0.7]'' Removed text coloring of headers re: conflict with TableSortingPlugin refresh. ''2008.09.14 [1.0.6]'' Cosmetic - Add header. ''2007.09.12 [1.0.6]'' Added overflow scroll to TWHelp-SearchResults for long titles or tags. ''2006.02.03 [1.0.5]'' Added facility for holding the results of multiple searches with tick box on dashboard. ''2006.02.02 [1.0.4]'' Added several options, cleaned up design.Planning one version basic and one with added options this is the added options version. ''2006.01.27 [1.0.3'' Added a column for the size of the text in each tiddler, this does not include the size of the title or tags. Added overall TW statistics button requires TiddlerStatsPlugin. ''2006.01.23 [1.0.2 ]'' ''a)''Changed function reportSearchResults(text,matches) to window.reportSearchResults=function(text,matches) ''b)''Added a line so that Incremental Search is automatically disabled config.options.chkSearchIncremental=false; turn off key-by-key searching ''c)''Removed space inside parens. bgcolor(#fe8 )" to "bgcolor(#fe8)". This is what was causing IE to 'crap out' halfway through drawing the table headings. ''d)''Added {{{config.options.chkSearchList=true;}}} ''2006.01.20 [1.0.1]'' ELS: reportSearchResults() definition moved to this Plugin Tweak tiddler and removed extranous code ''2006.01.19 [1.0.0]'' This is an adaptation of Eric Shulman's SearchOptionsPlugin. Adapted by MorrisGray to provide search results in table form. All the necessary controls for refining the search is provided within the table including slide-down access to AdvancedOptions. <<< !!!!!Code ***/ //{{{ if (config.options.chkSinglePageMode==undefined) config.options.chkSinglePageMode=false; if (config.options.chkRegExpSearch==undefined) config.options.chkRegExpSearch=true; if (config.options.chkSearchTitles==undefined) config.options.chkSearchTitles=false; if (config.options.chkSearchText==undefined) config.options.chkSearchText=true; if (config.options.chkSearchTags==undefined) config.options.chkSearchTags=false; if (config.options.chkSearchTitlesFirst==undefined) config.options.chkSearchTitlesFirst=true; if (config.options.chkSearchList==undefined) config.options.chkSearchList=true; if (config.options.chkSearchIncremental==undefined) config.options.chkSearchIncremental=false; if (config.options.chkToggleLinks==true) config.options.chkToggleLinks=false; if (config.options.chkHoldSearches==undefined) config.options.chkHoldSearches=false; if (config.options.chkSortTags==undefined) config.options.chkSortTags=false; config.options.chkToggleLinks=false; config.options.chkSinglePageMode=false; config.options.chkHoldSearches=false; config.options.chkSearchIncremental=false; config.options.chkHttpReadOnly = false; config.options.chkRegExpSearch=true; config.options.chkSearchList=true; config.options.chkToggleLinks=false; config.shadowTiddlers.AdvancedOptions += "\n<<option chkHoldSearches>> Hold search results"; //}}} //{{{ // Give the report a custom name config.macros.search.reportTitle="TWHelp-SearchResults"; // Override default SearchOptionsPlugin formatting for SearchResults tiddler window.reportSearchResults=function(text,matches) { var title=config.macros.search.reportTitle config.macros.search.reportTitle; var q = config.options.chkRegExpSearch ? "/" : "'"; if (!config.options.chkHoldSearches) body=""; body+="\n|>|bgcolor:#4c4c4c;@@color(#ccc):''"+config.macros.search.successMsg.format([matches.length,q+"{{{"+text+"}}}"+q])+"''@@|bgcolor:#4c4c4c; @@color:#ffffc8; Ver: <<version>>@@ "+"|"+"\n"; body+="|>|>|bgcolor:#999;color:#000;<<search>> <<option chkSearchTitles>> Titles <<option chkSearchText>> Text <<option chkSearchTags>>Tags <<option chkHoldSearches>> Hold |"+"\n"; body+="\n|bgcolor:#4c4c4c; |bgcolor:#4c4c4c; ''Titles'' |bgcolor:#4c4c4c; ''Size'' |bgcolor:#4c4c4c; ''Tags'' |bgcolor:#4c4c4c; ''Modified'' |h"; for(var t=0;t<matches.length;t++) body+="\n"+"| "+(t+1)+"|[["+matches[t].title+"]]| "+matches[t].text.length+"|"+matches[t].tags+"|"+matches[t].modified.formatString('YYYY.0MM.0DD')+"|"; body+="\n|sortable|k"; body+="\n"; // create/update the tiddler var tiddler=store.getTiddler(title); if (!tiddler) tiddler=new Tiddler(); tiddler.set(title,body,config.options.txtUserName,(new Date()),"excludeLists excludeSearch killbookmark"); store.addTiddler(tiddler); story.closeTiddler(title); // render tiddler var oldprompt=config.macros.search.label; config.macros.search.label="search again"; // use alternate "search again" label story.displayTiddler(null,title,1); // force refresh config.macros.search.label=oldprompt; // restore standard search label } //}}}