Short Urls for Embedded G2

valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-03-26 15:39

The goal of this discussion is to bring back Short Url Support for embedded G2. I hope to have feedback from the authors of the different integration to see if they see more/other problems/solutions. The authors of the original and the new G2 short url approach should also participate to find a new solution for short urls in embedded G2.

Problem:
G2 Short Urls worked in embedded G2 before G2 beta 1 - or before PathInfo was replaced by the url rewrite (mod_rewrite) module.
The problem with the url_rewrite approach is that it doesn't regard the case of embedded G2 at all. I.e. it doesn't consider that the "url rewrite base" is different for standalone G2 and embedded G2.

With the old GalleryUrlGenerator one could dynamically set the baseFile for each request and all urls, even the short format were based on this baseFile. That's still possible for non short urls, but not for short urls with the new approach.

Solutions:
1. Make the url_rewrite module fit for embedded G2.
i.e. set the rewrite base dynamically with the baseFile. Or have several rewrite bases (at least two) to have a standalone rewrite base and an embedded rewrite base. GalleryUrlGenerator would check if it is called in embedded context and use the other rewrite base.
url rewrite would create 2 .htaccess rewrite rule sets. One for standalone placed in the gallery2 directory, another for the embedded context, in the other directory.
The mod rewrite rules of G2 may conflict with the one of the embedded application, if it also uses mod_rewrite (luckily not the case for xaraya).

2. Have another GalleryUrlGenerator class, similar to the old short url style with PathInfo. If G2 is in embedded context, use the EmbeddedGalleryUrlGenerator. This should be straight forward.

3. Have a GalleryUrlGenerator for each integration, perhaps all integrations are too different to try to solve it with just a single approach.

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sat, 2005-03-26 19:38

Solution 1:
I think the rewrite module easily could be modified to fit the needs of an embeded Gallery installation. As it is now, Rewrite does not take the relative path in consideration, but do use baseFile. The htaccess file is created like this:

RewriteBase /<galleryDir>/
RewriteRule ^<rule>$ /<galleryDir>/<baseFile>?<queryString> [QSA]

The htaccess file is installed in galleryDir. For an embeded environment the htaccess file probably shoud be installed in the CMS dir and look something like this:

RewriteBase /<customDir>/
RewriteRule ^<rule>$ /<galleryDir>/<baseFile>?<queryString> [QSA]

Come to think of it, the htaccess file location should be configurable as I had it with some privious (never in CVS) versions of the Rewrite module. If this sounds reasonable I'm willing to bring it back.

valiant wrote:
The mod rewrite rules of G2 may conflict with the one of the embedded application...

With the new Rewrite module I'm working on users will be able to customize the rules quite alot, and hopefully be able to resolve any conflicts.

One could, for example, have a CMS in /cms/ with Gallery in /cms/mod/gallery/ and make /cms/gallery/album/item.jpg.html map to /cms/index.php?mod=gallery&path=/album/item.jpg.html