pwnt.be

Introducing Pwnt.TagSphere

As you may know, I’ve already done quite a few experiments with visualizing tags. Sadly, up until now, I was mostly unsatisfied. Today, however, I am presenting Pwnt.TagSphere, a three-dimensional tag cloud I hope you’ll all enjoy. Head here for an example.

Update: The code has changed a bit since I wrote this, mostly to mimic the behavior of WP-Cumulus. Everything’s backward compatible, so all the documentation below still applies. I’ve also set up a little demo.

Chihuly Glass Seaforms
Chihuly Glass Seaforms by Jill Clardy
Some rights reserved

As the name suggests, Pwnt.TagSphere puts your tags on a spherical body. The sphere automatically rotates, but you can also drag it around in a very natural way. Like with any other tag cloud, the more important a tag is, the more prominently it is visualized. Clicking on a tag takes you to the URL associated with it. The whole thing was written in JavaScript, with MooTools and using a bit of CSS for visual styling.

Of course, you’ll want to use Pwnt.TagSphere on your own web site. Good news: you can; all I ask is that you give credit. I’ll now try and explain how to integrate this gizmo.

Basic Installation

  1. Get the scripts. You need both MooTools (Core) and tag_sphere.js.

  2. Include the scripts in your HTML code, e.g.

    <script type="text/javascript"
        src="/js/tag_sphere.js"></script>
  3. Add the following bit of JavaScript code to your page:

    window.addEvent("load", function() {
        var tags = [
            [ "One", 12, "/tag/1" ],
            [ "Two", 345, "/tag/2" ]
        ];
        var sphere = new Pwnt.TagSphere(tags);
        sphere.getElement().inject(document.body);
        sphere.start();
    });

    This creates a Pwnt.TagSphere with two tags: “One,” which was used 12 times and links to the URL /tag/1, and “Two,” with 345 uses and the URL /tag/2. Of course, you can add as many tags as you like, and you’ll probably want to fetch them from some data source; I’ll leave that to you.

    As you can see, sphere exposes a getElement() method, which actually returns the panel containing the whole thing—a HTML <div>. It’s up to you to add it to the document and subsequently call the start() function to activate it.

  4. If you navigate to the page, you should already see some action, but it won’t be pretty. That’s because we haven’t added any CSS code yet. So, let’s do so now. At the very least, you need to set the tag sphere’s dimensions:

    .tag-sphere {
        width: 400px;
        height: 300px;
    }

    If, for whatever reason, you want to include multiple tag spheres, you can easily assign an ID to the panel returned by getElement() and adjust your CSS accordingly.

  5. That’s it. You’ve got yourself a spiffy tag sphere.

Further Configuration

You may find the default tag sphere ugly and boring. Fortunately, you can do a hell of a lot of tweaking via both JavaScript and CSS. I’ll first cover the CSS part, since it’ll probably be less complicated.

Stylesheet Options

As you may have noticed above, the <div> returned by getElement() has the tag-sphere class by default. The individual tags are actually standard <a> elements with absolute positioning. This provides an easy way to apply some styles to the tag sphere. I’ll suggest a few …

  • To set the maximum font size used in the sphere to 18 points, use

    .tag-sphere {
        font-size: 18pt;
    }
  • If you want to remove underlining from the tag links, just add

    .tag-sphere a {
        text-decoration: none;
    }
  • To emphasize the tag the cursor is currently hovering, use

    .tag-sphere a:hover {
        opacity: 1 !important;
        z-index: 101 !important;
    }

    This makes the link opaque and brings it to the front. The latter works because the links silently get a z-index between 0 and 100 while rotating. Any value over 100 will thus place it in front.

  • While any of the links is hovered, the whole panel temporarily receives the focused class. This allows you to “dim” all the non-hovered links to silver, while making the hovered one black:

    .tag-sphere.focused a {
        color: silver;
    }
    
    .tag-sphere a:hover {
        color: black;
    }

    You could also use the opacity property for this, but keep in mind that you would lose the depth effect.

  • If you want to change the cursor for the whole panel, use

    .tag-sphere, .tag-sphere.dragging a:hover {
        cursor: move;
    }

    While the user is manually rotating the sphere, the panel receives the dragging class. This explains the part after the comma: if, while dragging, the cursor hits a tag, it won’t change. While not dragging, on the other hand, it’ll behave like any other link.

Class Options

By adding a second parameter to the constructor, you can configure a couple of options. For instance, if you wanted to change the tag opacity range—don’t worry, we’ll get to that in a moment—, you’d write:

var sphere = new Pwnt.TagSphere(tags, {
    minAlpha: 0.5,
    maxAlpha: 0.75
});

Now, here’s a list of available options and their default values:

minAlpha: 0.05
maxAlpha: 1.00

The minimum and maximum opacity of a tag. The least important tag gets minimal opacity, the most important one maximal.

