[Yanel-dev] easier way to view 'source' for resource-types: a bookmarket

Guillaume Déflache guillaume.deflache at wyona.com
Fri Mar 5 16:53:32 CET 2010


Hi!

Today I had enough fiddling with über-long URLs to add
yanel.resource.viewid=source to view the untransformed data, so I though
about creating a bookmarket for it.

Here it is (*):
javascript:(function()%7Bvar%20l=location,q=l.search,h=l.protocol+'//'+l.host+l.pathname+q+(q?'&':'?')+'yanel.resource.viewid=source',n=h.replace(new%20RegExp('[%3A/.?=&-]','g'),'_'),W=open(h,n);/*alert(n);*/W.focus();%7D)()
This works in Firefox, IE6 and IE7 AFAICS(*).


To use it, simply create a new bookmark with the above URL as link and
e.g. "Yanel RT 'source' view" as name.
When you will click on it on a suitage page(*), the 'source' view of the
resource-type associated with the page will be loaded in another window
(or tab depending on your browser configuration).
It should work with all kinds of URLs (not sure what will happen on
pages loaded through POST though), except it will remove the hash part
(#...) as it won't generally make sense for the 'source' view.
A neat thing IMHO is that only one window/tab will be loaded per URL
which you want the 'source' view for, e.g. you do not have to keep
closing many windows/tabs when keeping debugging the same page! :)

One could also adapt it to invoke the page info (?yanel.resource.meta) 
on realms where it is not already (easily) accessible from the toolbar.
Ditto for easily adding the toolbar (cf. 
http://lists.wyona.org/pipermail/yanel-development/2009-August/003978.html 
for the original feature request).
There are probably many other uses I did not think of! ;)


(*) Note to self: the regexp-replace hack is for MSIE which does not 
support many non-alphanumeric characters in window names (there are 
probably others that I haven't escaped yet).

(**): Calling this bookmarklet will only do something on a page generated
by a Yanel resource-type that define the 'source' view (preferably in a
meaningful way).
In general bookmarklets can not show if they are relevant in some given
context, i.e. on many pages some should really be disabled, but it's not
technically possible. So you just have to try for yourself, the best one
can do is make sure they don't break where they do not make sense.

HTH,
    Guillaume



More information about the Yanel-development mailing list