added will pagination action.
This commit is contained in:
parent
30667a5bc9
commit
46ab63de36
16 changed files with 26 additions and 10 deletions
1
Gemfile
1
Gemfile
|
|
@ -20,6 +20,7 @@ gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git',
|
||||||
gem 'addressable', :require => "addressable/uri"
|
gem 'addressable', :require => "addressable/uri"
|
||||||
gem 'em-websocket'
|
gem 'em-websocket'
|
||||||
gem 'thin'
|
gem 'thin'
|
||||||
|
gem 'will_paginate', '3.0.pre'
|
||||||
|
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ class BlogsController < ApplicationController
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@blogs = Blog.sort(:created_at.desc).all
|
@blogs = Blog.paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ class BookmarksController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@bookmark = Bookmark.new
|
@bookmark = Bookmark.new
|
||||||
@bookmarks = Bookmark.sort(:created_at.desc).all
|
@bookmarks = Bookmark.paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class DashboardController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@posts = Post.sort(:created_at.desc).all
|
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ class StatusMessagesController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def index
|
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|
|
respond_to do |format|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@users = User.sort(:created_at.desc).all
|
@users = User.sort(:created_at.desc).all
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ class Post
|
||||||
many :comments, :class_name => 'Comment', :foreign_key => :post_id
|
many :comments, :class_name => 'Comment', :foreign_key => :post_id
|
||||||
belongs_to :person, :class_name => 'Person'
|
belongs_to :person, :class_name => 'Person'
|
||||||
|
|
||||||
|
|
||||||
|
cattr_reader :per_page
|
||||||
|
@@per_page = 10
|
||||||
|
|
||||||
timestamps!
|
timestamps!
|
||||||
|
|
||||||
after_save :send_to_view
|
after_save :send_to_view
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,5 @@
|
||||||
%ul#stream
|
%ul#stream
|
||||||
- for blog in @blogs
|
- for blog in @blogs
|
||||||
= render "blog", :post => blog
|
= render "blog", :post => blog
|
||||||
|
#pagination
|
||||||
|
= will_paginate @blogs
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,5 @@
|
||||||
%ul#stream
|
%ul#stream
|
||||||
- for bookmark in @bookmarks
|
- for bookmark in @bookmarks
|
||||||
= render "bookmark", :post => bookmark
|
= render "bookmark", :post => bookmark
|
||||||
|
#pagination
|
||||||
|
= will_paginate @bookmarks
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
= form_tag("/comments", :remote => true, :class =>"new_comment", :id => "new_comment-#{post.id}") do
|
= form_tag("/comments", :remote => true, :class =>"new_comment", :id => "new_comment-#{post.id}") do
|
||||||
%p
|
%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]"
|
= hidden_field_tag "comment_post_id", "#{post.id}", :name => "comment[post_id]"
|
||||||
= submit_tag 'comment', :id => "comment_submit_#{post.id}", :name => "commit"
|
= submit_tag 'comment', :id => "comment_submit_#{post.id}", :name => "commit"
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,5 @@
|
||||||
%ul#stream
|
%ul#stream
|
||||||
- for post in @posts
|
- for post in @posts
|
||||||
= render type_partial(post), :post => post
|
= render type_partial(post), :post => post
|
||||||
|
#pagination
|
||||||
|
= will_paginate @posts
|
||||||
|
|
@ -14,3 +14,6 @@
|
||||||
%td= link_to 'Destroy', friend, :confirm => 'Are you sure?', :method => :delete
|
%td= link_to 'Destroy', friend, :confirm => 'Are you sure?', :method => :delete
|
||||||
|
|
||||||
%p= link_to "New Friend", new_friend_path
|
%p= link_to "New Friend", new_friend_path
|
||||||
|
|
||||||
|
#pagination
|
||||||
|
= will_paginate @friends
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,6 @@
|
||||||
|
|
||||||
- for status_message in @status_messages
|
- for status_message in @status_messages
|
||||||
= render "status_message", :post => status_message
|
= render "status_message", :post => status_message
|
||||||
|
#pagination
|
||||||
|
= will_paginate @status_messages
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@ module WebSocket
|
||||||
EM.add_timer(0.1) do
|
EM.add_timer(0.1) do
|
||||||
@channel = EM::Channel.new
|
@channel = EM::Channel.new
|
||||||
puts @channel.inspect
|
puts @channel.inspect
|
||||||
|
|
||||||
|
#this should really be a controller
|
||||||
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
|
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
|
||||||
|
|
||||||
class << @view
|
class << @view
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
include ActionController::RequestForgeryProtection::ClassMethods
|
include ActionController::RequestForgeryProtection::ClassMethods
|
||||||
include ActionView::Helpers::FormTagHelper
|
|
||||||
include ActionView::Helpers::UrlHelper
|
|
||||||
def protect_against_forgery?
|
def protect_against_forgery?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ Diaspora::Application.routes.draw do |map|
|
||||||
resources :comments
|
resources :comments
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#routes for devise, not really sure you will need to mess with this in the future, lets put default,
|
#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
|
#non mutable stuff in anohter file
|
||||||
devise_for :users, :path_names => {:sign_up => "signup", :sign_in => "login", :sign_out => "logout"}
|
devise_for :users, :path_names => {:sign_up => "signup", :sign_in => "login", :sign_out => "logout"}
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,12 @@ $(document).ready(function(){
|
||||||
|
|
||||||
$('#bookmark_link').click(clearForm);
|
$('#bookmark_link').click(clearForm);
|
||||||
$('#debug_more').hide();
|
$('#debug_more').hide();
|
||||||
|
$(":text").click(clearForm);
|
||||||
|
|
||||||
function clearForm(){
|
function clearForm(){
|
||||||
|
var text = $(this).text()
|
||||||
$(this).val("");
|
$(this).val("");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#debug_info').click(function() {
|
$('#debug_info').click(function() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue