Restructure notes URLs according to standard rails conventions
This commit is contained in:
parent
6aca6cfabf
commit
c9fb146608
21 changed files with 196 additions and 80 deletions
8
app/views/notes/_description.html.erb
Normal file
8
app/views/notes/_description.html.erb
Normal file
|
@ -0,0 +1,8 @@
|
|||
<div>
|
||||
<% description.comments.each do |comment| -%>
|
||||
<div class="note-comment" style="margin-top: 5px">
|
||||
<div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment, :only_path => false) %></div>
|
||||
<div class="note-comment-text"><%= comment.body %></div>
|
||||
</div>
|
||||
<% end -%>
|
||||
</div>
|
15
app/views/notes/_note.gpx.builder
Normal file
15
app/views/notes/_note.gpx.builder
Normal file
|
@ -0,0 +1,15 @@
|
|||
xml.wpt("lon" => note.lon, "lat" => note.lat) do
|
||||
xml.desc do
|
||||
xml.cdata! render(:partial => "description", :object => note, :formats => [ :html ])
|
||||
end
|
||||
|
||||
xml.extension do
|
||||
if note.status = "open"
|
||||
xml.closed "0"
|
||||
else
|
||||
xml.closed "1"
|
||||
end
|
||||
|
||||
xml.id note.id
|
||||
end
|
||||
end
|
22
app/views/notes/_note.json.jsonify
Normal file
22
app/views/notes/_note.json.jsonify
Normal file
|
@ -0,0 +1,22 @@
|
|||
json.type "Feature"
|
||||
|
||||
json.geometry do
|
||||
json.type "Point"
|
||||
json.coordinates [ note.lon, note.lat ]
|
||||
end
|
||||
|
||||
json.properties do
|
||||
json.id note.id
|
||||
json.date_created note.created_at
|
||||
json.nearby note.nearby_place
|
||||
json.status note.status
|
||||
json.closed_at note.closed_at if note.status == "closed"
|
||||
|
||||
json.comments(note.comments) do |comment|
|
||||
json.date comment.created_at
|
||||
json.uid comment.author_id unless comment.author_id.nil?
|
||||
json.user comment.author_name
|
||||
json.action comment.event
|
||||
json.text comment.body unless comment.body.nil?
|
||||
end
|
||||
end
|
18
app/views/notes/_note.rss.builder
Normal file
18
app/views/notes/_note.rss.builder
Normal file
|
@ -0,0 +1,18 @@
|
|||
xml.item do
|
||||
if note.status == "closed"
|
||||
xml.title t('note.rss.closed', :place => note.nearby_place)
|
||||
elsif note.comments.length > 1
|
||||
xml.title t('note.rss.comment', :place => note.nearby_place)
|
||||
else
|
||||
xml.title t('note.rss.new', :place => note.nearby_place)
|
||||
end
|
||||
|
||||
xml.link url_for(:controller => "browse", :action => "note", :id => note.id, :only_path => false)
|
||||
xml.guid url_for(:controller => "note", :action => "read", :id => note.id, :only_path => false)
|
||||
xml.description render(:partial => "description", :object => note, :formats => [ :html ])
|
||||
xml.author note.author_name
|
||||
xml.pubDate note.updated_at.to_s(:rfc822)
|
||||
xml.geo :lat, note.lat
|
||||
xml.geo :long, note.lon
|
||||
xml.georss :point, "#{note.lat} #{note.lon}"
|
||||
end
|
21
app/views/notes/_note.xml.builder
Normal file
21
app/views/notes/_note.xml.builder
Normal file
|
@ -0,0 +1,21 @@
|
|||
xml.note("lon" => note.lon, "lat" => note.lat) do
|
||||
xml.id note.id
|
||||
xml.date_created note.created_at
|
||||
xml.nearby note.nearby_place
|
||||
xml.status note.status
|
||||
|
||||
if note.status == "closed"
|
||||
xml.date_closed note.closed_at
|
||||
end
|
||||
|
||||
xml.comments do
|
||||
note.comments.each do |comment|
|
||||
xml.comment do
|
||||
xml.date comment.created_at
|
||||
xml.uid comment.author_id unless comment.author_id.nil?
|
||||
xml.user comment.author_name
|
||||
xml.text comment.body
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
17
app/views/notes/_notes_paging_nav.html.erb
Normal file
17
app/views/notes/_notes_paging_nav.html.erb
Normal file
|
@ -0,0 +1,17 @@
|
|||
<p>
|
||||
|
||||
<% if @page > 1 %>
|
||||
<%= link_to t('changeset.changeset_paging_nav.previous'), params.merge({ :page => @page - 1 }) %>
|
||||
<% else %>
|
||||
<%= t('changeset.changeset_paging_nav.previous') %>
|
||||
<% end %>
|
||||
|
||||
| <%= t('changeset.changeset_paging_nav.showing_page', :page => @page) %> |
|
||||
|
||||
<% if @notes.size < @page_size %>
|
||||
<%= t('changeset.changeset_paging_nav.next') %>
|
||||
<% else %>
|
||||
<%= link_to t('changeset.changeset_paging_nav.next'), params.merge({ :page => @page + 1 }) %>
|
||||
<% end %>
|
||||
|
||||
</p>
|
1
app/views/notes/_user.html.erb
Normal file
1
app/views/notes/_user.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= link_to user.display_name, :controller => "user", :action => "view", :display_name => user.display_name %>
|
46
app/views/notes/feed.rss.builder
Normal file
46
app/views/notes/feed.rss.builder
Normal file
|
@ -0,0 +1,46 @@
|
|||
xml.instruct!
|
||||
|
||||
xml.rss("version" => "2.0",
|
||||
"xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#",
|
||||
"xmlns:georss" => "http://www.georss.org/georss") do
|
||||
xml.channel do
|
||||
xml.title t('note.rss.title')
|
||||
xml.description t('note.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon )
|
||||
xml.link url_for(:controller => "site", :action => "index", :only_path => false)
|
||||
|
||||
@comments.each do |comment|
|
||||
xml.item do
|
||||
if comment.event == "closed"
|
||||
xml.title t('note.rss.closed', :place => comment.note.nearby_place)
|
||||
elsif comment.event == "commented"
|
||||
xml.title t('note.rss.comment', :place => comment.note.nearby_place)
|
||||
elsif comment.event == "opened"
|
||||
xml.title t('note.rss.new', :place => comment.note.nearby_place)
|
||||
else
|
||||
xml.title "unknown event"
|
||||
end
|
||||
|
||||
xml.link url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false)
|
||||
xml.guid url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false)
|
||||
|
||||
description_text = ""
|
||||
|
||||
if comment.event == "commented" and not comment.nil?
|
||||
description_text += "<b>Comment:</b><br>"
|
||||
description_text += htmlize(comment.body)
|
||||
description_text += "<br>"
|
||||
end
|
||||
|
||||
description_text += "<b>Full note:</b><br>"
|
||||
description_text += comment.note.flatten_comment("<br>", comment.created_at)
|
||||
|
||||
xml.description description_text
|
||||
xml.author comment.author_name
|
||||
xml.pubDate comment.created_at.to_s(:rfc822)
|
||||
xml.geo :lat, comment.note.lat
|
||||
xml.geo :long, comment.note.lon
|
||||
xml.georss :point, "#{comment.note.lat} #{comment.note.lon}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
7
app/views/notes/index.gpx.builder
Normal file
7
app/views/notes/index.gpx.builder
Normal file
|
@ -0,0 +1,7 @@
|
|||
xml.instruct!
|
||||
|
||||
xml.gpx("version" => "1.1",
|
||||
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
||||
"xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
|
||||
xml << render(:partial => "note", :collection => @notes)
|
||||
end
|
5
app/views/notes/index.json.jsonify
Normal file
5
app/views/notes/index.json.jsonify
Normal file
|
@ -0,0 +1,5 @@
|
|||
json.type "FeatureCollection"
|
||||
|
||||
json.features(@notes) do |note|
|
||||
json.ingest! render(:partial => "note", :object => note)
|
||||
end
|
13
app/views/notes/index.rss.builder
Normal file
13
app/views/notes/index.rss.builder
Normal file
|
@ -0,0 +1,13 @@
|
|||
xml.instruct!
|
||||
|
||||
xml.rss("version" => "2.0",
|
||||
"xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#",
|
||||
"xmlns:georss" => "http://www.georss.org/georss") do
|
||||
xml.channel do
|
||||
xml.title t('note.rss.title')
|
||||
xml.description t('note.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon )
|
||||
xml.link url_for(:controller => "site", :action => "index", :only_path => false)
|
||||
|
||||
xml << render(:partial => "note", :collection => @notes)
|
||||
end
|
||||
end
|
3
app/views/notes/index.xml.builder
Normal file
3
app/views/notes/index.xml.builder
Normal file
|
@ -0,0 +1,3 @@
|
|||
xml.instruct!
|
||||
|
||||
xml << render(:partial => "note", :collection => @notes)
|
37
app/views/notes/mine.html.erb
Normal file
37
app/views/notes/mine.html.erb
Normal file
|
@ -0,0 +1,37 @@
|
|||
<h1><%= @heading %></h1>
|
||||
<p><%= raw @description %></p>
|
||||
|
||||
<%= render :partial => 'notes_paging_nav' %>
|
||||
|
||||
<table id="note_list" cellpadding="3">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><%= t'note.mine.id' %></th>
|
||||
<th><%= t'changeset.changesets.user' %></th>
|
||||
<th><%= t'changeset.changesets.comment' %></th>
|
||||
<th><%= t'changeset.changesets.saved_at' %></th>
|
||||
<th><%= t'note.mine.last_changed' %></th>
|
||||
</tr>
|
||||
<% @notes.each do |note| -%>
|
||||
<tr<% if note.author != @user2 %> bgcolor="#EEEEEE"<% end %>>
|
||||
<td>
|
||||
<% if note.status == "closed" %>
|
||||
<%= image_tag("closed_note_marker.png", :alt => 'closed') %>
|
||||
<% else %>
|
||||
<%= image_tag("open_note_marker.png", :alt => 'open') %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= link_to note.id.to_s, :controller => "browse", :action => "note", :id => note.id %></td>
|
||||
<% if note.author.nil? %>
|
||||
<td> <%= note.author_name %> </td>
|
||||
<% else %>
|
||||
<td><%= link_to h(note.author_name), :controller => "user", :action => "view", :display_name => note.author_name %></td>
|
||||
<% end %>
|
||||
<td> <%= htmlize note.comments.first.body %> </td>
|
||||
<td><%= l note.created_at %></td>
|
||||
<td><%= l note.updated_at %></td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</table>
|
||||
|
||||
<%= render :partial => 'notes_paging_nav' %>
|
7
app/views/notes/show.gpx.builder
Normal file
7
app/views/notes/show.gpx.builder
Normal file
|
@ -0,0 +1,7 @@
|
|||
xml.instruct!
|
||||
|
||||
xml.gpx("version" => "1.1",
|
||||
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
||||
"xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
|
||||
xml << render(:partial => "note", :object => @note)
|
||||
end
|
1
app/views/notes/show.json.jsonify
Normal file
1
app/views/notes/show.json.jsonify
Normal file
|
@ -0,0 +1 @@
|
|||
json.ingest! render(:partial => "note", :object => @note)
|
13
app/views/notes/show.rss.builder
Normal file
13
app/views/notes/show.rss.builder
Normal file
|
@ -0,0 +1,13 @@
|
|||
xml.instruct!
|
||||
|
||||
xml.rss("version" => "2.0",
|
||||
"xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#",
|
||||
"xmlns:georss" => "http://www.georss.org/georss") do
|
||||
xml.channel do
|
||||
xml.title t('note.rss.title')
|
||||
xml.description t('note.rss.description_item', :id => @note.id)
|
||||
xml.link url_for(:controller => "site", :action => "index", :only_path => false)
|
||||
|
||||
xml << render(:partial => "note", :object => @note)
|
||||
end
|
||||
end
|
3
app/views/notes/show.xml.builder
Normal file
3
app/views/notes/show.xml.builder
Normal file
|
@ -0,0 +1,3 @@
|
|||
xml.instruct!
|
||||
|
||||
xml << render(:partial => "note", :object => @note)
|
Loading…
Add table
Add a link
Reference in a new issue