The Bitland Prince Development Blog

.:: development horror stories ::.

You might know that Diavolo has a feature which dinamically injects JavaScript files in a specific location into your portal pages, without you having to modify anything specific. You drop that .js file and Diavolo will pick it and add it to your page. I really can't say how handy that feature is to me since many pages of my test project use some kind of JQuery/JS goodness and that will be enabled only by dropping my JS file in a specific location and add my code.

Actually, up until now you had another step which was needed in order to let your eye-candy JQuery scripts to run : a CSS file. Because we all know those scripts usually need a companion CSS file. If you use (like Diavolo does) ASP.NET Themes, you can simply drop your CSS inside relevant folder and theming engine will include that on next run. That's very effective and was a very nice innovation from ASP.NET team, though many projects prefer to use home-grown solutions.

But since developers aren't ever satisfied Yell I thought one might need an half-way solution. Imagine you want to use a CSS for a single page on your portal : in most cases (other CMS) you would add a new HTML section and add a reference for that new CSS file inside it. It's quick and dirty but it works, expecially when testing something.

Diavolo now supports loading extra CSS files in a per-page fashion. That is, you will still have all of your common CSS files inside your App_Themes folder, but now you can also have page-specific CSS files inside your /scripts/auto/dynamic/xxxx folder. If you're wondering if that's the very same folder where your dinamically-injected JS scripts will be placed, the answer is YES ! Reason for this is to keep things simple: in most cases, additional per-page CSS files will be somewhat linked to Javascript goodies. By using the same folder, we will keep things easy and straightforward: just drop your CSS files where you drop your JS files and you're ready to go.

Why should you care about that ? If you're using lots of JQuery scripts, each of them will be using its own CSS file. However, if you need that plugin on a single page of your 100-pages portal, why should you load that JS and its companion CSS all the time ? After sticking some plugin in, you will find yourself loading tons of JS and CSS files on every page and that's not desiderable.

Now you can keep your ASP.NET App_Themes folder for what it really is : a place for common files, while specific files will be dynamically loaded and injected at your will. I'm very excited for this feature which, in my opinion, also walks the very same spirit of ASP.NET itself : configuration when possible, code change only if needed, possibly decoupling those two.

P.S. Did I mention that extra CSS will be automatically minified too? Yes! It's true! Thanks to wonderful mbCompression handler, dynamically injected CSS files will be minified as well with no extra steps taken ! Gosh !


Diavolo gets an extensible dashboard

Lots of development time, lately !

Once I finished integrating VisualWebGUI into Diavolo, I was able to think to refactor a lot of code and I just had to decide where to start. I'm planning to rewrite most administrative functions using VWG because that will make a lot easier to implement even complex functionalities. But go a step forward toward finishing Diavolo, I thought to work on its Dashboard.

You might wonder why Diavolo needs a Dashboard so I'm just grabbing a screenshot for you (and preview for our new corporate Website implemented with Diavolo !):

So dashboard is that nice panel which can be scrolled down to reveal a few functionalities which are usually handy to provide on every page of website even if they're not part of any specific page. For example, login controls will be placed on dashboard and they will be available on every page. In that screenshot, you can see a snap of currently-enabled admins panes on dashboard: an overview of your login status, a security panel which allows to quickly change roles allowed to view and edit that page and a panel with shortcuts to common administrative tasks. Dashboard can be closed or opened at will. Here's a peek of what dashboard panel will look like when closed :

You open it with a click and the close it. That will allow you to save precious screen real estate while still providing some non-essential functionalities like login, shortcuts to pages and so on. Great thing about Diavolo dashboard is I made it extensible and customizable at will. It will be built around panels which are basically web controls which Diavolo will load on demand when building dashboard so portal administrators will be able to add and remove panels which will be shown to users, being able to even decide order in which panels will be shown.

This is really a nice point of extensibility as panels can basically be everything since your ASCX files can even just include simple HTML markup if you just want to provide simple HTML contents. At runtime, Diavolo will show a list of all ASCX files in a specific folder and allow administrators to decide which panels to show :

 

