Roger Martin's Blog

Gallery Server Pro 2.4 DotNetNuke Module Beta Released

Friday, August 20, 2010

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 Standard - $69 Full functionality, unlimited number of media objects, can be installed on unlimited number of portals in a single DotNetNuke installation. Includes Gallery Server Pro logo on the bottom of each page. No source code.

Gallery Server Pro Enterprise - $199 Includes all features of the standard version, but the logo is not displayed. Includes source code.

Posted by Roger Martin, Fri, 20 Aug 2010 09:14:00 GMT

Add comment There are 0 comments.

Due to caching, it may take up to an hour for comments to appear.

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

Tuesday, August 03, 2010

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:

rearrange1

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(this.parentNode.parentNode.id + '.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:

users

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="GalleryServerPro.Web.gs.pages.admin.manageusers" 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.

Posted by Roger Martin, Tue, 03 Aug 2010 10:37:00 GMT

Add comment There are 0 comments.

Due to caching, it may take up to an hour for comments to appear.

Adding a gallery to your .NET 4.0 application

Monday, July 26, 2010

After a frustrated user posted his troubles getting GSP to work in a .NET 4.0 application, I thought I would dig into it to see what was going on. I have step by step directions for Visual Studio 2008 in the Admin Guide, but it turns out they don’t quite work for Visual Studio 2010. I also felt I could improve upon the explanation that is in the Admin Guide, so I decided to completely rewrite it in this blog post. Eventually I will update the Admin Guide to include this information.

I will create a default .NET 4.0 web application and then add a gallery to it. These steps are largely the same for Visual Studio 2005 and 2008, too.

Download the sample application I created for this post. A couple notes: (1) Log in to the gallery with username Admin (password=111). (2) For demonstration purposes, it includes the latest release of the AJAX Control Toolkit, not the version that ships with GSP.

Integration strategies

First, let’s review the ways one can add a gallery into an existing ASP.NET app, in order from least coupled to most coupled:

1. Deploy the GSP support files and DLLs and don’t use assembly references – The contents of the gs directory are deployed to your server but not included as content files in your Visual Studio project. The GSP assemblies are deployed to the bin directory but not referenced by the project. The only parts of your project that are “aware” of GSP are: (1) App_GlobalResources contains the resource file GalleryServerPro.resx, (2) web.config contains the required GSP configuration, (3) the web page for the gallery contains a Register tag for the GSP user control and, of course, the Gallery user control itself.

The advantage of this approach are:

  1. You can add a gallery to your site without having to recompile it.
  2. You can update to new versions of GSP without having to recompile – just copy the new files to your server.
  3. Your Visual Studio project has minimal knowledge of GSP, which helps to keep things clean and allows you to focus on your application without thinking too much about GSP.

The disadvantages of this approach are:

  1. You cannot use the GSP API (which may be used in advanced customization scenarios).
  2. You no longer have your entire app contained within a single project, which makes management more difficult.
  3. You cannot use the built-in publishing functionality in Visual Studio to deploy your app. Well, not the GSP portion anyway.

This is the approach I use for the demo gallery on www.galleryserverpro.com.

2. Include the files as part of the Visual Studio solution, but don’t reference the GSP DLLs – Copy the gs directory and other files into your app and make them part of your solution/project. This is the method documented in the Admin Guide. It has the advantage of keeping everything organized in one project, which allows for simple source control and deployment, but tends to clutter up your app with GSP dependencies that can be a distraction.

3. Same as above, but also reference the GSP DLLs - Copy the files into your app and make them part of your solution/project. Add references to the GSP assemblies to make your app aware of GSP. This is required when you use the API in advanced scenarios (for example, if you want to create your own upload page and add media objects yourself). But doing this in .NET versions higher than 2.0 will often give you compile errors. They are all solvable without too much work, but they can be a hassle.

Step by step: Adding a gallery

Each strategy can be the right solution depending on your requirements. Unless you intend to use the GSP API, most developers will want to use the first or second technique.

Here are step by step directions for adding a gallery to an existing .NET 4.0 application using the first strategy. In this example, I’ll use Visual Studio 2010 Ultimate to add a gallery to a default ASP.NET application. Just for fun, I am using a Visual Basic project, which works great even though GSP is written in C#. I believe the steps are the same for all web-enabled versions of Visual Studio, including the free Express one.

Note: By default, Visual Studio creates pages that require compilation, but at the end of this post I’ll show how to create pages that don’t require compilation, thus providing you with the no-compile advantage I mentioned above.

Note: If you already have an existing web app, skip to step # 3.

  1. Use Visual Studio 2010 to create a new ASP.NET 4.0 application using the ASP.NET Web Application template. Here I am using Visual Basic, but you can use another language.

    dotnet4_1

  2. The project will be created. In Solution Explorer, right click Default.aspx and choose View in Browser. The home page appears:

    dotnet4_2

  3. Okay! We have a working ASP.NET 4.0 app. Now we want to add a gallery to it. If you do not have an App_GlobalResources directory in your application, create one by using Visual Studio to right click the web project node in the Solution Explorer and choosing Add - Add ASP.NET Folder - App_GlobalResources. Similarly, add an App_Data folder if your project does not have one.

  4. Download the compiled version of Gallery Server Pro and extract the contents to a temporary directory. Use Windows Explorer to copy the following items:

    1. Copy the gs directory into your ASP.NET app. It should be at the same level as your other top-level directories, such as App_Data.
    2. Copy the contents of the bin directory into your bin directory.
    3. Copy GalleryServerPro.resx from App_GlobalResources into the same directory in your app.
    4. Copy galleryserverpro_data.sqlite from App_Data into the same directory in your app (not necessary if you use SQL Server).
    5. Copy web_4.0.config into the root of your app. Delete the existing web.config and rename web_4.0.config to web.config. NOTE: Your web.config may have settings you need to preserve, so you may need to manually merge the two instead.
  5. Create a new web page to hold the gallery. In this example, I created a page named Gallery.aspx from the Web Form Using Master Page template and then selected Site.Master for the master page. At the top of the page add a line to tell the page where the Gallery user control is defined:

    <%@ Register TagPrefix="gsp" Namespace="GalleryServerPro.Web" Assembly="GalleryServerPro.Web" %>

  6. Then add the user control somewhere in the body of the page:

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

  7. Compile the application. You will probably get the compilation error “Type ‘GalleryServerPro.Web.Gallery’ is not defined”, as seen here:

    dotnet4_3

  8. This error is not covered in the Admin Guide because it never happened under Visual Studio 2008. The reason for this error is because Visual Studio added a definition for the control in the page’s designer file and the compiler doesn’t know where the user control is defined. This doesn’t seem right to me - I would argue that it should know where it is because we explicitly defined it in the <%@ Register … /> tag.

  9. But no matter, because we can easily fix it. Double click the error to show the offending code:

    dotnet4_4

  10. Delete the line that is causing the error. As best I can tell there are no harmful consequences to removing it. The page will look like this when you are done:

    dotnet4_5

  11. Now compile the application. It should succeed. Right click the page and choose View in Browser. The page will appear with an empty gallery:

    dotnet4_6

  12. By default, no users are defined and the gallery is configured to use SQLite for data storage, so run the install wizard to set up the membership system and optionally configure SQL Server. In the web browser, add “?g=install” to the URL. The install wizard appears:

    dotnet4_7

  13. Step through the install wizard. When complete, you are redirected back to your gallery, which now includes a sample album and image. All done!

    dotnet4_8

Integrating with existing users

The integration example above assumes you are setting up a new set of users, but you might want the gallery to be integrated with your existing membership provider. After running the install wizard, open web.config and update the membership, role, and profile sections to point to the desired providers. GSP will use the default provider unless you specify a particular provider in the galleryserverpro.config settings membershipProviderName and roleProviderName.

After pointing web.config to your membership, you may get the following error:

dotnet4_9

This is happening because GSP doesn’t know what kind of security access any of your users have, so it assumes a “better safe than sorry” position and doesn’t let anybody in. To define the administrator, open the table gs_Role. GSP should have created a list of records in this table that mirror the roles in your role provider (if you don’t see any, try restarting the web app, which triggers the validation code that synchronizes the roles in gs_Role with the roles in your role provider). Pick the record that represents the system administrator role and set the AllowAdministerSite column to true. Then restart the app (or edit the album summary, which clears the role cache). Any users in this role should now have full administrative permission to the gallery. Now that you can log on as an administrator, you can use the normal GSP admin functions to define the security for the rest of the users.

No compile option

To add a gallery to your app without requiring compilation, remove the code behind file from the web page that contains the gallery user control. For example, in the example above, change the first line from this:

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

to this:

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" %>

After this change, the code behind files Gallery.aspx.vb and Gallery.aspx.designer.vb are no longer need and can be deleted.

An added benefit to this option is that you won’t be affected by the compile error we received above, since the designer file does not exist.

ASP.NET compatibility

Update 2010-08-03: Check out this blog post for more info.

If you look carefully at the screen shots, you will notice we lost the nice formatting of the menu after we added the gallery:

dotnet4_10

This is because the 4.0 version of web.config that ships with GSP is configured to render objects the pre-4.0 way. That is, the attribute controlRenderingCompatibilityVersion is set to 3.5:

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

This is an application wide setting, so this causes the menu to render using tables (<table>) rather than list items (<li>), which breaks the CSS in the default ASP.NET application.

You can restore the formatting of the menu by setting the compatibility version to 4.0, or removing it altogether. After this change, it looks like this:

dotnet4_11

I specified 3.5 compatibility mode in web.config because I wanted to guarantee that everything worked the same in .NET 4.0. I am not sure it is required, though. In some very brief testing, I couldn’t find anything that was broken in 4.0 mode. It is possible that future releases will default to the native 4.0 rendering.

AJAX Control Toolkit

GSP ships with version 1.0.10920 of the AJAX Control Toolkit, which is the most recent version of the toolkit that is compatible with .NET 2.0. If you want to use later versions in your app, GSP will work with it, but you must update web.config so that GSP uses the desired version rather than looking in vain for the one it was compiled against. Open web.config and add this line just before the final </configuration> element:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="AjaxControlToolkit" publicKeyToken="28f01b0e84b6d53e" />
      <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="4.1.40412.0" />
     </dependentAssembly>
  </assemblyBinding>
</runtime>

Update the newVersion attribute as needed to reflect the version of your AjaxControlToolkit.dll.

MVC apps

GSP is a webforms application, which is very different than the MVC pattern recently introduced by Microsoft. Generally speaking, webforms and MVC functionality don’t belong in the same application and can give you trouble if you try.

Having said that, it *is* possible to add a gallery to an MVC app. I actually did it for a customer not long ago. Here are the key lessons I learned:

  • The gallery user control must be added to a webforms page, not an MVC one.

  • I added a line to global.asax to tell the routing system to ignore paths to the webforms page. In my case, I put the webform (an .aspx page containing the Gallery user control) in a directory named Webforms and then added this line to global.asax: routes.IgnoreRoute("Webforms/{*pathInfo}");

  • The javascript on the Rearrange objects page failed until I set controlRenderingCompatibilityVersion to “3.5” in web.config.

  • Getting MVC and webform pages to share the same master page is difficult. I actually had to define a top level master page Root.Master that inherited from System.Web.UI.MasterPage. In this page I put the main layout. Then I created two child master pages – one was called Mvc.Master and it inherited System.Web.Mvc.ViewMasterPage; the other was called Webform.Master and it inherited from System.Web.UI.MasterPage. Both child pages used Root.Master as its own master page, and served as essentially empty containers for the web pages. All MVC pages used Mvc.Master; webforms used Webform.Master. A big problem with this approach is that the top level master page cannot use any MVC code. And if you add something to Mvc.Master, you must duplicate it in Webform.Master. This is a fragile approach that might create maintainability issues down the road, but I couldn’t come up with anything better. An alternative was to create identical master pages – one for MVC and one for webforms, but that is obviously not ideal.

Posted by Roger Martin, Mon, 26 Jul 2010 14:44:00 GMT

Add comment There are 5 comments.

Due to caching, it may take up to an hour for comments to appear.

Roger Martin said on Mon, 09 Aug 2010 11:22:09 GMT:

ML Stockell: Restarting the web app should synchronize the aspnet_roles table with the gs_Role table. I have a fix to help prevent this in the upcoming 2.4 release.

ML Stockell said on Sat, 07 Aug 2010 18:32:05 GMT:

Hi Roger,
When integrating into a site that already has users/roles/profiles in its database, I run into an issue where the user may have a role that is not registered in GSP. An exception is thrown by IGalleryServerRoleCollection. Should I just comment out
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, "Could not find a Gallery Server role named '{0}'. Verify the data table contains a record for this role and the current gallery, and that the cache is being properly managed.", roleName));


