end
def index
- @links = Link.where(head_kind: 'orvos#collection') |
- Link.where(tail_kind: 'orvos#collection')
+ @links = Link.eager.where(head_kind: 'orvos#collection') |
+ Link.eager.where(tail_kind: 'orvos#collection')
+ @collections = {}
+ @links.each do |l|
+ if l.head_kind == 'orvos#collection'
+ c = (@collections[l.head_uuid] ||= {uuid: l.head_uuid})
+ if l.link_class == 'resources' and l.name == 'wants'
+ if l.head.respond_to? :created_at
+ c[:created_at] = l.head.created_at
+ end
+ c[:wanted] = true
+ if l.owner == current_user.uuid
+ c[:wanted_by_me] = true
+ end
+ end
+ end
+ if l.tail_kind == 'orvos#collection'
+ c = (@collections[l.tail_uuid] ||= {uuid: l.tail_uuid})
+ if l.link_class == 'group' and l.name == 'member_of'
+ c[:projects] ||= {}
+ c[:projects][l.tail_uuid] = true
+ end
+ if l.link_class == 'data_origin'
+ c[:origin] = l
+ end
+ end
+ end
end
end
- <h1>Bootstrap starter template</h1>
- <p>Use this document as a way to quick start any new project.<br> All you get is this message and a barebones HTML document.</p>
+<% content_for :head do %>
+<style>
+ table.topalign>tbody>tr>td {
+ vertical-align: top;
+ }
+ table.topalign>thead>tr>td {
+ vertical-align: bottom;
+ }
+ .deemphasize {
+ font-size: .8em;
+ color: #888;
+ }
+</style>
+<% end %>
-<p>foo
-</p>
+<table class="topalign">
+ <thead>
+ <tr class="contain-align-left">
+ <th>
+ uuid
+ </th><th>
+ created
+ </th><th>
+ protected
+ </th><th>
+ projects
+ </th><th>
+ origin
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+
+ <% @collections.values.sort_by { |c| c[:created_at] }.reverse.each do |c| %>
+
+ <tr class="collection">
+ <td>
+ <%= c[:uuid] %>
+ </td><td>
+ <%= distance_of_time_in_words(c[:created_at], Time.now).sub('about ','~').sub(' ',' ') if c[:created_at] %>
+ </td><td>
+ <%= ('Y' if c[:wanted_by_me]) or ('y' if c[:wanted]) %>
+ </td><td>
+ <%= c[:projects].size if c[:projects] %>
+ </td><td>
+ <% if c[:origin] %>
+ <span class="deemphasize"><%= c[:origin].name %></span>
+ <%= c[:origin].head_uuid %>
+ <% end %>
+ </td>
+ </tr>
+
+ <% end %>
+
+ </tbody>
+</table>