Permalink
Browse files

Added a new home page with support for featured categories.

  • Loading branch information...
1 parent eb5d68c commit c9325a2c94c1168dd082477d1f5c07dad5b75104 @kench kench committed Feb 27, 2010
@@ -0,0 +1,13 @@
+class HomeController < ApplicationController
+ def index
+ @featured_categories = Category.find( :all, :conditions => { :is_featured => true } )
+ @featured_categories.delete_if {|x| !x.allowed_to_read} #Hide Private Featured Categories
+ @categories = Category.roots
+ @featured_categories.delete_if {|x| !x.allowed_to_read} #Hide Private Root Categories
+ @categories.delete_if {|x| !x.allowed_to_read} #Hide Private Root Categories
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @categories }
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module HomeHelper
+end
@@ -13,6 +13,7 @@
</li>
<li><%= f.label :private, "Is Private" %> <%= f.check_box :private %><span>Checking this box will make this category only visible to my group.</span></li>
<li><%= f.label :writable, "Everyone can edit" %> <%= f.check_box :writable %><span>Checking this box will make it so that everyone can edit and add docs.</span></li>
+ <li><%= f.label :is_featured, "Featured category" %> <%= f.check_box :is_featured %><span>Checking this box will make appear as a featured category on the front page.</span></li>
<% if !(controller.action_name == "new") %>
<li><%= f.label :user, "Admin" %> <%= f.collection_select :user_id, User.all, :id, :full_name %></li>
<% end %>
@@ -0,0 +1,7 @@
+<div id="cat_tree">
+ <div id="cat_tree_inset">
+ <div id="cat_tree-padding">
+ <%= aac_tree(Category.roots, {:name => "Home Category", :path => root_path}) %>
+ </div>
+ </div>
+</div>
@@ -0,0 +1,24 @@
+<% form_for(@category, :html => { :class => 'cmxform', :multipart => true }) do |f| %>
+ <%= f.error_messages %>
+ <fieldset>
+ <ol>
+ <li><%= f.label :name %> <%= f.text_field :name %></li>
+ <li><%= f.label :description %> <%= f.text_area :description %></li>
+ <li><%= f.label :parent_id %> <%= aac_select(Category.roots, {:id =>'category_parent_id', :name => 'category[parent_id]', :selected => @category.parent_id, :option_nil => 'None'}) %></li>
+ <li><%= f.label :group %> <%= f.collection_select :group_id, Group.all, :id, :name %></li>
+ <li>
+ <div style="float:left;"><%= f.label :background %> </div>
+ <div style="float:left; margin-left:8px; width:80%;"><%= render :partial => 'backgrounds/select', :locals => {:form => f} %></div>
+ <div style="clear:both;"></div>
+ </li>
+ <li><%= f.label :private, "Is Private" %> <%= f.check_box :private %><span>Checking this box will make this category only visible to my group.</span></li>
+ <li><%= f.label :writable, "Everyone can edit" %> <%= f.check_box :writable %><span>Checking this box will make it so that everyone can edit and add docs.</span></li>
+ <% if !(controller.action_name == "new") %>
+ <li><%= f.label :user, "Admin" %> <%= f.collection_select :user_id, User.all, :id, :full_name %></li>
+ <% end %>
+ </ol>
+ </fieldset>
+ <p class="submitbutton"><%= f.submit button_text %></p>
+<% end %>
+
+
@@ -0,0 +1,42 @@
+<h1 class="main-title">Flagship Document Management System</h1>
+<div class="hr_dl flush"><%= image_tag("bl.png", :alt => "") %></div>
+<br />
+<div id="mc-indent" class="mc-indent">
+ <h1>Featured Categories</h1>
+ <ul class="iconlist" class="featured">
+ <% @featured_categories.each do |category| %>
+ <li>
+ <% link_to category do %>
+ <div class="iconlist_padding">
+ <div class="ins">
+ <div class="type-folder"><%= image_tag("icons/icon_folder.png", :alt => "Icon_folder") %></div>
+ </div>
+ <h2><%=h category.name %></h2>
+ </div>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+ <div style="clear:both;"></div>
+ <h1>Other Categories</h1>
+ <br />
+ <% if admin_logged_in? %>
+ <%= link_to 'New Category', new_category_path, :class => "link-button" %>
+ <br /><br />
+ <% end %>
+ <ul class="iconlist">
+ <% @categories.each do |category| %>
+ <li>
+ <% link_to category do %>
+ <div class="iconlist_padding">
+ <div class="ins">
+ <div class="type-folder"><%= image_tag("icons/icon_folder.png", :alt => "Icon_folder") %></div>
+ </div>
+ <h2><%=h category.name %></h2>
+ </div>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+ <div style="clear:both;"></div>
+</div>
View
@@ -43,7 +43,7 @@
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- map.root :controller => "categories"
+ map.root :controller => "home"
# See how all your routes lay out with "rake routes"
@@ -0,0 +1,9 @@
+class AddFeaturedFlagToCategories < ActiveRecord::Migration
+ def self.up
+ add_column :categories, :is_featured, :boolean
+ end
+
+ def self.down
+ remove_column :categories, :is_featured
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100201143130) do
+ActiveRecord::Schema.define(:version => 20100227203223) do
create_table "backgrounds", :force => true do |t|
t.string "image_file_name"
@@ -34,6 +34,7 @@
t.integer "ancestors_count"
t.integer "descendants_count"
t.integer "background_id"
+ t.boolean "is_featured"
end
add_index "categories", ["background_id"], :name => "background_id_index"
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class HomeControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class HomeHelperTest < ActionView::TestCase
+end

0 comments on commit c9325a2

Please sign in to comment.