Skip to content

Commit

Permalink
Items list
Browse files Browse the repository at this point in the history
  • Loading branch information
hrefhref committed Mar 8, 2009
1 parent e965c8e commit 599d77f
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 6 deletions.
9 changes: 9 additions & 0 deletions app/controllers/items.rb
@@ -0,0 +1,9 @@
class Items < Application

def index
@current_page = params[:page] ? params[:page].to_i : 1
@page_count, @items = Item.paginated :page => @current_page, :per_page => 20, :order => [:created_at.desc]
display @items
end

end
5 changes: 5 additions & 0 deletions app/helpers/items_helper.rb
@@ -0,0 +1,5 @@
module Merb
module ItemsHelper

end
end # Merb
1 change: 1 addition & 0 deletions app/models/item.rb
Expand Up @@ -10,4 +10,5 @@ class Item
property :created_at, DateTime, :nullable => false
belongs_to :feed
validates_is_unique :permalink
is_paginated :per_page => 20
end
13 changes: 13 additions & 0 deletions app/views/items/index.html.erb
@@ -0,0 +1,13 @@
<% for item in @items %>
<div id="item-<%= item.id %>" class="item">
<div class="item-header">
<h1><a href="<%= item.permalink %>"><%=h item.title %></a></h1>
<h2>par <%= item.author %> sur <a href="<%= item.feed.url %>"><%= item.feed.name %></a></h2>
</div>
<div class="item-content">
<%= item.content %>
</div>
</div>
<% end %>
<%= paginate(@current_page, @page_count, :inner_window => 5, :default_css => true, :prev_label => '&laquo; Précédent', :next_label => ' Suivant &raquo;') %>
11 changes: 7 additions & 4 deletions app/views/layout/application.html.erb
@@ -1,12 +1,15 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head>
<title>Fresh Merb App</title>
<title>planet-mashpit</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="/stylesheets/planet.css" type="text/css" media="screen" charset="utf-8" />
</head>
<body>
<%#= message[:notice] %>
<%= catch_content :for_layout %>
<h1>planet-mashpit</h1>
<div id="content">
<div class="notice"><%= message[:notice] %></div>
<%= catch_content :for_layout %>
</div>
</body>
</html>
5 changes: 4 additions & 1 deletion config/dependencies.rb
Expand Up @@ -31,4 +31,7 @@
dependency "dm-validations", dm_gems_version
dependency "dm-serializer", dm_gems_version

dependency "merb_datamapper", merb_gems_version
dependency "merb_datamapper", merb_gems_version

dependency "dm-is-paginated"
dependency "merb-pagination"
2 changes: 1 addition & 1 deletion config/router.rb
Expand Up @@ -44,5 +44,5 @@
default_routes

# Change this for your home page to be available at /
# match('/').to(:controller => 'whatever', :action =>'index')
match('/').to(:controller => 'items', :action =>'index')
end
45 changes: 45 additions & 0 deletions public/stylesheets/planet.css
@@ -0,0 +1,45 @@
body {
font-family: Arial, Verdana, sans-serif;
font-size: 12px;
background-color: #fff;
}
h1 {
font-size: 40px;
font-weight: normal;
}
#content {
margin-left: 20px;
}
#content h1 {
font-size: 30px;
}

#content .item {
margin-bottom: 40px;
}

#content .item-content h1 {
font-size: 115%;
}

#content .item-content h2 {
font-size: 110%;
}

#content .item-content h3 {
font-size: 105%;
}

#content .item-header h1,h2 {
margin: 0;
padding: 0;
}

#content .item-header h2 {
font-weight: normal;
font-size: 120%;
}

#content .item-header h1 a {
color: black;
}
7 changes: 7 additions & 0 deletions spec/requests/items_spec.rb
@@ -0,0 +1,7 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')

describe "/items" do
before(:each) do
@response = request("/items")
end
end

0 comments on commit 599d77f

Please sign in to comment.