Here you can see very simple Dashboard management : on the left, a list of all panels (components) which are available in ~/Modules/DashboardModule/Panes folder of your portal. Then admins can customize components for three different users types : Anonymous, LoggedIn and Admins. If you carefully look at that image (I hope you can: it's very small !), you will see that components Login (to allow users to login) and NewRegister (guess!) are configured for anonymous users.

Logged-in users will be shown a LoggedInVSW panel, which is a customized version of LoggedIn component which will ship with Diavolo, and UsersShortcuts components which simply is some HTML markup to provide shortcuts to specific pages (like orders, for example) for users of our own corporate website.

Admins will instead be shown LoggedInVSW panel (which, for example, will allow to logout and to edit your own profile), SecurityPanel (a panel to manage security for current page) and AdminShortcuts.

I have to say that I'm implementing panels for our website and dashboard already proved to be a very nice and easy point of extensibility. I plan to let portal admins to be able to customize Dashboard based on user role, not only their statuses, but I think we had a good start with current configuration.

Panels need not to be Diavolo modules and, infacts, they should not be unless you really need to have your panel be a module too. Panels are simply web controls (or better, they inherit from UserControl) so any control can be a panel. You will just need to pay attention that any dependency your panels will need will be installed into Diavolo (i.e. assemblies in bin folder, images and so on).

And one of most exciting feature is panels are fully localizable ! YaY ! You might say I'm a bit obsessed with localization but in my job I usually need to work with websites which can be accessed by different users and I usually stumble in products or CMS which are only partly localizable (last one I met : Orchard... pffff) and that means you have to fight with those applications to achieve a good result. I'm happy to say that even dashboard panels will be localizable, both with markup and in code, since while they don't really depend on Diavolo itself, they can use standard .NET resource management Diavolo implements to localize contents.

And that's GREAT ! Tongue out


Let me state it : Diavolo is ASP.NET WebForms. I know most people is now fond of MVC and that stuff but let me say I tried to use one of those stars lately, that is Orchard, to gain some knowledge about new kids on the block and, while I find it interesting, Orchard is very convoluted, like probably most of those projects. Don't get me wrong, I'm sure it has lots of potential and lots of innovative things since it's probably one of the most interesting project which grew up lately, however WebForms is a different beast. Nothing currently matches its flexibility and, via WebControls and extensions, its ability to become anything and everything you want. Of course, there's some overhead in it but in my opinion it's worth the pain.

So how does Diavolo compare to new Web 2.0 stuff ? Well, I should say XHTML conformance wasn't my top priority as a start. I'm now focusing on ironing things together and then I will also focus con standards. I consider that an optimization rather than a mandatory things and since we didn't have our first release (which would probably be Diavolo v4.3), I'm not putting too much emphasis on XHTML conformance yet.

So what's in Diavolo now which relates to Web 2.0 ? First of all, I was really happy to be able to create a container which proved itself flexible enough to accomodate many different technologies. Diavolo currely is WebForms (never forget!) but supports new ASP.NET 4 routing for WebForms meaning you can create your stuff eliminating postbacks, if that's what you want, and relying on URL parameters. To make it easier, it has a very basic but flexible parameters engine which will automatically detect your parameters and make them available to your code without relying on parsing query strings. So when in your "news" module, you can rely on postbacks to display selected news or you could redirect to your "XXX/read/167" URL where read is your parameter to tell your module it needs to load a specific news and "167" is your news ID. That's similar to MVC actions / controllers though Diavolo is not MVC. You could also redirect to "XXXX/year/2011/month/10/" to list all news for October 2011 and so on. Whether you prefer to use postbacks or URL routing, that's up to you but that opens new possibilities for SEO lovers. And we all love SEO stuff.. Wink

Then you have MS AJAX Extensions and that means UpdatePanels, AJAX Control Toolkit and everything from MS AJAX arsenal. I agree MS AJAX Control Toolkit slowed development a lot lately but UpdatePanels are, in my opinion, great stuff. Plus, you can use UpdatePanels with other AJAX frameworks to provide AJAX development and newer stuff. I don't really know if AJAX CT will still be around in a year from now since it really seems things kind of halted, however a few extenders are very useful (validator callouts, for ex.) so it's very nice to have Diavolo support both UpdatePanels and AJAX Control Toolkit, even if you won't use them.

Then you have JQuery. I agree JQuery is where most AJAX development is happening and you will find lots (and I mean: lots!) of JQuery resources, scripts, widgets, plugins and so on. So for serious Web 2.0 development, we had to support JQuery and... I did it ! Diavolo fully supports JQuery and, best of all, it allows to mix and match jQuery and MS AJAX framework together. I love those cool JQuery UI dialogs opening on my pages and displaying UpdatePanels which will make it possible to add server-side code to handle your AJAX stuff directly in your page and that means events and so on. I also love the idea to be able to control my JQuery scripts right from code-behind by emitting my management scripts right from server-side code. That makes it possible not to have logic in your JS scripts and only care to manage things server-side. And you still have power of JQuery at your disposal and that means all the cool stuff you can find on the Web. JQuery is a must and we have it.

Finally, VisualWebGUI joined the camp. Let me say that being able to integrate so different technologies is really a proof of stability for Diavolo and a proof of flexibility as well. VWG is king for AJAX development and it makes difficult tasks very to handle. Kind of Web the way it should have been since the start. Most administrative tasks in Diavolo will be handled by VisualWebGUI and they are being rewritten right now (for example, Dashboard management is know a VWG module) and it's so cool to be able to control JQuery right from VWG.

So here you go: WebForms, SEO-friendly routing, JQuery and VisualWebGUI... what would you ask more for Web development ? Cool


While I didn't post that much lately, work around Diavolo is going on. I have to say that I'm appreciating flexibility I was able to achieve everyday more ! Now the good news: I recently took some time to integrate VisualWebGUI support into Diavolo and I have to say it worked like a charm ! I already had some experience in integrating VWG into WebForms applications since I did that a few months ago in a different project. But the good news is everything works as expected, including all things which were supported in the past !

As you might know, VWG now uses JQuery as its rendering engine. Not that JQuery is exposed to VWG developers but VWG does its magic undercover. I was a bit skeptic that I could stick everything together and make it work but it was easier than expected. VWG runtime has been integrated in a pretty easily way but the most charming thing is how you can call JQuery from VWG to run your JS code inside a page.

VWG has a nice theming system but that didn't really took off. Core developers and a few users took time to develop a few themes for VWG apart standard ones but most of them don't really work as expected in modern browsers. In most cases, you end up having to use Windows Vista theme which they have implemented in a very good way but it's not what you would expose on your website. Consider dialogs, for example... plus, I worked to integrate JQuery UI into Diavolo so I was using that engine for dialogs and so on and I didn't want to use some Vista-like stuff.

To my suprise, I had to work a few hours and I was able to allow VWG forms to call JQuery and JQuery UI code to display things. Quite awesome!

In a few days, I will take care to convert all administrative logic (pages, properties for modules and so on) to VWG to achieve an easier way to manage things while still allowing modules and hance pages to work as expected without any VWG code.

All in all, that was a very good achievement as I'm now able to exploit VWG whenever I need to obtain quick development/deployment or complex interation with users.


Since it's Saturday, I was planning to do some checkings which you can only do during quiet times, i.e. when you have no screaming customers worried because their websites aren't working, for whatever reasons including them being brick-heads Cool.

I was checking a new server which recently came into production (for your own records, its name is Almania) so we're still filling it with websites and found out that we basically have a 11% ratio (active / configured). On that server we are using a very aggressive shutdown policy which basically means your website will be shutted down and removed from memory after 5 mins when idle, that is to say your website will be shutted down 5 minutes after last connection has been served. Of course, website will be restored when it will receive a new connection.

As a comparison, I wanted to check another server which has been in production for almost 2 years now (Bal'demnic) to check if ratio was close or not. This server has way more websites configured on it since it's been in production way longer that Almania and it uses a somewhat relaxed recycle policy which is set to 10 mins. I was somewhat surprised to find out that Bal'demnic ratio (active / configured) was almost 16% which is very close to previous measure. Interesting indeed.


It's been a while since my last post but I have to say that many things moved in past 3 months. Today I want to blog about a new cool feature which I added a few days ago : a very basic intra-module communication system which will allow modules to send and receive requests among each other during page life-cycle.

I know you MVC kids won't easily understand what the problem is but for WebForms developers there has always been a a quite annoying problem: when processing web controls, expecially custom controls, those which will be processed earlier in page life-cycle have no way to respond to changes performed by controls which get processed later. While this is acceptable in many cases and that's the way most framework works (including MVC), real big advantage of WebForms is to clear ground for advanced processing. That big advantage over other technologies is someway limited by restricted communications between controls since webcontols usually change their processing based on postback data or query string parameters.

Consider this example: I have many controls on my page and one of them is showing a list of pictures which are tagged. Another controls is displaying a list of blog posts and those are tagged as well. In my page life-cycle, webcontrol for pictures get processed before the one displaying posts so if I decide to select a post to read it, maybe inside the very same window, when my postback event gets processed my list of pictures have already been generated since that webcontrol will be processed earlier. So, in that case, how can I generate a list of pictures based on post tags when a user selects a specific post to read it ?

That seems to be an esotheric question for most Web developers but having such feature would be very good in a WebForms context and that's why Microsoft created its connections in WebParts Framework. Connections just do that: take data from other WebParts to create custom processing.

A MVC kid would probably laugh at this problem and state that he/she could simply generate an AJAX Javascript call to a controller and pass it a post id which could be used to generate a list of pictures to show inside pictures box. Nice and true. Except that you won't have clean and nice separation between modules (webcontrols) and independence about them. MVC solution would make posts list (or page) dependent on pictures while WebForms solution would allow both controls to be 100% independent from each other. Admins could also remove one of them and page will keep working.

So I found a nice solution which is both easy to implement and effective... at least I hope !

Each DiavoloPageBase class now has a ModuleCommunicator class inside of it, which gets initialized on page Init. Each module can subscribe this class to receive notifications from other modules where a notification is simply a combination of a name (roughly equivalent to event name), a dictionary of parameters and a flag which specifies if that call is an AJAX call.

Each module can subscribe to receive notifications (events) by simply:

CType(Page, DiavoloPageBase).ModuleComm.AddNotification(AddressOf EventTarget)

        Private Sub EventTarget(ByVal Name As String, ByVal Params As Dictionary(Of String, String), Optional ByVal IsAJAX As Boolean = False)
            ' Code here
        End Sub

First line of code will add a delegate (whose name is EventTarget) to current page module communicator. From now on, EventTarget will receive notifications from other modules and module can trigger a notification event this way:

Dim Params As New Dictionary(Of String, String)()
Params.Add("OrderID", "12345")
CType(Page, DiavoloPageBase).ModuleComm.Notify("ShowOrder", Params, True)

In this example, we create a new dictionary for parameters to pass a new order ID and then we invoke Notify for a "ShowOrder" event (or trigger name, or whatever you want to call it).

Our EventTarget procedure will receive these parameters. Notice that EventTarget will receive ALL notifications and thus it should check event name to understand if it has to handle that specific notification. Also notice that notifications targets (i.e. procedure which will be invoked) cannot modify parameters and pass them on.

Automatic subcriptions

We borrowed this idea from DotNetNuke (thank you guys!) though our implementation is quite different. Basically, a module could implement interface IDiavoloCommModule to be automatically subscribed to notifications. When adding modules, Diavolo checks if module implements that specific interface and, if that's the case, it will add a subscription to mandatory procedure which has been defined by module as part of implementation of IDiavoloCommModule.

That makes subscribing to notifications very easy and straightforward. However, that's not mandatory because, since ModuleCommunicator class is exposed as page property, modules can also decide to explicitly subscribe and unsubscribe. That might be helpful if subscription is only needed as an answer to specific conditions.

Difference among Diavolo implementation and WebParts connections

Since the purpose of this new extension is somewhat close to WebParts connections, what's the difference between them ? Well, Diavolo Module Communicator is less formal and, in my opinion, less flexible than our implementation which is quite open. WP connections goal is to automatically share data among controls and they require a less flexible approach which force developers to decorate their code with specific attribute. This is less flexible because :

  • consumers just pull data out of providers: nothing more;
  • connection only happens during page pre-rendering;
  • you cannot unsubscribe because your connection has been in code via attributes;
  • you only have one way to communicate, i.e. from providers to consumer, and nothing else.

In our implementation, notifications can happen anytime during page life-cycle and notifier aren't just providing data to consumers. In WP implementation, my consumer gets all relevant data in a property which also requires (in most cases) to define an interface to give shared data a structure, as long as you don't need a primitive type. Diavolo implementation is less formal since you could stick all information you want inside a dictionary. Purists would say formal is better but I'd say that flexible is better.

Moreover, with connections you only have one way to communicate and a single provider with multiple consumers which, by the way, must be aware of providers in order to properly function. Our implementation doesn't require module to be aware of each other but just to agree on a name and parameters. Knowing that a blog module would broadcast blog post ID when displaying its content, another module only need to know trigger name and parameter name to receive such notification.

Modules can freely communicate among each other as there's not a clean separation between providers and consumers: modules can invoke each other multiple times. For example, blog module could broadcast post ID it is showing and a pictures gallery module could use post tags to display relevant pictures but at a later time in page life-cycle, another module could use same tags to download a RSS feed and discover new tags which could be relevant for the same post and broadcast them as well. Gallery module could then expand / refine its search for pictures based on those new tags and a message from a module appearing later in page life-cycle. That looks flexible to me !

Comparing to DNN  module communication

Things are very close to DNN implementation but again our implementation is less formal and more open. However, a cool idea for DNN is to be able to pass sender control reference which might be useful in some cases. That's something we could decide to implement at a later time. However, we will probably keep our ability to pass a dictionary of strings in order to let module basically communicate anything.

Other than that, idea behind Diavolo Module Communicator is very close to DNN one.


Maybe some kind of JS purist won't like this but... I really love new Diavolo JS scripts management ! Once I started to use it, I'm wondering how could I even live without it !

To be honest, I didn't dig into Javascript that much up until this year. You know, I don't like embedding some kind of logic, except basic one, into client code because that seems highly dangerous. Or maybe because I'm lazy and I don't want to add an extra layer which needs to be secured Undecided

For whatever reason, I didn't dig into JS meaning that my websites had a few JS into them. But I have to admit that fancy scripts to perform some UI actions are now very common and, in general, they are considered a must to design a modern, Web2.0, website. When designing Diavolo, I wanted to keep the best of ASP.NET WebForms in, avoid MVC and attempt to stick both MS AJAX library and jQuery in. I also tried to ensure that jQuery and MS AJAX (and AJAX Control Toolkit) could work together even if jQuery is taking ground and MS AJAX and expecially the toolkit are becoming less relevant. Anyway, UpdatePanels are great so I wanted something which could work with all of those features together and let developers decide what to use.

In a earlier post, I wrote about a new Diavolo feature which would allow JS scripts to be automatically included into dynamic and static pages, just by dropping files into specific folders. That way, if I want to include jQuery, I could simply drop it into /scripts/auto/dynamic/ or /scripts/auto/static/ folders and have it included in every page. That was working in a very nice way and I was quite happy with results since I could add support for a specific JS file in a very super-easy way by simply adding a script in those folders. That way, I could remove any explicit dependency on jQuery and let all be dynamic which means users are able to remove jQuery support and switch to another JS framework, if they really wish. It's very useful and smart and it is explicitly modeled after ASP.NET Themes and its ability to automagically include CSS file into themes.

Ever since that feature was in place, I knew that next step was to make it even more flexible by allowing users to automatically set per-page scripts to include because that was very natural to me. By per-page scripts, I mean having a folder dedicated to a specific page and collect to a single folder any JS script you need to include in that specific page. That was pretty easy to implement and I'm happy to tell you that... it's on ! Now you can create a /scripts/auto/dynamic/7171/ or /scripts/auto/dynamic/3481/ folder and put there any JS your want to include in pages with matching ID (7171 or 3481): Diavolo will detect that and add those scripts to your page, in no specific order right now.

I tested that feature while developing a ContactUs module for Diavolo and I was looking to remove AJAX Control Toolkit dependency because I believe the toolkit is not actively developed as it was before. I was looking for a jQuery validation plugin and found a good one (though it has no callout feature... Cry ). Not sure if I will end up reverting to ASP.NET validators without Control Toolkit because in essence that's the same as jQuery validation but anyway I had to test many scripts to find a suitable one and that was super-easy with dynamic per-page scripts already in place. I was just able to drop jQuery plug-in into specific folder and change my control to enable them. Compile & Run and everything was working !

You don't like it and you need to remove those scripts ? Just delete them from filesystem and it's done. By the way, I was also able to test Google's reCaptcha support and, guess??, it works like a charm. No problems with Diavolo pages and anything else. That's nice since it confirms I'm on good track !

What's next ?
So what's next ? I'm very pleased how things work since those features support many different scenarios, including tricky ones : suppose that you have a few scripts you really need but they don't work with newer jQuery versions. How can you solve this ? Easy! You remove jQuery from being added to all pages, that is you remove jQuery JS file from /scripts/auto/dynamic/ and put it into specific folders for pages and then you replace newer jQuery file with older one, in any page where newer versions won't work with your scripts. So you automatically have pages where you can use newer jQuery versions and also pages where older or legacy versions will be used. Isn't that nice ?

My next step to make this feature 100% complete will be:

  • adding caching support: Diavolo must be able to read filesystem structure for scripts when application starts and cache it. Thus a simple dependency over folders will allow to re-read files and update caching when new files will be added or removed;
  • after adding caching, there will be a way to set order for scripts loading, that is setting that jQuery file must be added before one of its plugin, for obvious reasons. That will probably involve sorting by filename since I want everything to be automatic. This really requires caching to avoid sorting those files everytime.

There's no ETA for such changes but they will definitely happen.

Oh, did I mention that Diavolo won't only add all of your scripts but will also compress and minimize them on the fly ? Cool Thank you, mbComression !


Hello BlogEngine.NET v2 RC !

I was going to get crazy because of hundreds SPAM comments per week I was receiving on this blog. Literally ! So today I decided to install a SPAM blocking extension for BlogEngine.NET. I read about a few of them being available. Then I got aware that BE v2.0 RC was out and I thought to take the big jump !

I had a few problems because this website runs on VistaDB and it looks like support for that database was discontinued (bad choice !) so I had to try to manually upgrade my existing database which posed some little problems because of strange errors when using SQL Server upgrade code. VistaDB is supposed to be T-SQL compatible but maybe my version is a bit old and thus I had some troubles using the very same code. Anyway, after applying a few changes manually and compacting my database, everything was quite straightforward.

So now this blog runs BlogEngine.NET v2.0 RC which seems very neat and well-organized. I hope new features will pop out soon but as a general rule, BlogEngine.NET seems to be best blogging platform for .NET. And runs very quick on our VaiSulWeb shared hosting packages !


I was waiting for this moment, when basic underlying code could be complete and I could start toying around with Diavolo and its services. I'm telling this because you design things and write code but it's not up until you start working with your code that you can understand if what you did really has a value. And how much value it actually has. After finishing localization subsystem, basic portal code was near the end. I think I have about 90% code done for this first version and next step will be to add a few minor features and fix bugs I will be able to find. Then I'll try to make some stress tests and I will consider Diavolo v4.3 ready. Which basically means I will be able to start adding more features... Tongue out

Since my short-term goal for Diavolo was to use it to build my company's website (yes, that's VaiSulWeb !), I simply started doing that, asking our gfx-guys to create a good looking design while I avoided to set too many constraints. Basically, we need a portal-style website but I didn't ask them to feel too constrained by that. Result was a quite pleasant graphic design which I then attempted to enhance by jQuery and other stuff. Of course, one can have a better impression when you start working on real data, trying to solve real problems and check how good and stable your code can be and that's why I started implementing my company website to get my hands dirty and dig into real stuff.

My feelings were extremely positive, so far. First of all, I was able to implement graphic design without too many problems and that was positive. Now, our design isn't a very advanced one and is based on a simpe 3-column layout, with header and footer as well. However, I had very few problems to implement parts which were a bit more complex than usual. I'm also amazed how well MS AJAX Extensions and jQuery run together. In our code we are able to use both and mix and match them to solve different problems, usually based on how simple is to solve them when using one of those technologies. Sometimes it's better to use jQuery, sometimes you prefer to go with MS AJAX Extensions and its control toolkit. I'm also amazed how well jQuery and Update Panels can coexist, and integration is so deep we were able to use Update Panels just to provide server-side processing of code (basically, panels wraps buttons only) and then use on-the-fly-generated jQuery scripts to update page controls and provide feedback to end users. That was really amazing, in a way, as I didn't expect it could be so easy. So now you push a button and you have very little overhead since Update Panel doesn't need to sync all of your controls: when done, jQuery will take care of that. Perfect and, mostly important, quite fast ! This is like having the best of both worlds as you don't expose any business-logic processing nor any hook (service/endpoint/whatever) that then you need to secure but you can still use tons of goodies designed for jQuery. And, of course, that will improve your indexing score as well. In many cases, postback-logic is still there but users won't even notice that and will just experience quite fast processing and no page submitting.

One of such proof of concept was integration of this very beautiful slide down menu, whose integration was very straightforward and proved how flexible Diavolo theming engine actually is. I was able to remove default menu (standard ASP.NET one) from homepage theme and add that new jQuery-based menu and I'm still able to use that for homepage only, as a way to impress users. Other pages will use standard menu and all I need to do is to remove this Javascript code and enable standard ASP.NET menu again. On some pages, I could even use the same code in a completely different layout and/or theme. Very flexible ! I'd really like to use that menu on all pages but, given its way of functioning, it can provide a limited subset of choices and our website will be BIG for sure.

Modules development
Once basic implementation was complete, one of major proofs for the platform was module development so my first goal was to try to implement some modules to check how easy and cool it might be Wink. First attempt was about a module to display plain HTML contents with a multi-language version of that closely followed. I have to say that it was quite easy to develop such modules, expecially when dealing with stored data. In most cases, I was able to focus on features rather than technical problems to store my data or to retrieve it. Then I switched to development of external modules, i.e. modules which weren't part of core Diavolo code and I have to say that it worked like a charm. First attempts to install such modules were already successful with no major problems at all. I was very happy to note that modules development looked very straightforward and easy. 

Data layer
My first concern obiouvsly was about data layer and how easy interacting with data (and RavenDB !) could be. A few details are still fluid, a few things still leave me uncertain but I had no major problems interacting with data. Most data-related functions are trivial and didn't require many lines of code. My major goal was to be able to work with plain .NET objects to give maximum flexibility to my code and I have to say that I seem to have met my goal. Accessing, modifying and deleting data is basically very easy, expecially when dealing with properties of my base objects (DataObject in Diavolo). I'm still trying to understand if more specialized classes should be used or a generic one is enough to deal with most complex scenarios but overall I'm pleased that it was quite easy to deal with my objects. I can direcly access my data via Raven Sessions but I'm usually creating helper classes to deal with specific object types. Basically, in the end I should have a few helper classes which I could make available to other modules, if needed.

Portal responsiveness was very good and now I enabled portal to start Raven HTTP server, if configured to do so, enabling external access even when embedded configuration is being used. As of today, I'm quite pleased by end result and code flexibility.


Diavolo localization subsystem is now 100% ready. I have to say I'm really happy about this result because now everything is in place and I can really appreciate its strength, thank to .NET framework structure.

As I wrote in my last post, all localization features are supported and can be used but what I find extremely useful is inline (literal) expressions. While Javascript is getting stronger and stronger for advanced UIs, JS code is usually markup-based and in that context .NET developers have two choices: embedding JS scripts or emit them, meaning using server code to emit client-side scripts. The second way makes it easy to support localization and other customization while first one is easier to use and maintain. Diavolo now makes it possible to produce markup like this:

 

<ul id="sdt_menu" class="sdt_menu">
		<li>
			<a href="/">
				<img src="/images/2.jpg" alt=""/>
				<span class="sdt_active"></span>
				<span class="sdt_wrap">
				<span class="sdt_link">
<asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:system, home >" />                                                                                </span>
					<span class="sdt_descr">Torna alla pagina<br />principale del sito</span>
				</span>
			</a>
		</li>

 

This is a simple unordered list which can be used to create menus and other elements and to support localization and customization you can simply replace relevant code (for example, menu items or text) with a simple server-side code and leave other stuff intact. At run time, this code:

<asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:system, home%>" />

will simply be replaced by relevant text, using different languages according to user locale. That's exetremely useful per se but you must also consider that things get very juicy when you couple that with administrator's ability to edit keys in a very easy way inside portal itself. Following picture shows a (very basic) localization editor where portal administrators can explore keys for a specific category and locale:

On top of page you will find a list of categories (more about them in a moment) and locales while table shows all defined keys and their values. Single items can be edited and updated by portal administrator or even deleted. Unless they are system keys, the meaning of which I will explain in a moment. Inline editing makes it very easy to change key values and browsing among locales is also very easy. I also plan to add a way to filter items, maybe by specifying part of the key. When you will have tens of keys, even if they will be sorted, you need a quick way to find a specific key or at least a group of them.

Advanced features
Earlier, I mentioned a few things which probably aren't so clear. Let me start by explaining categories. In old, RESX-based context, first item in your key specification was resource filename or assembly name. That is, in "system, home" first term was meant to specify filename or assembly name and secondo one its actualy key. Diavolo has no assembly name nor RESX files but I thought that way to create keys partition was very handy so I decided to support that scheme by creating categories, which have the same task. Their goal is to provide a logical boundary among keys so, for example, system category will probably contain most system-wide keys while a blog category could include all keys related to a blog module or to blogging support. That's very handy.

Also note that Diavolo fully supports local resources, that is resources which are created for specific controls or pages, which were represented by old App_LocalResources folders. It's important to note that part of original specifications is fully supported and basically virtual path to object will become category name when you will use local resources. And, best of all, local resources will be editable as well and that's so handy for module developers !

Finally, we have system keys. While each installation of Diavolo will feature a system category which will group most system-wide, platform-defined keys, developers and administrators can also turn each key into a system key. Those keys need to be considered vital in order to let portal work as expected, maybe because they're used in administration pages or other important areas. Maybe they're just hardcoded in ASPX/ASCX code and, if deleted, compilation would not succeed. Either way, removing such key could be harmful and that's why portal administrators won't be able to remove them. Also, there will be two different functions in code to remove standard and system keys, so developer must be aware about what he/she's doing before doing that.

The good part is portal administrators can promove keys from standard to system. They will be able to edit such key and select specific checkbox to turn them into SKs and that's very useful. Imagine an admin installs a new module which rely on a specific key to be present. Now that key wasn't a SK and could be removed by other modules or maybe another admin who doesn't know such module has been installed. By promoving such key to be a system key, administrators won't be able to delete them by using editor and other modules will need to treat it as a system key in order to remove it and that probably means they will show a warning about it. This will reduce chances that key will be deleted by accident.

Lastly, I wrote that admins won't be able to delete a system key: that's not 100% true. If they use editor to remove one, an error will occurr. If they are 100% sure they want to remove it, they can edit such key and turn it into a non-SK and then they will be able to delete it. Either way, that extra operation will make them aware they are potentially deleting an important key.