Jelle Druyts .NET Consultant
Just another ignorant weirdo from Antwerp, Belgium trying to make sense out of it all
Cool, I just finished up a quick dasBlog hack to make my referrers publicly available. Check it out in the navigation bar! I also parsed the google referrers to show the actual search they entered in stead of just the url which is less readable. Just because I got curious after Rory's google explorations Furthermore, it's now also possible to show more than only today's referrers, you can specify how many days it should look up.
For those of you with fat glasses and a wireless router that has toilet-reach: here's how I pulled it off without having to touch the dasBlog codebase... If you look at the dasBlog sourcecode, the aspx pages are extremely simple: they don't contain any markup but are rendered by their code-behind classes. These are defined in the dll that makes up the dasBlog runtime (which I don't want to touch or recompile). Luckily, there's another way to get pages with code-behind without precompiling the sourcefiles: that is to use the Src-tag of an aspx page. This points to a sourcefile which will be JIT-compiled the first time the page is requested. Same goes for user controls.
Src
Now the referrers in dasBlog are shown in the admin area only, and they're defined in a Referrers.aspx page which just checks security and loads the ReferrersBox.ascx control. So in order to bypass security (i.e. make it public) I needed to have a page with a codebehind that didn't check the security. Hence the PublicReferrers.aspx and PublicReferrers.aspx.cs files: the first one is just a copy of the original one - except that its "Src" tag points to the second file which is a C# source file. This is a copy of the original dasBlog file but with the security part stripped out and the loaded control replaced by PublicReferrersBox.ascx. Fairly simple, right?
The PublicReferrersBox.ascx is also a copy of the original ReferrersBox.cs but with the ActivityBar stripped out - it's only needed in the admin area. It points to its codebehind file PublicReferrersBox.ascx.cs which is a modified version of the original dasBlog file. So this is basically the code that provides the extra google goodness and the fact that it can show more than one day. I'm not going to bore you with the code, just take a look if you're interested.
So if you want this on your own blog: go and get your hands dirty recreating these steps. Or better yet: just download the necessary files and copy them in your root dasBlog directory
PublicReferrers.zip (5,21 KB)