After recently starting this blog using my Blogger account and its FTP publishing feature I wanted a more seamless integration with my existing site for the index page of the blog. In other words, I wanted to show the latest blogs as part of my existing site using the masterpage I have in ASP.NET.
To achive this goal, I have set Blogger to publish to /blog on my domain, with a proprietary filename and .html extension. I have then put a Default.aspx page in the /blog directory, which uses the site master page.
This default page basically opens the .html file server side and writes the stripped out relavent HTML content to a placeholder in the ASP.NET page. I have included some of the Blogger specific meta/link tags in the .aspx page head, to enable the RSS/Atom feeds from the page and to enable the edit post controls etc. to work.
As its ASP.NET you can also add extra features to the page. I have added a drop down list of the categories (Blogger labels) to use as a quick link to each category. Blogger.com creates a .html page for each of your labels containing links to the relevant posts, these files are stored under the 'labels' folder, which can be simply enumerated on the server.
if not IsPostback then
Dim file As String = "blog-content.html"
dim content as string=IO.File.ReadAllText(Server.MapPath(file))
content = content.Substring(content.IndexOf("<body>") + "<body>".Length, content.LastIndexOf("</body>") - content.IndexOf("<body>") - "<body>".Length)
content = content.Remove(content.IndexOf("<iframe"), content.IndexOf("</iframe>") + "</iframe>".Length - content.IndexOf("<iframe"))
'load the labels
dim labelFiles() as string=IO.Directory.GetFiles(Server.MapPath("labels"))
ddlCats.Items.Add(New ListItem("--Jump To Category--",""))
for each filename as string in labelFiles
dim url as string=filename.substring(filename.lastindexof("\")+1,filename.length-filename.lastindexof("\")-1)
catch ex as exception
lblContent.Text="Error: " & ex.Message
My site only uses this method for the index page, but you could extend this idea even further to display all blog pages within your custom ASP.NET / masterpage site, by putting the /blog directory under a custom HttpHandler (if your server allows this) and rewriting the URL to your ASP.NET page. Also I would suggest using regular expressions for filtering the HTML if your server supports it.
I have now improved the integration by using the HTML generated by my masterpage as the template on Blogger.com, so all the pages look like you are on my website. This means I could refine the above process of finding the correct content for each placeholder, (with the addition of a seperate placeholder for the sidebar) as the divs that contain the data have specific class names.
I have also created two more aspx pages, "index by date" and "index by category" - the code behind for these simply enumerate the "archives"/"labels" folders on the server, (the same as my drop down box above). Additionally, these pages open each .html file to parse the content for all of the post titles and permalinks to create the list of links for each date/label.
Since my blog no longer uses Blogger due to FTP publishing being cancelled this code is now redundant.