A quick update on MaVeriCk

I've been busy with some, paid (and therefore higher priority ;) ), work for the past week or so, which has meant I haven't had time to write up my Module Development in Maverick blog post.  I'll try to get that out next week.  In the mean time, you can pretty much just take the source (available here: http://github.com/anurse/Maverick) and start playing.  Creating a new module is as simple as copying one of the existing folders in the "Source/Web/Maverick.Web/Modules" folder, renaming it, and editing the "Module Application" class inside.  There's no registration necessary (thanks to MEF).

Have fun, feel free to post questions, and I'll talk to you next week!

MaVeriCk – An Open-Source CMS written in ASP.Net MVC

This is a big post, I know, but I think it’ll be worth it.  If you don’t have time to read it all, I organized it by importance, so the important stuff is at the top anyway :).

I’ve been hinting for a while that I’ve been working on a secret side project using ASP.Net MVC that was sort-of related to DotNetNuke.  Well, it’s finally time for me to put some code out there :).  Today, I published a source code package containing version 0.1 of MaVeriCk, a Content Management System written in ASP.Net MVC.  I’ll explain what it is and how to get started in this blog post.

Warning: MaVeriCk is nowhere near finished, and very much an alpha (maybe even a pre-alpha ;).  Major features are completely missing (such as user management, and any useful modules, see below for details)

Disclaimer: This project has NO RELATION to the DotNetNuke project.  While I am a DNN Core Team member, this is purely a personal side-project.  DotNetNuke has inspired some of the things I’ve done in MaVeriCk, but that’s the extent of the connection between the two.

What is MaVeriCk?

Maverick is an open-source Content Management System in the style of *Nuke applications such as DotNetNuke.  For the rest of this post, I’m going to assume you’re fairly familiar with that style of application.  Basically, users create pages and drop little widgets (or “Modules”) onto those pages to provide features like a Blog, Message Board, or even just a block of HTML.

Where (and how) do I get it?

