Website

New Drupal/Gallery2.2 plugin configuration challenges

Tagged:  •    •    •  

I like to my rewrite rules performed in the central Apache config (well, individual vhost files) so it can be revision controlled and centrally managed. The recent upgrade to the Gallery 5.x-2.0 module broke the rewriting rules I was using. Below are my new rewrite rules for a site-wide Gallery/Drupal install, but first the main snipped and differences of what was changed. For reference, my gallery install is at /photo.

The recommended URL rewrite rules would look like this:
RewriteCond %{THE_REQUEST} /gallery/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /photo/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /gallery/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_path=%1 [QSA,L]

I had to modify/remove the emphasized parts; I needed to change %{THE_REQUEST} to %{REQUEST_URI} because the path /gallery is also in drupal's admin paths. I wanted to anchor the /gallery gallery path, but can't do that with %{REQUEST_URI}. Also, because I removed %{REQUEST_URI}, I needed to remove the (\?.|\ .) match from the end since there would no longer be those characters after the URL.

My modified version would like like this (emphasis added to show changes):
RewriteCond %{REQUEST_URI} ^/gallery/([0-9]+)-([0-9]+)/([^/?]+)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /photo/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/([^?]+)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_path=%1 [QSA,L]

This wasn't good enough for me, though, as I wanted the clean URLs I had for most gallery paths in gallery 2.1. So my final Gallery2.2/Drupal config looks like the following:

# drupal/gallery integration
RewriteCond %{REQUEST_URI} ^/gallery/popular
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=dynamicalbum.PopularAlbum [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/updates
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=dynamicalbum.UpdatesAlbum [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/random
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=dynamicalbum.RandomAlbum [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/d/([0-9]+)-([0-9]+)/([^/?]+)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /photo/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/v/([^?]+)/slideshow\.html
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=slideshow.Slideshow&g2_path=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/c/view/([0-9]+)\.html
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=comment.ShowAllComments&g2_itemId=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/c/add/([0-9]+)\.html
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=comment.AddComment&g2_itemId=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/v/([^?]+)\.davmount
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=webdav.DownloadDavMount&g2_path=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/rating/([^?/]+)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=rating.RatingAlbum&g2_limit=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/rss/([^\/\?]+)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=rss.Render&g2_name=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/srss/([0-9]+)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=rss.SimpleRender&g2_itemId=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/key/([^?/]+)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_view=keyalbum.KeywordAlbum&g2_keyword=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/w(/[^?]*)?
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_controller=webdav.WebDav&g2_path=%1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/gallery/v/([^?]+)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?q=gallery&g2_path=%1 [QSA,L]

# drupal configuration
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^/(photo|album|download)(/.*)?
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

A non-custom CMS!? What are you thinking!?

Tagged:  •    •  

This is a big step for me. It's the first time I've used a non-custom CMS.

Since I've owned silfreed.net it's always been a custom app. I used jogger (then jolem, then blogstar) to create blog posts through a jabber/XMPP bot. However, this lacked the flexibility to create multiple tags. It was also getting difficult to maintain as my IM client of choice (Kopete) no longer has a subject bar, so I was relegated to starting up Psi then posting.

I'm sure you've read that I've been playing with Drupal a lot for Mozdev. The truth is I've learned to like it. A lot.

It might not be as lightweight as a custom CMS, but it makes up for it in flexibility. See those nice images over on the right-hand side? I've wanted to do that forever. See those multiple tags on this post? I've wanted to do that forever. See that trackback and pingback support? You get the idea.

Anyway, check it out and let me know if there are any broken links. I've tried to maintain historical links as much as possible, but I'm sure there are problems in places.

Look for much more blogging now that I can post with a lot less overhead.


Syndicate content