zoom: 0.9

The relative size of the furthest tag—i.e., the one at the back of the orb. The smaller this number, the deeper the sphere will appear to be. This factor also applies to opacity.

scale: "linear"

If the tags’ usage counts aren’t uniformly distributed, the sphere might look prettier if you set the scaling method to "quadratic" or "exponential", depending on your preference.

paddingX: 1/5
paddingY: 1/20

The horizontal and vertical distance from the edge of the panel to the outline of the sphere, expressed as a fraction of the width and height, respectively. As the tag names will overflow this outline, these distances will need to be sufficiently large.

rotationInterval: 100

The number of milliseconds between two frames—i.e., the inverse of the frame rate.

rotationAngleX: Math.PI/500
rotationAngleY: -Math.PI/200
rotationAngleZ: 0

The rotation angle around the X, Y and Z axis, expressed in radians per frame. Hence, set rotationInterval accordingly.

dragAngle: Math.PI

The rotation angle when manually rotating the sphere, expressed in radians divided by width or height, depending on the direction. For example, if the user dragged the mouse vertically over a distance that was half the height of the panel, the sphere would be rotated 0.5 * dragAngle radians around the X axis.

That’s it. If you’ve got any suggestions, I’d love to hear them.

Google Chrome Still Sucks

Google Chrome has matured quite a bit since I first reviewed it. In fact, yesterday, I decided to replace my primary web browser of many years, Mozilla Firefox, with Chrome. This is a record of those events.

Google Chrome
Google Chrome

So, first of all, why change a winning team? Well, the main reason is that Firefox feels sluggish to me. Don’t get me wrong: the Mozilla guys are making tremendous efforts to make it as lean as possible, and every release is a vast improvement in that area. If you told me Firefox had the best memory management among its peers, I’d believe you. But my perception is that Firefox is always struggling, even though I know that’s not the case. So it was time for a change.

Feature-wise, you can’t beat Firefox’s add-on system. Sure, Chrome is somewhat extensible too, but exploring that any further would just be comparing apples and oranges. Hence, I knew I’d be making compromises when I gave up Firefox, which is why I hunted for alternatives to most of my Firefox extensions, most importantly:

  1. Forecastfox is a Firefox extension I’d have waived at first. But ever since I realized how convenient it was to have a weather forecast readily accessible—and this was years ago—, Forecastfox has been sitting in my status bar. Instead of looking for a weather add-on for Chrome, I installed Yahoo! Widgets, just for the weather widget. Desktop widgets aren’t really my cup of tea, but this one’s okay.

  2. Another wonderful Firefox extension is the DownThemAll! download manager. It’s really nicely integrated with the browser and once you’ve used it a few times, you’ll wonder how you ever managed without it. Chrome’s download management, like any other browser’s, is of course very reduced. Again, I went for the standalone solution and installed Free Download Manager Lite. While it has its quirks, all the features are there, and integration with Chrome is reliable enough.

  3. I’m one of those guys who always keeps at least one browser window open—gotta keep up with the latest developments on Facebook, right? To save some taskbar space and also divert my attention, MinimizeToTray revived or MinTrayR came in very handy. The main reason I didn’t use PowerMenu, which was recommended to me a while ago, is because MinTrayR put some much-needed items in the tray icon’s context menu, such as one to open up a new Firefox window. With Chrome, on the other hand, the window’s context menu itself has those options, so PowerMenu can just borrow them. Problem solved.

    Update: Actually, TrayIt! is a much more elegant solution.

Of course, there are other extensions I’m going to miss. NoScript didn’t make the top three simply because Chrome lacks the possibility; the Developer menu is more than decent, but it’s certainly no Web Developer extension; the list goes on.

