Tuesday, May 24, 2011

Bug: Thumbnail image not generated for PDF files

Today I discovered a bug that affects all galleries upgraded from a version earlier than 2.4.3. You are affected if all of the following are true:

  • You have PDF files in your gallery.
  • You originally installed GSP before version 2.4.3 and then upgraded to one of the later versions.
  • Your site is running in Full Trust.
  • You installed the Gallery Server Pro Binary Pack.

In short, this is a bug in the SQL upgrade script that shipped in 2.4.3 and later. Fortunately, there is an easy fix.

First, some background: In a default installation GSP creates a generic thumbnail image for PDF files, like this:

GenericThumbnailImage_PDF

When you install the Gallery Server Pro Binary Pack, GSP uses the ImageMagick and GhostScript utilities to generate a thumbnail image that is an actual preview of the PDF file:

AdminGuide_ss_116x145

Today I discovered a bug, introduced in 2.4.3, where PDF files *always* get the generic thumbnail image, even when the binary pack is installed. The cause of this is a typo in the SQL upgrade script for 2.4.3:

UPDATE [gs_GallerySetting]
SET [SettingValue] = 'pdf,.txt,.eps,.psd,.tif,.tiff'
WHERE [SettingName] = 'ImageMagickFileTypes';

See the typo? I missed the period in front of ‘pdf’. To fix your gallery, update the setting to include the period. You can use this SQL:

UPDATE [gs_GallerySetting]
SET [SettingValue] = '.pdf,.txt,.eps,.psd,.tif,.tiff'
WHERE [SettingName] = 'ImageMagickFileTypes';

Since these settings are cached, recycle the IIS application pool to force the gallery to get a fresh copy from the database.

The next version of GSP will include a fix for this.

Tuesday, May 10, 2011

jQuery 1.6 introduces breaking change

On May 3, jQuery introduced a new version that breaks some of the functionality of Gallery Server Pro 2.4.6 and higher. Earlier versions are not affected. Also not affected is the Gallery Server Pro DotNetNuke Module, *unless* you explicitly changed the default jQuery settings. The good news is there is an easy fix I describe at the end of this post.

Background

Gallery Server Pro uses jQuery to provide a rich user experience. Starting with 2.3.3750, a default installation of GSP uses the Google hosted versions of the jQuery library rather than a locally stored copy of the .js file. This allows the browser to use a previously cached copy of jquery, resulting in a faster loading page.

There are a number of ways one can construct the URL to point to Google’s copy of jQuery. Here are a few examples of how I’ve tinkered with the URL:

2.3.3750: http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js

2.4.0: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

2.4.5: http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js

2.4.6 – 2.4.8: //ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js

Notice how the version number is specified. By omitting the minor version from the 2.4.6 and later releases, Google automatically serves the latest 1.X release. You get the benefit of having the latest version of jQuery without having to explicitly upgrade.

But there is some risk with that approach, which brings me to the topic of this post. On May 3, jQuery released version 1.6. It contains a number of improvements and performance enhancements. Unfortunately, it also introduces a breaking change that causes an immediate problem on all 2.4.6 and higher Gallery Server Pro releases. Earlier GSP versions are not affected because the jQuery URL pointed to either a local jQuery file (versions earlier than 2.3.3750) or one of the 1.4 versions. jQuery 1.6 changes how attributes are handled. The details are in this blog post, but what it means to GSP is that the handling of checkboxes and the enabling/disabling of HTML elements in several of the admin pages are broken.

For example, as user happylynlyn pointed out yesterday in the forum, selecting the option ‘Override the following default settings’ on the Gallery Control Settings page no longer enables the child options. This issue also affects the Manage Roles, User Settings, and Metadata pages.

The issue only affects these few pages in the site admin area – browsing the gallery and performing tasks in the gallery (add/editing objects, etc) are not affected.

The Fix

I will have this resolved in the next release. Until then, there is an easy workaround – just tell Gallery Server Pro to use an earlier version of jQuery. On the Site Settings – General page, update the jQuery path to specify version 1.5:

jquery1.6fix

Friday, April 29, 2011

Gallery Server Pro 2.4.8 Released

Version 2.4.8 was released today. It contains fixes for three bugs that won’t seriously affect most people, but I wanted to get it out the door so I can focus on the 2.5 drive. The release includes these fixes:

  • Logging in does not preserve the original requested album or media object
  • Cannot manage users or roles when they contain certain characters
  • (DotNetNuke) Gallery doesn't work when user-friendly URLs are disabled

Get more details about the bugs here. To upgrade from 2.4.7, download the 2.4.8 files to your hard drive. Then replace the GalleryServerPro.*.dll files in the bin directory with those from the download. Finally, replace the following files in your gallery with the matching file in the download:

  • App_GlobalResources/GalleryServerPro.resx
  • gs/pages/admin/usersettings.ascx

If you are upgrading from a version earlier than 2.4.7, follow the instructions in the Admin Guide.

Friday, April 22, 2011

Gallery Server Pro Roadmap

I’ve gotten a lot of good feedback in the poll about the future of Gallery Server Pro – keep on voting! I am particularly pleased that the two lowest vote-getters are “improve performance” and “improve reliability”. That tells me you think Gallery Server Pro is fast and robust. I spent a lot of time getting it there, so it is gratifying to see some objective confirmation.

Based on those results and my internal spidey sense, here is where I see the upcoming versions and features working out. This is rough and can and will change, but at this moment it is my best guess.

2.4.7 (Released April 21, 2011)

  • All known issues in the 2.4.X code base are fixed and the product is stable and performing well.

2.5 (June 2011)

  • Migrate the code base to .NET 4.0.
  • Replace the SQLite data provider with SQL Server CE 4.0. This will allow for simple xcopy deployment that works in medium trust – kind of the holy grail I’ve been wanting for several years.

