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/friends_controller.rb b/app/controllers/friends_controller.rb index a13c3f2e4..c39bd1d27 100644 --- a/app/controllers/friends_controller.rb +++ b/app/controllers/friends_controller.rb @@ -2,7 +2,7 @@ class FriendsController < ApplicationController before_filter :authenticate_user! def index - @friends = Friend.all + @friends = Friend.paginate :page => params[:page], :order => 'created_at DESC' end def show 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/_blog.html.haml b/app/views/blogs/_blog.html.haml index e0f63e52d..7cb179712 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml @@ -2,10 +2,11 @@ %span.from = link_to_person post.person %b wrote a new blog post + - if mine?(post) + .destroy_link + = link_to 'Destroy', status_message_path(post), :confirm => 'Are you sure?', :method => :delete %br %b= post.title %br = raw post.body %div.time= link_to "#{time_ago_in_words(post.updated_at)} ago", blog_path(post) - - if mine?(post) - = link_to 'Destroy', blog_path(post), :confirm => 'Are you sure?', :method => :delete 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/_bookmark.html.haml b/app/views/bookmarks/_bookmark.html.haml index 88208a619..7052c6b3c 100644 --- a/app/views/bookmarks/_bookmark.html.haml +++ b/app/views/bookmarks/_bookmark.html.haml @@ -2,12 +2,13 @@ %span.from = link_to_person post.person %b shared a link + - if mine?(post) + .destroy_link + = link_to 'Destroy', status_message_path(post), :confirm => 'Are you sure?', :method => :delete %br = post.title %a{:href => "#{post.link}"} = post.link %div.time= link_to "#{time_ago_in_words(post.updated_at)} ago", bookmark_path(post) - - if mine?(post) - = link_to 'Destroy', bookmark_path(post), :confirm => 'Are you sure?', :method => :delete 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/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml new file mode 100644 index 000000000..dfcd5d12c --- /dev/null +++ b/app/views/layouts/session_wall.html.haml @@ -0,0 +1,27 @@ +!!! +%html + %head + %title + = "diaspora" + %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/ + %meta{"http-equiv"=> "X-UA-Compatible", :content =>"chrome=1" } + + = stylesheet_link_tag "blueprint/screen", :media => 'screen' + = stylesheet_link_tag "sessions" + /= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" + = javascript_include_tag 'jquery142' + + = csrf_meta_tag + = yield(:head) + + %body + .container + - flash.each do |name, msg| + = content_tag :div, msg, :id => "flash_#{name}" + + %div#huge_text + welcome back, + %span + = User.first.real_name.downcase + + = yield diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index f9ec3c03b..af117e381 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -2,11 +2,11 @@ %span.from = link_to_person post.person = post.message + + - if mine?(post) + .destroy_link + = link_to 'Destroy', status_message_path(post), :confirm => 'Are you sure?', :method => :delete + %div.time = link_to(how_long_ago(post), status_message_path(post)) = render "comments/comments", :post => post - - if mine?(post) - = link_to 'Destroy', status_message_path(post), :confirm => 'Are you sure?', :method => :delete - - - 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() { diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 3f064d2c0..869e9c240 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -203,3 +203,12 @@ ul.comment_set { img#profile_picture { width: 100%; } + +.pagination a { + padding: 3px; } + +.destroy_link { + float: right; } + +#debug_info { + margin-top: 20px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 662225b86..16a007923 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -239,7 +239,13 @@ ul.comment_set img#profile_picture :width 100% + +.pagination + a + :padding 3px + +.destroy_link + :float right - - - +#debug_info + :margin-top 20px diff --git a/public/stylesheets/sass/sessions.sass b/public/stylesheets/sass/sessions.sass new file mode 100644 index 000000000..e21adfa80 --- /dev/null +++ b/public/stylesheets/sass/sessions.sass @@ -0,0 +1,34 @@ +body + :padding 2em + +#huge_text + :margin + :top 10% + :display inline block + :font + :size 40px + :weight bold + :line-height 120px + :letter + :spacing -2px + :color #eaeaea + :text-shadow 0 1px 1px #999 + + span + :display inline + :color #666 + +input + :font + :size 30px + :text + :align center + :width 300px + :margin + :bottom 0 + :top 0 + +.container + :top 30% + :text + :align center diff --git a/public/stylesheets/sessions.css b/public/stylesheets/sessions.css new file mode 100644 index 000000000..b3a2ba8f8 --- /dev/null +++ b/public/stylesheets/sessions.css @@ -0,0 +1,26 @@ +body { + padding: 2em; } + +#huge_text { + margin-top: 10%; + display: inline block; + font-size: 40px; + font-weight: bold; + line-height: 120px; + letter-spacing: -2px; + color: #eaeaea; + text-shadow: 0 1px 1px #999999; } + #huge_text span { + display: inline; + color: #666666; } + +input { + font-size: 30px; + text-align: center; + width: 300px; + margin-bottom: 0; + margin-top: 0; } + +.container { + top: 30%; + text-align: center; } diff --git a/spec/lib/web_socket_spec.rb b/spec/lib/web_socket_spec.rb new file mode 100644 index 000000000..55e383a73 --- /dev/null +++ b/spec/lib/web_socket_spec.rb @@ -0,0 +1,19 @@ +require File.dirname(__FILE__) + '/../spec_helper' + + + +describe WebSocket do + it 'should prepare a view along with an objects class in json' do + + EventMachine.run { + include WebSocket + user = Factory.create(:user) + post = Factory.create(:status_message) + + json = WebSocket.view_hash(post) + json.should include post.message + + EventMachine.stop + } + end +end \ No newline at end of file