Modified: trunk/app/helpers/application_helper.rb (2161 => 2162)
--- trunk/app/helpers/application_helper.rb 2009-04-07 10:52:14 UTC (rev 2161)
+++ trunk/app/helpers/application_helper.rb 2009-04-07 11:04:14 UTC (rev 2162)
@@ -1546,4 +1546,12 @@
text.match(/^[aeiou]/i) ? "an" : "a"
end
+ def comma_list(strings)
+
+ return "" if strings.empty?
+ return strings[0] if strings.length == 1
+
+ strings[0..-2].join(", ") + " and " + strings[-1]
+ end
+
end
Modified: trunk/app/views/home/_stats.rhtml (2161 => 2162)
--- trunk/app/views/home/_stats.rhtml 2009-04-07 10:52:14 UTC (rev 2161)
+++ trunk/app/views/home/_stats.rhtml 2009-04-07 11:04:14 UTC (rev 2162)
@@ -1,8 +1,9 @@
-<div class="stats">
- <%= Conf.sitename %> currently has
- <%= link_to pluralize(User.count(:conditions => "users.activated_at IS NOT NULL"), "user"), users_url -%>,
- <%= link_to pluralize(Network.count, "group"), groups_url -%>,
- <%= link_to pluralize(Workflow.count, "workflow"), workflows_url -%>,
- <%= link_to pluralize(Blob.count, "file"), files_url -%> and
- <%= link_to pluralize(Pack.count, "pack"), packs_url -%>
-</div>
+<% if !Conf.home_page_stats.empty? %>
+ <div class="stats">
+ <%= Conf.sitename %> currently has
+ <%= comma_list(Conf.home_page_stats.map do |stat|
+ link_to(pluralize(eval(stat["model"]).count(stat["conditions"] ?
+ { :conditions => stat["conditions"] } : { }), stat["label"]), stat["link"])
+ end) %>
+ </div>
+<% end %>