This project is read-only.

Suggestions for a future patch to help extension writers.

Topics: ASP.NET 2.0
Jan 3, 2008 at 9:40 PM
I have a few thoughts about extensions and what is currently possible with them. I happen to be very passionate about API's and Extensions so please ignore me if I sound too opinionated about the topic.

1) I was wondering if it would be possible to allow for an automatic (or easier) and safe way to grab information about the parent page (not a BE Page or BE Post mind you, but the System.Web.UI.Page). The reason being is that sometimes in a more complicated extension you may want to add CSS or JS code to the overall page, or maybe you want to modify (or add to) text underneath the blog description in your header. Right now as far as I understand you can modify text before it's served for a Page, Post and Comment and sometimes that isn't enough for what you might want to do. Currently, they only way I know how to do this was borrowed from someone else's extension and it seems a bit 'hackish':
HttpContext context = HttpContext.Current;
if (context.CurrentHandler.GetType() != typeof(BlogEngine.Core.Web.HttpHandlers.SyndicationHandler))
if (context.Items"wowitem" == null)
System.Web.UI.Page page = (System.Web.UI.Page)context.CurrentHandler;
string js = "<script src=\"\"></script>";
page.Header.Controls.Add(new System.Web.UI.LiteralControl(js));
context.Items"wowitem" = 1;

2) Going on the topic of CSS and JS additions from an extension, I was wondering if maybe it was possible to somehow add the text of your custom script to the CssHandler or the JavaScriptHandler. I noticed that if you add a reference to a CSS file to your theme page that it is automatically merged into the css.axd file, yet if you add a stylesheet reference tag during the execution of your extension you do not gain the benefit of the css.axd file.

3) I find that half of the the whole BlogEngine is capable to be used over the MSSQLProvider, yet there is still some bits of information that is left behind in APP_DATA. (An example is the user information). The one thing I noticed with the new ExtensionsManager is that it stores everything in XML and has no ability to store using an MSSQL provider. (This leads me to an aside comment about the MSSQLBlogProvider.cs class as to why nothing is databound and everything is read using ExecuteReader()... I will post this as a different discussion thread though). The main point of this suggestion is that it would be nice for an abstract storage class that would allow for extension authors to store settings in either SQL or XML or whatever data provider they chose.

The datastore (Whether XML, SQL or whatever) in my opinion would have four fields 1) guid 2) ExtensionName 3) ExtensionKey 4) ExtensionValue. That way a query could be made (using XPath or SQL or DataSet.DataTable.Filter etc) when you setup new ExtensionSettings("ExtensionName") and it would get all the key / value pairings required from that.

Right now ExtensionSettings works for setting up say how an extension should act, but it would be really nice to store data for that extension too. For instance, right now the current method works really well for the BBCode extension where I could set tags that get replaced by other values. It does not work really well for an extension that creates RandomQuotes or other silly things like that, which would hold a dataset worth of values.

Sorry for the long winded post, but I love BlogEngine soooooo much that I would love to see it grow to a point where I would customize nothing and create things all encompassed in individual extensions.
Jan 4, 2008 at 4:59 AM
jwendl, the only reason extension manager does not have SQL data provider is because the whole thing is just few weeks old... I know guys from Extensions project do some work on SQL data provider for the photo gallery extension and may be will borrow some ideas from what they are doing. SQL data provider definitely will be there, just give me some time :)
Jan 4, 2008 at 6:45 AM
rtur, excellent. This post was by no means a post asking why it wasn't done yet ;-).

As far as the ExtensionManager is concerned I just wanted to make sure it wasn't a feature added and then forgotten.

Some of the other points would be handy though such as allowing to add to the CssHandler from an Extension etc.

I was considering writing a PhotoGallery extension also, umm I guess if you guys need help writing anything I would be game. If the help isn't needed, then I can't wait to see what the photo gallery extension team comes up with for that!

Out of all of the blog platforms I have used (wordpress, .Text, CommunitServer etc) this is by far the best "Engine" I have seen yet so keep up the good work!
Jan 4, 2008 at 9:05 AM
I submitted a patch which includes an SQL provider for the Extension Manager. It's not perfect but it works. You can download it from the patch tab. On the Photo Gallery project, we are having a lot of internal discussions regarding the data layer (and business layers). For example, it would be nice for custom extensions to be able to create their own provider components under the data providers (SQL, XML or MSQL). We have some experimental code up on CodePlex for review and discussion. The design is also so more components to be dropped in (without have to modify existing BE code to get it hook in), yet still benefit from code-reuse. Actually, we're hoping that official BlogEngine.NET team would let us know their own ideas on the subject and if this is something we can collaborate on. We don't want to get carried away if the official team has other ideas.

BTW. The Photo Gallery extension has a demo site, the link is on the project page. It's a few weeks old now, but the main components are there. You can also download it and run it. The full download has our test pictures, albums, photo effect extensions, custom controls, etc. for now. Check it out.

Jan 4, 2008 at 6:02 PM
tgiphil, that rocks. You have exactly answered my questions about the photo gallery project. I am going to look at it myself and see if I have any constructive comments to make about it.

Thank you for the SqlProvider patch too for the Extension Manager I can't wait till it is merged into the main code.