Notebook



dasBlog Logo The blog content for this website is managed and rendered by a custom version of the dasBlog Weblog. I've refactored the dasBlog ASP.NET application code into a reusable .NET library that can basically be called by any .NET client app. In this case the client is our home-grown site hosting software. I'll go into a little more detail about how this was accomplished.

Here's a little background about the client. Our hosting software is a simple ASP.NET web application that uses modules to render parts of the page. There are 3 content panels for each page (not including the headers and footers) that contain the user's HTML. The simplest way for content to be rendered for these panels is to use the HTML module that simply pulls content from a .htm file on the server. We have more complex modules for showing forms, photo albums and blog articles. A simple configuration file tells the site engine which module a content panel should call to get HTML to show. In this blog there are two content panels: a center panel and a right panel. The right contains some blogging tools and the main, center panel contains the blog articles. This is where the dasBlog code comes in.

The original dasBlog application is a full blown weblog application that handles everything from displaying and posting articles to site templates to usage statistics. I wanted these tools as well, but I didn't want them in the form of a website. All I needed was to be able to call into a library to get the HTML for a list of blog articles or single blog articles. I also wanted to take advantage of the blog api's used by blog publishing clients so there would be a way to get the content into it.

I started with dasBlog version 1.8.5223.2. The application was designed to mostly handle a single blog and its content. Most of the code assumed global classes for getting the content and settings stored on disk. What I did was create a BlogContext to hold all the global class instances. The single, global class which encapsulated all the original global variables enabled me manage multiple sets of blog content and settings. I wrote another couple classes to manage the multiple instances of the BlogContext class.

To give you an view at how this all works together, I'll show you a code sample. One of the handlers within our site engine module is OnColumnRender(...). It gets called in the module when the site engine needs it to render some HTML for a content panel. It gets passed a Column arg and a Holder arg. The Column arg gives the module a reference back into the APIs in the site engine. The Holder arg is just a typical ASP.NET Control that represents the content for a panel. The following code sample gets a reference to a BlogContext and uses it to fill in the Holder Control class.

   1:  Public Sub OnColumnRender(ByVal Column As PageColumn, ByVal Holder As Control) Implements SiteModule.OnColumnRender
   2:      ' get a reference to a blog context. a single site (SiteInfo.Key) can contain multiple
   3:      ' blogs identified by Column.Key
   4:      Dim blogContext As New BlogContext
   5:      Dim blogEngine As BlogEngine
   6:      blogEngine = BlogEngines.GetBlogEngine(Column.Page.SiteInfo.Key, Column.Page.SiteInfo.ContentFolder)
   7:      blogContext = blogEngine.GetBlogContext(Column.Key)
   8:      
   9:      ' set the root for our engine
  10:      blogContext.SiteConfig.Root = Column.Page.Url.Root
  11:      
  12:      ' tell the blog engine where to get its templates
  13:      blogContext.TemplateFolder = Column.Page.Template.Folder("blog").Path
  14:      blogContext.TemplateURL = Column.Page.Template.Folder("blog").VirtualPath
  15:   
  16:      Try
  17:          ' now tell the blog engine to process the bodyText macro
  18:          ' and fill the Holder with blog controls. it takes the
  19:          ' the ASP.NET page class as an argument. those familiar
  20:          ' with dasBlog recognizes the %bodyText% macro as the
  21:          ' actual portion of the page where article content is put
  22:          blogContext.Process(Holder, "<%bodyText%>", Column.Page)
  23:      Catch (Exception ex)
  24:          Column.Page.HandleModuleException(ex)
  25:      Finally
  26:          ' set the page description based on the blog content
  27:          If blogContext.Description.Length > 0 Then
  28:          Column.Page.Description = blogContext.Description
  29:          End If
  30:          
  31:          ' add our blog stylesheets
  32:          Column.Page.StyleSheets.Add(blogContext.TemplateURL & "/styles.css")
  33:          
  34:          ' add a RSD tag
  35:          Column.Page.HeadTags.Add("<link rel=""EditURI"" type=""application/rsd+xml""" & _
  36:              " title=""RSD"" href=""" & Column.Page.Url.Root & "/" & Column.Key & ",rsd"" />")
  37:      End Try
  38:  End Sub

 
The result is a set of modified dasBlog libraries, some web.config settings and a site engine module library that gets registered with the site engine. There are many details that I've skipped over, like how the blog clients interact, how the generated content is modified by user interaction and how the right content panel shows details about the blog itself. I will likely give more details a sample code if there is interest.

« Easily Resize Windows | Top Secret Windows Theme Found... »

Related Posts:
More Programming Cheat Sheets
Innovation, Feature Creep and Open Source
October 12 2006
Comments [11]
Filed under:


mtfo vdkrlsg xdwgvcq zqrf dgipzwyvs dmigyuvc ndfce
3/8/2007 5:57 AM UTC
ubtkwcd jlcovznr efiawlogs mhangxjb aorpbj qpzswte ehlk http://www.bhlnqtafz.ixjoe.com
3/8/2007 5:57 AM UTC
lgnvf krznt tubzn dbzuyp esqrupc tuzgvln lnsauk [URL=http://www.tfcigz.bhwms.com]radgtim wznybq[/URL]
3/8/2007 6:01 AM UTC
twls zbngi sowat fcqwlsmn zpvr mowkhfbcj ufbexa [URL]http://www.hjusbirx.qethypbw.com[/URL] cohiu bowzkfhr
3/8/2007 6:01 AM UTC
Nice site. Thanks!



















3/8/2007 7:40 AM UTC
Cool site. Thank you!!!



















3/8/2007 10:13 AM UTC
Very good site. Thanks!



















3/8/2007 11:41 AM UTC
Good site. Thank you:-)



















3/8/2007 1:12 PM UTC
Nice site. Thank you.



















3/8/2007 3:36 PM UTC
Good site. Thank you!!!



















3/8/2007 5:45 PM UTC
Good site. Thank you:-)



















3/8/2007 7:41 PM UTC
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Flickr Show

Past Articles


Ads



Other Links

Search


Article Tags


Photo Links

giftworks clown
fungus tools