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

Commit

Permalink
made dashboard nicer, added quick post plugin to add widget to submit…
Browse files Browse the repository at this point in the history
… blog posts easily on dashboard
  • Loading branch information
Josh Adams committed Jan 29, 2009
1 parent 5219700 commit e4aa710
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/helpers/dashboard_helper.rb
@@ -0,0 +1,5 @@
module DashboardHelper
def render_dashboard_box dashboard_box
render :partial => 'shared/render_dashboard_box', :locals => { :dashboard_box => dashboard_box }
end
end
13 changes: 9 additions & 4 deletions app/views/admin/dashboards/show.html.erb
@@ -1,7 +1,12 @@
<%= title "Dashboard" %>

<% Ansuz::PluginManagerInstance.admin_dashboard_boxes.each do |dashboard_box| %>
<% render :layout => 'shared/dashboard_box', :locals => { :title => dashboard_box[0] } do %>
<%= render :partial => dashboard_box[1] %>
<div class='twocol'>
<% Ansuz::PluginManagerInstance.admin_dashboard_boxes.in_groups(2).each_with_index do |half, i| %>
<div class='col <%= "left" if i==0 %>'>
<% half.compact.each do |dashboard_box| %>
<%= render_dashboard_box dashboard_box %>
<% end %>
</div>
<% end %>
<% end %>
<div class='clear'></div>
</div>
3 changes: 3 additions & 0 deletions app/views/shared/_render_dashboard_box.html.erb
@@ -0,0 +1,3 @@
<% render :layout => 'shared/dashboard_box', :locals => { :title => dashboard_box[0] } do %>
<%= render :partial => dashboard_box[1] %>
<% end %>
5 changes: 4 additions & 1 deletion lib/ansuz/plugin_manager.rb
Expand Up @@ -2,7 +2,10 @@
module Ansuz
class PluginManager
include Ansuz::PluginSettings
attr_accessor :plugins, :plugin_nav, :admin_plugin_nav, :admin_menu, :admin_menu_top_level_entries, :page_types, :admin_dashboard_boxes, :at_a_glance_entries
attr_accessor :plugins, :plugin_nav, :admin_plugin_nav,
:admin_menu, :admin_menu_top_level_entries,
:page_types, :admin_dashboard_boxes,
:at_a_glance_entries
ADMIN_MENU_TOP_LEVEL_ENTRIES = ["Create", "Manage", "Ansuz"]

def initialize
Expand Down
10 changes: 10 additions & 0 deletions public/stylesheets/admin.css
Expand Up @@ -476,6 +476,7 @@ table.tree tr.odd:hover td {
background-color:#ebebeb !important;
}

/* dashboard */
.dashboard_box{
margin-bottom: 10px;
}
Expand All @@ -484,3 +485,12 @@ table.tree tr.odd:hover td {
color: white;
padding: 6px;
}

/* twocol */
.twocol .col{
width: 47%;
float: left;
}
.twocol .left.col{
margin-right:20px;
}
Expand Up @@ -23,10 +23,16 @@ def new
end

def create
@blog_post.settings = params[:settings]
if @blog_post.save
@blog_post.settings = params[:settings]
@blog_post.save # has_settings doesn't work like you might want on new records yet, so we save twice.
flash[:notice] = "Blog Post was created successfully."
redirect_to admin_blog_posts_path
# Weak, baked-in support for quick-post plugin.
if params[:quick_post]
redirect_to admin_dashboard_path
else
redirect_to admin_blog_posts_path
end
else
flash.now[:error] = "There was a problem creating the blog post."
render :action => 'new'
Expand Down
@@ -0,0 +1,7 @@
<% form_for :blog_post, :url => admin_blog_posts_path, :html => { :class => 'blog-post-form' } do |f| -%>
<%= render :partial => '/admin/blog_posts/form', :locals => { :f => f } -%>
<% if local_assigns.include?(:is_quickpost) && is_quickpost %>
<%= hidden_field_tag :quick_post, true %>
<% end %>
<%= submit_tag("Create Post") -%> or <%= link_to "Cancel", admin_blog_posts_path -%>
<% end -%>
@@ -1,7 +1,9 @@
<%= title "New Blog Post" -%>
<% content_for :sidebar do -%>
<%= link_to "All Blog Posts", admin_blog_posts_path, :class => 'button icon back' -%>
<% end -%>
<% form_for :blog_post, :url => admin_blog_posts_path, :html => { :class => 'blog-post-form' } do |f| -%>
<%= render :partial => 'form', :locals => { :f => f } -%>
<%= submit_tag("Create Post") -%> or <%= link_to "Cancel", admin_blog_posts_path -%>
Expand Down
@@ -0,0 +1,5 @@
<%
# nasty, required because of fckeditor_textarea's failings or my lack of understanding
@blog_post = Ansuz::JAdams::BlogPost.new
%>
<%= render :partial => 'admin/blog_posts/new', :locals => { :is_quickpost => true } %>
2 changes: 2 additions & 0 deletions vendor/plugins/ansuz_quick_post_dashboard_widget/init.rb
@@ -0,0 +1,2 @@
# Add a box to the admin dashboard from which to quick-post
Ansuz::PluginManagerInstance.register_admin_dashboard_box("Quick Post", 'admin/quick_posts/quick_post')

0 comments on commit e4aa710

Please sign in to comment.