The project is hosted on GitHub (http://github.com/anurse/MaVeriCk/) so you can feel free to clone the repository and hack away there.  Alternatively, if you either don’t have Git or don’t want to bother with getting the whole repository, you can download version 0.1.0, from the downloads section: http://github.com/anurse/MaVeriCk/downloads.  Also on the downloads page are the release notes for this version which include a full installation guide.  Unfortunately, there is no automated installation system, but the steps are quite straightforward if you’re familiar with ASP.Net.

Feel free to post comments on this blog, or send me email at: andrew AT andrewnurse DOT net

(After all, I’m just a junior programmer just out of college and don’t purport to be an expert in the various development patterns and architectures, so if you think something doesn’t look right, please let me know!)

How does it work?

The rest of this post will be a, very short, introduction to the Module Framework provided by Maverick.  I’ll be posting much more detailed information about the guts of Maverick later on, this is just a taste.  Feel free to send me email (see above) if you have questions about the rest of the architecture, and don’t be afraid to dive into the code!

Let’s start by taking a look at a MaVeriCk page:

image

Here, we see a page with two modules.  The first module is an instance of the “Current Time” Module Application, the second is an instance of the “Claim Dumper” Module Application.  A Module Application is an MVC Application, with its own Controllers and Views, which handles requests for a particular type of module.  If you’re familiar with DNN, the “Module Application” is analogous to the “Module Definition” concept in DNN.

Here’s a look at the code for the Current Time Module Application:

[Export(typeof(ModuleApplication))]
[ModuleApplication(ApplicationId, ApplicationName, "1.0.0.0", "Displays the Current Time", "Maverick", "~/Modules/CurrentTime/Content/Images/Icon.png")]
public class CurrentTimeModuleApplication : ModuleApplication {
    private const string ApplicationId = "A1FE2A31-0BC9-4B12-9B81-3B75C098EB33";
    private const string ApplicationName = "Current Time";

    protected override string FolderPath {
        get { return "CurrentTime"; }
    }

    protected internal override void Init(MaverickApplication application) {
        base.Init(application);
        RegisterRoutes(Routes);
    }

    private static void RegisterRoutes(RouteCollection routes) {
        routes.RegisterDefaultRoute("Maverick.Web.Modules.CurrentTime.Controllers");
    }
}

Compare this with the Global.asax file with an MVC app, and you’ll find it’s very similar.  The “Init” method is equivalent to “Application_Start” and is called the first time the Module Application is run during the current ASP.Net Application’s lifetime.  Just as you would in an MVC ‘Application_Start’ method, the Current Time Application registers routes into a route table for this module application.  In this case, the module is using a helper that Maverick provides to register the default route, but if we take a look at that helper, the only difference between the standard MVC route and this route is that we require that the namespace containing the Controllers is specified:

public static void RegisterDefaultRoute(this RouteCollection routes, string routeName, string defaultController, string defaultAction, string defaultId, string[] namespaces) {
    routes.MapRoute(
        routeName,
        "{controller}/{action}/{id}",
        new {controller = defaultController, action = defaultAction, id = defaultId},
        namespaces
        );
}

(Note: there are various overrides to this method, including the one you see used by the CurrentTimeModuleApplication class above)

Routing in Maverick is a little more complex than in standard MVC applications.  I’ll go into more details on it later, but the gist of it is that a portion of the URL for a request is handled by Maverick, and the rest (if any) goes to one of the modules on the page (called the “Active” or “Selected” module).  All the other modules (referred to as “Passive” modules) get an empty URL, and their default route is run.

From there on, a module is surprisingly similar to an MVC application.  It has Controllers and Views, just like an MVC app.  The big difference is that, in most cases, the ActionResult returned by a Controller does not represent the whole page, just a fragment of it.  Maverick collects all the ActionResults for a page and then renders them out one-by-one in the correct location.  Of course there are exceptions (for example, if a Module returns a FileResult or a RedirectResult), but that’s the core of it.

Missing Features

Maverick is in an early preview state at the moment.  There is a powerful authentication model available (or “Identity” model, as I call it), but at the moment, there’s only a very simple “Debug” implementation of it (which just automatically logs you in as an Administrator).  I have a prototype system which uses the Azure Access Control Service in the code, but it is not active by default (I’ll post more about that later).

Maverick does not really include any useful modules, so you’re on your own there.  Module development is relatively simple, and will be the focus of another blog post.  Feel free to check out the other modules for more info.  The only major component of Module Development not covered in the provided sample modules is data storage.  Maverick does have a system for modules to store data in the Maverick Database, but none of the built in modules do that.

There is a very rudimentary Theming system in place to allow you to create your own templates for the site (similar to DNN Skins).

Despite being touted as a Content Management System, Maverick doesn’t actually contain any Content Management features :), no Workflow, no Versioning, no Content Approval.  However, those features are planned for the future.

If you have any other suggestions, please let me know!

DotNetNuke Reports Module 5.1 enters the Release Tracker

It took almost a week longer than I said it would, but it’s finally done.  Version 5.1 of the DotNetNuke Reports Module is in the DotNetNuke Project Release Tracker.  I’ll post some more info over the next week, but for now, here are the release notes:

Reports Module 5.1 for DotNetNuke 5.0.1

Required DotNetNuke Version: 5.0.1 or above

