For 12 months I’ve been using Netvibes to store bookmarks. A few weeks ago I started using Del.icio.us, which is also integrated into Netvibes. Now I had two sets of bookmarks. That’s one too many. Time to retire the Netvibes bookmark module, but how do I migrate/export the netvibes bookmarks, and how do I upload them to Del.icio.us?
“How to export Netvibes bookmarks?”
Exporting Netvibes bookmarks is a major request on their forum, so here is the answer.
- Login to Netvibes
- Go to address: http://www.netvibes.com/modules/bookmarks/getUserBookmarks.php?nocache=0
- Save the XML as
netvibes_bm.xml
The XML should look something like:
<result>
<link id="4401802" title=".htaccess generator" url="http://www.tools.dynamicdrive.com/password/" tags="unix"/>
<link id="6444925" title="19 Rails Tricks Most Rails Coders Don't Know" url="http://www.rubyinside.com/19-rails-tricks-most-rails-coders-dont-know-131.html" tags="RoR"/>
<link id="4436310" title="37signals - the tools we use ourselves" url="http://37signals.com/svn/archives2/the_tools_we_use_to_run_and_build_37signals.php" tags="business, ideas, RoR"/>
...
</result>
Note that your Netvibes tags are included. These will be uploaded into Del.icio.us too.
“How to upload Del.icio.us bookmarks?”
Now you are ready to upload these bookmarks into Del.icio.us (or modify it yourself to upload it wherever you want). I’ve written a script to do this using the Ruby programming language (dowload and install instructions here). Why? Because it took 10 minutes to do so. Feel free to rewrite it if you really want, but it’d be quicker to install Ruby, run the script, and move on with your life
- Install Ruby
- Install Hpricot [1]: type
gem install hpricot (select the win32 version if you are on windows)
- Download the netvibes_delicious.rb script [2]
- Change the
username and password values in the script to your del.icio.us username/password.
- Execute the script:
ruby netvibes_delicious.rb netvibes_bm.xml
- The script will tell you how many bookmarks it will be uploading to Del.icio.us, and ask you to press return to continue. Press Ctrl-C to kill the script.
If you want to “test” the script first, create a copy of your netvibes_bm.xml file, and cut away all the <link ... > tags, except one or two. Check that the script works on these few bookmarks first, then rerun the script on the original file.
Now add the Del.icio.us module into Netvibes and remove the original Bookmarks module.
Tally ho.
[1] Hpricot is a brilliant library for parsing and processing HTML/XML data.
[2] The contents of the script:
['rubygems', 'hpricot', 'open-uri', 'net/https', 'cgi'].each {|lib| require lib}
# Netvibes bookmarks XML file
file = ARGV.shift
bookmarks = []
page = Hpricot(open(file))
page.search("//link").each do |link|
bookmarks << {
:title => link.get_attribute("title"),
:description => link.get_attribute("title"),
:url => link.get_attribute("url"),
:tags => link.get_attribute("tags").split(', ').join(" "),
:shared => "yes"
}
end
puts "Transferring #{bookmarks.length} bookmarks to Del.icio.us"
puts "Do it?"; gets
# Del.icio.us target for bookmarks
username = "" # your del.icio.us username
password = "" # your del.icio.us password
resp = href = "";
bookmarks.each do |bookmark|
begin
http = Net::HTTP.new("api.del.icio.us", 443)
http.use_ssl = true
http.start do |http|
pp bookmark
req = Net::HTTP::Post.new("/v1/posts/add",
{"User-Agent" => "drnicwilliams.com Netvibes to Delicious"})
req.basic_auth(username, password)
req.set_form_data bookmark
response = http.request(req)
resp = response.body
puts "#{Hpricot(resp).search('/result').first.get_attribute('code').humanize} -> #{bookmark[:title]}"
end
rescue SocketError
raise "Host " + host + " not accessible"
end
end
As a follow-up to the recent “Spy on the Japanese” post, you might want a nice set of links for your visitors to translate your page sinto their language.
But, here are your requirements (I can read your mind, I’m a doctor):
- You know what countries visit your site, so you want to configure it yourself.
- Since it requires Javascript to be turned on for it to work, you don’t want the links to show if the visitor doesn’t.
Solution: create the links using Javascript.
To allow translations of your blogs/websites via Google Translation, add the following inline Javascript into the sidebar. It was designed for WordPress – you may need to twiddle with the DOM elements created and/or CSS if it looks bad on your site.
The flags can be found at: http://www.famfamfam.com/lab/icons/flags/, and I’ve assumed you’ll store the png images in the /images/flags/ folder. If you store them somewhere else, change the images variable at the top of the script.
So, paste this script into your sidebar and you are saying “Aliens Welcome Here” [1].
<script>
// Each lang in an array: [google lang code, flag name, language name]
// Flags available at: http://www.famfamfam.com/lab/icons/flags/
var to_langs = [['ja', 'jp', 'Japanese'],
['de', 'de', 'German'],
['es', 'es', 'Spanish']];
var from_lang = 'en';
var images = '/images/flags/';
document.write("<li id='translation'></li>");
var liDiv = document.getElementById('translation');
var title = document.createElement("h2");
title.appendChild(document.createTextNode("Translation"));
liDiv.appendChild(title);
var ulDiv = document.createElement("ul");
liDiv.appendChild(ulDiv);
for (var i=0; i < to_langs.length; i++) {
var to_lang = to_langs[i][0];
var flag = to_langs[i][1];
var name = to_langs[i][2];
liDiv = document.createElement('li');
ulDiv.appendChild(liDiv);
liDiv.innerHTML = "<a href='#' onclick=\"location.href=" +
"'http://translate.google.com/translate?langpair=" +
from_lang + "&" + to_lang + "&hl=" + to_lang +
"&ie=UTF-8&oe=UTF-8&u='" +
" + encodeURIComponent(location.href)\">" +
"<img border=0 src='" + images + flag + ".png' /> " + name + "</a>";
}
var getme = "<a href='http://drnicwilliams.com/2006/08/30/foreign-tourists-to-your-websites-part-2/'>How to translate my site?</a>";
var getme_li = document.createElement("li");
getme_li.innerHTML = getme;
ulDiv.appendChild(getme_li);
</script>
[1] Americans mightn't know that when foreigners visitor your country, we are presented with paperwork to fillout that refers to us as Aliens. Perhaps your government never watches its own Hollywood movies, but this isn't the best phrase to use, I think. Not very welcoming.
Their Ruby code is surrounded by a shrouded of Japanese symbols. You know there is gold in there, but its left to the reader to interpret the purpose of the article. Happy Japanese man? Cranky Japanese man?
The creator of Ruby is Japanese, the Rubist magazine is in Japanese, and a great many users of Ruby are Japanese, yet I can’t understand a word they are saying. That’s not their fault. It’s my French teacher’s fault.
Wonder no longer. Thanks to Google Translate’s Japanese to English translation and the Bookmarklet feature of Firefox (and other browsers?)
Drag this Bookmarklet into your links toolbar, and start spying on the Japanese.
Bookmarklet: Spy on Japanese
Want to spy on the Germans? Drag it again, and change the embedded url. Look for the langpair=ja&en and change ja to de. (Cheat: Spy on Germans)
Want to encourage our Japanese friends to spy on you? Perhaps add links on your pages for instant translations from English to Japanese (change ja -> en, and en -> ja), and change the hl=en to hl=ja.
<a href="#" onclick="location.href='http://translate.google.com/translate?langpair=en&ja&hl=ja&ie=UTF-8&oe=UTF-8&u=' + encodeURIComponent(location.href)">Translate into Japanese</a>
Test this here:
I’m not promising there ever will be a Dr Nic’s Online Civilizations game, but it has seemed like a good idea for a few weeks, and today I went from ASCII map through to beautiful CSS rendering of the map.
6am ASCII to HTML mapping |
8am Base tiles |
6pm Correct edges |
9pm Convert table to div structure |
 |
 |
 |
 |
