myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2162] trunk/app: configurable home page stats


From: noreply
Subject: [myexperiment-hackers] [2162] trunk/app: configurable home page stats
Date: Tue, 7 Apr 2009 07:04:14 -0400 (EDT)

Revision
2162
Author
dgc
Date
2009-04-07 07:04:14 -0400 (Tue, 07 Apr 2009)

Log Message

configurable home page stats

Modified Paths

Diff

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 %>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]