Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
added ability to link a given statistic to an url associated with it
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Jan 27, 2009
1 parent 4fe98fa commit c87a4a0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions app/views/admin/default_dashboard_boxes/_at_a_glance.html.erb
@@ -1,8 +1,13 @@
<ul class='at-a-glance'>
<% Ansuz::PluginManagerInstance.at_a_glance_entries.each do |entry| %>
<li>
<em><%= entry[1].call %></em>
<%= entry[0] %>
<em><%= entry[2].call %></em>
<% if entry[1] # they provided an url
%>
<%= link_to entry[0], entry[1] %>
<% else %>
<%= entry[0] %>
<% end %>
</li>
<% end %>
</ul>
4 changes: 2 additions & 2 deletions lib/ansuz/plugin_manager.rb
Expand Up @@ -43,8 +43,8 @@ def register_admin_dashboard_box title, partial_path
# register_at_a_glance_statistic "Posts" do
# Post.count
# end
def register_at_a_glance_statistic title, &block
@at_a_glance_entries << [title, block]
def register_at_a_glance_statistic title, options={}, &block
@at_a_glance_entries << [title, options[:url], block]
end

# Plugins may have external gem depdencies, such as ansuz_content_section (RedCloth/BlueCloth)
Expand Down
2 changes: 1 addition & 1 deletion lib/ansuz/setup_default_admin_dashboard_boxes.rb
Expand Up @@ -2,7 +2,7 @@
Ansuz::PluginManagerInstance.register_admin_dashboard_box("At a Glance", 'admin/default_dashboard_boxes/at_a_glance')

# Register an At-a-Glance entry for number of pages, page comments.
Ansuz::PluginManagerInstance.register_at_a_glance_statistic "Pages" do
Ansuz::PluginManagerInstance.register_at_a_glance_statistic "Pages", :url => "/admin/pages" do
Page.count
end
Ansuz::PluginManagerInstance.register_at_a_glance_statistic "Page Comments" do
Expand Down
2 changes: 1 addition & 1 deletion vendor/plugins/ansuz_blog/init.rb
Expand Up @@ -10,7 +10,7 @@
Ansuz::PluginManagerInstance.register_admin_dashboard_box("Recent Comments", 'articles/recent_comments_admin_dashboard_box')

# Add a statistic to the admin "At a Glance" box for Comments, Posts
Ansuz::PluginManagerInstance.register_at_a_glance_statistic "Blog Posts" do
Ansuz::PluginManagerInstance.register_at_a_glance_statistic "Blog Posts", :url => "/admin/blog_posts" do
Ansuz::JAdams::BlogPost.count
end
Ansuz::PluginManagerInstance.register_at_a_glance_statistic "Blog Comments" do
Expand Down

0 comments on commit c87a4a0

Please sign in to comment.