One of the cool new features of the latest version of Subtext is the support for enclosures.
What can a enclosure do for you?
You can use it to:
- host a podcast
- host a webcast/screencast
- to have photoblog
- or just to include a downloadable file to your post, like a code archive, a pdf file or a PowerPoint presentation
How to add a enclosure
At the bottom of the post page you’ll find a new section. Just enter the following data:
- the url of the enclosure: it must be the absolute URL of the file of the enclosure (absolute even if on the same domain as the blog)
- mime type: it’s automatically selected when you enter the url, but you can change it in case you have a strange mimetype. This is used by most client to show a icon of the enclosure
- size of the enclosure: the size in bytes. Again, used only by clients to display the size of the file.
- the title of the enclosure: this is used only in the web frontend of the blog (no use in RSS), to display a link to the enclosure from the post page
- as last thing you can decide whether to show the enclosure from the blog or syndicated with RSS, or both.
How the enclosure is rendered in the browser
Once you added the enclosure to the post, it will show up in different ways depending on how you are looking at it.
Directly from the blog, if the skin you are using supports it, you will see a link to the enclosure at the end of the post.
If your skin doesn’t support this, it’s just a matter of adding a <asp:Label> control to a few ascx files. I’ll explain how to do it at the end of this post.
Here on the left you see how it is rendered in the post view page, with the title and the size of the enclosure. The same will be displayed in the homepage.
If you read the RSS feed syndicated by your blog directly within the browser, Firefox and IE will format it in different ways.
How the enclosure shows up in feedreaders
RSS feeds are not displayed only inside the browser but also and mainly from feed readers. Here is how my feedreader FeedDemon renders the enclosure:
Subtext-powered podcast on iTunes
Probably most of the people are going to enclosures for doing podcasts. The most used podcast downloader is iTunes, and here is how the enclosure from Subtext are displayed:
Subtext doesn’t have a full support for iTunes yet (there are many custom rss elements needed to provide to iTunes all the information it needs) but it’s already in the works and will be released in the next version of Subtext.
How to add enclosure support to your skin
As I said earlier it’s quite a trivial fix. All you need to do is add the following lines in the Day.ascx and ViewPost.ascx user controls.
<asp:Label id="Enclosure" runat="server" DisplaySize="True" />
Day.ascx is the control that renders the posts in the homepage while ViewPost.ascx is the one that is rendered in the single post page.
If you set DisplaySize to false, the size of the enclosure will not be rendered on the page.
Tomorrow I’ll talk about another cool new feature of Subtext: frontend performance optimization. Please subscribe to the feed if you want to get it automatically in your feedreader.