Commit ca42b0384febd656bcdc458d0dfac95c060eae41

list recent projects on homepage

Commit diff

app/controllers/site_controller.rb

 
22
33 def index
44 @tags = Project.tag_counts
5 @projects = Project.find(:all, :limit => 5, :order => "id desc")
56 end
67
78 def about
toggle raw diff

app/views/site/index.html.erb

 
55 <small><%= link_to "more…", about_path -%></small></p>
66</div>
77
8<div id="site_description">
9
10</div>
11
12<div id="newest_projects">
13 <h2>New projects</h2>
14 <ul>
15 <% @projects.each do |project| -%>
16 <li>
17 <strong><%= link_to h(project.title), project -%></strong>
18 <small class="hint"><%= truncate(project.description, 100) -%></small>
19 </li>
20 <% end -%>
21 </ul>
22</div>
23
824<div id="site_project_list">
9 <h1>Project categories</h1>
25 <h2>Project categories</h2>
1026
1127 <ul class="tag_list large_tags">
1228 <% tag_cloud @tags, default_css_tag_sizes do |tag, css_class| %>
toggle raw diff

public/stylesheets/base.css

 
598598 color: #666;
599599 font-size: 90%;
600600}
601small.hint { font-size: 83%;}
602
601603.info_hint {
602604 font-size: 95%;
603605 color: #666;
711711table.sidebyside td.ins ins { background: #afa; }
712712table.codediff col.lines {
713713 width: 3em;
714}
715
716#newest_projects, #site_project_list {
717 margin-bottom: 3em;
718}
719
720#newest_projects ul li {
721 margin-left: 1em;
722 margin-bottom: 5px;
714723}
toggle raw diff

spec/controllers/site_controller_spec.rb

 
22
33describe SiteController do
44
5 #Delete this example and add some real ones
6 it "should use SiteController" do
7 controller.should be_an_instance_of(SiteController)
5 describe "#index" do
6
7 it "GETs sucessfully" do
8 get :index
9 response.should be_success
10 end
11
12 it "gets the tag list" do
13 get :index
14 assigns[:tags].should == Project.tag_counts
15 end
16
17 it "gets a list of the most recent projects" do
18 get :index
19 assigns[:projects].should == Project.find(:all, :limit => 5, :order => "id desc")
20 end
821 end
922
1023end
toggle raw diff