ailon's DevBlog: Development related stuff in my life

Porting Old BlogEngine.net Comments to Disqus

12/29/2011 10:45:36 AM

Yesterday I’ve finally managed to upgrade this blog to the latest version of BlogEngine.net. Let me know if you notice any issues related to that.

The process was smooth and easy. Except that I wanted to move commenting to Disqus at the same time. Enabling Disqus comments was easy too, but moving old comments up there was not.

First I found this method and tool. It looked like it worked at first but comments didn’t show up in Disqus. Then I figured that BE.net uses Permalink for Disqus URLs and this tool was using “friendly” link. So I modified what it was exporting and then it just started crashing when trying to upload comments to Disqus.

Then I found this method and tool. It takes standard export from BlogEngine.net in BlogML format, extracts comments from it and saves them in WRX format that can be imported into Disqus. Unfortunately it uses the same “friendly” URLs and BE uses permalinks as identifiers for Disqus threads. Obviously its possible to modify BE code to use the same URLs but it’s not future-proof (among other issues).

So finally I decided to make a small utility that would take WRX generated by the above mentioned tool and original BlogML and replaces “friendly” URLs with permalinks in the WRX. It’s very primitive and not flexible so I’m posting source here instead of binary.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace BlogML2WRXFix
{
class Program
{
static void Main(string[] args)
{
var wrx = XDocument.Load(args[0]);
var blogML = XDocument.Load(args[1]);
XNamespace blogMLNS = "http://www.blogml.com/2006/09/BlogML";
string hostPrefix = args[2];

var wrxItems = wrx.Descendants("item");

foreach (var wrxItem in wrxItems)
{
var linkNode = wrxItem.Descendants("link").First();
// URLs in my WRX included extra slash at the beginning
string linkUrl = linkNode.Value.Substring(1);
linkNode.Value = String.Format(hostPrefix + "post.aspx?id={0}", blogML.Descendants(blogMLNS + "post").First(f => f.Attribute("post-url").Value == linkUrl).Attribute("id").Value);
}

wrx.Save(args[0]);

Console.ReadLine();
}
}
}

It takes path to the WRX file as the first parameter, path to BlogML file as the second and host prefix to use for the output URLs (like http://devblog.ailon.org/) as the third.

Tags:

BlogEngine.NET Extension: In-line Tags

5/7/2008 5:40:25 PM

One more BE.NET extension from me. I decided to write it since Diarist works with BlogEngine.NET now but it doesn't let you attach tags to your post. And I think that's not the only one way to post to your blog without the ability to specify tags.

So this extension allows you to specify your tags in the content of your post. Simply place a code like this in your post:


This post for example would have a string like this


Download InlineTags Extension (1.5kb)

kick it on DotNetKicks.com

Tags: , , ,

Slug Transliterator Extension for BlogEngine.NET

4/28/2008 3:17:51 PM

While I'm at it, I decided to write another extension for BlogEngine.NET. Those writing in English or in other Latin alphabet language only aren't probably familiar with this issue but everyone else is (I think).

When you create a post in Russian (for example) with title like "Привет, мир!" ("Hello, World!") you get automatic slug and (as a result your post link) looking like this:

/blog/post/2008/04/d09fd180d0b8d0b2d0b5d1822c-d0bcd0b8d180!.aspx

This doesn't look much better then the GUID version if you ask me. So, this is where SlugTransliterator comes to rescue. After this post passes through this extension this URL will look like this:

/blog/post/2008/04/Privet--mir!.aspx

A little better, don't you think? I don't know if it has any positive effect on SEO related aspects but it's definitely much more readable and rememberable (is this a word?).

By default SlugTransliterator is configured to transliterate from Russian (Cyrillic) and Lithuanian (Baltic) titles. But it can be configured to do any sort of char-to-char translation using Extension Manager.

Download

SlugTransliterator for BlogEngine.NET v.1.0 (2.5kb)

Installation

Just copy SlugTransliterator.cs to your App_Code/Extensions directory and configure in the admin section as you see fit.

Hope this helps someone. If not, I did it for myself anyway :P

kick it on DotNetKicks.com

P.S.: you may also want to use this extension to transliterate * symbol which results in bad URL in current (1.3) version of BE. Default configuration translates "*" to "-"

Tags: , ,

Cross-post to LJ 1.0

4/25/2008 12:27:06 PM

Just a quick note for those who subscribe to my RSS feed and who's reader doesn't show updated posts:

I've released an updated version of Cross-post to LiveJournal Extension for BlogEngine.net.

Tags: , ,

Cross-post to LiveJournal Extension for BlogEngine.NET

4/24/2008 7:07:00 PM

Some time ago I decided to cross-post all my blog posts from various blogs to my blog at LiveJournal. I used cross-posting plugin for Windows Live Writer by Daniel Cazzulino for some time but then it stopped working with newer releases of WLW. So after toying with idea for some months I decided to write an extension for BlogEngine.NET to do this automatically.

Update: 2008-04-25: I've updated the extension to version 1.0. Here's what was added/fixed

  1. FEATURE ADDED: username, password, xml-rpc url and prepended text could now be edited in Extension Manager
  2. FEATURE ADDED: tags are now cross-posted along with the post
  3. BUGFIX: LiveJournal assumed that posts are in ASCII. Though they were stored and displayed just fine, it wasn't possible to correctly edit them in LJ. Added ver=1 protocol version number.

Note that you will need to configure the extension in Extension Manager after installation

Download it: BECrossPostToLJ-1.0.zip (2kb)

I've used excellent XML-RPC.NET library by Charles Cook so you'll need that too.

Installation

  1. Download XML-RPC.NET library from http://www.xml-rpc.net/
  2. Copy bin/CookComputing.XmlRpcV2.dll to Bin directory of your BlogEngine.NET installation
  3. Upload the files in App_Code/Extensions/ directory to the App_Code/Extensions/ of your BlogEngine.NET installation
  4. Configure the extension in Extension Manager

Known limitations/issues

  • In case your post includes relative URLs in links or image source attributes they wont work. I use WindowsLiveWriter for most of my posts and it inserts images with absolute URLs so this is a minor problem in my case
  • Only new posts are being cross-posted. Cross-posting updates adds too much overhead in tracking IDs, etc. so I don't plan to do this in the nearest future.

Other APIs

I plan to create similar extension for MetaWeblog API if someone needs it. So, again, let me know if you do, so I don't waste time for no reason.

kick it on DotNetKicks.com

P.S.: here's this post cross-posted to LiveJournal using this extension.

Tags: , ,

Copyright © 2003 - 2017 Alan Mendelevich
Powered by BlogEngine.NET 2.5.0.6