diff --git a/Gemfile b/Gemfile index 6480c2f73..fca45187a 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index c709b0801..333cb694a 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -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 diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb index 5d62eace7..bf3e54f08 100644 --- a/app/controllers/bookmarks_controller.rb +++ b/app/controllers/bookmarks_controller.rb @@ -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 diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 4bf1ade9d..d6225c3ed 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -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 diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 00b1b8e1a..bec255e55 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -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| diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 393f3cffd..eb6a95578 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,9 +1,7 @@ class UsersController < ApplicationController before_filter :authenticate_user! - def index @users = User.sort(:created_at.desc).all end - end diff --git a/app/models/post.rb b/app/models/post.rb index 1366e2877..e5974f4c6 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/views/blogs/index.html.haml b/app/views/blogs/index.html.haml index c7aab6525..37cfb1f3c 100644 --- a/app/views/blogs/index.html.haml +++ b/app/views/blogs/index.html.haml @@ -3,3 +3,5 @@ %ul#stream - for blog in @blogs = render "blog", :post => blog +#pagination + = will_paginate @blogs diff --git a/app/views/bookmarks/index.html.haml b/app/views/bookmarks/index.html.haml index 48bfedc50..321153e13 100644 --- a/app/views/bookmarks/index.html.haml +++ b/app/views/bookmarks/index.html.haml @@ -3,3 +3,5 @@ %ul#stream - for bookmark in @bookmarks = render "bookmark", :post => bookmark +#pagination + = will_paginate @bookmarks diff --git a/app/views/comments/_new_comment.html.haml b/app/views/comments/_new_comment.html.haml index bb16dffbb..230b49ec9 100644 --- a/app/views/comments/_new_comment.html.haml +++ b/app/views/comments/_new_comment.html.haml @@ -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" diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml index 8d669a018..ad9bc6eef 100644 --- a/app/views/dashboard/index.html.haml +++ b/app/views/dashboard/index.html.haml @@ -3,3 +3,5 @@ %ul#stream - for post in @posts = render type_partial(post), :post => post +#pagination + = will_paginate @posts \ No newline at end of file diff --git a/app/views/friends/index.html.haml b/app/views/friends/index.html.haml index 52abf1451..cda1e225b 100644 --- a/app/views/friends/index.html.haml +++ b/app/views/friends/index.html.haml @@ -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 diff --git a/app/views/status_messages/index.html.haml b/app/views/status_messages/index.html.haml index 6773a6ffa..28cf8be85 100644 --- a/app/views/status_messages/index.html.haml +++ b/app/views/status_messages/index.html.haml @@ -4,4 +4,6 @@ - for status_message in @status_messages = render "status_message", :post => status_message +#pagination + = will_paginate @status_messages diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 61fb85d59..701cc0502 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index c021120ae..647627f87 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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"} diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 31ab2d57e..4851adf2f 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -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() {