The following issues have been resolved in this release of the Reports Module

  • RPT-9810: Simple URL Parameter system - A simple URL parameter system has been added which allows users to provide a list of QueryString parameters which will be added to the query. The parameter names are in the following format: @url_[QueryString Parameter Name]. Only the parameters specified in the "Allowed URL Parameters" section will be added.
  • RPT-5953: XSLT Extension Objects - CLR objects can now be provided to the XSLT Visualizer to use as XSLT Extension Objects. These objects must have a parameter-less constructor and MAY (but are not required to) implement the IXsltExtensionObject interface (found in DotNetNuke.Modules.Reports.dll) in order to receive additional context information.
  • RPT-7025: Search Indexing fails due to an exception - When there is an error in a Data Source, that exception is also thrown by the Search Indexer. Since Reports Module Exceptions were localized, through the Message property, when the Scheduler caught the exception thrown by the module, it would attempt to localize the text and fail (since there is no HttpContext). This has been corrected so that Data Source errors are no longer masked.
  • RPT-9543: Exception thrown when opening "Manage Add-Ins" page on DNN 5.0 - The DotNetNuke Extensions Installer API was moved to a different namespace in 5.0. The Reports module has been updated to reflect this change.
  • RPT-8145: Reports Module does not release file handle - The HTML Visualizer was opening a StreamReader and using ReadToEnd to load the contents, but not closing the StreamReader. It has been corrected to use System.IO.File.ReadAllText. A similar issue in the XSLT Visualizer was discovered and resolved the same way
  • RPT-7237: Show Info Pane working incorrectly - The "Show Info Pane", "Show Controls", and "Auto Run Report" settings were not being updated if the user is not a Super User, despite the fact that these settings are visible to non-Super Users. This has been corrected in the 5.1 release.
  • RPT-7236: Critical error when no file name entered for HTML Template Visualizer setting - The HTML Visualizer allowed users to leave the Template file field empty, causing a Critical Error on the view page. The view page has been corrected to avoid causing this error. A similar issue with the XSLT Visualizer has also been corrected
  • RPT-7238: Show Header field cannot be unchecked - A bug prevented the ShowHeader option from being deselected in the Grid Visualizer.

Also included is an update for the UDT Data Source for the Reports Module, here are the release notes:

Forms and Lists Data Source for DotNetNuke Reports 1.1.0 - Release Notes

This is a minor update to the User Defined Table Data Source for the DotNetNuke Reports Module. It has been renamed to the Forms and List Data Source, to match the new project name. Only one minor change is included: The stored procedure used to retrieve the list of Forms and List modules has been removed and replaced with (safe) dynamic SQL to reduce installation overhead. Requires DotNetNuke Reports 5.0 or above.

Track the progress of the module through the DotNetNuke Release process here: http://www.dotnetnuke.com/Development/ReleaseManagement/ProjectReleaseTracking/tabid/997/ctl/History/mid/3337/ItemID/394/Default.aspx

School is done! On to Reports, and something else ;)

Well, it's official.  Assuming I pass the two courses I haven't received grades from, I completed my final day of continuous education (well, except for the summer breaks/internships) for 18 straight years (K-12 + 5 years of post-secondary) today.  I've already got marks for 3 of the 5 courses I took this year, and they were pretty good (couple of A's and a B).  This semester has been a bit of a strange one, since I had only one computing science course and it was a "Writing for Computer Scientists" course which involved no programming! (Despite that, it was one of my favorite courses this semester :D).  I took introductory courses in Communications, Linguistics and Nutrition as well as a intro to the Physics of Sound and Music entitled "Logarithm and Blues" taught by a two-man team of a musician and a physicist (sorry "Writing for Computing Scientists", this one takes the top slot this semester :)).

Now that I'm finished school, probably for a while (still eying a part-time masters at University of Washington when I've been at Microsoft for a while), I can settle down and finish up a few side-projects and some DNN Reports work.  Reports Module version 5.1 is finished from a code perspective and contains a number of bugfixes (details to come) as well as two new features:
  • XSLT Extension Objects - The XSLT Visualizer now allows you to provide a list of .Net Types which are constructed at runtime and mapped into the XSLT file as XML namespaces.
  • Experimental and mostly hacky support for QueryString parameters in Report Queries - A number of people have been asking for this, and it's a relatively simple feature in the Reports Module architecture.  On the settings page, you can provide a comma-separated list of QueryString parameters which will be passed to the Report Query.  The parameters are prefixed with "url_" in the query to distinguish them from the existing parameters.  NOTE: Don't forget that many Databases use still another prefix, such as SQL Server ("@"), so for example, the full name of the SQL Server parameter mapped to "foobar" QueryString parameter is "@url_foobar".  This is only a stopgap solution to allow for some linking into Reports with parameters, so expect the next version to include a more detailed system (which may include breaking changes which will require that you update your queries). I'll do my best to support an upgrade path, but no promises, so use at your own risk