3.0 (2012)

  • Easier skinning/customizing UI (the top vote-getter in the poll)
  • User comments/ratings (#2 in the poll)
  • New upload experience (#3 in the poll). Allow multiple file selection on client. Possibly include option to create optimized images on client and upload those rather than original images, greatly reducing upload time.
  • Tagging (heirarchical?)
  • Virtual albums: browse by tags, most recent, top rated, most commented, user
  • Editable metadata
  • New sorting options
  • Allow users to password protect individual albums/media objects
  • Namespaced javascript so multiple instances of control can be on same web page

Future (2012-2013)

  • Add viewmode 'Map' that displays map of GPS coordinates
  • Allow gallery-level settings to be overridden at the album level (MO title template, watermark, etc)
  • Allow separate media object title templates for thumbnail and optimized images
  • User quotas
  • Ability to regenerate captions from updated MO title template
  • Mobile app support
  • DeepZoom support
  • Fullscreen slideshow
  • Expand scope of error log to be an event log
  • E-mail notifications of gallery updates
  • Log history (viewing, edits, delete, etc)

Way, way Future (2040-2050)

  • Include teleport feature to take viewer to GPS location embedded in image

Keep your feedback coming. Does this roadmap gel with your needs?

And keep those donations coming! Your financial support allows me to continue working on Gallery Server Pro instead of taking some high-paying consulting work. The pay is poverty-level (average donation for Jan-Mar 2011 was $1300/month), but is highly satisfying, so I expect to keep at it as long as I can keep paying the bills.

Thursday, April 21, 2011

Gallery Server Pro 2.4.7 Released

Today I released version 2.4.7 of Gallery Server Pro. All versions have been updated, but the Web Application Gallery version takes a few days to get approved by Microsoft, so be patient for that one. There are no new features in this release; only bug fixes and one web.config change:

  • Various functions do not work when viewStateEncryptionMode="Always"
  • Case difference in username during logon causes duplicate user album
  • Username not HTML encoded
  • Exception data of inner exception not logged
  • Possible NullReferenceException when gallery contains images with GPS metadata
  • HTML embed code contains incorrect URL when the website is installed in a virtual directory
  • Role name that contains HTML cannot be assigned to user
  • Cannot add/remove roles for user when membership is read-only
  • embed.aspx moved from web root to \gs\ directory
  • web.config change: ViewStateEncryptionMode now set to “Always”

More details can be found in the Fixed Defect Report.

To upgrade from 2.4.6, download the 2.4.7 files to your hard drive. Then replace the GalleryServerPro.*.dll files in the bin directory with those from the download. Finally, replace the following files in your gallery with their matching file in the download:

  • App_GlobalResources/GalleryServerPro.resx
  • gs/embed.aspx (this is a new location; you may want to keep the original embed.aspx in the root directory if you have existing bits of embed code that point to this file)
  • gs/controls/myaccount.ascx
  • gs/controls/albumedittemplate.ascx
  • gs/controls/thumbnailview.ascx
  • gs/pages/admin/manageroles.ascx
  • gs/pages/admin/manageusers.ascx
  • gs/pages/myaccount.ascx
  • gs/script/mediaobjectview.js

If you are upgrading from a version earlier than 2.4.6, follow the instructions in the Admin Guide.

I’ll discuss a couple of the more interesting bugs.

Various functions do not work when viewStateEncryptionMode="Always"

I first learned about this issue from a user about a month ago. First, some background: One can specify that the view-state always be encrypted by setting a property in web.config:

<pages … viewStateEncryptionMode="Always">

When not specified, this setting is “Auto”, which means view-state is encrypted only when a control requests it. GSP works fine in “Auto” mode, but one of the third party controls it uses cannot handle the setting “Always”. This is the Callback control from ComponentArt, which is a nifty control I use for Ajax callbacks that is a nice balance between raw Ajax requests and the heavyweight UpdatePanel. When view-state is encrypted and the Callback control’s PostState property is set to “true”, this control fails with one of these messages:

“An error occurred while communicating with the server. Try again. Error: Invalid response from server.”

“The data could not be loaded.”

This issue affected the following functions in GSP:

  • Album thumbnail paging
  • Adding/editing a user on the Manage Users page
  • Adding/editing a role on the Manage Roles page

While this problem has always existed, it hasn’t appeared on my radar until a few weeks ago. This is because version 5.6.1 of DotNetNuke, released January 19, 2011, started using “Always” as its default setting. DotNetNuke didn’t announce the change ahead of time because they didn’t think it would be a breaking change for anyone. But this was a big problem for GSP.

I contacted ComponentArt and they were responsive in evaluating the issue, but in the end they couldn’t provide a fix, acceptable workaround, or estimated date for a fix. So I replaced the album thumbnail paging with a traditional hyperlink architecture, where navigating to the next and previous pages is done with hyperlinks. And I re-architected the user and role management pages to use Microsoft’s UpdatePanel. In the end the changes should be largely invisible to end users.

To keep the settings consistent between the various flavors of GSP, the web.config of all versions now set this setting to “Always”. There is a small performance impact of this change (about 1-2%), so if you don’t need this extra security and want the fastest possible gallery, feel free to change this back to “Auto”.

Cannot add/remove roles for user when membership is read-only

One of the great features of Gallery Server Pro is its ability to use Active Directory integration for membership. This can be easily achieved through a few simple edits to web.config (see the Admin Guide for step by step directions). However, there has always been a limitation where one can’t add or remove roles for a user when the web application doesn’t have permission to modify Active Directory data. The Admin Guide describes a few workarounds, but I finally got around to eliminating the limitation altogether.

When clicking the Save button for a user on the Manage Users page, the gallery does two things: (1) update the user properties in the membership provider (such as e-mail address, comment, or approval status), and (2) update the list of roles the member belongs to. Starting with 2.4.7, if there aren’t any changes to the user properties, then only the role membership is updated. That is, the gallery skips a call to the membership UpdateUser() method, thereby sidestepping the possibility of the membership provider throwing a permission error. Voila – you can now manage role membership for users even when using Active Directory in read-only mode.

Thursday, March 17, 2011

Better looking galleries in IE9

Gallery Server Pro makes extensive use of rounded corners and drop shadows to make a great looking gallery. While other browsers have supported these features for a while, IE has lagged behind. Now I am pleased to report that IE has finally caught up! After you upgrade to IE9 your galleries will suddenly look a little more awesome.

For example, here is a typical album as seen in IE8:

album_view_ie8

Now the same album in IE9:

album_view_ie9

The thumbnail images, the frame, and the paging controls all have nice rounded corners, and the images have a nice drop shadow effect.

When you click an image, this is what IE8 will show:

mo_view_ie8

The same image in IE9:

mo_view_ie9

Astute observers will notice that the IE8 screen shots *do* have a drop shadow similar to the IE9 shots. That is because years ago I decided I couldn’t wait for IE to add drop shadow support, so I implemented a complicated hack to simulate the effect with nested div tags and images. I describe the technique in this blog post. Gallery Server Pro still uses the older technique for IE 8 and earlier, but all other browsers – including IE9 – get the new CSS drop shadow. The end result is that using CSS instead of a hack results in much simpler HTML, allowing for such basic improvements as centering images. Here is an image in IE8 – notice how it is left-aligned:

image_not_centered[4] 

The same image in IE9:

image_centered[4]

These are just a few of the places where better CSS support results in a better looking gallery. To get these improvements, all you need is IE9 and any version of Gallery Server Pro 2.4.0 or higher. Enjoy!

Thursday, March 10, 2011

Add the Facebook comment widget to your gallery

One of the frequent requests I get is the ability for users to comment on photos and other media objects. I am considering adding this feature – in fact, it is one of the items you can vote for in the poll I am running. But today I discovered a technique for incorporating the Facebook comment widget right into your gallery. I enabled this feature on an album in the demo site so you can see for yourself. Feel free to leave a comment on one or more photos – I’ll purge them periodically.

This is not for everyone. Users need a Facebook account, and it is a little tricky to set up and maintain. For these reasons, I am reluctant to add this as a built-in feature. But for some of you this will be an excellent addition to the gallery.

Here is what it looks like:

gsp_with_facebook_comments

There are a few steps getting this to work.

1. Add a script tag to the web page hosting the gallery control.

Open default.aspx in a text editor and add this line somewhere in the <head> section:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>

2. Update mediaobjectview.js

Two javascript functions in \gs\script\mediaobjectview.js must be updated to call the Facebook API. In showNextMediaObject() and showPrevMediaObject(), find this line of code:

document.body.style.cursor = "default";

Then add this line just *before* it:

if (typeof (FB) != 'undefined') FB.XFBML.parse();

Because the file is minified, it is difficult to edit, so for your convenience just grab the one used on the demo site. If you are running a different version than the one on the demo site you’ll have to manually edit the file. To make this easier, you could edit the un-minified version that is in the source code download (Website\gs\script\mediaobjectview.debug.gs) and then run it through any minifier (like this one).

3. Enable HTML editing and add the ‘fb:comments’ tag.

Log in to your gallery as an administrator and turn on HTML editing on the User Settings page. Then add ‘fb:comments’ as a valid HTML tag.

image

4. Update each media object caption with the Facebook HTML snippet.

For each media object where you want to enable comments, edit the caption and add this HTML after the regular caption:

               <div id="fb-root"></div>
<fb:comments href="http://www.site.com/default.aspx?moid=8274"></fb:comments>

Replace the URL with the actual URL to your media object. Notice there are several spaces before the first <div>. That is intentional, as it provides a buffer to prevent Gallery Server Pro from accidentally rendering the comment widget on the thumbnail image. Save your changes and then refresh the page. The Facebook comment widget should appear just below the caption.

Pretty cool, huh?

Updating the caption for every media object is pretty tedious, so below I describe a shortcut.

Disclaimers and caveats

BROKEN CAPTION EDITING – This technique breaks the ability to edit a caption on the single media object view. Once you comment-enable a media object, the only way to edit its caption is through the Edit Captions task available in the Actions menu. And when you do, you have to be careful not to edit the Facebook HTML that is part of the caption.

Remember, Gallery Server Pro was not designed for this comment widget, so it is kind of a hack to add it to the comment field. If you don’t like this limitation, then don’t use this technique.

NO SUPPORT – Gallery Server Pro does not provide support for the Facebook comment widget, so you are on your own. I did minimal testing and don’t know how robust it is or even whether it is a good idea. It may kill your hamster. That said, I am curious to hear your feedback and experiences.

Comment-enable your whole gallery (or just an album) in one step

Rather than update each media object one at a time, you can execute a SQL statement against the database to comment-enable all your media objects at once. Here is some example SQL – it adds the necessary Facebook HTML to any existing text in the Title column of the gs_MediaObject table.

SQLite:

UPDATE gs_MediaObject
SET Title=Title || "                <div id='fb-root'></div><fb:comments href='http://www.site.com/default.aspx?moid=" || MediaObjectId || "'></fb:comments>"

SQL Server:

UPDATE gs_MediaObject
SET Title=Title + "                <div id='fb-root'></div><fb:comments href='http://www.site.com/default.aspx?moid=" + MediaObjectId + "'></fb:comments>"
WHERE FKAlbumId=XXXX

Add a WHERE clause – like in the second SQL – to update the items in just one album. It is beyond the scope of this post to tell you how to execute SQL, so if you don’t know, you’ll have to learn or just forget the idea.

As you add objects to your gallery, you will need to manually update each caption or re-apply the SQL. But don’t run the SQL more than once against the same set of media objects, or you’ll start to get multiple copies of the Facebook HTML.

More information

To learn more about the Facebook Comments Box, read the documentation. It includes information about moderation tools to help you manage the comments.

I think some of you will really like this trick. Let me know how it goes!