Prabir's Blog

where the tech matters...

Migrating Existing BlogEngine.Net Comments to Disqus

May 17
by prabir 17. May 2010 13:55

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) [Downloads: 111]

 DisqusUploader-Src.zip (4.02 mb) [Downloads: 124]

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: ,

BlogEngine.NET

Bing Translator For Blog Engine .NET

October 06
by prabir 6. October 2009 16:23

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) [Downloads: 182]

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags:

BlogEngine.NET

Blog Engine.Net Google Translator Widget

July 08
by prabir 8. July 2009 20:33

Have you ever wanted people from different backgrounds and geographical regions to be able to read your blog in the language they prefer? Well, it isn’t hard as you thought so. You don’t need to hire anyone and pay them to translate it for you. There are lot of free translation services provided by Google, Microsoft and Yahoo to name a few popular ones.

image

The one I’m using is from Google as it supports a lot more than others. (I can’t comment on the accuracy, I don’t understand those many languages).

To make life easier I have created a widget which works with BlogEngine.Net. You are simply required to upload the folder which you can download at the end of the post to you BlogEngine’s "widgets" folder.

Once you are done with uploading the files. You will need to login as administrator in your BlogEngine. Widgets dropdown box will be visible. Then select Google Translator from the drop down and click add. Its that easy.

For live example you can use my Google Translation Widget at the right hand side.

image

Google Translator.zip (942.00 bytes) [Downloads: 223]

For Microsoft (Bing) Translator click here.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: ,

BlogEngine.NET

Syntax Highlighter 2.0 and Blog Engine.Net

July 07
by prabir 7. July 2009 21:47

This post is a continuation of my previous article on integrating Syntax Highlighter 2.0 with Windows Live Writer. I would recommend you to read it also. This article will take it one step further by learning how to integrate it with Blog Engine.Net 1.5. For Syntax Highlighter 1.5 with Blog Engine and Windows Live Writer you can find my article here.

You will need to download the Syntax Highlighter 2.0 files from http://alexgorbatchev.com/wiki/SyntaxHighlighter or at the end of this post.

You will need to upload the necessary files and folders (scripts and styles folder are only required). Then login to your blog as administration and go to the settings tab of the BlogEngine. In your html head section paste the following code and click save settings.

<link type="text/css" rel="stylesheet" href="/styles/shCore.css" />
<link type="text/css" rel="stylesheet" href="/styles/shThemeDefault.css" />
<script type="text/javascript" src="/scripts/shCore.js"></script>
<script type="text/javascript" src="/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="/scripts/shBrushCpp.js"></script>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = '/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>

At the moment only C# and C++ syntax highlighting is available. If you would like to support more languages please add the appropriate javascript file as shown below

<script type="text/javascript" src="/scripts/shBrushXml.js"></script>

The list of available languages can be seen from Scripts folder that you just uploaded.

syntaxhighlighter_2.0.320.zip (81.54 kb) [Downloads: 210]

Windows Live Writer Plugin (Setup recommended):
Prabir.wlw.Syntaxhiglighter.dll.zip (38.40 kb) [Downloads: 263]
Prabir.wlw.SyntaxHiglighter.msi (Setup) (360.00 kb) [Downloads: 315] 

Get from Windows Live Gallery

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: , ,

BlogEngine.NET

Syntax Highlighter

May 20
by prabir 20. May 2009 18:40

You might have seen a few code snippets that I have been posting in my blog which is powered by BlogEngine.NET. In this article I am going to guide you through installation of Syntax Highlighter 1.5.1 in blog engine. (For Syntax Higlighter 2.0 click here)

First of all you need to download the syntax highlighter from its official site (version 1.5.1) from here and would also require you to install the installer from http://wlwsyntaxhighlighter.codeplex.com (tested with version 2.1.1).

Then you will need to upload the syntax highlighter files (Scripts and Style folder only) to your blog. Then login to your blog as a administrator and go to the settings tab in the control panel of blog engine. In your html head section paste the following code

<LINK rel=stylesheet type=text/css href="Styles/SyntaxHighlighter.css"></LINK>
<SCRIPT language=javascript src="Scripts/shCore.js">
</SCRIPT>
<SCRIPT language=javascript src="Scripts/shBrushCSharp.js">
</SCRIPT>
<SCRIPT language=javascript>
window.onload = function() {
 dp.SyntaxHighlighter.ClipboardSwf = 'Scripts/clipboard.swf';
 dp.SyntaxHighlighter.HighlightAll('code');
};
</SCRIPT>

At this moment only C# synatx is available. If you would like to support more languages please add the appropriate javascript file as shown below

<SCRIPT language=javascript src="Scripts/shBrushCpp.js">
</SCRIPT>

The list of available languages can be seen from Scripts folder that you just uploaded.

SyntaxHighlighter.msi (368.00 kb) [Downloads: 186]
SyntaxHighlighter_1.5.1.zip (41.16 kb) [Downloads: 173]

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: , ,

BlogEngine.NET