That being said, I’m not regretting migrating to Chrome just yet. It’s a modern web browser that has some very interesting features, such as the OmniBar Omnibox and the Task Manager. However, it didn’t take me very long to find 10—yes, ten—things wrong with it.

  1. The New Tab page. Seriously, what’s up with that? I’m sure it’s useful to some people, but why don’t I have the option of opening up a blank tab instead? Sure, there’s a workaround, but come on!

  2. The Other Bookmarks menu. Like many people, I’m not great with bookmark organization. I never jumped on the social bookmarking bandwagon and I’m too lazy to create folders and/or tag my bookmarks. The result? A long list. Which is allright in Firefox, since you can navigate through it using keyboard accelerators: Home and End work as expected. In Chrome, not so much.

  3. No bookmark separators. Yeah, another Firefox trick I used to manage my bookmark jungle. That little horizontal—or vertical, in the case of the Bookmarks Bar—line makes all the difference.

  4. Hiding the Bookmarks Bar. While we’re on the subject of the Bookmarks Bar, why does the menu item to hide it read “Always show the bookmarks bar”? To me, that implies that, if I disable that menu item, there’s a key or button to momentarily show the bar, and then hide it as soon as I select a bookmark. If not, just call the menu item “Bookmarks Bar” and be done with it.

  5. Capitalization. Of course, the menu item wouldn’t be called “Bookmarks Bar”: the second B wouldn’t be capitalized, going against Windows UI conventions. Many applications suffer from this, but I expect better from Google.

  6. Dot dot dot. It’s even worse if you do follow a convention, but only half the time. If a menu item opens a new window, its label should have three dots. So, apart from the capitalization, “Create application shortcuts…” is correct, while “Bookmark manager”, “Options”, “About Google Chrome” and a few others aren’t.

  7. No master password. In the event that my machine gets stolen, it’d be nice if its new owner couldn’t easily extract all of my stored passwords from my Chrome data. This lack of security is keeping me from using the password manager on my laptop—major burden!

  8. No native theme. I’ll admit I like the way Chrome looks, and adapting to the OS’s colors is a nice touch. And I’m sure they’ll eventually come up with themes that don’t suck. But none of those things change the fact that Chrome still looks a bit out of place. I use Windows Classic and I expect every window to respect that.

  9. No plugin manager. The ability to manage MIME type associations for plugins is a feature that was introduced in Firefox not too long ago, but it’s certainly convenient. For instance, I have both Adobe Reader and Foxit Reader installed, and I’d prefer if Chrome allowed me to choose my PDF viewer plugin from those. There’s an about:plugins page, which even shows whether or not an association is enabled, but there doesn’t seem to be any way to change it. I ended up renaming the Adobe Reader DLL file so Chrome couldn’t find it, which isn’t the most elegant solution.

  10. The crash handler. When Chrome first came out, the fact that Google Update was always running bothered me. They’ve now changed that: you’ve always got a GoogleCrashHandler.exe process. Never mind the fact that you can’t disable it, but that name isn’t very reassuring, is it? And you will need the crash handler: since I started using Chrome yesterday, it’s crashed out on me four times. I’ve since switched to the beta channel, which, ironically, seems more stable.

You could argue that a lot of this is nitpicking or even whinging. Perhaps, but to me, it says that, even after a few years year, Chrome hasn’t quite left the beta stages yet. On many occasions, it still feels like an Open Source project a couple of hackers threw together in their garage—which can be okay, but not for a web browser, and certainly not for Google.

Mass-Convert Your Music

While flash storage is reasonably affordable these days, your average portable audio player probably won’t be able to hold your entire music collection. That’s why it couldn’t hurt to convert—or, if you like it fancy, “transcode”—all your songs to a more economical format, allowing you to carry around as many of your favorite songs as possible.

2009-03 München 024
2009-03 München 024 by Allie_Caulfield
Some rights reserved

Let’s say you wanted to convert audio files in any input format—MP3, FLAC, WAV, or whatever—to a single, uniform output format—Ogg Vorbis, for instance. Sure, you could go hunting for a shareware tool with a half-assed GUI, but why should you? Free and Open Source utilities exist for just about any format, so it’s a matter of chaining them together.

Luckily, you don’t need to do the chaining, since I wrote replicator.pl to do just that. The script will clone an entire directory tree, converting any audio file it encounters, and updating M3U playlists to match. Windows users will want to look into ActivePerl; most other OSes come with Perl. You may also need the following Open Source utilities:

Obviously, you can ignore the formats that you won’t be using. However, MediaInfo is required no matter what. Moreover, you can easily add support for more formats, as long as you know the right command to decode to standard output and/or encode standard input.

How do you use the script? Easy as pie. Just type

perl replicator.pl input_dir output_dir output_format

For example, on Windows, if you wanted to convert everything under C:\Music into Ogg Vorbis and store the result in C:\Ogg, you’d type

perl replicator.pl "C:/Music" "C:/Ogg" ogg

Mind the forward slashes—even though they’re not strictly necessary. Also, the quotation marks are optional in this case, but you’ll probably be using paths with spaces in them, so just keep them around. Enjoy!

Update: Those of you who downloaded the script before September 5 may want to do so again. Tagging now behaves as it should, and I fixed some other miscellaneous bugs while I was at it.

Disorientation
Continuity
Retributions
Automating OpenVPN Connection on Windows XP
blanky, sky, Tim, Geb, 12vpn, Tim, neecom
Simple Linear Regression with JFreeChart
Nicolas Machado, Sascha, Tim, Sascha, Tim, Sascha
De Canvascrack: een epiloog
Tim, Steven Noels
Lplayer for the Rest of Us
jesus2099, Tim, jesus2099, Tim, jesus2099, Tim, PixelPirate
Proximus, Universiteit Gent, Kafka: schrappen wat niet past
Tim, Bart Coppens, Tim, Steven, Tim, Femke
Colophonics