Skip to content

Commit

Permalink
Added stupid simple pagination.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Apr 5, 2009
1 parent 3cae40a commit f6c519d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ class ApplicationController < ActionController::Base
protect_from_forgery

filter_parameter_logging :password, :password_confirmation

private
def ensure_authorized
redirect_to new_authorization_url unless current_user.authorized?
end
end
5 changes: 5 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
class HomeController < ApplicationController
before_filter :authenticate
before_filter :ensure_authorized

def index
params[:page] ||= 1
@tweets = current_user.client.friends_timeline(:page => params[:page])

params[:older] = params[:page].to_i + 1
params[:newer] = params[:page].to_i - 1
end
end
15 changes: 8 additions & 7 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<%- if current_user.authorized? -%>
<div id="statuses">
<%- for tweet in current_user.client.friends_timeline -%>
<div id="statuses">
<%- for tweet in @tweets -%>
<%= render :partial => 'statuses/status', :object => tweet %>
<%- end -%>
</div>
<%- else -%>
<p>We need you to authorize this app. <%= link_to 'Authorize', new_authorization_url %></p>
<%- end -%>
</div>

<div class="pagination">
<%= link_to '&lt; Newer', {:page => params[:newer]}, :class => 'newer' if params[:newer] > 0 %>
<%= link_to 'Older &gt;', {:page => params[:older]}, :class => 'older' %>
</div>
6 changes: 1 addition & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@

<div id="header">
<div id="header_inner">
<h3><%= link_to "Twitter App", root_url %></h3>
<h3><%= link_to "Home", root_url %></h3>
<%- if signed_in? -%>
<div class="actions">
<%#= link_to image_tag('reload.gif'), '#', :id => 'refresh' %>
</div>

<p>
Logged in as <%= current_user.email %>
<%= link_to 'Logout', session_url, :method => :delete %>?
Expand Down
18 changes: 8 additions & 10 deletions public/stylesheets/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
div.notice {border:1px solid #74C774; background:#E8F6E8;}

div.status {float:left; display:inline; width:550px; border-bottom:1px solid #eee; padding:15px 0;}
div.info {float:left; display:inline; width:250px; margin:0; font-size:11px; text-align:right;}
div.info {float:left; display:inline; width:240px; margin:0; font-size:11px; text-align:right;}
div.info a.profile_image {float:right; display:block; margin:0 30px;}
div.info a.profile_image img {float:left; width:48px; height:48px; border:1px solid #ddd; padding:1px;}
div.info a.profile_image:hover {background:none;}
div.info a.profile_image:hover img {border-color:#090;}
div.info span.date {color:#aaa;}
div.text {float:left; display:inline; width:300px;}

div.profile {float:left; width:550px; border-bottom:1px solid #eee; margin:0 0 0 170px; padding:15px 0;}
div.profile {float:left; width:380px; border-bottom:1px solid #eee; margin:0 0 0 170px; padding:15px 0;}
div.profile a.icon {float:right;}
div.profile p {margin:0; padding:0;}
div.profile img.profile_image {float:left; display:inline; margin:0 30px 10px 0; padding:1px; width:48px; height:48px; border:1px solid #eee;}
Expand All @@ -40,9 +40,11 @@
div.profile p.other {color:#777; font-size:12px; line-height:12px;}
div.profile p.description {clear:left; color:#777; padding:0 0 0 80px;}

div.pagination {float:left; width:550px; margin:15px 0; text-align:center;}
div.pagination a {padding:3px 7px; color:#46B546; text-decoration:none;}
div.pagination {float:left; width:550px; margin:15px 0;}
div.pagination a {float:left; display:block; padding:3px 7px; color:#46B546; text-decoration:none;}
div.pagination a:hover {color:#fff; background:#090;}
div.pagination a.newer {float:left;}
div.pagination a.older {float:right;}
div.pagination span.disabled {padding:3px 7px; text-transform:lowercase; color:#ccc;}
div.pagination span.current {padding:3px 5px; font-weight:bold;}

Expand All @@ -51,17 +53,13 @@
#header_inner {width:550px; margin:0 auto;}
#header a {color:#fff; text-decoration:none; background:none;}
#header a:hover {text-decoration:underline;}
#header h3 {float:left; display:inline; margin:0; padding:0; line-height:12px;}
#header h3 {float:left; display:inline; margin:0 0 0 240px; padding:0; line-height:12px;}
#header h3 a {display:block; font-size:12px;}
#header p {float:left; display:inline; margin:0; padding:0 0 0 13px; font-size:11px; color:#ccc; line-height:12px;}
#header p a {color:#ccc;}
#header div.actions {float:right; margin:-7px 0;}
#header div.actions a {float:left; display:block; margin:0 0 0 10px; padding:5px;}
#header div.actions a:hover {background:#444;}
#header div.actions img {float:right;}

#content {float:left; display:inline; width:100%; background:#fff;}
#content_inner {width:550px; margin:0 auto;}
#content_inner {overflow:auto; width:550px; margin:0 auto;}

#footer {float:left; display:inline; width:100%; padding:30px 0 0; background:#eee; border-top:1px solid #ccc;}
#footer_inner {width:550px; margin:0 auto;}
Expand Down

0 comments on commit f6c519d

Please sign in to comment.