From 3f7d992a0bed0abcfbd92158220f1db3d39111d4 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Thu, 8 Dec 2011 16:47:28 -0800 Subject: [PATCH] DH DG; added new routes for streams; fixed pagination --- config/assets.yml | 2 +- public/javascripts/routers/comment-stream.js | 5 ----- public/javascripts/routers/stream.js | 3 +++ public/javascripts/routers/stream/comments.js | 5 +++++ public/javascripts/routers/{ => stream}/mentions.js | 0 public/javascripts/routers/stream/people.js | 5 +++++ public/javascripts/routers/stream/tag_followings.js | 5 +++++ public/javascripts/routers/stream/tags.js | 5 +++++ public/javascripts/views/stream.js | 10 ++++------ 9 files changed, 28 insertions(+), 12 deletions(-) delete mode 100644 public/javascripts/routers/comment-stream.js create mode 100644 public/javascripts/routers/stream/comments.js rename public/javascripts/routers/{ => stream}/mentions.js (100%) create mode 100644 public/javascripts/routers/stream/people.js create mode 100644 public/javascripts/routers/stream/tag_followings.js create mode 100644 public/javascripts/routers/stream/tags.js diff --git a/config/assets.yml b/config/assets.yml index 1ea2c607b..58e17bbd2 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -20,8 +20,8 @@ javascripts: - public/javascripts/collections/* - public/javascripts/views/* - - public/javascripts/routers/stream.js - public/javascripts/routers/* + - public/javascripts/routers/stream/* - public/javascripts/rails.validations.js - public/javascripts/rails.js diff --git a/public/javascripts/routers/comment-stream.js b/public/javascripts/routers/comment-stream.js deleted file mode 100644 index adac3d891..000000000 --- a/public/javascripts/routers/comment-stream.js +++ /dev/null @@ -1,5 +0,0 @@ -App.Routers.CommentStream = App.Routers.Stream.extend({ - routes: { - "comment_stream": "stream" - } -}); diff --git a/public/javascripts/routers/stream.js b/public/javascripts/routers/stream.js index 220e501b1..7b1546465 100644 --- a/public/javascripts/routers/stream.js +++ b/public/javascripts/routers/stream.js @@ -5,5 +5,8 @@ App.Routers.Stream = Backbone.Router.extend({ stream: function() { App.stream = new App.Views.Stream; + $("#main_stream").html(App.stream.el); + + App.stream.loadMore(); } }); diff --git a/public/javascripts/routers/stream/comments.js b/public/javascripts/routers/stream/comments.js new file mode 100644 index 000000000..5efbd26c7 --- /dev/null +++ b/public/javascripts/routers/stream/comments.js @@ -0,0 +1,5 @@ +App.Routers.Comments = App.Routers.Stream.extend({ + routes: { + "comment_stream": "stream" + } +}); diff --git a/public/javascripts/routers/mentions.js b/public/javascripts/routers/stream/mentions.js similarity index 100% rename from public/javascripts/routers/mentions.js rename to public/javascripts/routers/stream/mentions.js diff --git a/public/javascripts/routers/stream/people.js b/public/javascripts/routers/stream/people.js new file mode 100644 index 000000000..202593c02 --- /dev/null +++ b/public/javascripts/routers/stream/people.js @@ -0,0 +1,5 @@ +App.Routers.People = App.Routers.Stream.extend({ + routes: { + "people/:id": "stream" + } +}); diff --git a/public/javascripts/routers/stream/tag_followings.js b/public/javascripts/routers/stream/tag_followings.js new file mode 100644 index 000000000..bd8191b60 --- /dev/null +++ b/public/javascripts/routers/stream/tag_followings.js @@ -0,0 +1,5 @@ +App.Routers.TagFollowings = App.Routers.Stream.extend({ + routes: { + "tag_followings": "stream" + } +}); diff --git a/public/javascripts/routers/stream/tags.js b/public/javascripts/routers/stream/tags.js new file mode 100644 index 000000000..b00ff8bf3 --- /dev/null +++ b/public/javascripts/routers/stream/tags.js @@ -0,0 +1,5 @@ +App.Routers.Tags = App.Routers.Stream.extend({ + routes: { + "tags/:id": "stream" + } +}); diff --git a/public/javascripts/views/stream.js b/public/javascripts/views/stream.js index 9dc8d768e..79c2af518 100644 --- a/public/javascripts/views/stream.js +++ b/public/javascripts/views/stream.js @@ -3,14 +3,11 @@ App.Views.Stream = Backbone.View.extend({ "click #paginate": "loadMore" }, - initialize: function(){ - this.el = $("#main_stream"); - _.bindAll(this, "appendPost", "collectionFetched"); + initialize: function() { + _.bindAll(this, "appendPost", "collectionFetched", "loadMore"); this.collection = new App.Collections.Stream; this.collection.bind("add", this.appendPost); - - this.loadMore(); }, appendPost: function(post) { @@ -23,7 +20,8 @@ App.Views.Stream = Backbone.View.extend({ this.$("#paginate").remove(); $(this.el).append($("", { href: this.collection.url(), - id: "paginate" + id: "paginate", + "class": "paginate" }).text('more')); },