added will pagination action.

This commit is contained in:
maxwell 2010-06-28 21:56:58 -07:00
parent 30667a5bc9
commit 46ab63de36
16 changed files with 26 additions and 10 deletions

View file

@ -20,6 +20,7 @@ gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git',
gem 'addressable', :require => "addressable/uri"
gem 'em-websocket'
gem 'thin'
gem 'will_paginate', '3.0.pre'
group :test do

View file

@ -3,7 +3,7 @@ class BlogsController < ApplicationController
def index
@blogs = Blog.sort(:created_at.desc).all
@blogs = Blog.paginate :page => params[:page], :order => 'created_at DESC'
end
def show

View file

@ -3,7 +3,7 @@ class BookmarksController < ApplicationController
def index
@bookmark = Bookmark.new
@bookmarks = Bookmark.sort(:created_at.desc).all
@bookmarks = Bookmark.paginate :page => params[:page], :order => 'created_at DESC'
end
def edit

View file

@ -4,7 +4,7 @@ class DashboardController < ApplicationController
include ApplicationHelper
def index
@posts = Post.sort(:created_at.desc).all
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
end

View file

@ -2,7 +2,7 @@ class StatusMessagesController < ApplicationController
before_filter :authenticate_user!
def index
@status_messages = StatusMessage.sort(:created_at.desc).all
@status_messages = StatusMessage.paginate :page => params[:page], :order => 'created_at DESC'
respond_to do |format|

View file

@ -1,9 +1,7 @@
class UsersController < ApplicationController
before_filter :authenticate_user!
def index
@users = User.sort(:created_at.desc).all
end
end

View file

@ -12,6 +12,10 @@ class Post
many :comments, :class_name => 'Comment', :foreign_key => :post_id
belongs_to :person, :class_name => 'Person'
cattr_reader :per_page
@@per_page = 10
timestamps!
after_save :send_to_view

View file

@ -3,3 +3,5 @@
%ul#stream
- for blog in @blogs
= render "blog", :post => blog
#pagination
= will_paginate @blogs

View file

@ -3,3 +3,5 @@
%ul#stream
- for bookmark in @bookmarks
= render "bookmark", :post => bookmark
#pagination
= will_paginate @bookmarks

View file

@ -1,5 +1,5 @@
= form_tag("/comments", :remote => true, :class =>"new_comment", :id => "new_comment-#{post.id}") do
%p
= text_field_tag "comment_text", 'dislike!', :size => 30, :name => 'comment[text]'
= text_field_tag "comment_text", 'leave a comment', :size => 30, :name => 'comment[text]'
= hidden_field_tag "comment_post_id", "#{post.id}", :name => "comment[post_id]"
= submit_tag 'comment', :id => "comment_submit_#{post.id}", :name => "commit"

View file

@ -3,3 +3,5 @@
%ul#stream
- for post in @posts
= render type_partial(post), :post => post
#pagination
= will_paginate @posts

View file

@ -14,3 +14,6 @@
%td= link_to 'Destroy', friend, :confirm => 'Are you sure?', :method => :delete
%p= link_to "New Friend", new_friend_path
#pagination
= will_paginate @friends

View file

@ -4,4 +4,6 @@
- for status_message in @status_messages
= render "status_message", :post => status_message
#pagination
= will_paginate @status_messages

View file

@ -6,14 +6,14 @@ module WebSocket
EM.add_timer(0.1) do
@channel = EM::Channel.new
puts @channel.inspect
#this should really be a controller
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
class << @view
include ApplicationHelper
include Rails.application.routes.url_helpers
include ActionController::RequestForgeryProtection::ClassMethods
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::UrlHelper
def protect_against_forgery?
false
end

View file

@ -6,7 +6,6 @@ Diaspora::Application.routes.draw do |map|
resources :comments
#routes for devise, not really sure you will need to mess with this in the future, lets put default,
#non mutable stuff in anohter file
devise_for :users, :path_names => {:sign_up => "signup", :sign_in => "login", :sign_out => "logout"}

View file

@ -31,9 +31,12 @@ $(document).ready(function(){
$('#bookmark_link').click(clearForm);
$('#debug_more').hide();
$(":text").click(clearForm);
function clearForm(){
var text = $(this).text()
$(this).val("");
}
$('#debug_info').click(function() {