From b78d25a3a8f0f059eb0f7104b8861c50e685e51e Mon Sep 17 00:00:00 2001 From: Dan Karran Date: Mon, 3 Sep 2007 22:37:42 +0000 Subject: [PATCH] Allow people to add coordinates to diary entries, add them to the RSS feeds and diary display pages using geo microformat. --- app/controllers/diary_entry_controller.rb | 5 +-- app/views/diary_entry/_diary_entry.rhtml | 5 ++- app/views/diary_entry/new.rhtml | 55 ++++++++++++++++++++++- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 92f541332..83fcb4aea 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -41,10 +41,7 @@ class DiaryEntryController < ApplicationController end @entries.each do |entry| - # add geodata here - latitude = nil - longitude = nil - rss.add(latitude, longitude, entry.title, entry.user.display_name, url_for({:controller => 'diary_entry', :action => 'list', :id => entry.id, :display_name => entry.user.display_name}), entry.body, entry.created_at) + rss.add(entry.latitude, entry.longitude, entry.title, entry.user.display_name, url_for({:controller => 'diary_entry', :action => 'list', :id => entry.id, :display_name => entry.user.display_name}), entry.body, entry.created_at) end render :text => rss.to_s, :content_type => "application/rss+xml" diff --git a/app/views/diary_entry/_diary_entry.rhtml b/app/views/diary_entry/_diary_entry.rhtml index 168bb832b..366a67f0e 100644 --- a/app/views/diary_entry/_diary_entry.rhtml +++ b/app/views/diary_entry/_diary_entry.rhtml @@ -1,5 +1,8 @@ <%= diary_entry.title %>
<%= simple_format(diary_entry.body) %> -Posted by user <%= link_to diary_entry.user.display_name, :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name %> at <%= diary_entry.created_at %>
+<% if diary_entry.latitude and diary_entry.longitude %> +Coordinates:
<%= diary_entry.latitude %>; <%= diary_entry.longitude %>
(<%=link_to 'map', :controller => 'site', :action => 'index', :lat => diary_entry.latitude, :lon => diary_entry.longitude, :zoom => 14 %> / <%=link_to 'edit', :controller => 'site', :action => 'edit', :lat => diary_entry.latitude, :lon => diary_entry.longitude, :zoom => 14 %>)
+<% end %> +Posted by <%= link_to diary_entry.user.display_name, :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name %> at <%= diary_entry.created_at %>


diff --git a/app/views/diary_entry/new.rhtml b/app/views/diary_entry/new.rhtml index 16974fad2..8daf769c4 100644 --- a/app/views/diary_entry/new.rhtml +++ b/app/views/diary_entry/new.rhtml @@ -8,11 +8,64 @@ Body - <%= f.text_area :body, :cols => 80 %> + <%= f.text_area :body, :cols => 80, :rows => 10 %> + + Location +

+ Latitude: <%= f.text_field :latitude, :size => 20, :id => "latitude" %> Longitude <%= f.text_field :longitude, :size => 20, :id => "longitude" %> + <%= submit_tag 'Save' %> <% end %> + +<% if @user.home_lat.nil? or @user.home_lon.nil? %> + <% lon = params['lon'] || '-0.1' %> + <% lat = params['lat'] || '51.5' %> + <% zoom = params['zoom'] || '4' %> +<% else %> + <% lon = @user.home_lon %> + <% lat = @user.home_lat %> + <% zoom = '12' %> +<% end %> + + +<%= javascript_include_tag 'map.js' %> + + \ No newline at end of file -- 2.39.5