Mostrando entradas con la etiqueta html. Mostrar todas las entradas
Mostrando entradas con la etiqueta html. Mostrar todas las entradas

2007/09/22

XUL templates and tabs


I had some problems using XUL templates to populate a tabbox using a RDF data source: the tabs were created, but switching tabs did not work. Avoiding the use of inline templates and moving the template outside of the tabbox element solved this. Looks like the tabbox was confused by the <tabs> and <tabpanels> elements inside the <template> node.


<template id="tabTemplate">
<tabs>
<tab uri="rdf:*" label="rdf:http://multirunner.blah/rdf#name"/>
</tabs>
<tabpanels>
<tabpanel uri="rdf:*">
<label value="rdf:http://multirunner.blah/rdf#name"/>
</tabpanel>
</tabpanels>
</template>
<tabbox id="rdftabbox"
datasources="rdftabs.rdf"
ref="http://multirunner.blah/tabs"
template="tabTemplate" />

2007/08/04

SendTo Clipboard coolness (TiddlyWiki links to your files)

The SendTo folder is a simple and powerful tool to customize Windows Explorer to simplify some recurring tasks. If you often want to link to files in your PC from your TiddlyWikis, you'll like this hack. It creates two new items in the "Send To" menu:

  • clipboard - file url: Copies to the clipboard the file: url of the file or folder that was showing the "Send To" menu
  • clipboard - new tiddler javascript url: Copies to the clipboard a javascript: url that, when pasted into the address bar of a Firefox tab showing a TiddlyWiki, will create a tiddler with the contents of the file that was showing the "Send To" menu

You can jump and just download and run the thing, a small .hta file, or take less than three minutes watching it in action in one of the lamest screencasts ever:

SendTo Clipboard Screencast from Xavier Vergés and Vimeo

Using it
  • Just download the .hta file and open it. No, wait! Never open .hta files unless you trust its author or you have taken a look at the code.
  • Provided that you trust me or that you have checked the code, you can now open it. Maybe a double click will be enough (your Windows associates .hta files to mshta.exe, a version of IE with high security privileges in your machine). Maybe you need to use the command line and type mshta path2twlink.hta.
  • Follow the simple steps described in the .hta file, and you can start using your new shinny Send To menu items.
  • You are expected to edit the file to customize what gets copied into the clipboard. It should be easy. You may get ideas to push the sendto+clipboard+javascript urls concept further; adding them to the tool should not be too hard.
  • You are also expected to do some dancing, since this is DanceLikeMattHardingWare.
Lessons learned while hacking
  • I initially wanted to use just a .js file. Getting access to the clipboard from a .js file is hard, so I went for an .hta. It turned out to be a good thing, because it ended up providing a way to avoid to the users the trouble of creating the shortcuts by hand and to me the trouble of documenting the recipe.
  • The problem of using an .hta file is that I found no way to keep it invisible, that it has an unusual way to receive its params, and that I had to warn you about its dangerousness.
  • I think that I've spent more time recording the lousy screencast and comparing video hosting services that coding. The number of times that I rerecorded the #@%! thing will remain undisclosed; I have my pride. Regarding the hosting services, after reading about them, I posted the video to google, blip.tv and vimeo.
    I still have no winner, but google's video quality was awfull, so I had to drop it despite its super cool feature of letting you link to a specific point of the video.
    Update: looks like the winner is http://viddler.com: links, comments and tags on specific points of the video, plus the best player of all (in full screen mode, showing the original size, the quality was just perfect): http://www.viddler.com/explore/xdexavier/videos/1

2007/01/09

My browser, my rules, my chrome

Summary: there are times when Firefox security gets in your way. Having a directory where you can place xul, html and scripts to run with chrome privileges enables you to shoot yourself in the foot and to create nice and handy hacks.

The itch that called for scratching: I wanted to hack something to let me upload several files at once to googlepages [1]. The problem is that, for very good reasons, you can not use JavaScript to change the value of input fields of type file: you usualy don't want scripts reading files in your disk. So, a bookmarklet, that to the browser looks as if it were part of the page, wouldn't cut it. Greasemonkey userscripts do run sandboxed, but not under chrome privilege [2], so I did not try that. I tried to give the page UniversalFileRead privilege [3][4], but failed.

A chrome folder. From Under chrome's influence, slightly modified,


In the browser's installation directory, create a new file chrome/mychrome.manifest and put a single line into it:
content mychrome file:///D:/whatever/mychrome/
Note that the trailing slash is significant. Then create the file D:\whatever\mychrome\hello.txt and add some text:
hello world!
After a complete restart of your browser, you can open that file using chrome://mychrome/content/hello.txt.
You need to keep in mind that chrome is catched, so you may not see the changes you make immediately. Setting nglayout.debug.disable_xul_cache to true [5] or the Extension Developer's Extension ability to reload chrome without restarting the browser are helpful here.

Future plans:
  • the bulk upload to googlepages is working nicely; needs some docu before uploading it.
  • I want to have a browser window with chrome privileges so that I can have more freedom of what I can do with some file: urls. Specifically
    • have known tiddlywikis granted UniversalXPConnect privilege without having to grant it to everything from file: and without having to mess with the capability.principal.codebase annoyance.
    • have local files use a script loaded from the web, or have a remote file load a script from my disk, so that I don't have to upload files while writing/debugging javascript.
Footnotes:
[1] googlepages: yeah, I know, I'm cheap!
[2] Mark Pilgrim's slides on sandboxing greasemonkey have a wonderful "how to become an expert" detour. Don't miss it.
And, just in case you are a powerpoint author, consider S5 (a Simple Standards-Based Slide Show System), the tool used for Mark's slides.
[3] UniversalFileRead: I added to my user.js
user_pref("capability.principal.codebase.googlepages1.granted", "UniversalFileRead");
user_pref("capability.principal.codebase.googlepages1.id", "http://pages.google.com/");
but still got a security exception.
[4] Highlighted link thanks to http://citebite.com.
[5] nglayout.debug.disable_xul_cache: I haven't tried it. As I write this,I realize that my user.js sets it to true while my prefs.js ignores it and keeps it to false. I'm clueless here. Update: A ";" was missing at the end of its user_pref line. Life is much better with this setting enabled!

2006/12/05

dW chats: Making the move to Ajax

IBM Rational's Bill Higgins will be the moderator of a developerWorks chat on Ajax. to be held on Wednesday December 6th at 1pm his time or 7pm my time. I was not aware of these dW chats going on (this is the second one, as far as I've seen).