aspect stream uses backbone; don't ajax in aspect selectors for now

This commit is contained in:
danielgrippi 2011-12-27 00:31:27 -05:00 committed by Dennis Collinson
parent 4029b26c03
commit 505adbe07b
7 changed files with 24 additions and 11 deletions

View file

@ -9,21 +9,26 @@ class AspectsController < ApplicationController
before_filter :save_selected_aspects, :only => :index
before_filter :ensure_page, :only => :index
respond_to :html, :js
respond_to :json, :only => [:show, :create, :index]
respond_to :html,
:js,
:json
def index
@backbone = true
stream_klass = Stream::Aspect
aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
@stream = Stream::Aspect.new(current_user, aspect_ids,
:max_time => params[:max_time].to_i)
:max_time => params[:max_time].to_i)
respond_with do |format|
format.html do
if params[:only_posts]
render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts}
else
render 'aspects/index'
end
end
format.json{ render :json => @stream.stream_posts.to_json(:include => {:author => {:include => :profile}}) }
format.json{ render_for_api :backbone, :json => @stream.stream_posts, :root => :posts }
end
end

View file

@ -2,8 +2,9 @@ app.collections.Stream = Backbone.Collection.extend({
url: function() {
var path = document.location.pathname;
if(this.models.length) { path += "?max_time=" + _.last(this.models).createdAt(); }
if(this.models.length) {
path += "?max_time=" + _.last(this.models).createdAt();
}
return path;
},

View file

@ -1,6 +1,7 @@
app.Router = Backbone.Router.extend({
routes: {
"stream": "stream",
"aspects:query": "stream",
"comment_stream": "stream",
"like_stream": "stream",
"mentions": "stream",
@ -11,8 +12,9 @@ app.Router = Backbone.Router.extend({
"posts/:id": "stream"
},
stream: function() {
stream : function() {
app.stream = new app.views.Stream().render();
$("#main_stream").html(app.stream.el);
}
});

View file

@ -22,7 +22,8 @@ app.views.Publisher = Backbone.View.extend({
"status_message" : {
"text" : serializedForm["status_message[text]"]
},
"aspect_ids" : serializedForm["aspect_ids[]"]
"aspect_ids" : serializedForm["aspect_ids[]"],
"photos" : serializedForm["photos[]"]
});
// clear state

View file

@ -9,6 +9,9 @@ app.views.StreamObject = app.views.Base.extend({
destroyModel: function(evt){
if(evt){ evt.preventDefault(); }
this.model.destroy();
this.remove();
$(this.el).slideUp(400, function(){
this.remove();
});
}
});

View file

@ -12,8 +12,6 @@ var Stream = {
},
initializeLives: function(){
Stream.setUpNsfwLinks();
// reshare button action
$(".reshare_button", this.selector).live("click", function(evt) {
evt.preventDefault();

View file

@ -86,6 +86,9 @@
};
this.performAjax = function() {
window.location = self.generateURL(); // hella hax
// and fuck all this stuff VVVV
var post = $("#publisher textarea#status_message_fake_text").val(),
newURL = self.generateURL(),
photos = {};