From 1a5e493b222f9b9be6616ee2a4abdb330ef24c03 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Mon, 26 Dec 2011 01:39:44 -0500 Subject: [PATCH] downcase namespacing of app --- app/views/layouts/application.html.haml | 2 +- public/javascripts/app/app.js | 18 +++++++++--------- public/javascripts/app/collections/comments.js | 4 ++-- public/javascripts/app/collections/likes.js | 4 ++-- public/javascripts/app/collections/stream.js | 4 ++-- public/javascripts/app/models/comment.js | 2 +- public/javascripts/app/models/like.js | 2 +- public/javascripts/app/models/post.js | 6 +++--- public/javascripts/app/router.js | 6 +++--- public/javascripts/app/views.js | 4 ++-- public/javascripts/app/views/comment_view.js | 2 +- .../app/views/commment_stream_view.js | 4 ++-- public/javascripts/app/views/feedback_view.js | 2 +- public/javascripts/app/views/header_view.js | 4 ++-- .../javascripts/app/views/post_content_view.js | 6 +++--- public/javascripts/app/views/post_view.js | 8 ++++---- .../app/views/stream_object_view.js | 2 +- public/javascripts/app/views/stream_view.js | 6 +++--- public/javascripts/diaspora.js | 2 +- spec/javascripts/app/app-spec.js | 8 ++++---- .../javascripts/app/collections/stream-spec.js | 6 +++--- spec/javascripts/app/models/post-spec.js | 4 ++-- .../app/views/feedback_view_spec.js | 8 ++++---- spec/javascripts/app/views/header_view_spec.js | 6 +++--- spec/javascripts/app/views/post_view_spec.js | 16 ++++++++-------- spec/javascripts/app/views/stream_view_spec.js | 8 ++++---- spec/javascripts/app/views_spec.js | 6 +++--- 27 files changed, 75 insertions(+), 75 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 47d955d56..afd83b8b5 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -61,7 +61,7 @@ - unless @landing_page = include_javascripts :main :javascript - App.user({ + app.user({ current_user: #{current_user.person.as_api_response(:backbone).to_json} }); diff --git a/public/javascripts/app/app.js b/public/javascripts/app/app.js index d21aa6c69..9f7e3b84a 100644 --- a/public/javascripts/app/app.js +++ b/public/javascripts/app/app.js @@ -1,7 +1,7 @@ -var App = { - Collections: {}, - Models: {}, - Views: {}, +var app = { + collections: {}, + models: {}, + views: {}, user: function(user) { if(user) { return this._user = user; } @@ -10,16 +10,16 @@ var App = { }, initialize: function() { - App.router = new App.Router; + app.router = new app.Router; if(this._user){ - App.header = new App.Views.Header; - $("body").prepend(App.header.el); - App.header.render(); + app.header = new app.views.Header; + $("body").prepend(app.header.el); + app.header.render(); } Backbone.history.start({pushState: true}); } }; -$(function() { App.initialize(); }); +$(function() { app.initialize(); }); diff --git a/public/javascripts/app/collections/comments.js b/public/javascripts/app/collections/comments.js index 954e8f160..03fc518cb 100644 --- a/public/javascripts/app/collections/comments.js +++ b/public/javascripts/app/collections/comments.js @@ -1,3 +1,3 @@ -App.Collections.Comments = Backbone.Collection.extend({ - model: App.Models.Comment +app.collections.Comments = Backbone.Collection.extend({ + model: app.models.Comment }); diff --git a/public/javascripts/app/collections/likes.js b/public/javascripts/app/collections/likes.js index 3be259918..d576b8e59 100644 --- a/public/javascripts/app/collections/likes.js +++ b/public/javascripts/app/collections/likes.js @@ -1,3 +1,3 @@ -App.Collections.Likes = Backbone.Collection.extend({ - model: App.Models.Like +app.collections.Likes = Backbone.Collection.extend({ + model: app.models.Like }); diff --git a/public/javascripts/app/collections/stream.js b/public/javascripts/app/collections/stream.js index 55146137f..c0de92043 100644 --- a/public/javascripts/app/collections/stream.js +++ b/public/javascripts/app/collections/stream.js @@ -1,4 +1,4 @@ -App.Collections.Stream = Backbone.Collection.extend({ +app.collections.Stream = Backbone.Collection.extend({ url: function() { var path = document.location.pathname + ".json"; @@ -7,7 +7,7 @@ App.Collections.Stream = Backbone.Collection.extend({ return path; }, - model: App.Models.Post, + model: app.models.Post, parse: function(resp){ return resp.posts; diff --git a/public/javascripts/app/models/comment.js b/public/javascripts/app/models/comment.js index 6ce1fe181..c4c35ce71 100644 --- a/public/javascripts/app/models/comment.js +++ b/public/javascripts/app/models/comment.js @@ -1,3 +1,3 @@ -App.Models.Comment = Backbone.Model.extend({ +app.models.Comment = Backbone.Model.extend({ urlRoot: "/comments" }); diff --git a/public/javascripts/app/models/like.js b/public/javascripts/app/models/like.js index 3bed073f0..d18d96685 100644 --- a/public/javascripts/app/models/like.js +++ b/public/javascripts/app/models/like.js @@ -1,2 +1,2 @@ -App.Models.Like = Backbone.Model.extend({ +app.models.Like = Backbone.Model.extend({ }) diff --git a/public/javascripts/app/models/post.js b/public/javascripts/app/models/post.js index fd3e8d3cc..97f8e3528 100644 --- a/public/javascripts/app/models/post.js +++ b/public/javascripts/app/models/post.js @@ -1,9 +1,9 @@ -App.Models.Post = Backbone.Model.extend({ +app.models.Post = Backbone.Model.extend({ initialize: function() { - this.comments = new App.Collections.Comments(this.get("last_three_comments")); + this.comments = new app.collections.Comments(this.get("last_three_comments")); this.comments.url = this.url() + '/comments'; - this.likes = new App.Collections.Likes(this.get("user_like")); // load in the user like initially + this.likes = new app.collections.Likes(this.get("user_like")); // load in the user like initially this.likes.url = this.url() + '/likes'; }, diff --git a/public/javascripts/app/router.js b/public/javascripts/app/router.js index dd07d2a9b..f9bd6c9cf 100644 --- a/public/javascripts/app/router.js +++ b/public/javascripts/app/router.js @@ -1,4 +1,4 @@ -App.Router = Backbone.Router.extend({ +app.Router = Backbone.Router.extend({ routes: { "stream": "stream", "comment_stream": "stream", @@ -12,7 +12,7 @@ App.Router = Backbone.Router.extend({ }, stream: function() { - App.stream = new App.Views.Stream().render(); - $("#main_stream").html(App.stream.el); + app.stream = new app.views.Stream().render(); + $("#main_stream").html(app.stream.el); } }); diff --git a/public/javascripts/app/views.js b/public/javascripts/app/views.js index 06f67bd1c..dfa6323f8 100644 --- a/public/javascripts/app/views.js +++ b/public/javascripts/app/views.js @@ -1,11 +1,11 @@ -App.Views.Base = Backbone.View.extend({ +app.views.Base = Backbone.View.extend({ presenter : function(){ return this.defaultPresenter() }, defaultPresenter : function(){ var modelJson = this.model ? this.model.toJSON() : {} - return _.extend(modelJson, App.user()); + return _.extend(modelJson, app.user()); }, render : function() { diff --git a/public/javascripts/app/views/comment_view.js b/public/javascripts/app/views/comment_view.js index e8aa7a692..25db04874 100644 --- a/public/javascripts/app/views/comment_view.js +++ b/public/javascripts/app/views/comment_view.js @@ -1,4 +1,4 @@ -App.Views.Comment = App.Views.StreamObject.extend({ +app.views.Comment = app.views.StreamObject.extend({ template_name: "#comment-template", diff --git a/public/javascripts/app/views/commment_stream_view.js b/public/javascripts/app/views/commment_stream_view.js index 818e703fa..4eb3509fe 100644 --- a/public/javascripts/app/views/commment_stream_view.js +++ b/public/javascripts/app/views/commment_stream_view.js @@ -1,4 +1,4 @@ -App.Views.CommentStream = App.Views.Base.extend({ +app.views.CommentStream = app.views.Base.extend({ template_name: "#comment-stream-template", @@ -32,7 +32,7 @@ App.Views.CommentStream = App.Views.Base.extend({ }, appendComment: function(comment) { - this.$("ul.comments").append(new App.Views.Comment({ + this.$("ul.comments").append(new app.views.Comment({ model: comment }).render().el); }, diff --git a/public/javascripts/app/views/feedback_view.js b/public/javascripts/app/views/feedback_view.js index 3b89fcf56..27c9932f3 100644 --- a/public/javascripts/app/views/feedback_view.js +++ b/public/javascripts/app/views/feedback_view.js @@ -1,4 +1,4 @@ -App.Views.Feedback = App.Views.StreamObject.extend({ +app.views.Feedback = app.views.StreamObject.extend({ template_name: "#feedback-template", events: { diff --git a/public/javascripts/app/views/header_view.js b/public/javascripts/app/views/header_view.js index d054dcba0..6bf42bd3d 100644 --- a/public/javascripts/app/views/header_view.js +++ b/public/javascripts/app/views/header_view.js @@ -1,4 +1,4 @@ -App.Views.Header = Backbone.View.extend({ +app.views.Header = Backbone.View.extend({ events : { "click ul.dropdown li:first-child" : "toggleDropdown" @@ -16,7 +16,7 @@ App.Views.Header = Backbone.View.extend({ render : function(){ this.template = _.template($("#header-template").html()); - $(this.el).html(this.template(App.user())); + $(this.el).html(this.template(app.user())); return this; }, diff --git a/public/javascripts/app/views/post_content_view.js b/public/javascripts/app/views/post_content_view.js index 4c2ae3d32..878d0c99d 100644 --- a/public/javascripts/app/views/post_content_view.js +++ b/public/javascripts/app/views/post_content_view.js @@ -1,11 +1,11 @@ -App.Views.StatusMessage = App.Views.StreamObject.extend({ +app.views.StatusMessage = app.views.StreamObject.extend({ template_name : "#status-message-template" }); -App.Views.Reshare = App.Views.StreamObject.extend({ +app.views.Reshare = app.views.StreamObject.extend({ template_name : "#reshare-template" }); -App.Views.ActivityStreams__Photo = App.Views.StreamObject.extend({ +app.views.ActivityStreams__Photo = app.views.StreamObject.extend({ template_name : "#activity-streams-photo-template" }); diff --git a/public/javascripts/app/views/post_view.js b/public/javascripts/app/views/post_view.js index 31bf07474..f41e94719 100644 --- a/public/javascripts/app/views/post_view.js +++ b/public/javascripts/app/views/post_view.js @@ -1,4 +1,4 @@ -App.Views.Post = App.Views.StreamObject.extend({ +app.views.Post = app.views.StreamObject.extend({ template_name: "#stream-element-template", @@ -16,8 +16,8 @@ App.Views.Post = App.Views.StreamObject.extend({ }, initialize : function() { - this.feedbackView = new App.Views.Feedback({model : this.model}); - this.commentStreamView = new App.Views.CommentStream({ model : this.model}); + this.feedbackView = new app.views.Feedback({model : this.model}); + this.commentStreamView = new app.views.CommentStream({ model : this.model}); return this; }, @@ -33,7 +33,7 @@ App.Views.Post = App.Views.StreamObject.extend({ renderPostContent: function(){ var normalizedClass = this.model.get("post_type").replace(/::/, "__"); - var postClass = App.Views[normalizedClass] || App.Views.StatusMessage; + var postClass = app.views[normalizedClass] || app.views.StatusMessage; var postView = new postClass({ model : this.model }); this.$(".post-content").html(postView.render().el); diff --git a/public/javascripts/app/views/stream_object_view.js b/public/javascripts/app/views/stream_object_view.js index 016c3246e..05a1ade5e 100644 --- a/public/javascripts/app/views/stream_object_view.js +++ b/public/javascripts/app/views/stream_object_view.js @@ -1,4 +1,4 @@ -App.Views.StreamObject = App.Views.Base.extend({ +app.views.StreamObject = app.views.Base.extend({ className : "loaded", initialize: function(options) { diff --git a/public/javascripts/app/views/stream_view.js b/public/javascripts/app/views/stream_view.js index 255fdb37a..4987f2421 100644 --- a/public/javascripts/app/views/stream_view.js +++ b/public/javascripts/app/views/stream_view.js @@ -1,17 +1,17 @@ -App.Views.Stream = Backbone.View.extend({ +app.views.Stream = Backbone.View.extend({ events: { "click #paginate": "render" }, initialize: function() { - this.collection = this.collection || new App.Collections.Stream; + this.collection = this.collection || new app.collections.Stream; this.collection.bind("add", this.appendPost, this); return this; }, appendPost: function(post) { - var postView = new App.Views.Post({ model: post }); + var postView = new app.views.Post({ model: post }); $(this.el).append(postView.render().el); }, diff --git a/public/javascripts/diaspora.js b/public/javascripts/diaspora.js index 1159836fa..dbf31ac6a 100644 --- a/public/javascripts/diaspora.js +++ b/public/javascripts/diaspora.js @@ -85,7 +85,7 @@ // temp hack to check if backbone is enabled for the page Diaspora.backboneEnabled = function(){ - return window.App.router.routes[window.location.pathname.replace("/","")]; + return window.app.router.routes[window.location.pathname.replace("/","")]; } window.Diaspora = Diaspora; diff --git a/spec/javascripts/app/app-spec.js b/spec/javascripts/app/app-spec.js index 958cd5b95..5f2e3b19a 100644 --- a/spec/javascripts/app/app-spec.js +++ b/spec/javascripts/app/app-spec.js @@ -1,11 +1,11 @@ -describe("App", function() { +describe("app", function() { describe("user", function() { it("sets the user if given one and returns the current user", function() { - expect(App.user()).toBeUndefined(); + expect(app.user()).toBeUndefined(); - App.user({name: "alice"}); + app.user({name: "alice"}); - expect(App.user()).toEqual({name: "alice"}); + expect(app.user()).toEqual({name: "alice"}); }); }); }); diff --git a/spec/javascripts/app/collections/stream-spec.js b/spec/javascripts/app/collections/stream-spec.js index f633b4f68..7de1f1698 100644 --- a/spec/javascripts/app/collections/stream-spec.js +++ b/spec/javascripts/app/collections/stream-spec.js @@ -1,13 +1,13 @@ -describe("App.Models.Stream", function() { +describe("app.collections.Stream", function() { describe("url", function() { - var stream = new App.Collections.Stream(), + var stream = new app.collections.Stream(), expectedPath = document.location.pathname + ".json"; it("returns the json path", function() { expect(stream.url()).toEqual(expectedPath); }); it("returns the json path with max_time if the collection has models", function() { - var post = new App.Models.Post(); + var post = new app.models.Post(); spyOn(post, "createdAt").andReturn(1234); stream.add(post); diff --git a/spec/javascripts/app/models/post-spec.js b/spec/javascripts/app/models/post-spec.js index f409f1459..a9b32f1cf 100644 --- a/spec/javascripts/app/models/post-spec.js +++ b/spec/javascripts/app/models/post-spec.js @@ -1,6 +1,6 @@ -describe("App.Models.Post", function() { +describe("app.models.Post", function() { describe("createdAt", function() { - var post = new App.Models.Post(); + var post = new app.models.Post(); it("returns the post's created_at as an integer", function() { var date = new Date; post.set({ created_at: +date * 1000 }); diff --git a/spec/javascripts/app/views/feedback_view_spec.js b/spec/javascripts/app/views/feedback_view_spec.js index 5bcbabc6e..a96dff4df 100644 --- a/spec/javascripts/app/views/feedback_view_spec.js +++ b/spec/javascripts/app/views/feedback_view_spec.js @@ -1,11 +1,11 @@ -describe("App.views.Feedback", function(){ +describe("app.views.Feedback", function(){ beforeEach(function(){ - window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); + window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"]; - this.post = new App.Models.Post(posts[2]); - this.view = new App.Views.Feedback({model: this.post}); + this.post = new app.models.Post(posts[2]); + this.view = new app.views.Feedback({model: this.post}); }); it("has a like from the post", function(){ diff --git a/spec/javascripts/app/views/header_view_spec.js b/spec/javascripts/app/views/header_view_spec.js index 3a35cffb2..712cdb5d6 100644 --- a/spec/javascripts/app/views/header_view_spec.js +++ b/spec/javascripts/app/views/header_view_spec.js @@ -1,10 +1,10 @@ -describe("App.Views.Header", function() { +describe("app.views.Header", function() { beforeEach(function() { // should be jasmine helper - window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); + window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); spec.loadFixture("aspects_index"); - this.view = new App.Views.Header().render(); + this.view = new app.views.Header().render(); }); describe("#toggleDropdown", function() { diff --git a/spec/javascripts/app/views/post_view_spec.js b/spec/javascripts/app/views/post_view_spec.js index 1bab5dcc8..f0e70e6c3 100644 --- a/spec/javascripts/app/views/post_view_spec.js +++ b/spec/javascripts/app/views/post_view_spec.js @@ -1,18 +1,18 @@ -describe("App.views.Post", function(){ +describe("app.views.Post", function(){ describe("#render", function(){ beforeEach(function(){ // should be jasmine helper - window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); + window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"][0]; - this.collection = new App.Collections.Stream(posts); + this.collection = new app.collections.Stream(posts); this.statusMessage = this.collection.models[0]; }) it("contains a '.like_action' link", function(){ - var view = new App.Views.Post({model : this.statusMessage}).render(); + var view = new app.views.Post({model : this.statusMessage}).render(); var statusElement = $(view.el); expect(statusElement.find(".like_action").html()).not.toBeNull(); @@ -22,7 +22,7 @@ describe("App.views.Post", function(){ it("contains a shield element", function(){ this.statusMessage.set({text : "this is safe for work. #sfw"}); - var view = new App.Views.Post({model : this.statusMessage}).render(); + var view = new app.views.Post({model : this.statusMessage}).render(); var statusElement = $(view.el) expect(statusElement.find(".shield").html()).toBeNull(); @@ -31,7 +31,7 @@ describe("App.views.Post", function(){ it("does not contain a shield element", function(){ this.statusMessage.set({text : "nudie magazine day! #nsfw"}); - var view = new App.Views.Post({model : this.statusMessage}).render(); + var view = new app.views.Post({model : this.statusMessage}).render(); var statusElement = $(view.el) expect(statusElement.find(".shield").html()).toNotBe(null); @@ -40,7 +40,7 @@ describe("App.views.Post", function(){ context("Reshare link", function(){ it("is present if the post is public", function(){ - var view = new App.Views.Post({model : this.statusMessage}).render(); + var view = new app.views.Post({model : this.statusMessage}).render(); this.statusMessage.set({"public" : true}); var statusElement = $(view.el) @@ -51,7 +51,7 @@ describe("App.views.Post", function(){ it("is not present if the post is not public", function(){ this.statusMessage.set({"public" : false}); - var view = new App.Views.Post({model : this.statusMessage}).render(); + var view = new app.views.Post({model : this.statusMessage}).render(); var statusElement = $(view.el) expect(statusElement.find(".reshare_action").html()).toBeNull(); diff --git a/spec/javascripts/app/views/stream_view_spec.js b/spec/javascripts/app/views/stream_view_spec.js index e36d1841e..e468f5089 100644 --- a/spec/javascripts/app/views/stream_view_spec.js +++ b/spec/javascripts/app/views/stream_view_spec.js @@ -1,17 +1,17 @@ -describe("App.views.Stream", function(){ +describe("app.views.Stream", function(){ describe("#render", function(){ beforeEach(function(){ // should be jasmine helper - window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); + window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"]; - this.collection = new App.Collections.Stream(posts); + this.collection = new app.collections.Stream(posts); this.statusMessage = this.collection.models[0]; this.reshare = this.collection.models[1]; - this.view = new App.Views.Stream({collection : this.collection}); + this.view = new app.views.Stream({collection : this.collection}); this.view.render(); this.statusElement = $(this.view.$("#" + this.statusMessage.get("guid"))); this.reshareElement = $(this.view.$("#" + this.reshare.get("guid"))); diff --git a/spec/javascripts/app/views_spec.js b/spec/javascripts/app/views_spec.js index 0177e65dc..11842192b 100644 --- a/spec/javascripts/app/views_spec.js +++ b/spec/javascripts/app/views_spec.js @@ -1,4 +1,4 @@ -describe("App.Views.Base", function(){ +describe("app.views.Base", function(){ function stubView(text){ var stubClass = Backbone.View.extend({ render : function(){ @@ -12,7 +12,7 @@ describe("App.Views.Base", function(){ describe("#render", function(){ beforeEach(function(){ - var staticTemplateClass = App.Views.Base.extend({ template_name : "#static-text-template" }) + var staticTemplateClass = app.views.Base.extend({ template_name : "#static-text-template" }) this.model = new Backbone.Model({text : "model attributes are in the default presenter"}) this.view = new staticTemplateClass({model: this.model}) @@ -31,7 +31,7 @@ describe("App.Views.Base", function(){ context("subViewRendering", function(){ beforeEach(function(){ - var viewClass = App.Views.Base.extend({ + var viewClass = app.views.Base.extend({ template_name : "#static-text-template", subviews : { ".subview1": "subview1",