Prabir's Blog

open source geek and lover of all tech  

If you have been moderating a blog or writing your own, you must have experienced a lot of spammers invading your blog with comments. To solve it you might have disabled comments after a particular day, installed some extensions (plugins) to help you moderate your comments or even out-sourced you commenting system. Well, in my case I had decided to out-source it and choose Disqus as my commenting system. I was pretty lucky that I choose Disqus commenting system as BlogEngine.Net now officially allows to choose between either its own commenting system or Disqus commenting system, making it more easier for me to upgrade to newer versions as it wouldn’t require me to hack the BlogEngine.Net source code to inject some Disqus related codes.

One of the down side was that my blog already had some comments posted using the BlogEngine.Net. I didn’t want my old comments to be hidden (lost) and yet I wanted to choose some commenting system that would help me manage comments more easily. I decided to go with Disqus Comments after researching with its competitors.

I landed up disabling the BlogEngine.Net add new comments but still putting the old comments. Any new comments would had to be entered using the newly installed Disqus Comments as show below.

sample1 This was a temporary hack to use Disqus as the core commenting system. Later on with version 1.6.0.5 of BlogEngine.Net they officially supported Disqus Commenting system and would allow us to choose between the BlogEngine’s one or Disqus. Then I thought of migrating all my comments to Disqus as this would help me upgrade my blog more easily.

To solve this, I started searching for options to migrate existing comments to Disqus. They had official support for importing Intense Debate comments. I then created an extension for exporting BlogEngine.Net’s comments to Intense Debate comments xml format. But it was taking too long to import and finally gave me errors after importing. Tried it many times but was having no success. Finally I landed up writing a C# API to communicate with Disqus. The source code is open sourced and can be downloaded here (I’m using git version control system. please checkout to dev branch to see the codes). I decided to name it Disqus#.

Enough of the history. Lets start migrating.

First of you will need to download the BlogEngine.Net extension which allows you to export your blog engine.net comments at the end of the post. (Note: nested comments are not supported. This extension was created in hurry and is based on only my requirements.)

There are two things you will need to upload to your website. The extension it self called CommentsExporter.cs to App_Code\Extensions folder and the web-GUI front-end for exporting comments to User controls\ExportComments.aspx.*

You will then need to login as the Blog moderator (administrator) and go to the extensions tab of the control panel.

image

Then select Edit link in the settings column of the CommentExporter. You will land up with the following page.

image

You can then click Export Comments button and choose Disqus Comments as the format. (Nested comments are not supported.) Map Authorized Users was basically created for exporting to Intense Debate (which I had chosen as my first export format, unfortunately it didn’t turn out well). This feature can still be used for Disqus Comments format. For example, in some of my comments I had written the author name as prabir or prabirshrestha. When I wanted to migrate I wanted to make them both as the same user – prabirshrestha. This was achieved by typing prabir:prabirshrestha; color(:) separates the key and value while semi-color(;) allows you to write more mappings. This is case sensitive too. You can write multiple values by entering prabir:prabirshrestha;Prabir:prabirshrestha; After you are done click the export button and save the exported comments. (The exported format is same as when you export comments from the Disqus website.)

Included with the download (below) there is a GUI frontend (Prabir.DisqusUploader) which looks similar as below.

image

Click browse and locate the file you just exported (saved) from the BlogEngine.Net website. You will need to then enter the User Api Key at the bottom left. If you don’t know your Disqus User Api Key, login to disqus and navigate to this link http://disqus.com/api/get_my_key/ Copy paste the User Api Key from the browser and click Get Websites button. Choose the appropriate website and click Upload to Disqus button. Once you are done with uploading a MessageBox is shows saying - “Your comments have been uploaded to Disqus.”

Here’s the sample of uploaded Disqus Comments.

sample3

Then I finally upgraded my BlogEngine.Net to the latest version which supports Disqus Comments. The old comments were also removed. Finally I landed up as …

image

Note: There is a small issue when uploading the comments to Disqus, it tends to truncate the comments if you have a single or double quote in the comments (‘ “) or have a semi-colon in the comments (;). I had to manually edit the truncated comments. If you want to fix it you can also download the source code. (Now that I am done migrating, most probably I wouldn’t have to be touching the source code, but if any one wants to contribute it back I would be more than happy.) Please use it at your own risk.

 DisqusUploaderWithBlogEngineExtensions.zip (778.56 kb)

 DisqusUploader-Src.zip (4.02 mb)

The driving force that landed me to create this blog that you are reading now, has mainly been that I wanted to contribute back to the society, “the internet society” from where I have learned so much. And the other one was to also put as a reference from the future. There are many times when I actually need to refer to my own blog.

