[Yanel-dev] easier way to view 'source' for resource-types: a
bookmarket
Guillaume Déflache
guillaume.deflache at wyona.com
Wed May 26 14:17:58 CEST 2010
Hi!
Guillaume Déflache schrieb:
> 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! ;)
Here is a better version of this bookmarklet updated not to include the
toolbar (as it pops up in the middle of (X)HTML source data, as it should):
javascript:(function()%7Bvar%20l=location,q=l.search,h=l.protocol+'//'+l.host+l.pathname+q+(q?'&':'?')+'yanel.resource.viewid=source&yanel.toolbar=suppress',n=h.replace(new%20RegExp('[%3A/.?=&-]','g'),'_'),W=open(h,n);/*alert(n);*/W.focus();%7D)()
So, in Web 1.0 style: "please update your bookmarklets"! :)
> (*) 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).
Since then I have come across several resource-types that use a 'xml'
view which looks pretty similar to the 'source' view: maybe we should
standardize on the source-view ID (I suggest 'source' ;) of course) or
else add the 'source' view too when the 'xml' view has some other meaning.
> 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
>
Cheers,
Guillaume
More information about the Yanel-development
mailing list