Adding RSS feed to main diary page, with space for lat/long info to be associated with each post in the future, though that needs adding still.
This commit is contained in:
parent
c43fac76df
commit
b4e6a72858
2 changed files with 24 additions and 1 deletions
|
@ -5,6 +5,7 @@ class DiaryEntryController < ApplicationController
|
||||||
before_filter :require_user, :only => [:new]
|
before_filter :require_user, :only => [:new]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@title = 'new diary entry'
|
||||||
if params[:diary_entry]
|
if params[:diary_entry]
|
||||||
@entry = DiaryEntry.new(params[:diary_entry])
|
@entry = DiaryEntry.new(params[:diary_entry])
|
||||||
@entry.user = @user
|
@entry.user = @user
|
||||||
|
@ -15,6 +16,25 @@ class DiaryEntryController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def list
|
def list
|
||||||
|
@title = 'recent diary entries'
|
||||||
@entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit=>20)
|
@entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit=>20)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def rss
|
||||||
|
@entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit=>20)
|
||||||
|
|
||||||
|
rss = OSM::GeoRSS.new('OpenStreetMap diary entries', 'Recent diary entries from users of OpenStreetMap', 'http://www.openstreetmap.org/diary')
|
||||||
|
|
||||||
|
@entries.each do |entry|
|
||||||
|
# add geodata here
|
||||||
|
latitude = nil
|
||||||
|
longitude = nil
|
||||||
|
rss.add(latitude, longitude, entry.title, url_for({:controller => 'user', :action => 'diary', :id => entry.id, :display_name => entry.user.display_name}), entry.body, entry.created_at)
|
||||||
|
end
|
||||||
|
|
||||||
|
response.headers["Content-Type"] = 'application/xml+rss'
|
||||||
|
|
||||||
|
render :text => rss.to_s
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
<h3>most recent posts:</h3>
|
<h3>Recent diary entries:</h3>
|
||||||
<br />
|
<br />
|
||||||
<%= render :partial => 'diary_entry/diary_entry', :collection => @entries %>
|
<%= render :partial => 'diary_entry/diary_entry', :collection => @entries %>
|
||||||
|
|
||||||
|
<%= link_to(image_tag("RSS.gif", :size => "16x16", :border => 0), :action => 'rss') %>
|
||||||
|
<%= auto_discovery_link_tag(:atom, :action => 'rss') %>
|
Loading…
Add table
Add a link
Reference in a new issue