order of album
This commit is contained in:
parent
947cb93ff8
commit
838e504cba
5
README
5
README
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module ScanFiles
|
||||
require "find"
|
||||
|
||||
|
||||
supported_files = ["jpeg", "jpg", "gif", "png"]
|
||||
|
||||
|
|
Loading…
Reference in a new issue