Friday, August 20, 2010

Gallery Server Pro 2.4 DotNetNuke Module Beta Released

Today I am excited to announce the immediate availability of a beta version of the Gallery Server Pro 2.4 DotNetNuke Module. It is based on the same code architecture as the regular version of Gallery Server Pro, which means all the great features you love are now available in a module that runs natively inside a DotNetNuke web application. In addition, version 2.4 brings some great new features such as thumbnail generation for videos, PDF, EPS, text and Photoshop (PSD) files.

The module works in all versions of DotNetNuke 5.0.0 and higher.

Download the beta here. It is fully functional with no expiration. Later in this post I will walk you through the installation process. I will quickly point out that uninstalling the module completely removes all traces of it, including the database tables. Note, however, that any media files you added to the gallery will remain in the default location within the Portals directory – you can delete these manually (this was an intentional decision to prevent accidental deletion).

If you haven’t heard of DotNetNuke, it is a popular platform for building highly functional .NET web applications. The community version of DotNetNuke is free and the source code can be downloaded and modified if desired. It has an extensible module architecture that allows third parties to add additional functionality. There is even a website named SnowCovered where you can browse – and purchase - the available modules.

I created a public demo to show off the Gallery Server Pro module and let you play with it. Here is a screen shot of the gallery:

DNN home 1

The gallery functionality is nearly identical to the stand-alone version of Gallery Server Pro. The only differences are minor tweaks due to the nature of it being a module inside of DotNetNuke. For example, by default, the Gallery Server Pro module does not render a login link since DotNetNuke provides one. Plus, a few redundant features are disabled, such as allowing users to create and mange their own accounts.

The module integrates with DotNetNuke’s users and roles to easily manage secure access to the gallery objects. All SuperUser accounts and users in the Administrators role automatically have admin permissions to the gallery. All users in the Registered Users role have view permissions on objects. This can be changed by editing the role permissions on the Manage Roles page in Gallery Server Pro’s Site admin area.

Just like with the regular version, you can restrict certain albums from users by using the role-based security access. And use watermarking to protect your images. The user album feature can be used to give each DotNetNuke user their own personal gallery. There are dozens of configuration options that let you set up the gallery exactly the way you want it.

If you would like to perform advanced customization, the source code for this module will be available at the general release.

Install instructions

Install the Gallery Server Pro module the same way you do any other module. Log in with a host account (SuperUser) and go to Host – Module Definitions. Click the down arrow and select Install Module.

DNN GSP install 1

Select the Gallery Server Pro Module zip file and click Next.

DNN GSP install 2

Gallery Server Pro uses ASMX web services, which causes DotNetNuke to issue a warning. Select Ignore File Restrictions and click Next.

DNN GSP install 3

The next page shows some information about the module.

DNN GSP install 4

The next page shows the release notes. Pay special attention to the note about requiring full trust! Even though the regular version of Gallery Server Pro can run in medium trust, the DotNetNuke module must run in a web application running at full trust. This is because of an unfortunate decision by DotNetNuke to disable .resx language files, which Gallery Server Pro uses to support multiple languages. The Gallery Server Pro module re-enables this feature, but it requires full trust to do it. I submitted a feature request with DotNetNuke that will eliminate this requirement – please vote on it to help make it a priority with them.

DNN GSP install 5

The next page shows the license, which is a standard commercial license rather than the GNU GPL the regular version is released under. See below for more info about the licensing and pricing.

I have no plans to change the license for the regular version of GSP – it will remain under the GPL for as far into the future as I am capable of seeing.

DNN GSP install 6

The next page shows the results of the installation. Click Return to go back to the Module Definitions page.

DNN GSP install 7

Now that the module is installed, it is time to add it to one of the web pages. For this example, I created a page called Gallery and included it in the menu. From this page, I select the Gallery Server Pro module from the Module dropdown list and click the Add Module button.

DNN GSP install 8

An empty gallery appears.

DNN GSP install 9

At this point you can interact with the gallery the same way you do the regular version of Gallery Server Pro. Add albums and upload media files, or copy files to the Portals directory and then synchronize. Refer to the Media Objects – General page in the Site admin area to view and optionally change the directory that contains your media files.

Thumnbails from videos and other file types

Gallery Server Pro 2.4 now supports the extraction of thumbnail images from virtually all videos, text files, PDF, EPS, and PSD (Photoshop) files. Below is an album showing thumbnails from WMV, AVI, FLV (Flash video), MP4, DIVX, ASF, and MOV. Notice that only the Shockwave Flash file (SWF) does not have a thumbnail.

DNN GSP install 10

And here is an album with thumbnails of EPS, PSD, TXT, and PDF files.

DNN GSP install 11

Thumbnail creation is made possible through the use of three open source components:

ImageMagick – Creates thumbnail images from EPS, PSD, TXT, and PDF files. It requires GhostScript to be able to create images from EPS and PDF files.

GhostScript – It knows about the internal format of EPS and PDF files.

FFmpeg – Creates thumbnail images from video files.

These utilities must be installed separately. ImageMagick and FFmpeg are EXE files that can simply be copied into the bin directory of the web application. GhostScript must be installed using a setup program. You can acquire these programs from the sites linked above or from any number of sites that redistribute them. For your convenience, I created a Gallery Server Pro Binary Pack that includes all three.