I miss home.

This was a technically interesting process. The images used are actually all on the one base tile sheet
[1], and each panel of the map is allocated a separate CSS class relating to the specific tile required.
So for example, to show the base grasslands tile, you’d need some CSS like:
.tiles {height: 30px; width: 30px; background: url(tiles.png) top left no-repeat; ...}
.grasslands {background-position: 0px -30px;}
For a desert tile, with some grasslands to the left, you might use:
.desert-left {background-position: -60px -60px;}
This really gives a nice tiling effect without you needing to do any fancy image manipulations or the user loading up lots of small images. You just assign the appropriate CSS class to the panel (a DIV or TD, for example). Want to change a tile? Change the class (e.g. using Prototype/jQuery libraries)
Yes, this solution requires lots of individual CSS class definitions; but you’re clever – you’ll generate them won’t you
Reader assistance required
The one technical trick that I don’t have a solution for at the moment is a Google Maps-like interface for scrolling map around. I’d love to hear from anyone with some bright thoughts on how they implement that (I don’t want to have to try to read their compact Javascript code).
Any thoughts?
[1] The source images came from the FreeCiv GPL game
While other people in the world have been doing real work, I’ve been on maternity leave. Thus in spare time, I’ve been cooking up something much more fun…
Today, you get to see a magic trick. No code to download, no brain cells to engage. Its Sunday after all. A day of rest, BBQs, beer, football, and magic tricks. Everyone knows that.
But I can’t show you the trick here in your feed reader… the lighting is terrible. Jump to my site for the live magic show itself.
…pausing…
Ok, at the top of the screen… I introduce to you the Magic Announcements. They are just brilliant, and good looking to boot.
Once you’ve read each one, you click on them to make them go away and they will never return. Once you’ve read the announcement of verson 0.7.1 of Dr Nic’s Magic Models, you will never see another announcement until a new version is released (be it 0.7.2, 0.8.0, or 1.0.0, etc). Nod your head with me, this is cool.
When you get your hands on this, it will be a pure Javascript install into any page (or domain of pages such as a blog). It will fetch announcements AND version change information from anywhere on the web, not just the presentation site. For example, the version information for the two projects are being retrieved from the project home pages themselves. This way, I never have to modify my blog to enter new announcements or versions: I just update the relevant data at the relevant place.
How cool is this? Imagine if you could plug the Magic Announcements directly into RubyForge or SourceForge, etc, and whenever you released a new version of your code to *Forge, your blog automatically started announcing it to your readers! Keep nodding, sexy, yes.
I’m still writing up the install/usage docco for it, but I hope to release it within a day or two.
But to give you some preparation time, for each project you want to provide announcements for, you will need to create files that look like this:
MagicAnnouncement.show('magicmodels', '0.7.1');
If you want to provide generic site announcements, like “Welcome to my website”, then it will look like this:
MagicAnnouncement.show('general_notes', 1,
"Very rarely, you\'ll learn something here. Mostly, you'll just be entertained by the programming magic.",
"<strong>Welcome to Dr Nic's Magic Castle of Programming Mystery</strong>");
In both cases, the 2nd argument is the announcement version number. The 3rd is an additional description (useful for version announcements and site announcements), and the 4th is for the header. You’ll normally want the header to be generated for you for version announcements, as per the Magic Models and Composite Keys announcements above.
Bonus: want to see the announcements again? Turn on the Debug Controller…