Wednesday, December 20, 2006

Runnning ASP.1.1 and ASP.NET 2.0 in IIS 6.0

Since it is not possible to run both ASP.1.1 and ASP.NET 2.0 in the same application pool, create a new application pool for .NET 20 applications and set the web site's application pool (Properties->Home Directory->Application Pool) to the new pool created. Do not forget to set (Properties->ASP.NET->ASP.NET version) the asp.net's version to 2.0!

Wednesday, December 13, 2006

MovableType, XMLRPC, ATOM

Atom Api Spec:
http://www.atomenabled.org/developers/api/atom-api-spec.php

Typed Atom API:
http://www.sixapart.com/pronet/docs/typepad_atom_api

Six Apart Atom Centre:
http://www.sixapart.com/pronet/breese/atom.html
http://www.sixapart.com/developers/atom.html

Rss Vs Atom
http://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared

Atom Api in Movable Types:
http://www.benhammersley.com/undocumented_features/atom_api_in_movable_type.html

Movable Type Developer Centre:
http://www.sixapart.com/developers/movabletype.html

XMLRPC:
http://www.xmlrpc.com/

Atom Api Urls
To get the list of services sens a get request on the following URL:
http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/

This will give you a response in a similar format as below. For each blog set up on the server similar informarion will be returned.

<feed xmlns="http://purl.org/atom/ns#">
<link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.post" href="http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8" title="YOUR BLOG'S TITLE #8" />
<link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.feed" href="http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8" title="YOUR BLOG'S TITLE #8" />
<link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.upload" href="http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8/svc=upload" title="YOUR BLOG'S TITLE #8" />
<link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml" rel="service.categories" href="http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8/svc=categories" title="YOUR BLOG'S TITLE #8" />
<link xmlns="http://purl.org/atom/ns#" type="text/html" rel="alternate" href="http://www.YOURDOMAIN.com/blogs/main/" title="YOUR BLOG'S TITLE #8" />
</feed>


Each link returned in the response is actually a URL of another request. The response above gives us five different links for a blog which has an ID of 8. rel attrubute gives the information about the URL. The URL of the blog from where users can see it is given in the alternate link.

If you want to post something using the API then use the URL in the item which has "service.post" rel attribute
If you want to retrieve data using the API then use the URL in the item which has "service.feed" rel attribute
To get the blog data:
http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8
As a default it will be returning the blog and its most recent 20 posts. The data is returned in a feed node having posts in entry tags. To diffrentiate the published and unpublisged posts, check the draft nodes inside each entries. If the entry is not published this node exists and its value becomes 'true'. If the entry is published, you may not be able to find it in the server's response.
Everything has a URL in Atom Api.
To get a specific post's data with the ID of 80 send a GET request on the following URL.
http://www.YOURDOMAIN.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=8/entryid=80
The data will be returned in one entry node.
To get the list of categories:
If you want to retrieve the list of categories using the API then use the URL in the item which has "service.categories" rel attribute.

While the username and password is sent in plain text using xmlrpc, it has to be sent encrypted in Atom Api. They do not use the logon password which you use it to logon to Movabletype. If you scroll down to Password section and to the bottom, you will see another password which is called "web services password". You will be using this password in both Apis and your username as you logon to Movabletype. Another problem is, instead of Author's display name, the username is returned inside an Entry node in Atom Api. It also returns the url and the email of the author. But in XmlRpc, there is no way to get the user details. You can only retrieve the details by providing the user's username and password. The other problem is, it returns the id, not even the username!! In XmlRpc there us no option to filter the unpublished posts. While it is very easy to get the most recent posts using XmlRpc, I could not find a way using Atom Api. Working on it!!!

If you want to implement those APIs, start by looking to Atomizer and xml-rpc.net Both are written in C# and working with Movabletypes.


To get the list of APIs that are supported by your blog server:

This link explains howto do it.

http://www.sixapart.com/pronet/breese/atom/protocol/atom_autodiscovery.html

View the source of your weblog's homepage.
In the of the HTML document, look for a link relation entitled "EditURI." It should look very similar to:
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.yourdomain.com/rsd.xml">
Cut and paste the value of the href attribute into your browser. This is the URL of the autodisovery document and contains a list of the APIs supported by the corresponding weblog.

To view your blog in atom format.
http://BLOGURL/atom.xml

To view your blog in rss format.
http://BLOGURL/index.xml

How to open a popup window using Javascript

<A href="<YOUR POP WINDOW>" onclick="OpenWindow(this.href);return false;">tell us online</A>

Rules:
-Provide the link in both onclick and the link's href attribute
-Instead of passing the url twice, one in href and one in onclick event, refer to the link's href attribute.
-Return false at the end of onclick method.

These rules enables us to update the link only in place. If the javascript is not supportted by the browser, users will be able to navigate by the link provided in the href attribute like a normal navigation.

Let's open a window with dynamic height. The height of the window will be calculated according to the screen resolution. Th width is 760. So we will center the window in the screen.

var popupWindow = null;
function OpenWindow(link)
{
if (popupWindow != null){
if(!popupWindow .closed)
popupWindow .close();
}

//Adjust the height according to the screen resolution
var height =800;
var left=20;
if (window.screen && window.screen.height && window.screen.width)
{
height = screen.height-70;
left = screen.width/2-380;
}
popupWindow =window.open (link, 'popupwindow','top=5,width=760,left=' + left + ',' + 'height=' + height + ',scrollbars,resizable');
popupWindow .focus();
}

How to implement CreateControlHierarcy in a Composite Control

There is a good article about how to implement a composite control and itexplains the usage of this method in detail.
http://msdn2.microsoft.com/en-us/library/aa479016.aspx

CreateChildControls must accomplish at least the following tasks:
-Clear the Controls collection,
-Build the control's tree
-Clear the viewstate of child controls.

protected override void CreateChildControls()
{
Controls.Clear();
//If it is not in design mode, get the posts and display them
if ((Page.Site == null) (!Page.Site.DesignMode))
{
CreateControlHierarchy(posts);
}
else //Set design time properties
{
this.Width = 100;
this.Height = 10;
}
ClearChildViewState();
}