Commit ca42b0384febd656bcdc458d0dfac95c060eae41
- Date: Sat Jan 26 14:59:29 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: ca42b0384febd656bcdc458d0dfac95c060eae41
- Tree SHA1: 94831284ab6c25f01e511dc04ddccf07491f2f54
list recent projects on homepage
Commit diff
| |   |
| 2 | 2 | |
| 3 | 3 | def index |
| 4 | 4 | @tags = Project.tag_counts |
| 5 | @projects = Project.find(:all, :limit => 5, :order => "id desc") |
| 5 | 6 | end |
| 6 | 7 | |
| 7 | 8 | def about |
| toggle raw diff |
--- a/app/controllers/site_controller.rb
+++ b/app/controllers/site_controller.rb
@@ -2,6 +2,7 @@ class SiteController < ApplicationController
def index
@tags = Project.tag_counts
+ @projects = Project.find(:all, :limit => 5, :order => "id desc")
end
def about |
| |   |
| 5 | 5 | <small><%= link_to "more…", about_path -%></small></p> |
| 6 | 6 | </div> |
| 7 | 7 | |
| 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 | |
| 8 | 24 | <div id="site_project_list"> |
| 9 | | <h1>Project categories</h1> |
| 25 | <h2>Project categories</h2> |
| 10 | 26 | |
| 11 | 27 | <ul class="tag_list large_tags"> |
| 12 | 28 | <% tag_cloud @tags, default_css_tag_sizes do |tag, css_class| %> |
| toggle raw diff |
--- a/app/views/site/index.html.erb
+++ b/app/views/site/index.html.erb
@@ -5,8 +5,24 @@
<small><%= link_to "more…", about_path -%></small></p>
</div>
+<div id="site_description">
+
+</div>
+
+<div id="newest_projects">
+ <h2>New projects</h2>
+ <ul>
+ <% @projects.each do |project| -%>
+ <li>
+ <strong><%= link_to h(project.title), project -%></strong>
+ <small class="hint"><%= truncate(project.description, 100) -%></small>
+ </li>
+ <% end -%>
+ </ul>
+</div>
+
<div id="site_project_list">
- <h1>Project categories</h1>
+ <h2>Project categories</h2>
<ul class="tag_list large_tags">
<% tag_cloud @tags, default_css_tag_sizes do |tag, css_class| %> |
| |   |
| 598 | 598 | color: #666; |
| 599 | 599 | font-size: 90%; |
| 600 | 600 | } |
| 601 | small.hint { font-size: 83%;} |
| 602 | |
| 601 | 603 | .info_hint { |
| 602 | 604 | font-size: 95%; |
| 603 | 605 | color: #666; |
| … | … | |
| 711 | 711 | table.sidebyside td.ins ins { background: #afa; } |
| 712 | 712 | table.codediff col.lines { |
| 713 | 713 | 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; |
| 714 | 723 | } |
| toggle raw diff |
--- a/public/stylesheets/base.css
+++ b/public/stylesheets/base.css
@@ -598,6 +598,8 @@ div.comment p.byline {
color: #666;
font-size: 90%;
}
+small.hint { font-size: 83%;}
+
.info_hint {
font-size: 95%;
color: #666;
@@ -709,4 +711,13 @@ table.sidebyside td.del del { background: #fbb; }
table.sidebyside td.ins ins { background: #afa; }
table.codediff col.lines {
width: 3em;
+}
+
+#newest_projects, #site_project_list {
+ margin-bottom: 3em;
+}
+
+#newest_projects ul li {
+ margin-left: 1em;
+ margin-bottom: 5px;
}
\ No newline at end of file |
| |   |
| 2 | 2 | |
| 3 | 3 | describe SiteController do |
| 4 | 4 | |
| 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 |
| 8 | 21 | end |
| 9 | 22 | |
| 10 | 23 | end |
| toggle raw diff |
--- a/spec/controllers/site_controller_spec.rb
+++ b/spec/controllers/site_controller_spec.rb
@@ -2,9 +2,22 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe SiteController do
- #Delete this example and add some real ones
- it "should use SiteController" do
- controller.should be_an_instance_of(SiteController)
+ describe "#index" do
+
+ it "GETs sucessfully" do
+ get :index
+ response.should be_success
+ end
+
+ it "gets the tag list" do
+ get :index
+ assigns[:tags].should == Project.tag_counts
+ end
+
+ it "gets a list of the most recent projects" do
+ get :index
+ assigns[:projects].should == Project.find(:all, :limit => 5, :order => "id desc")
+ end
end
end |