??

Roger Martin said on Thu, 29 Jul 2010 07:59:05 GMT:

Not sure why you are getting that error. I just downloaded the app, ran it, and was able to browse and add objects without trouble.

Matt Dunn said on Thu, 29 Jul 2010 06:09:25 GMT:

Hi Roger,

I'm new to GSP. This compiled with VS2010 but I am getting a script error when clicking on any image in the sample gallery.

Line: 155
Error: 'AjaxControlToolkit' is undefined

Any idea? Thanks!

Alexander said on Mon, 26 Jul 2010 17:09:50 GMT:

Hey Roger,
Thanks a lot for this post. I'm struggling exactly with this issue for the last two days, and this clarifies a LOT, about the three different ways to integrate gsp! If you add this later to the admin guide it would make it even better ;)
greets

Turning a lemon into lemonade: Multiple galleries in a single web application

Tuesday, July 06, 2010

A clash between DotNetNuke portals and Gallery Server Pro architecture

Back in March I released an alpha build to a few select users for a new DotNetNuke module version of Gallery Server Pro. At the time I thought I was nearly done. Well, it turns out that DotNetNuke has one feature that conflicted with GSP’s architecture: Multiple Portals. And I’ve been working to resolve this ever since.

Portals are a concept in DNN where a single web application can have one or more mini-web sites that appear – to the outside world – as if they are separate applications. They can even have different URLs: www.p1.site.com, www.p2.site.com, etc. For example, a user navigating to www.p1.site.com would see a site that looks completely different than www.p2.site.com. It can have a different theme, different content, and even different users, but behind the scenes it is a single web application connecting to a single database.

