Function Hijacking of TiddlyWiki.prototype.reverseLookup

10 views
Skip to first unread message

Clint Checketts

unread,
Sep 6, 2005, 7:41:50 PM9/6/05
to TiddlyWikiDev
I want to extend the TiddlyWiki.prototype.reverseLookup method,
however, the typical technique doesn't seem to work. Any tips?

-Clint

Jeremy Ruston

unread,
Sep 6, 2005, 7:58:15 PM9/6/05
to Tiddly...@googlegroups.com
Because it's a prototype method, I think you'll need to do something like:

store.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
{
// ...
// Call the old implementation
TiddlyWiki.prototype.reverseLookup(lookupField,lookupValue,lookupMatch,sortField)
// ...
}

I haven't tested this, though.

Cheers

Jeremy
--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

Clint Checketts

unread,
Sep 7, 2005, 12:16:15 PM9/7/05
to Tiddly...@googlegroups.com
As a followup, Jeremy's technique does work, however the prototype functions all reference the 'this' keyword so I need a way to grab the 'this' again.

-Clint

Tim Morgan

unread,
Sep 7, 2005, 4:34:56 PM9/7/05
to TiddlyWikiDev
I do this kind of thing a lot in ZiddlyWiki...

TiddlyWiki.prototype._reverseLookup =
TiddlyWiki.prototype.reverseLookup;
TiddlyWiki.prototype.reverseLookup =


function(lookupField,lookupValue,lookupMatch,sortField) {
// ...
// Call the old implementation

results =
this._reverseLookup(lookupField,lookupValue,lookupMatch,sortField)
// ... do something with results (or not)
}

If that doesn't work, you might try using the JavaScript call() method:

store.reverseLookup =
function(lookupField,lookupValue,lookupMatch,sortField) {
// ...
// Call the old implementation

TiddlyWiki.prototype.reverseLookup.call(this,lookupField,lookupValue,lookupMatch,sortField)
// ...
}

Jonathan Ploudre

unread,
Sep 7, 2005, 5:25:04 PM9/7/05
to Tiddly...@googlegroups.com
A while back I modified TW to not do live searching to make it more responsive with a TW I have with ~1500 Tiddlers. That tiddler is a great reference that I use all the time and would like to be able to search it from other pages or Tiddlywikis.

Is there a way to have TiddlyWiki receive a posting from a html form on another page/across the web. When I try to permaview a search, I get the results as the URL, not the 'query' that produced them. It looks like all the search goodness is embedded in the javascript search function. How would I send something to it across the web...?

Jonathan

Keith Hodges

unread,
Sep 8, 2005, 10:39:52 PM9/8/05
to Tiddly...@googlegroups.com
Dear Jonathan,
 
I think that the answer is not yet. The url is currently parsed assuming that the user is supplying a list of tiddlers. In my code I will be wanting to make some modifications to supply other parameters though I havent considered what the syntax might be as yet, so I think that some discussion could be in order.
I think the usual syntax for a url is something like this
 
url#anchor?param=value&param2=value1
 
currently the 'anchor' field is used to pass in the list of tiddlers to be viewed, and there is no code to handle input/form parameters.
 
I want to have the user be able to select a named wiki, one of several contained in a single TW file, and supply a list of tiddlers to display, but I would like the named wiki to be earlier in the url rather than later... to do this I think that the result would end up looking something like this.

Daniel Baird

unread,
Sep 9, 2005, 1:24:26 AM9/9/05
to Tiddly...@googlegroups.com

So, to solve the original problem, what we need is a macro or something, that you can put into a tiddler that does a live search when the tiddler is opened.  Then Jonathan could create a tiddler called "HowCoolArePirates" (for example), with contents something like:

!How much do pirates rock?

Here's everything I know about pirates:

<<liveSearch pirate>>

and the liveSearch macro would run a search on the word "pirate" or whatever and either show the search results inside the tiddler, as tiddler titles, or even open all the matching tiddlers up like a normal search does.

Then Jonathan just has to permalink to the HowCoolArePirates tiddler, and everyone's happy.

So there you are chaps -- a feature request.. at the speed TiddlyWiki development goes, I expect this to be on my desk by the morning :)


Daniel
--
Daniel...@graduates.jcu.edu.au

christianhauck

unread,
Sep 9, 2005, 3:45:30 AM9/9/05
to TiddlyWikiDev
in my old adaptation, based upon version 1.2.6 (stone age), I modified
the parser to accept other meanings of the url:, e.g. it could be a
search string or a tiddlergroup or all tiddlers created at a given
date.
For a description, see
http://www.christianhauck.net/html/14300.html#ExternalControl
To see it working, see
http://www.christianhauck.net/html/14300.html#*text

Steve Rumsby

unread,
Sep 9, 2005, 4:41:44 AM9/9/05
to Tiddly...@googlegroups.com
On 09/09/05, Daniel Baird <danie...@gmail.com> wrote:
>
> So, to solve the original problem, what we need is a macro or something,
> that you can put into a tiddler that does a live search when the tiddler is
> opened. Then Jonathan could create a tiddler called "HowCoolArePirates"
> (for example), with contents something like:
>
> !How much do pirates rock?
>
> Here's everything I know about pirates:
>
> <<liveSearch pirate>>
>
> and the liveSearch macro would run a search on the word "pirate" or
> whatever and either show the search results inside the tiddler, as tiddler
> titles, or even open all the matching tiddlers up like a normal search does.
>
> Then Jonathan just has to permalink to the HowCoolArePirates tiddler, and
> everyone's happy.
>
Something a bit like this, perhaps? (watch those line breaks when you
cut'n'paste...)

