example db&setting files. maps

This commit is contained in:
Espen Antonsen 2009-07-06 15:41:19 +02:00
parent 07493aaaad
commit 879a26aec3
8 changed files with 71 additions and 54 deletions

2
.gitignore vendored
View file

@ -5,6 +5,8 @@ doc/api
doc/app
public/files
public/thumbs
config/database.yml
config/settings.yml
config/deploy.rb
config/deploy
Capfile

View file

@ -51,7 +51,7 @@ class Photo < ActiveRecord::Base
end
def tag_list
return self.tags.find(:all, :order => 'title').collect{ |t| t.title }.sort.join(" ")
return self.tags.find(:all, :order => 'title').map{ |t| t.title }.sort.join(" ")
end
def tag_list=(tags)

View file

@ -1,9 +1,15 @@
<% content_for :javascript do %>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAA2ASeVD5kkQjUA-G_DcpW6xTYEJCoV24wtogQseyPWcfAg67ZQBRSqFfegsi4Rb7m5RD95qnEcX8gNg" type="text/javascript"></script>
<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>
<%= hidden_field_tag :all_tags, "'#{Tag.find(:all).map { |tag| tag.title }.join('\',\'')}'" %>
<%= hidden_field_tag :collection_id, params[:collection_id] %>
<%= form.hidden_field :id %>
<%= form.hidden_field :latitude %>
<%= form.hidden_field :longitude %>
<%= form.label :title, :Title, {:class => 'big'} %><br />
<%= form.text_field :title, {:class => 'big'} %><br />
@ -18,7 +24,7 @@
<%= form.text_area :note %><br />
<%= form.label :tags %><br />
<%= form.text_field :tags, { :autocomplete => "off", :class => 'tag_list', :value => @album.tags.map{|tag|tag.title}.join(" ") } %><br />
<%= form.text_field :tags, { :autocomplete => "off", :class => 'tag_list', :value => (@album.tags.map{|tag|tag.title}.join(" ") unless @album.tags.nil?) } %><br />
<br />
<% if @album.path? %>

View file

@ -9,7 +9,7 @@
<% content_for :action_links do %>
<% if has_role?("admin") %>
<br /><%= link_to("Delete album", { :action => "destroy", :id => @album },
<%= link_to("Delete album", { :action => "destroy", :id => @album },
:confirm => "Are you sure you want to delete this album?",
:method => :delete) %>
<% end %>

View file

@ -22,7 +22,7 @@
<% end %>
</div>
<h1>ImageGallery</h1>
<form action="/photos" method="get" id="search">
<form action="/albums" method="get" id="search">
<input type="text" name="q" class="textfie.d"/>
<input type="submit" value="Search" class="button" />
</form>

View file

@ -1,20 +0,0 @@
development:
adapter: postgresql
database: gallery_development
username: gallery
password: changeme
production:
adapter: mysql
encoding: utf8
username: photogallery
password: changeme
database: gallery_production
socket: /var/run/mysqld/mysqld.sock
test: &TEST
adapter: postgresql
database: gallery_test
username: gallery
password: changeme
cucumber:
<<: *TEST

View file

@ -1,30 +0,0 @@
development:
site_name: Gallery
admin_email: espen@inspired.no
site_url: gallery.dev:3000
photos_path: '/users/Espen/gallery/dev/originals/'
thumbs_path: '/users/Espen/gallery/dev/thumbs/'
photos_path_public: '/files/'
thumbs_path_public: '/thumbs/'
thumb_width: 200
thumb_height: 200
production:
site_name: 'Espen Antonsen photos'
admin_email: espen@inspired.no
site_url: photos.inspired.no
photos_path: '/home/espen/photos/originals/'
thumbs_path: '/home/espen/photos/thumbs/'
photos_path_public: '/files/'
thumbs_path_public: '/thumbs/'
thumb_width: 200
thumb_height: 200
test:
site_name: Gallery
admin_email: espen@inspired.no
site_url: gallery.dev:3000
photos_path: '/users/Espen/gallery/test/originals/'
thumbs_path: '/users/Espen/gallery/test/thumbs/'
photos_path_public: '/files/'
thumbs_path_public: '/thumbs/'
thumb_width: 200
thumb_height: 200

View file

@ -5,6 +5,65 @@ jQuery(function($) {
tags: $('#all_tags').val().split('\'')
})
}
if ( $('#map_canvas').length ) {
var map, locations_on_map = new Array();
mapInitialize()
}
$("#album_address").change( function () {
var geocoder = new GClientGeocoder()
//console.log( $("#album_address").val() )
geocoder.getLatLng( $("#album_address").val() , function(point) {
//console.log( point )
if ( point ) {
$('#album_latitude').val( point.lat() )
$('#album_longitude').val( point.lng() )
map.setCenter(new GLatLng( $('#album_latitude').val(), $('#album_longitude').val()), 13);
var marker = mapCreateMarker( { 'title' : $("#album_title").val(), 'address' : $("#album_address").val(), 'latitude': point.lat(), 'longitude' : point.lng() } );
map.addOverlay(marker);
}
else
{ alert('Unable to find address') }
}
)
}
)
function mapInitialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setUIToDefault();
map.setCenter(new GLatLng( $('#album_latitude').val(), $('#album_longitude').val()), 13);
var marker = mapCreateMarker( { 'id' : $("#album_id").val(), 'title' : $("#album_title").val(), 'address' : $("#album_address").val(), 'latitude': $("#album_latitude").val(), 'longitude' : $("#album_longitude").val() } );
map.addOverlay(marker);
map.setCenter( new GLatLng( $("#album_latitude").val(), $("#album_longitude").val() ), 13 )
locations_on_map[ $("#album_id").val() ][0].openInfoWindowHtml( locations_on_map[ $("#album_id").val() ][1] )
}
}
function mapProcessData(data) {
var locations = eval('(' + data + ')');
for (var i=0; i<locations.length; i++) {
var marker = mapCreateMarker(locations[i].location )
if ( marker ) {
map.addOverlay( marker )
}
}
}
function mapCreateMarker(location) {
if ( !location.latitude || !location.longitude ) {
return false;
}
var marker = new GMarker( new GLatLng(parseFloat( location.latitude), parseFloat( location.longitude) ) )
var html = "<b>" + location.title + "</b> <br/>" + location.address + "<br /><br/>"
locations_on_map[location.id] = [marker, html]
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker
}
//$('div.scrollable').scrollable().click( $('#gallery ul').children().index( $('#gallery li.active') ) )
});