My alpha testers noticed that the GSP module worked fine EXCEPT that media objects were shared across multiple portals. Not cool - Each portal must have its own set of media objects and its own administration settings. At first I thought – no big deal – GSP already has the concept of a gallery – all I need to do is create a unique gallery for each portal.

The problem, however, was that the Gallery ID was specified in galleryserverpro.config, and there is only one of those per web application. I had to figure out how to manage multiple galleries within *one* application. There was no way to shoehorn the config file to support multiple galleries unless I radically changed its structure. Even then, an administrator updating a setting in one portal would cause the entire application pool to recycle, since that is how the ASP.NET configuration system works. Something big had to change.

Refactoring gallery settings to the database

In the end, I abandoned the galleryserverpro.config file and moved everything into the database. There are now five new tables:

gs_GallerySetting – Stores most of the items in the <core> section of galleryserverpro.config, such as ShowErrorDetails and MediaObjectPath. The column FKGalleryId is a foreign key to gs_Gallery, so each gallery gets its own set of settings.

gs_AppSetting – It made sense to keep a few items from galleryserverpro.config at the application level, and these are stored here. It has just a few records that apply to all galleries, such as JQueryScriptPath and ProductKey.

gs_BrowserTemplate – These are the HTML templates from galleryserverpro.config.