I just need to do some testing and then I'll put 5.1 into the release process.  I expect to do that this week, so depending on how long it takes the diligent reviewers in the release process to make sure that the new version won't obliterate your existing site (and believe me, you don't want to rush that!), it should be out very soon!

Moving on to a new project...  I've been hinting to some of the people in the internal project forums at DotNetNuke that I've been working on a top-secret project involving MVC.  (This is a pure side-project, not part of the DNN Project at all).  I'm very close to releasing something which, I think, is pretty cool.  I'll keep the secret for now, but let's say this: I've been working on/with DotNetNuke for a few years, and I've a huge fan of ASP.Net MVC.  I've learned a lot from DNN and I think MVC users can benefit from some of that experience ;).  I'm hoping to have something ready on this secret project, which I call "MaVeriCk", in the next week or two (but Reports 5.1 is my priority at the moment).

Hope that teased you just enough to stay tuned :P

I’m still here… just cramming… and working

Hello avid readers!  It’s been over a week since I blogged, I know, but I’ve been cramming for exams.  The CMPT 376 assignment I mentioned a while ago has finished, so I’m no longer required to blog for grades.  Having said that, after exams, I plan to keep blogging, so keep watching the feed :).

Just to tease you a bit: I’ve got a cool little ASP.Net MVC side-project well underway that I’m just dying to show off on the blog, so stick around :P

Also, to the Reports Module users out there, 5.1 is very close to being finished.  There may be a surprise new feature in there too.  Details to follow later :D.

Quantum Computing in .Net “Looflirpa”

Microsoft is really taking major strides in terms of improving the programming experience for developers on all current and future computing platforms.  That’s why, earlier today, Microsoft released a beta of the new “System.QuantumEntanglement” library.  This library, being considered for integration with .Net 4.1 (which, my sources say, is codenamed “Looflirpa”), provides features for developers working on quantum computers.  I won’t go in to too much detail, but this essentially means working in an environment where objects can be in many different states (possibly an infinite number) and where observation may change the state of an object.  Microsoft has proposed a few options, but I have some additional ideas.

Microsoft’s Proposal

Eilon Lipton, of the ASP.Net MVC team, is proposing a number of new additions to the .Net BCL in 4.1.  The first, is a class called “StringOr<T>” which has the following API:

namespace System.QuantumEntanglement {
    public class StringOr<TOther> {
        public StringOr(string stringValue, TOther otherValue);

        public string StringValue { get; }
        public TOther OtherValue { get; }
    }
}

This class is used to encapsulate a value which may be a string, but may be another value.  This is a common user-input scenario, since almost all user input arrives as strings, but will usually be converted to another data type.  He also proposes a more general class called “SchrodingOr<TDead, TAlive>”

namespace System.QuantumEntanglement {
    public class SchrodingOr<TDead, TAlive> {
        public SchrodingOr(TDead dead, TAlive alive);

        public TAlive Alive { get; }
        public TDead Dead { get; }
    }
}

This generalizes StringOr<T> to support any two types. 

Eilon’s not the only one talking about this, Scott Hanselman (well known Microsoft blogger), and Rob Conery (Author of the .Net Object-Relational Mapper: SubSonic) have also posted on this topic.  So I figured I’d add my comments to the blogosphere.

StringOr and SchrodingOr are great starts, but what if we need to represent objects which may be in 2 states? What about 3 states? Infinite states?  That’s where my proposals come in.  I propose the following additions to Eilon’s library:

Generalizing SchrodingOr

The first is SchrodingOr<T1, T2, T3, T4, T5, … , Tn> (for infinite n).  This allows the developer to represent objects in as many states as they want. 

C# 5.0 Compiler Support

I’m also proposing the following language syntax to help developers work with these types.  Similar to the way the C# compiler converts “int?” to “Nullable<int>” (which would now be replaced with “SchrodingOr<int, Void>” as it more accurately represents the concept of a type which may or may not have a value), the new syntax takes the following:

int?string?bool?DateTime? foo = GetUserInput(...);

And produces output code which looks like this:

SchrodingOr<int, DateTime, bool, string> foo = GetUserInput(...);

Then, we can defer observation until a later time, using the AsA<T>/AsAn<T> method (since Eilon's Alive and Dead properties no longer work in an infinite state environment). If we just want to observe the type and then make a decision, we can use IsA<T>/IsAn<T> methods (of course, both are required, just in case the type starts with a vowel), which returns a boolean indicating if the object is of the type T. For example:

if(foo.IsA<string>()) { return foo.AsA<string;>; }

Probabilistic Observation

Sometimes, we may want to observe an object only if there is a high probability of it being in the right state, to avoid additional quantum variations. To do this, we can use the CouldBeA<T>/CouldBeA<T> methods. These can, optionally, accept a probability threshold beyond which a object is considered in the right state.

Quantum Snapshots

Unfortunately, in between a call to IsA/An/CouldBeA/An and AsA/An, the state of the object may change.  So, we may wish to observe an object and record the state of the object at the time of observation.  Since in observing the object we may change its state, our observations must be recorded in “Snapshots”.  The snapshot is an instance of QuantumSnapshotOf<TSchrodingOr> (where TSchrodingOr must be one of the SchrodingOr<T1, ..., Tn> types), and has a property "Taken", which is a DateTimeOffset (after all, we need precise timing here) containing the exact time that the snapshot was taken.

Here’s an example combining Probabilistic Observation and Snapshots:

if(foo.CouldBeA<string>()) {
	QuantumSnapshotOf<SchrodingOr<int, string>> snapshot = foo.Observe();
	if(snapshot.Taken.Day == 1 && snapshot.Taken.Month == 4) {
		throw new UnreliableObservationException(snapshot, "The data is unreliable");
	}
	return snapshot.AsA<string>();
}

Summary

I think this is really interesting, forward-thinking, stuff from Microsoft. Eilon has done some fantastic work getting the ball rolling, and its up to us to give our feedback! Microsoft has created a section on MSDN for discussion on these new features: http://msdn.microsoft.com/en-US/QuantumEntanglement/Default.aspx

DotNetNuke on IgniteIT

Did you know that the largest open-source project on the Microsoft platform was started in Vancouver, Canada?  It’s true!  DotNetNuke is the largest Open-Source community in the .Net by downloads (at least).  Since moving to CodePlex (Microsoft’s Open-Source hosting platform) in January 2009, DNN has been downloaded over 180,000 times (at time of writing).  This makes it second only to a World Of Warcraft Add-On development studio which has been on CodePlex since Sept 2007 (at least that was the earliest check-in I could find).  Adding that to the all-time download score on SourceForge (the project’s previous host) of 4.3 Million downloads, and you’ve got the the largest .Net open-source project (and one which I am proud to contribute to)!

And here’s the great part for us Canucks, DotNetNuke was created right here (by “here”, I mean where I live :P) in Vancouver!

Microsoft Canada is running a contest called the “Ignite It” award to honour Canadian developers and IT professionals.  DotNetNuke is nominated in the Developer category, and we’re looking for your votes!  There’s only 2 days left, and we’re in the top 5 (which will go on to be judged).  Still, we’d like to be up at number one before voting ends, so here comes the shameless plug :P.  Here’s the deal: You can vote once per Windows Live account per day (though there aren’t many days left :( ).  It only takes a second to vote, and I’ve even created a TinyURL to share with your friends: http://tinyurl.com/dnnigniteit

Let’s push DNN into the top spot!

Windows Live Writer – After 2 Months

Back in January, I started blogging more frequently due to a course I was taking.  As part of that, I started using Windows Live Writer to write all my blog posts.  I use the DasBlog engine to power my blog, and it supports one of the many blogging APIs that Windows Live Writer uses (I believe it’s MetaWeblog).  So, I hooked it up to my blog, and everything just worked!

My favorite feature is the ability to create and save drafts and then publish them on demand.  I have inspiration at the strangest times, and often in large batches, so I end up with a couple ideas of things to blog in a day, and no ideas the next day.  So, I just create a bunch of drafts, get them ready to publish and then publish them over a longer period of time (like say… a day :P).  For example, I wrote this post 5 minutes after the previous post, but I thought it might overload my readers to post it immediately :).  So, I save a draft and post it a bit later (when I don’t have anything to blog about :D).

If you have a blog, and it supports one of the blogging APIs, and you’re running on Windows, you really should try Windows Live Writer!