On Thursday, June 4, 2020 at 5:15:34 PM UTC-7, TonyM wrote: > > Once again inspired by you work, I recall that on > https://www.w3schools.com/ a search is "enhanced by Google" and the > results appear in a drop down. > I wonder if we could develop this for tiddlywiki? >
Here's yet another version. This one skips the Google search input page, and goes directly to the search results. <$edit-text tiddler="$:/temp/google" tag="input" placeholder="enter search text" default="" /> <$vars keywords={{{ [<currentTiddler>] +[addsuffix[+]] +[addsuffix{$:/temp/google}] +[split[ ]join[+]] }}}> <$vars URL={{{ [[https://www.google.com/search?q=]] +[addsuffix<keywords>] }}}> <$button message="tm-open-external-window" param=<<URL>>> {{$:/core/images/advanced-search-button}} </$button> </$vars> </$vars> Note that this version uses $vars widgets to construct the desired search keywords and the URL before opening the external window. This was not, strictly speaking, *necessary*, but was done to make the code more readable. enjoy, -e > > > Regards > Tony > > On Friday, June 5, 2020 at 10:00:56 AM UTC+10, Eric Shulman wrote: >> >> On Thursday, June 4, 2020 at 1:17:55 PM UTC-7, Eric Shulman wrote: >>> >>> This might help get you in the right direction: >>> \define google(term) >>> <a href={{{ [[https://www.google.com?q=$(currentTiddler)$+$term$]split[ >>> ]join[+]] }}} target="_blank">$term$</a> >>> \end >>> >> >> Here's another version that doesn't need to define a macro and also >> provides an input field for the search term: >> <$edit-text tiddler="$:/temp/google" tag="input" placeholder="enter >> search text" default="" /> >> <$button message="tm-open-external-window" param={{{ [[ >> https://www.google.com?q=]] +[addsuffix<currentTiddler>] +[addsuffix[+]] >> +[addsuffix{$:/temp/google}] +[split[ ]join[+]] }}}> >> search >> </$button> >> >> 1) Define a tiddler (e.g., "Google") containing the above code >> 2) Create any other tiddler containing the following: >> {{||Google}} >> >> How it works: >> * As with the previous macro version, the desired URL is constructed >> using the currentTiddler value >> * Instead of using a macro parameter to insert the search term, and >> $edit-text widget is used to save the term input into a temporary tiddler, >> $:/temp/google >> * The contents of $:/temp/google are appended to the constructed URL >> * A $button widget is used to open a new 'external' browser window with >> the fully constructed URL >> >> To use it: >> * Instead of invoking a macro (i.e., <<google ...>>), transclusion is >> used (i.e., {{||Google}} to display the input field and button >> * Note the use of || in the transclusion. This allows the *context* of >> the containing tiddler to be applied, which means that the value of >> currentTiddler is the title of the tiddler in which the transclusion >> occurs, rather than the title of the tiddler in which the input field and >> button are defined. >> >> Again, let me know how it goes... >> >> enjoy, >> -e >> >> >> -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/920b0cd8-efa6-4c5d-9402-0a68386d5f30o%40googlegroups.com.