gs_MimeType – This is a read-only list of all MIME types.

gs_MimeTypeGallery – This stores whether each MIME type is enabled or disabled for a gallery.

These changes were applied to the source code trunk, meaning it affects the main release of GSP in addition to the DotNetNuke branch.

With these changes, the next version of GSP will support multiple, distinct sets of media objects within a single web application. Each set – called a gallery – has its own settings, users and roles. From the user’s perspective, the media objects are completely isolated from each other, although a site administrator can move or copy objects between galleries. And the galleryserverpro.config file has been confined to the dustbins of history.

A quick note about users and roles: GSP continues to use the membership and role provider model. This model enforces a unique set of user and role names across the entire application. That means that once a user is created, that username cannot be created again in other galleries. You can, however, *share* users and roles across galleries. For example, you can assign user ‘Bob’ to have view permission in gallery 1, write permission in gallery 2, and no permission whatsoever in gallery 3.

I used the phrase “turning lemon into lemonade” in the title because this was not something I wanted to spend three months working on, nor do I think this is a feature that regular GSP users are clamoring for. I would have rather spent this time adding tagging support, improving the upload experience, or just about any of the one hundred items on my to-do list.

Making lemonade

However, it turns out there are significant benefits to this change. One of my favorites is that the application pool no longer recycles when you update a setting. Now you can edit a setting without affecting any in-progress uploads or synchronizations.

