order of album

This commit is contained in:
Espen Antonsen 2009-08-03 16:23:51 +02:00
parent 947cb93ff8
commit 838e504cba
4 changed files with 10 additions and 6 deletions

5
README
View file

@ -59,7 +59,10 @@ Ruby Gems
The gallery has a web-based upload tool using Flash. Alternatively you can upload files directly by doing this:
Put photos in containing folders(albums) in the specified gallery folder. This format is recommended:
Put photos in containing folders(albums) in the specified gallery folder.
Hierarchy of folders is not fully supported.
This format is recommended:
./ski weekend in hemsedal/snow.jpg
./ski weekend in hemsedal/afterski.jpg

View file

@ -4,14 +4,14 @@ class AlbumsController < ApplicationController
def index
if params[:tag_id]
@albums = Album.find(:all, :conditions => [ "id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.id IN ( SELECT photo_id FROM photo_tags WHERE photo_tags.tag_id = :q) )", { :q => Tag.find( params[:tag_id] ).id } ])
@albums = Album.find(:all, :conditions => [ "id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.id IN ( SELECT photo_id FROM photo_tags WHERE photo_tags.tag_id = :q) )", { :q => Tag.find( params[:tag_id] ).id } ], :order => 'title')
elsif params[:q]
#search = params[:q]
#search = search.split("AND").map{|q|q.strip}
#@albums = Album.find(:all, :select => 'DISTINCT albums.id, albums.title', :limit => 20, :conditions => { :tags => {:title => search}}, :joins => 'LEFT OUTER JOIN photos ON albums.id = photos.album_id LEFT OUTER JOIN photo_tags ON photos.id = photo_tags.photo_id LEFT OUTER JOIN tags ON photo_tags.tag_id = tags.id', :order => "albums.title ASC" )
@albums = Album.find(:all, :conditions => [ "id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.description LIKE :q OR photos.title LIKE :q OR photos.id IN ( SELECT photo_id FROM photo_tags LEFT OUTER JOIN tags ON photo_tags.tag_id = tags.id WHERE tags.title LIKE :q) )", { :q => '%' + params[:q] + '%' } ])
@albums = Album.find(:all, :conditions => [ "id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.description LIKE :q OR photos.title LIKE :q OR photos.id IN ( SELECT photo_id FROM photo_tags LEFT OUTER JOIN tags ON photo_tags.tag_id = tags.id WHERE tags.title LIKE :q) )", { :q => '%' + params[:q] + '%' } ], :order => 'title')
else
@albums = Album.find(:all)
@albums = Album.find(:all, :order => 'title')
end
respond_to do |format|
format.html

View file

@ -13,7 +13,7 @@ class Album < ActiveRecord::Base
attr_accessor :tags
attr_protected :path
named_scope :untouched, :conditions => "albums.Id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags) )"
named_scope :untouched, :conditions => "albums.Id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags) )", :order => 'title'
def to_param
"#{id}-#{title.parameterize}"
@ -27,7 +27,7 @@ class Album < ActiveRecord::Base
end
def set_title
self.title = File.basename( File.dirname(self.path) ) unless self.title || !self.path
self.title = File.basename( self.path) unless self.title || !self.path
end
def tags

View file

@ -1,5 +1,6 @@
module ScanFiles
require "find"
supported_files = ["jpeg", "jpg", "gif", "png"]