For instance, I often need to redirect HTTP to HTTPS. (You can find this article at http://blog.prabir.me/post/HTTP-redirection-to-HTTPS.aspx). But opening blog.prabir.me and then typing redirect in the search box would quite lose my time. So I landed up creating a Windows 7 Federated Search Connector – a cool new Windows 7 feature.

When I search for redirect keyword in my blog using the Window 7 connector I would get the following result.

image

 

How does the magic happen. Well first the search results show up as RSS feeds using the open search URL conventions. And luckily BlogEngine.NET already supports it out of the box. Try this url http://blog.prabir.me/syndication.axd?q=redirect

It already contains the page called syndication.axd where we can pass you search query using the q querystring.

To do that we define a Windows 7 Search Connector file ending with .osdx extension. It is a normal text file. So you can edit it using your favorite text editor.

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
  <ShortName>Prabir's Blog - www.prabir.me</ShortName>
  <Description>Prabir's Blog - where the tech matters</Description>
  <Language></Language>
  <Url type="application/rss+xml" template="http://blog.prabir.me/syndication.axd?q={searchTerms}"/>
</OpenSearchDescription>

Notice the URL, we pass the search query in querystring q as {searchTerms}, that is how Windows 7 uses it.

Once you save it to .osdx file, double click it and you will asked if you want to add it. Click add then you are all set.

But the fun doesn’t end here. In the search results when you double click, it will open the article in Web Browser. And if you have the preview pane, it will show up in the Window Explorer Search Window it self as shown below.

image

prabirDOTme-Windows7FederatedSearchConnector.zip (371.00 bytes)

Syntax Highlighter v0.2 has been released along with source code at Codeplex. This is an update to my original Windows Live Writer plugin which can be found at http://blog.prabir.me/post/Windows-Live-Writer-Syntax-Highlighter.aspx.

As you might have noticed some of the features such as auto link detection, collapse, gutter (line numbering), toolbar, wrap lines and starting line number have been added.

image

To download the files please visit http://codehighlighter.codeplex.com

or download from windows live gallery.

More features coming soon. If you want to help develop this plug-in please leave a comment below or contact me at http://blog.prabir.me/contact.aspx.

It had been a month since I got an invitation to (Bing) Microsoft Translator Widget, but had not found my time to play around. So I decided to create a Blog Engine .NET widget so that other users from various parts of the world can easily read through the articles. I have also created Google Translator Widget earlier which you can find here. I’m not going to fight about which one is the best out here, I leave it to you to choose. Mimageicrosoft Translator has quite a good Ajaxified Translator which you can check it in my blog (from right hand side menu) but it does require you to have an invitation before you can actually use one. You can register for at http://www.microsofttranslator.com/Widget 

Installation:

  • Simply upload the folder to the Blog Engine’s “Widget” folder.
  • Then login as administrator, and you will see Microsoft Translator as seen on the picture below.

image

  • Then click the edit widget and the popup will come up.

image

 

For example my details are as follows:

<div id="MicrosoftTranslatorWidget" style="width: 200px; min-height: 83px; border-color: #3A5770; background-color: #78ADD0;"><noscript><a href="http://www.microsofttranslator.com/BV.aspx?a=http%3a%2f%2fwww.prabir.me%2f">Translate this page</a><br />Powered by <a href="http://www.microsofttranslator.com">Microsoft® Translator</a></noscript></div>
<script id="MicrosoftTranslatorWidgetScript" type="text/javascript"  charset="UTF-8" src="http://api.microsofttranslator.com/v1/widget.svc/Embed?appId=4e-dM3lMn4etY3cW_Vtngdh03oVcKRAU&amp;from=en&amp;layout=ts"></script>

From the above script that was generated pickup appropriate settings and click save and you are done. Congratulations, you have integrated Microsoft Translator in your BlogEngine.Net

Here’s a sample pic of my blog after the translation by Microsoft Translator.

image

Microsoft Translator For BlogEnginedotNet.zip (2.29 kb)

In one of my old post http://blog.prabir.me/post/Windows-Live-Writer-Syntax-Highlighter.aspx, I had release the binary of Syntax Higlighter plugin that I had created. This plugin contained the basic functionalities of the Syntax Higlighter plugin, which would more than suffice for an ordinary code.

But due to my hectic schedule and other different projects, I haven’t been able to develop this plugin further. So, I have decided to release the full source  code (at first I was planning to release the source code when the plugin is complete). You can download the code which is hosted by codeplex.com at http://synatxhiglighter.codeplex.com. The code is written in C#.

I have been searching for some developers who would like to contribute to this project. If you are interested please leave a comment below or us the contact page to contact me.

To download the source code please visit http://synatxhiglighter.codeplex.com

You can download the binaries from http://blog.prabir.me/post/Windows-Live-Writer-Syntax-Highlighter.aspx, or directly from one of the below links

Prabir.wlw.Syntaxhiglighter.dll.zip (38.40 kb)
Prabir.wlw.SyntaxHiglighter.msi (Setup) (360.00 kb)

Get from Windows Live Gallery