Plus, more complex scenarios suddenly become possible:

  • You want to have one gallery for staging and another for production. Media objects are first added to the staging area, where they are organized and prepped. When they are ready to be deployed, they can be moved or copied to the production gallery.
  • You have departments in your company that should each have their own gallery. Each gallery should have its own administrator and can have its own settings, such as user accounts, watermark, permissions, etc. Rather than setting up and maintaining multiple web applications, this can now be handled in a single app.
  • You have media files in multiple locations you want to expose, such as D:\Pictures and D:\Video.
  • You want to set up a gallery for each member of your family. Each person is a mini-administrator for their area and can't edit another person's media objects, yet everything is contained within a single web application and database.
  • You want some images to be 640x480 and others to be smaller (or larger).
  • You want to have a watermark applied to one set of images but another set should have no watermark, and all images are to be accessible to anonymous users. Or you have different watermarks that should be applied to different sets of images.
  • You want to provide a user with different gallery-wide permissions. For example, user 'Bob' should be a gallery administrator for one set of objects, but have edit-only permission for another set.
  • You want to allow some users to upload any file type of any size, but others should only be able to upload .JPEG's that are less than 5 MB.

Gallery administration

To accommodate this change, the concept of a “gallery administrator” has been introduced. A gallery administrator can change settings for a particular gallery but has no rights to other galleries. She can add users and roles, but those accounts are restricted to the current gallery.

The previous concept of a site administrator remains. The site administrator has complete access to all galleries.

Creating multiple galleries

The desired gallery is now specified on the Gallery user control defined in the web page. For example, the Gallery definition in default.aspx now looks like this:

<gsp:Gallery ID="g" runat="server" GalleryId="1" />

To create a second gallery, just add a new ASPX page and specify a new gallery ID:

<gsp:Gallery ID="g" runat="server" GalleryId="2" />

The first time you load this page, GSP will automatically create the gallery and a default set of gallery settings. One of the first things you may want to do is check the media object path to ensure it is at a unique location. You *can* use the same media object path in multiple galleries, but note that updating an object in one gallery does not update the database record associated with the other gallery.

Example: Create a staging gallery

To create a staging gallery where you can prep objects before pushing them to the production gallery, copy default.aspx to create a second ASPX page called gallerystaging.aspx. Change the gallery ID to a new value (such as 2). Open this page in your browser – you don’t need to run the install wizard or compile any source code. Log in with any account with ‘Allow site administration’ permission and configure the settings as desired, such as disabling anonymous access and changing the media object file path. Synchronize or add your media objects and organize them as you wish.

I’ll assume the original page default.aspx is your production gallery. While in your staging gallery, use the move/copy function to transfer the items to the production gallery. Voila! You have just deployed your items to production.

Roadmap

My priority is to get a beta version of the DotNetNuke module released as soon as possible. There are still some odds and ends to take care of, like how to implement licensing, but hopefully nothing significant. If I didn’t have any distractions, I think it would be ready within a few weeks. But my development time has been split to support a few customers, and it is unclear how much time will be devoted to them in the coming weeks.

My best guess is that I will have the DotNetNuke beta out by the end of August. That should be followed relatively quickly with the release of GSP 2.4, which contains the multiple gallery feature I am talking about here, some bug fixes, and some great new properties on the Gallery user control that website integrators will love. I will also try to squeeze in some high-value, easy-to-implement feature requests.

Once the DotNetNuke module and 2.4 is out, I plan to implement those top features requests you have:

  • Tagging
  • Better upload experience – especially the ability to upload a compressed version of an image rather than the original
  • Extract video thumbnails
  • Advanced sorting
  • Much more…