// //''Name:'' liveSearch macro
// //''Version:'' <<getversion liveSearch>> (<<getversiondate
liveSearch "DD MMM YYYY">>)
// //''Author:'' SteveRumsby

// //''Syntax:''
// //<< {{{liveSearch //string//}}} >> or << {{{liveSearch //string//
//prefix//}}} >>

// //''Description:''
// //The first produces a simple list of tiddlers, one per line, that
match //string//. The usual search rules apply, including the regexp
search option.
// //The second produces the same list, but with //prefix// before
each tiddler and with the result being wikified, so that a prefix of
//*// will
// //produce a bullet list, etc.

config.macros.liveSearch = {};

version.extensions.liveSearch = { major: 0, minor: 1, revision: 0,
date: new Date(2005, 08, 09)};

config.macros.liveSearch.handler = function(place,macroName,params)
{
var matches = store.search(params[0],
config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch,"title","excludeSearch");
var string = "";
for(var r=0;r<matches.length;r++) {
if(params[1]) string = string + params[1] + " ";
string = string + "[[" + matches[r].title + "]]\n";
}
wikify(string, place, null, null);
}

This produces a simple list of tiddlers, a la listTags. It would be
easy enough to produce a version that opened them all instead, or even
a macro that gave you the choice...

> So there you are chaps -- a feature request.. at the speed TiddlyWiki
> development goes, I expect this to be on my desk by the morning :)
>
Happpy to oblige...:-)

Steve.
--
Steve Rumsby

Jonathan Ploudre

unread,
Sep 9, 2005, 3:53:10 PM9/9/05
to Tiddly...@googlegroups.com
I'm still figuring out how this would work. What I'd like to do is search a different TiddlyWiki that the one I'm currently in. (Admittedly that macro seems useful, too. I'll have to think about how I'd use it.)

When I was reading Google Hacks, I learned that you can create a pretty simple form to send a complex query to Google. I used it to search for pdf files. Essentially what I'm thinking is inserting a second search box that would open up a different Tiddlywiki and run that search. Perhaps I can do this with GreaseMonkey/Javascript?

Man, I'm still freaked out about how easily great useful bits are being added to TiddlyWiki!

Jonathan

Keith Hodges

unread,
Sep 10, 2005, 9:03:05 PM9/10/05
to Tiddly...@googlegroups.com
Freaked out! Me too, its driving me nuts trying to keep up while trying to code some cool features that will not pluginize
 
patience is needed I think
 
Keith

artm

unread,
Sep 11, 2005, 8:08:57 AM9/11/05
to TiddlyWikiDev
Sorry for being offtopic and silly, but [I just noticed] [1] that
google comes up with weird ads in this topic.

anti-offtopic: the hyperlinking style I used here is from [markdown]
[2]. I find some bits of markdown (backticks for code, reference style
hyperlinking like above and ![images like this] [3]) very nice and
consider adding a plugin for them (maybe based on [js-markdown] [4] if
the site comes back up)

[1]: http://www.artm.org/?p=18 "AdSense on artm.org"
[2]: http://daringfireball.net/projects/markdown "Markdown: a
text-to-HTML conversion tool for web writers. "
[3]: http://www.flickr.com/photo_zoom.gne?id=42258050&size=o "full
resolution screenshot of the AdSence weirdness"
[4]: rephrase.net/box/js-markdown/ "JavaScript implemenation of a
subset of markdown syntax"

Paul Petterson

unread,
Sep 11, 2005, 11:24:30 AM9/11/05
to Tiddly...@googlegroups.com
that is pretty funny!

Daniel Baird

unread,
Sep 11, 2005, 9:20:16 PM9/11/05
to Tiddly...@googlegroups.com

I misunderstood your request Jonathan -- i thought you wanted to link to the live results of a specific, pre-determined search, from outside (which Mr Rumsby kindly provided a few hours later -- cheers Steve).

What you actually want (if i understand correctly) is, given two tiddlywikis TW1 and TW2:
- in TW1, have a place to type text, and a search button
- when you click Search, open TW2 and run a search in TW2 for the text you typed into the text box in TW1

That seems a bit harder, and I think Christian's right, the sensible way to do it would be to use some kind of addition to the url (as you point out in your original post :).

If you just want it for yourself, it's probably not too hard to kludge something up in greasemonkey.  Otherwise I guess there will need to be something that gets notified on open, like refreshTitle() etc.  I'm sure when Jeremy finally writes his developer's book on TiddlyWiki there'll be a chapter on doing stuff when the page opens..

Anyway I already know I won't have time to do any coding so this is all just blather.  I'lll cross my fingers that someone else gets inspired..

d
--
Daniel...@graduates.jcu.edu.au

christianhauck

unread,
Sep 12, 2005, 4:47:09 AM9/12/05
to TiddlyWikiDev
really weird, looks like it was my entry (#12) above. Might b ebecause
of the words "External control", that it triggers "animal repellent"?
And even stranger: years ago, in my job (drug metabolism studies), I
was indeed analysing the contents of animal and human urine!

Jonathan Ploudre

unread,
Sep 18, 2005, 1:23:27 AM9/18/05
to Tiddly...@googlegroups.com
I was reading today and found out about the location.search part of javascript. Apparently you can create a simple form that will add your search term to the URL (in TiddlyWiki 1) and then get that search term back in Tiddlywiki 2 using location.search.

Since I'm not a real programmer, it may take a little time to figure out how to get the search part of tiddlywiki to use that as the search term.

http://www.eggheadcafe.com/articles/20020107.asp

has some examples of ways to can get data into another page.

Jonathan
Reply all
Reply to author
Forward
0 new messages