From 84c041ba6a0653a07cc3d7de19ed8211d0ee2460 Mon Sep 17 00:00:00 2001 From: maxwell <maxwell@joindiaspora.com> Date: Fri, 17 Dec 2010 19:29:26 -0800 Subject: [PATCH] aspects streams now ajax --- app/controllers/aspects_controller.rb | 1 + app/views/aspects/index.html.haml | 5 ++--- app/views/aspects/index.js.erb | 1 + app/views/aspects/show.html.haml | 7 ++----- app/views/aspects/show.js.erb | 1 + app/views/shared/_stream.haml | 7 ++++--- config/assets.yml | 1 + public/javascripts/application.js | 7 +++++++ 8 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 app/views/aspects/index.js.erb create mode 100644 app/views/aspects/show.js.erb create mode 100644 public/javascripts/application.js diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 0b278535b3..4d64499463 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -7,6 +7,7 @@ class AspectsController < ApplicationController respond_to :html respond_to :json, :only => :show + respond_to :js def index @posts = current_user.visible_posts(:_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 9dbf397a5e..31bcec16c6 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -15,10 +15,9 @@ = render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @contacts.count = render 'aspects/no_posts_message', :post_count => @post_hashes.length, :contact_count => @contacts.count - = render 'shared/stream', :posts => @post_hashes + %ul{:class => 'stream', :id => 'main_stream'} + = render 'shared/stream', :posts => @post_hashes - #pagination - = will_paginate @posts .span-8.last = render 'aspects/all_aspects_contacts' diff --git a/app/views/aspects/index.js.erb b/app/views/aspects/index.js.erb new file mode 100644 index 0000000000..aa27af5a0b --- /dev/null +++ b/app/views/aspects/index.js.erb @@ -0,0 +1 @@ +$('#main_stream').html("<%= escape_javascript(render('shared/stream', :posts => @post_hashes)) %>"); diff --git a/app/views/aspects/show.html.haml b/app/views/aspects/show.html.haml index f209ddae35..a8b7692e6d 100644 --- a/app/views/aspects/show.html.haml +++ b/app/views/aspects/show.html.haml @@ -23,8 +23,5 @@ = render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @aspect_contacts_count, :options => false = render 'aspects/no_posts_message', :post_count => @post_count, :contact_count=> @aspect_contacts_count - = render 'shared/stream', :posts => @post_hashes - - #pagination - = will_paginate @posts - + %ul{:class => 'stream', :id => 'main_stream'} + = render 'shared/stream', :posts => @post_hashes diff --git a/app/views/aspects/show.js.erb b/app/views/aspects/show.js.erb new file mode 100644 index 0000000000..aa27af5a0b --- /dev/null +++ b/app/views/aspects/show.js.erb @@ -0,0 +1 @@ +$('#main_stream').html("<%= escape_javascript(render('shared/stream', :posts => @post_hashes)) %>"); diff --git a/app/views/shared/_stream.haml b/app/views/shared/_stream.haml index b43f40f5d4..bf5dbbf6a4 100644 --- a/app/views/shared/_stream.haml +++ b/app/views/shared/_stream.haml @@ -1,7 +1,8 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. +- for post_hash in posts + = render 'shared/stream_element', post_hash.merge(:aspects => @aspects, :commenting_disabled => defined?(@commenting_disabled)) -%ul{:class => 'stream', :id => 'main_stream'} - - for post_hash in posts - = render 'shared/stream_element', post_hash.merge(:aspects => @aspects, :commenting_disabled => defined?(@commenting_disabled)) +.pagination + = will_paginate @posts diff --git a/config/assets.yml b/config/assets.yml index 567cf0bcc7..739b08db35 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -14,6 +14,7 @@ javascripts: - public/javascripts/vendor/fileuploader.js - public/javascripts/view.js - public/javascripts/stream.js + - public/javascripts/application.js mobile: - public/javascripts/vendor/jquery144.min.js - public/javascripts/custom-mobile-scripting.js diff --git a/public/javascripts/application.js b/public/javascripts/application.js new file mode 100644 index 0000000000..c4b61cb4db --- /dev/null +++ b/public/javascripts/application.js @@ -0,0 +1,7 @@ +$(function () { + $('#main_stream .pagination a').live('click', function () { + $.getScript(this.href); + return false; + } + ); +}); -- GitLab