Posted by Roger Martin, Tue, 06 Jul 2010 10:03:00 GMT

Add comment There are 2 comments.

Due to caching, it may take up to an hour for comments to appear.

RustyTools said on Fri, 16 Jul 2010 12:23:30 GMT:

I'm so excited to see you are continuing to work on the DNN integration! Can't wait for the beta and thanks for the great update.

Dave Burke said on Wed, 07 Jul 2010 18:16:26 GMT:

Thanks for providing such a detailed description of what's coming, Roger. Looking forward to adapting to the new way of doing things.

Best regards,
Dave

Issues with Visual Studio 2010

Monday, May 03, 2010

ACTION ALERT: See the end of this post for a request to vote on a Visual Studio bug that is affecting Gallery Server Pro development. I need your help!

UPDATE 2010-5-5: Microsoft has confirmed they can reproduce the issue and is investigating it. Keep voting to keep the pressure on!

Visual Studio 2010 just came out, so I installed it, opened up the Gallery Server Pro solution, and took a peak around. The first thing I noticed is that all my ascx and aspx pages had squiggly marks all over the place:

Visual Studio 2010 error

When I hover over the @Control directive in the first line, I see this message:

"ASP.NET runtime error: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format."

That is a tell-tale sign that Visual Studio is trying to load the 64-bit version of System.Data.SQLite into its own 32-bit process. Kind of makes sense, but this worked fine in VS 2008.

This problem also seems to cause issues with custom user controls and third party server controls. For example, when I hover over the uc1 user control declaration (you can see it in the screen shot), I see this message:

"Unrecognized tag prefix or device filter 'uc1'"

I also lose intellisense on these controls.

Despite these problems in Visual Studio, these errors seem to be more cosmetic than a show-stopper. I can compile the solution and run it in IIS. It is annoying to lose intellisense and the squigglies are making me sea sick, but at least I can continue working.

If you are working with the Gallery Server Pro source code on a 64-bit operating system, you may run into this as well. Not a big deal, but if it drives you nuts, here are the known workarounds:

1. Use Visual Studio 2005 or 2008 instead.

2. Use a 32-bit OS.

3. If using a 64-bit OS and VS 2010, avoid IIS (which is 64-bit) and stick with the built-in Cassini web server (which is 32-bit). Rename the dll in TIS.GSP.Data.SQLite\assemblies\x64 to something else such as System.Data.SQLite_x64.dll (or delete it) and then recompile. This forces Visual Studio to use the 32-bit version of System.Data.SQLite.dll.

None of these workarounds are very attractive to me, so my best hope is for Microsoft to fix this in a service pack. To start this process, today I submitted a bug report with Microsoft. To make this a priority for Microsoft, I need lots of people to validate the issue and vote on it. So I ask for your help. Please go to the bug report and vote for it. Thanks!

Posted by Roger Martin, Mon, 03 May 2010 14:03:00 GMT

Add comment There are 4 comments.

Due to caching, it may take up to an hour for comments to appear.

Roger Martin said on Fri, 02 Jul 2010 05:53:26 GMT:

Now that Scott Guthrie announced SQL Server Compact Edition, I think I can say this is what I was referring to. Look for a version of GSP to support this model.

Dave Burke said on Tue, 04 May 2010 19:14:59 GMT:

As long as it's not SQLExpressLite I'm all for it! :-) Thanks for the reply.

Roger Martin said on Tue, 04 May 2010 18:20:54 GMT:

Yes, getting rid of SQLite would end the 32/64 bit annoyance. I can't comment on specifics, but Microsoft has asked for my feedback on something new they are working on that would offer the advantages of SQLite without the disadvantages. I'll comment more when I can.

Dave Burke said on Tue, 04 May 2010 15:55:08 GMT:

Thanks for giving us the heads-up! Ya know, I LOVE Gallery Server Pro, but if there's one issue that's always been a thorn in my side it's SQLite support. I go between 64- and 32-bit machines all the time and it's always been an issue. Getting rid of SQLite would resolve the VS2010 issue, would it not? :-)

See more blog entries...

Page generated at 9/3/2010 8:27:58 AM