Back at fourth!

In march, I noticed that a google search for ”staffan” yielded my blog at 23th place, down from 4th. I am now happy to announce that I’m yet again the fourth most important ”staffan” on the web (at least on the US google.com). This might mean that Rasmus google-poisoning powers has worn off. I’m also number two in a search for ”malmgren”, which I think is an all-time high.

I think there’s some kind of executive desk toy that displays things like stock indexes and website load with real-life analog dials, that get their information from some sort of radio network (I remember reading about it in Wired somewhere). I’d like to have one of those hooked up to my google rating.

Blog updated

I’ve now updated the software running this blog to dasBlog 1.6. It came with a default theme that looks so nice I’m going to keep it. Only problem so far is that dates are rendered with the locale settings of the browsing user, at least with IE (I get ”den 4 maj 2004” when I want to get ”Tuesday, May 04, 2004″, which is what I get with Mozilla). Anyway, it seems to fix the problems with the ASP.NET 1.1 paranoid security settings that Göran encountered in this thread (which is an interesting discussion that you should follow, by the way).

Update: No, spoke too soon. It seems you can still cannot post anything containing the string ”script:” in a comment on a dasBlog instance.

One more example of why I should not be entrusted with sysadmin duties

The computer that’s serving you this blog is also my main hobby development machine. As such, I have a couple of test/development web sites on it, in subdirectories. However, I’m running dasBlog from the root directory. This occasionally causes problems, for example the web.config file for dasblog references a bunch of assemblies used for http handlers and other stuff. This stuff is inherited to all other asp.net applications, and I can’t seem to turn it off (specifying <clear/> under <httpHandlers> does not seem to work). As a workaround, I copy all the dasblog dll’s to each and every web application’s bin directory. Cludgy, but at least it allows me to get stuff done. Except when I move instead of copy… which lead to my other application working, but the main blog being broken for several hours.

However, I find this info from Netcraft to be a little funny:

Old permalinks sort of not working

It seems that there is some sort of subtle bug in my import script. If there are more than one entry per day, permalinks to the earliest item turn up an empty page. Here’s an example. The entry as such is sort-of-working, as you can see in this date view, but the permalink (and edit/delete links as well) simply turn up empty pages. The problem doesn’t manifest itself with entries created by dasblog, so I think the bug is in my script.

Stuff now imported into dasBlog

I went ahead and wrote a little C# program to convert a sharpreader-style cache RSS file into a set of dasBlog-compatible dayentry files. One little problem surfaced in that while BlogX used a url + random GUID for each entry’s guid, dasBlog uses only a random guid. This will have the effect of a bunch of entries (15, to be exact) appearing as new in your RSS aggregators. Sorry about that as well.

Anyway, if someone needs to do something similar, here’s the code I used. It expects a sharpreader-generated file named ”backup.xml” in its working directory (look for a suitable file in %USERPROFILE%\Application Data\SharpReader\Cache and rename it), and if you’re not in the CEST timezone, you should probably fix the line with the FIXME comment.

using System;
using System.Xml;

namespace DasBlogImport
{
  class Importer
  {
    static private void addElementToEntry(XmlDocument doc, 
                                          XmlElement entry, 
                                          String elementName, 
                                          String elementValue) 
    {
      XmlElement e = doc.CreateElement(elementName);
      e.InnerText = elementValue;
      entry.AppendChild(e);
    }
    [STAThread]
    static void Main(string[] args)
    {
      XmlDocument doc = new XmlDocument();
      doc.Load("backup.xml");
      XmlNodeList nodeList = doc.GetElementsByTagName("Items");
      XmlNode element;
      XmlNode entries = null;
      String lastDate = String.Empty;
      XmlDocument dayentry = null;

      foreach  (XmlNode item in nodeList) 
      {
        element = item.SelectSingleNode("PubDate");
        String date = element.InnerText.Substring(0,10);
        

        if (date != lastDate) 
        {
          // flush the entries for the current day, and start a new document
          if (dayentry != null)
            dayentry.Save(lastDate+".dayentry.xml");
          dayentry = new XmlDocument();
          dayentry.LoadXml("");
          XmlElement root = dayentry.DocumentElement;
          element = dayentry.CreateElement("Date");
          element.InnerText = date + "T02:00:00.0000000+02:00"; // FIXME: If you're not in the CEST timezone, you probably want to change this
          root.AppendChild(element);
          entries = dayentry.CreateElement("Entries");
          root.AppendChild(entries);
          lastDate = date;
        }
        XmlElement entry = dayentry.CreateElement("Entry");
        entries.AppendChild(entry);

        addElementToEntry(dayentry, entry, "Content",        item.SelectSingleNode("Description").InnerText);
        addElementToEntry(dayentry, entry, "Created",        item.SelectSingleNode("PubDate").InnerText);
        addElementToEntry(dayentry, entry, "Modified",       item.SelectSingleNode("PubDate").InnerText);
        String guid = item.SelectSingleNode("Guid").InnerText;
        addElementToEntry(dayentry, entry, "EntryId",        guid.Substring(guid.Length-36,36)); // 36 = the length of a 128-bit GUID in standard string form
        addElementToEntry(dayentry, entry, "Description",    String.Empty);
        addElementToEntry(dayentry, entry, "Title",          item.SelectSingleNode("Title").InnerText);
        if (item.SelectSingleNode("Subject") != null)
          addElementToEntry(dayentry, entry, "Categories",   item.SelectSingleNode("Subject").InnerText);
        else
          addElementToEntry(dayentry, entry, "Categories",   String.Empty);

        addElementToEntry(dayentry, entry, "IsPublic",       "true");
        addElementToEntry(dayentry, entry, "ShowOnFrontPage","true");
        addElementToEntry(dayentry, entry, "Crossposts",     String.Empty);
      }
    }
  }
}

Is this on?

Ok, so after re-installing my main home
PC I’ve finally come to the point where I re-enable the blog. I decided to be a little
daring and replace the old and not-very-maintained BlogX engine
with a brand new dasBlog installation. I haven’t
managed to import the old blog entries yet, despite them being very similar in structure.
Well, got to save something for another night.