Installing these utilities is optional. If they are not present, Gallery Server Pro falls back to the default technique of using a generic image for the thumbnail.

This feature will also be included in the stand-alone version of Gallery Server Pro 2.4, which I expect to release shortly after the DotNetNuke module.

Licensing and pricing

I would love to use the donation-supported model for the module, just like I do with the regular version of Gallery Server Pro. However, donations have not been sufficient to pay the bills, so in order to be able to continue working on it I need to increase revenue. Using a commercial license for this module while keeping the original version donation-supported and GPL seems like a good way to do it. The vast majority of DotNetNuke modules are commercial, and developers are used to paying a small chunk of money in order to enhance the value of their DotNetNuke sites.

Therefore I have adopted a pretty standard commercial license and expect to offer two versions of the module. Note that this may change by the final release.

Gallery Server Pro Professional - $69 Full functionality, unlimited number of media objects, can be installed on unlimited number of portals in a single DotNetNuke installation. No source code.

Gallery Server Pro Enterprise - $199 Includes all features of the Professional version. Includes source code.

Tuesday, August 3, 2010

Adding a gallery in .NET 4.0 without requiring ClientIDMode in web.config

My previous blog post described how to add a gallery to a default ASP.NET 4.0 application. However, yesterday I noticed some strange behavior surrounding the new ClientIDMode property in .NET 4.0. It appears that in some cases you may have to specify ClientIDMode=“AutoID” in your application, but it doesn’t have to be in web.config. Read on for the details.

The tutorial in my previous blog post told you to replace the default web.config file with the .NET 4.0 version that ships with GSP. That version includes a couple attributes to tell GSP to use the legacy 3.5 behavior:

<pages theme="" styleSheetTheme="" validateRequest="false" controlRenderingCompatibilityVersion="3.5"
 clientIDMode="AutoID" />

If you use controlRenderingCompatibilityVersion and clientIDMode like this, I haven’t noticed any issues with GSP in .NET 4.0. If you are content with this, skip the rest of this post and go have a beer (preferably homebrew). Life is good.

But your app might be using the new client ID rendering features in .NET 4.0 and you don’t want to specify legacy behavior. Or you just don’t like the idea of putting your whole app in a legacy mode just because a piece needs it.

As best I can tell, GSP doesn’t need the controlRenderingCompatibilityVersion attribute, so go ahead and change it to “4.0” or delete it altogether.

But you can’t get rid of ClientIDMode so easily, nor use its default value of Predictable. In a stand-alone version of GSP, I can find one thing that breaks – the rearrange page.

Fixing the code on the Rearrange page

One of the really nice functions in GSP is the ability to drag the items in an album to reposition them:


But when ClientIDMode is left out of web.config or set to Predictable (or Static), you can no longer drag the thumbnails around. This turned out to be pretty easy to fix by changing one line of code in \gs\pages\task\rearrange.ascx:

onmousedown="<%# Container.ClientID %>.startDragging(event);">

Change it to this:

onmousedown="eval( + '.startDragging(event);');">

You can make this change by just editing the file in a text editor like Notepad, and you do not have to recompile the source code. The next version of GSP will incorporate this fix.

I don’t really understand why the original code fails, since Container.ClientID should return the client-side name of the object. But the reality is that Container.ClientID returns a different ID than what is eventually output to the page, and this makes the javascript unhappy.

Does anything else break?

Well, it depends. In the stand-alone version of GSP (that is, when the gallery is the entire application), everything else seems to work. But when I add a gallery to an existing site, like I did in the tutorial, at least two of the ComponentArt controls failed – the Grid and Dialog controls. This breaks a bunch of stuff, including the image metadata window and several pages in the Site Admin area. For example, here is the Manage Users page:


I poked around for a bit, and I don’t know why it is failing. It is a mystery why it works when run as stand-alone app but not when added to an existing site. I tried it in both a default VB and C# ASP.NET 4.0 app and got the same (failing) results. If you have any theories let me know.

But the workaround is easy. Tell the gallery to use ClientIDMode=”AutoID”. This causes ASP.NET to generate client IDs the same way it did in earlier versions of .NET. By default, controls inherit this setting from their parent container, so you can set this once in web.config to get everything working very quickly. But, as I noted earlier, you might not want the entire app to use this mode. That leaves you with a few choices as to where you want to set it:

Page – Choose the .aspx page that contains the gallery and use a page directive to set it:

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" 
    CodeBehind="Gallery.aspx.vb" Inherits="WebWithGsp.Gallery" ClientIDMode="AutoID" %>

Gallery control – Add the property to the top-level gallery control:

<gsp:Gallery ID="g" runat="server" ClientIDMode="AutoID" /> 

One or more child pages or controls – You can add this property to child user controls or server controls. For example, you could set it on the Manage Users page at gs\pages\admin\manageusers.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="manageusers.ascx.cs"
Inherits="" ClientIDMode="AutoID" %>

But you would have to do it multiple times, which can be error prone (you might miss a few). Don’t do this. Just choose one of the top-level locations – web.config, .aspx page, or Gallery control, and set it there. Do it once and you are done. As with the edit to the rearrange page, you do not need to recompile the source code.

Hope this helps.