And I’ve listened. There are two big changes in the latest Extension Manager version – you can bring in your own admin UI and default settings page provided by manager became dynamic. Now it is not just two predefined boxes, you can add as many parameters as you like.

You can tell Manager to use your own admin page instead of default one by including this code in the extension initialization:

ExtensionManager.SetAdminPage("MyExtension", "~/path/to/mycustompage.aspx");

Where "MyExtension" is your extension class name and "~/path/to/mycustompage.aspx" is a path to your default custom page. When used, "settings/edit" link will point to your custom admin UI rather than standard setting page.

Default settings page became dynamic. This means you can define number of parameters you want Extension Manager to handle and for each parameter text box will be added to settings page at run time. It has basic validation on maximum characters allowed, required field and uniqueness. It is not yet support strong typing but it will in the future with corresponding validation provided. It also only uses text box for parameter input at this stage, support for other controls (combo boxes, check boxes, date and color picker etc.) will be added later on. I will put together section in the WIKI documentation on how to use it when 1.3 released, but here is quick preview of the main features:

With default page, main focus was on ease of use - couple of examples should be sufficient for learning how to use it. At the simplest level, all you need to do is add your parameters as so:

ExtensionSettings settings = new ExtensionSettings("BBCode");
settings.AddParameter("Code");
settings.AddParameter("OpenTag");
settings.AddParameter("CloseTag");
ExtensionManager.ImportSettings(settings);

Then, you can grab your data as data table, where columns are your parameter names and rows are actual values:

DataTable table = _settings.GetDataTable();
foreach (DataRow row in table.Rows)
{
  if (string.IsNullOrEmpty((string)row["CloseTag"]))
    Parse(ref body, (string)row["Code"], (string)row["OpenTag"]);
  else
    Parse(ref body, (string)row["Code"], (string)row["OpenTag"], (string)row["CloseTag"]);
}

Extension manager will automatically set default validation rules, all of which overridable. You can also import your default values to Extension Manager and they will show up in settings list right away. The full list of options you can use will be published in the WIKI once 1.3 is in.

settings.AddValues(new string[] { "b", "strong", "" });
settings.AddValues(new string[] { "u", "span style=\"text-decoration:underline\"", "span" });

At this point, I consider current version is a "release candidate". There is still some work to do, but interface itself is highly unlikely to change. Now I'll concentrate on stabilizing code, error handling, adding more validation, localization and probably a bit of refactoring. And a lot of testing to make sure code is solid and works on every machine every time. If you'll be playing with it and run into issues or have any concerns - don't hesitate to drop a line.

Signature

Related posts

Comments

12/17/2007 10:41:04 AM

I hate to come into this late in the game when you appear to be finalizing the code on this, but I really think that there are a few changes that need to be made with the extension manager. An extension that I just recently made was to submit comments to Akismet in order to filter spam. Well, I saw that you were working on an extension manager that would allow me to save the API key and Blog URL somewhere other than the source of the extension. Well, I started looking into the extension API and saw that it appears that it is being aimed at a particular use case and that is where you have a multi-dimensional list of settings for one particular use. What I am wondering though is why there is no easy way to just save a single setting? I don't need a list of API keys and Blog URL's. I just need a single API key and Blog URL. And with that said, having the only way to pull out the settings is to call "GetDataTable()", well that also kinda points to it having only one real use. I'm sorry if this is coming across as overly negative, I don't mean to be, the work you have done is a great contribution to BlogEngine.net. I just hope that BlogEngine.net 1.3 has an easy way to persist single settings for Extensions without writing custom code. Also, I would be willing to help if you wanted any assistance in implementing any of these changes.

Justin Etheredge

12/17/2007 11:30:17 AM

Justin, I'll look at your extension to make sure I understood correctly, but it seems like you only need to create two parameters, in you case "API key" and "Blog URL", and manager will add two text boxes to let blogger to enter or change these settings. I understand that table is overkill in your case, so I think I'll add a constraint that you can specify in extension only let to enter a single value, then grid view will never show up. I also add a method that will return single setting (first field in the first row behind the scene). May be also first row as string collection, might come in handy in some cases. I'm pretty sure it won't take long to code, no redesign needed, only few simple additions on top. These are very good points you brought, I'll contact you later so we can discuss if this is exactly what you need and if there a better fit. Thanks for interesting in the project.

rtur.net

12/17/2007 11:41:17 AM

Yes, the scenario you describe would work in my case, but it wouldn't work if I needed a few settings and a list of setting. Pretend that I had an extension like the BBCode extension, but also needed a extra setting for an APIKey like in the Akismet extension, then this configuration would not word. Having said that, your solution would work for a large number of cases and I would certainly rather see it implemented in this way than not implemented at all. Again, I know how much it sucks when people criticize things that you worked hard on and so I just want to be clear that I most certainly am not trying to trash your work, your work is making the extensions so much easier to configure!

Justin Etheredge

12/17/2007 11:52:44 AM

I'm definitely aware that it will not work in all possible cases. I thought about scenario you just described, and decided that for complex situation it is easier to be able to build custom page and bring it in. In the future, if there is a demand, it will be possible to enhance existing framework to have multiple settings so it will support this scenario, but it would be problematic to pull it in couple weeks I have on my hands.

rtur.net

Add comment


 

  Country flag

biuquoteimg
Loading



<<  May 2008  >>
SuMoTuWeThFrSa
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Enhanced with Snapshots

Subscribe to Rtur.net