For some reason I got the idea that importing my Firefox bookmarks.html into a TiddlyWiki would be a good idea. I know its just a .html file and that I could just open it in a text editor and paste it inside a TiddlyWiki tiddler and be done with it.

Deciding against the easy option, I decided to have the bookmarks.html file process its self by adding some JavaScript to it. After making a copy of my bookmarks.html file I added this code to the top of the file:



<SCRIPT LANGUAGE="JavaScript">

var theOutput="";

function run_me()

{

    myDiv=document.getElementById("my_div");

    theOutput="";

    theDL=document.getElementsByTagName('dl')[0];

    theOutput="";

    walkBookmarks(theDL);

    myDiv.innerHTML="<textarea cols=\"80\" rows=\"20\">"+theOutput+"</textarea>";

}

function walkBookmarks(node)

{

    if (node.nodeName =="H3")

    {

        theOutput +="!"+node.firstChild.nodeValue+"<br>\n";

    }

    if (node.nodeName =="A")

    {

        theURL = node.href;

        theText=node.firstChild.nodeValue;

        theOutput += "[["+theText+"|"+theURL+"]]<br>\n";

    }

    if (node.childNodes != null)

    {

        for (var i=0; i < node.childNodes.length; i++)

        {

            walkBookmarks(node.childNodes.item(i));

        }

    }

}

</SCRIPT>

<div id="my_div">Working....</div>

And this code to the end of the file:



<script language="JavaScript">

run_me();

</script>

Which will give wiki formatted text like this:



!Bookmarks Toolbar Folder<br>

[[UnfocusedBrain.com -|http://www.unfocusedbrain.com/]]<br>

[[[Yahoo!]|http://www.yahoo.com/]]<br>

Works pretty nice.

My second attempt was to try using “rdf:bookmarks” as described in the RDF in Mozilla FAQ on the developer website. I really didn’t make much headway with this method. If I were to develop a plug-in for TiddlyWiki that works w/ Firefox’s built in bookmarks this would definitely be the way to go.

My third attempt was to use the ExternalTiddlersPlugin by Eric Shulman. Which allowed me to just put one line in a tiddler and have the bookmarks show up:

<<tiddler "file:///home/username/.mozilla/firefox/l3qbefb3.default/bookmarks.html">>

It almost worked. Since the bookmarks isn’t a really well formed html file it doesn’t come through the tiddly process very well. So I just added a couple lines of code to add around the file and it worked perfectly.



function my_textprocess(text)

{

    text = "<html>" + text + "</html>";

    return text;

}

With this method the links reflect the non editable nature of the real bookmarks from the TiddlyWiki.

In the end I’m not entirely satisfied with any of these methods. What I would like to make would be a plug-in to TiddlyWiki that will open the “rdf:bookmarks” interface. For each folder in the bookmarks it would create a new tiddler and under each tiddler would be the links. In addition to this I would like to add a Bookmarklet to add links to the wiki instead of the real bookmarks.

Tiddly.