aspect stream uses backbone; don't ajax in aspect selectors for now
This commit is contained in:
parent
4029b26c03
commit
505adbe07b
7 changed files with 24 additions and 11 deletions
|
|
@ -9,21 +9,26 @@ class AspectsController < ApplicationController
|
||||||
before_filter :save_selected_aspects, :only => :index
|
before_filter :save_selected_aspects, :only => :index
|
||||||
before_filter :ensure_page, :only => :index
|
before_filter :ensure_page, :only => :index
|
||||||
|
|
||||||
respond_to :html, :js
|
respond_to :html,
|
||||||
respond_to :json, :only => [:show, :create, :index]
|
:js,
|
||||||
|
:json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@backbone = true
|
||||||
|
stream_klass = Stream::Aspect
|
||||||
aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
|
aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
|
||||||
@stream = Stream::Aspect.new(current_user, aspect_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|
|
respond_with do |format|
|
||||||
format.html do
|
format.html do
|
||||||
if params[:only_posts]
|
if params[:only_posts]
|
||||||
render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts}
|
render :partial => 'shared/stream', :locals => {:posts => @stream.stream_posts}
|
||||||
|
else
|
||||||
|
render 'aspects/index'
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ app.collections.Stream = Backbone.Collection.extend({
|
||||||
url: function() {
|
url: function() {
|
||||||
var path = document.location.pathname;
|
var path = document.location.pathname;
|
||||||
|
|
||||||
|
if(this.models.length) {
|
||||||
if(this.models.length) { path += "?max_time=" + _.last(this.models).createdAt(); }
|
path += "?max_time=" + _.last(this.models).createdAt();
|
||||||
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
app.Router = Backbone.Router.extend({
|
app.Router = Backbone.Router.extend({
|
||||||
routes: {
|
routes: {
|
||||||
"stream": "stream",
|
"stream": "stream",
|
||||||
|
"aspects:query": "stream",
|
||||||
"comment_stream": "stream",
|
"comment_stream": "stream",
|
||||||
"like_stream": "stream",
|
"like_stream": "stream",
|
||||||
"mentions": "stream",
|
"mentions": "stream",
|
||||||
|
|
@ -11,8 +12,9 @@ app.Router = Backbone.Router.extend({
|
||||||
"posts/:id": "stream"
|
"posts/:id": "stream"
|
||||||
},
|
},
|
||||||
|
|
||||||
stream: function() {
|
stream : function() {
|
||||||
app.stream = new app.views.Stream().render();
|
app.stream = new app.views.Stream().render();
|
||||||
$("#main_stream").html(app.stream.el);
|
$("#main_stream").html(app.stream.el);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ app.views.Publisher = Backbone.View.extend({
|
||||||
"status_message" : {
|
"status_message" : {
|
||||||
"text" : serializedForm["status_message[text]"]
|
"text" : serializedForm["status_message[text]"]
|
||||||
},
|
},
|
||||||
"aspect_ids" : serializedForm["aspect_ids[]"]
|
"aspect_ids" : serializedForm["aspect_ids[]"],
|
||||||
|
"photos" : serializedForm["photos[]"]
|
||||||
});
|
});
|
||||||
|
|
||||||
// clear state
|
// clear state
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ app.views.StreamObject = app.views.Base.extend({
|
||||||
destroyModel: function(evt){
|
destroyModel: function(evt){
|
||||||
if(evt){ evt.preventDefault(); }
|
if(evt){ evt.preventDefault(); }
|
||||||
this.model.destroy();
|
this.model.destroy();
|
||||||
this.remove();
|
|
||||||
|
$(this.el).slideUp(400, function(){
|
||||||
|
this.remove();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ var Stream = {
|
||||||
},
|
},
|
||||||
|
|
||||||
initializeLives: function(){
|
initializeLives: function(){
|
||||||
Stream.setUpNsfwLinks();
|
|
||||||
|
|
||||||
// reshare button action
|
// reshare button action
|
||||||
$(".reshare_button", this.selector).live("click", function(evt) {
|
$(".reshare_button", this.selector).live("click", function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
this.performAjax = function() {
|
this.performAjax = function() {
|
||||||
|
window.location = self.generateURL(); // hella hax
|
||||||
|
// and fuck all this stuff VVVV
|
||||||
|
|
||||||
var post = $("#publisher textarea#status_message_fake_text").val(),
|
var post = $("#publisher textarea#status_message_fake_text").val(),
|
||||||
newURL = self.generateURL(),
|
newURL = self.generateURL(),
|
||||||
photos = {};
|
photos = {};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue