diff --git a/.gitignore b/.gitignore index 78c1684..7dddb03 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ doc/api doc/app public/files public/thumbs +config/database.yml +config/settings.yml config/deploy.rb config/deploy Capfile diff --git a/app/models/photo.rb b/app/models/photo.rb index bb8c38d..e112ddb 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -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) diff --git a/app/views/albums/_form.html.erb b/app/views/albums/_form.html.erb index 401cc15..4d6492a 100644 --- a/app/views/albums/_form.html.erb +++ b/app/views/albums/_form.html.erb @@ -1,9 +1,15 @@ <% content_for :javascript do %> + <% end %> +
+ <%= 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'} %>
<%= form.text_field :title, {:class => 'big'} %>
@@ -18,7 +24,7 @@ <%= form.text_area :note %>
<%= form.label :tags %>
-<%= form.text_field :tags, { :autocomplete => "off", :class => 'tag_list', :value => @album.tags.map{|tag|tag.title}.join(" ") } %>
+<%= form.text_field :tags, { :autocomplete => "off", :class => 'tag_list', :value => (@album.tags.map{|tag|tag.title}.join(" ") unless @album.tags.nil?) } %>

<% if @album.path? %> diff --git a/app/views/albums/edit.html.erb b/app/views/albums/edit.html.erb index f9c4fc4..7d52d78 100644 --- a/app/views/albums/edit.html.erb +++ b/app/views/albums/edit.html.erb @@ -9,7 +9,7 @@ <% content_for :action_links do %> <% if has_role?("admin") %> -
<%= 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 %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e4af6f7..5440c29 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -22,7 +22,7 @@ <% end %>

ImageGallery

- diff --git a/config/database.yml b/config/database.yml deleted file mode 100644 index bf3df02..0000000 --- a/config/database.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml deleted file mode 100644 index c457c46..0000000 --- a/config/settings.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/public/javascripts/application.js b/public/javascripts/application.js index bb923df..e285e55 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -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
" + location.address + "

" + 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') ) ) }); \ No newline at end of file