experimented with search and failed. google maps does not show if no geo
This commit is contained in:
parent
a279ba29f9
commit
e363680e86
|
@ -6,6 +6,9 @@ class AlbumsController < ApplicationController
|
|||
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 } ])
|
||||
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] + '%' } ])
|
||||
else
|
||||
@albums = Album.find(:all)
|
||||
|
|
|
@ -10,7 +10,10 @@ class PhotosController < ApplicationController
|
|||
elsif params[:album_id]
|
||||
@photos = Album.find( params[:album_id]).photos.find(:all, :order => "photos.id ASC")
|
||||
elsif params[:q]
|
||||
@photos = Photo.find(:all, :limit => 20, :conditions => [ "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] + '%' } ], :include => :album, :order => "photos.id ASC" )
|
||||
#search = params[:q]
|
||||
#search = search.split("AND").map{|q|q.strip}
|
||||
#@photos = Photo.find(:all, :select => 'DISTINCT photos.id, photos.album_id, photos.title, photos.path', :limit => 20, :conditions => { :tags => {:title => search}}, :joins => 'LEFT OUTER JOIN photo_tags ON photos.id = photo_tags.photo_id LEFT OUTER JOIN tags ON photo_tags.tag_id = tags.id', :include => [:album], :order => "photos.title ASC" )
|
||||
@photos = Photo.find(:all, :limit => 20, :conditions => [ "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 = :t) ", { :q => '%' + params[:q] + '%', :t => params[:q] } ], :include => :album, :order => "photos.id ASC" )
|
||||
else
|
||||
@photos = Photo.find(:all, :order => "photos.id ASC")
|
||||
end
|
||||
|
|
|
@ -23,6 +23,17 @@ class Photo < ActiveRecord::Base
|
|||
named_scope :previous, lambda { |p,a| { :conditions => ["id < :id AND Album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "Id DESC"} }
|
||||
named_scope :next, lambda { |p,a| { :conditions => ["id > :id AND Album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "Id ASC"} }
|
||||
|
||||
def self.search(q)
|
||||
if q
|
||||
conditions = q.split("AND").each {|var|
|
||||
|
||||
}
|
||||
find(:all)
|
||||
else
|
||||
find(:all)
|
||||
end
|
||||
end
|
||||
|
||||
def to_param
|
||||
self.id.to_s + '-' + self.title.parameterize
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<script src="/javascripts/tag/tag.js" type="text/javascript" charset="utf-8"></script>
|
||||
<% end %>
|
||||
|
||||
<div id="map_canvas" style="width: 500px; height: 300px;float:right;border:4px solid black;"></div>
|
||||
<div id="map_canvas"></div>
|
||||
|
||||
<%= hidden_field_tag :all_tags, "'#{Tag.find(:all).map { |tag| tag.title }.join('\',\'')}'" %>
|
||||
<%= hidden_field_tag :collection_id, params[:collection_id] %>
|
||||
|
|
|
@ -6,9 +6,10 @@ jQuery(function($) {
|
|||
})
|
||||
}
|
||||
|
||||
if ( $('#map_canvas').length ) {
|
||||
var map, locations_on_map = new Array();
|
||||
if ( $('#map_canvas').length && $('#album_latitude').val() > '' && $('#album_longitude').val() > '' ) {
|
||||
mapInitialize()
|
||||
$('#map_canvas').show()
|
||||
}
|
||||
|
||||
$("#album_address").change( function () {
|
||||
|
@ -17,6 +18,11 @@ jQuery(function($) {
|
|||
geocoder.getLatLng( $("#album_address").val() , function(point) {
|
||||
//console.log( point )
|
||||
if ( point ) {
|
||||
if (typeof map == "undefined") {
|
||||
$('#map_canvas').show()
|
||||
mapInitialize()
|
||||
}
|
||||
|
||||
$('#album_latitude').val( point.lat() )
|
||||
$('#album_longitude').val( point.lng() )
|
||||
map.setCenter(new GLatLng( $('#album_latitude').val(), $('#album_longitude').val()), 13);
|
||||
|
@ -24,7 +30,9 @@ jQuery(function($) {
|
|||
map.addOverlay(marker);
|
||||
}
|
||||
else
|
||||
{ alert('Unable to find address') }
|
||||
{
|
||||
$('#map_canvas').hide()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -191,6 +191,14 @@ div#header h1 p {
|
|||
font-weight: normal;
|
||||
}
|
||||
|
||||
DIV#map_canvas {
|
||||
width: 500px;
|
||||
height: 300px;
|
||||
float:right;
|
||||
border:4px solid black;
|
||||
display: none;
|
||||
}
|
||||
|
||||
DIV#breadcrumb {
|
||||
float: left;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue