Dave Burke : Freelance .NET Web Developer specializing in Online Communities

Adding Podcasting support in .Text

Adding Podcasting in .Text as I did it requires the addition or modification of the following components:

1) File Upload component in the Admin New and Edit Post forms.
2) SQL Table to hold information about the attachment (and retrieval stored proc.)
3) An Attachment Business Object
4) Data Layer methods to retrieve the attachment by PostID and populate the Attachment data object
5) Modifying the RSSWriter to add the ENCLOSURE tag.
6) Addition of attachment link in the post display.

File Upload component in the Admin New and Edit Post forms

Because this is not a podcast-centric site and attachments would be added to posts only occasionally (at first, anyway), I approached attachments as an optional design and UI element.  With this in mind, an "Add Attachment" expanding subform was added to the Admin New and Edit Post form, which, due to the smart architectural approach of ScottW, required me to add it only one time for both New and Edit functions.  The MimeType dropdown items were pulled from an XML file to be easily modified by the client.


SQL Table to hold information about the attachment (and retrieval stored proc.)

Click here to display the table layout and generation script. 

An Attachment Business Object

Again because of the optional nature of attachments for this particular community site, I created a separate Attachment business object rather than extend the Entry object or inherit from it like the CategoryEntry object.  I wanted to keep the logic of Attachments and Entries as separate as possible.  The complete Attachment business object is available here.

Data Layer methods to retrieve the attachment by PostID and populate the Attachment data object

Attachment attachment = Entries.GetAttachment(PostID) is the primary retrieval method call to determine the presence of a post attachment, and if available, do something with it.  Below is the Entries.Attachment() method followed by the core of the DTO and DB data layer methods as found in the LoadAttachment() method of the DataHelper Class.

public static Attachment GetAttachment(int postID)
{
 return DTOProvider.Instance().GetAttachment(postID);
}


public static Attachment LoadAttachment(IDataReader reader)
{
 Dottext.Framework.EC.XMLUtils oXMLUtils = new Dottext.Framework.EC.XMLUtils();

 Attachment a = new Attachment();
 a.AttachMimeType = (string)reader["MimeType"];
 a.AttachSizeInBytes = (int)reader["SizeInBytes"];
 a.AttachFileName = (string)reader["FileName"];

 string host = ConfigurationSettings.AppSettings["AggregateUrl"];
 string urlExt = oXMLUtils.getvalue("URLExtension").Trim();
 string path = oXMLUtils.getvalue("AttachmentURLPath");
 a.AttachmentURL =  host + urlExt + "/" + path + "/" + a.AttachFileName;

 return a;
}

Modifying the RSSWriter to add the ENCLOSURE tag

This was the most simple aspect of adding Podcasting support to .Text: updating the BaseRSSWriter and MainFeed classes.

Attachment attachment = Dottext.Framework.Entries.GetAttachment(entry.EntryID);
if (attachment != null)
{
 this.WriteStartElement("enclosure");
 this.WriteAttributeString("url", attachment.AttachmentURL);
 this.WriteAttributeString("length", attachment.AttachSizeInBytes.ToString());
 this.WriteAttributeString("type", attachment.AttachMimeType);
 this.WriteEndElement();
}


Addition of the attachment link in the post display

This is an attachments feature that I completely overlooked in the initial project estimate: adding attachment links to posts and post listings.  Fortunately it was a very easy matter of duplicating the logic of adding the enclosure tag to the RSS feed.  Below is a code excerpt followed by how an attachment link appears on a single post entry.


Attachment attachment = Entries.GetAttachment(entry.EntryID);
if (attachment != null)
{
 Literal bars = (Literal)e.Item.FindControl("bars");
 bars.Visible = true;
 HyperLink hlAttachment = (HyperLink)e.Item.FindControl("hlAttachment");
 hlAttachment.NavigateUrl = attachment.AttachmentURL;
 hlAttachment.Text = "Attachment Available";
}


 

So if you're a .Text user and want to get into Podcasting, here's how to get rolling.  Good luck and let me know if I can answer any questions you might have in adding Podcasting support to .Text.


 

Comments (6) | Post RSS RSS comment feed

Posted on 12/22/2004 1:26:00 PM by Dave Burke
Categories:
Tags: no tags for this post

Related posts

Comments (6) -

12/22/2004 3:29:00 PM Permalink

I love the red circles you do with the shadow.  How are you doing those?   Keep up the great work with .Text!!

Tim Haines |

12/22/2004 5:37:00 PM Permalink

Tim, THANK YOU!  I've been doing those red circles forever.  Quick screen capture in Paint Shop Pro (version 4.2, circa 1997) and then a Photoshop stroke and Drop Shadow effect.  I'll do a step-by-step post on it one day soon.  Thanks again for visiting.

Dave Burke |

12/27/2004 5:01:00 PM Permalink

This is great.  Thank you so much for publishing how you did this.  Working on the implementation now.

Aaron Junod |

1/7/2005 2:55:00 AM Permalink

Hi Dave,

I'd like to say that you have a great site here and it looks fantastic.  Now I have a quick question for a non .net coder like myself.  I want to implement some your you .text modifcations like the podcasting but know very little about coding.  Is there any chance you can send me some detailed instructions for adding the podcasting to .text?

Thanks in adance

Gary

Gary Twose |

3/9/2005 9:43:00 PM Permalink

being new to the .Text community. I am having trouble following where to make the changes you have listed here... I also am wondering if this all applies to the new community server 1.0 version that I am running?

Jeff |

3/9/2005 9:47:00 PM Permalink

Jeff, CS is quite a bit different from dotText.  QUITE a bit, so some of it will apply, but it won't be a straight port from dotText to CS.  I'm supplying the complete podcasting mod as part of my Code Camp 3 presentation on Customizing dotText this weekend, so you might want to check back here or on the Code Camp site for the full mod next week.

Dave Burke |


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke