app/views/items/_content_examples.html.erb in wontomedia-0.1.1 vs app/views/items/_content_examples.html.erb in wontomedia-0.2.0
- old
+ new
@@ -21,11 +21,11 @@
<p class="unimplemented">[The purpose of this area is to highlight
"samples" of the local installation's content. For now, we're
displaying the complete set of non-Property items.]</p>
<% end %>
-<div class="subheading">Recently Added Items</div>
+<h2 class="subheading">Recently Added</h2>
<style>
.item-title {
font-size: 120%;
font-weight: bold;
margin: 0;
@@ -35,22 +35,25 @@
margin: 0;
margin-bottom: 2ex;
}
</style>
-<% nouns_listed = 0
- @nouns.each do |item| %>
- <p class="item-title">
- <%= link_to "#{h filter_parenthetical item.title}",
- item_by_name_path(item.name) %>
- </p>
- <p class="item-desc">
- <% desc = h item.description
- if desc.length > 180
- desc = desc[0,180] + '…'
- end
- %>
- <%= desc %>
- </p>
-
-<% break if (nouns_listed += 1) >= 20
- end %>
+<% # TODO: if the controller made another list just for this, then it
+ # could have the database apply the filter/sort/limit, but I don't
+ # know if doing this here is slower or faster, so here for now:
+ @nouns.reject {|item| (item.flags & Item::DATA_IS_UNALTERABLE) != 0}.
+ sort {|a,b|
+ (b.updated_at or b.created_at) <=> (a.updated_at or a.created_at) }.
+ first(20).each do |item| %>
+ <p class="item-title">
+ <%= link_to "#{h filter_parenthetical item.title}",
+ item_by_name_path(item.name) %>
+ </p>
+ <p class="item-desc">
+ <% desc = h item.description
+ if desc.length > 180
+ desc = desc[0,180] + '…'
+ end
+ %>
+ <%= desc %>
+ </p><%
+ end %>