downcase namespacing of app

This commit is contained in:
danielgrippi 2011-12-26 01:39:44 -05:00 committed by Dennis Collinson
parent 6ad4c8e348
commit 1a5e493b22
27 changed files with 75 additions and 75 deletions

View file

@ -61,7 +61,7 @@
- unless @landing_page - unless @landing_page
= include_javascripts :main = include_javascripts :main
:javascript :javascript
App.user({ app.user({
current_user: #{current_user.person.as_api_response(:backbone).to_json} current_user: #{current_user.person.as_api_response(:backbone).to_json}
}); });

View file

@ -1,7 +1,7 @@
var App = { var app = {
Collections: {}, collections: {},
Models: {}, models: {},
Views: {}, views: {},
user: function(user) { user: function(user) {
if(user) { return this._user = user; } if(user) { return this._user = user; }
@ -10,16 +10,16 @@ var App = {
}, },
initialize: function() { initialize: function() {
App.router = new App.Router; app.router = new app.Router;
if(this._user){ if(this._user){
App.header = new App.Views.Header; app.header = new app.views.Header;
$("body").prepend(App.header.el); $("body").prepend(app.header.el);
App.header.render(); app.header.render();
} }
Backbone.history.start({pushState: true}); Backbone.history.start({pushState: true});
} }
}; };
$(function() { App.initialize(); }); $(function() { app.initialize(); });

View file

@ -1,3 +1,3 @@
App.Collections.Comments = Backbone.Collection.extend({ app.collections.Comments = Backbone.Collection.extend({
model: App.Models.Comment model: app.models.Comment
}); });

View file

@ -1,3 +1,3 @@
App.Collections.Likes = Backbone.Collection.extend({ app.collections.Likes = Backbone.Collection.extend({
model: App.Models.Like model: app.models.Like
}); });

View file

@ -1,4 +1,4 @@
App.Collections.Stream = Backbone.Collection.extend({ app.collections.Stream = Backbone.Collection.extend({
url: function() { url: function() {
var path = document.location.pathname + ".json"; var path = document.location.pathname + ".json";
@ -7,7 +7,7 @@ App.Collections.Stream = Backbone.Collection.extend({
return path; return path;
}, },
model: App.Models.Post, model: app.models.Post,
parse: function(resp){ parse: function(resp){
return resp.posts; return resp.posts;

View file

@ -1,3 +1,3 @@
App.Models.Comment = Backbone.Model.extend({ app.models.Comment = Backbone.Model.extend({
urlRoot: "/comments" urlRoot: "/comments"
}); });

View file

@ -1,2 +1,2 @@
App.Models.Like = Backbone.Model.extend({ app.models.Like = Backbone.Model.extend({
}) })

View file

@ -1,9 +1,9 @@
App.Models.Post = Backbone.Model.extend({ app.models.Post = Backbone.Model.extend({
initialize: function() { 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.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'; this.likes.url = this.url() + '/likes';
}, },

View file

@ -1,4 +1,4 @@
App.Router = Backbone.Router.extend({ app.Router = Backbone.Router.extend({
routes: { routes: {
"stream": "stream", "stream": "stream",
"comment_stream": "stream", "comment_stream": "stream",
@ -12,7 +12,7 @@ App.Router = Backbone.Router.extend({
}, },
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);
} }
}); });

View file

@ -1,11 +1,11 @@
App.Views.Base = Backbone.View.extend({ app.views.Base = Backbone.View.extend({
presenter : function(){ presenter : function(){
return this.defaultPresenter() return this.defaultPresenter()
}, },
defaultPresenter : function(){ defaultPresenter : function(){
var modelJson = this.model ? this.model.toJSON() : {} var modelJson = this.model ? this.model.toJSON() : {}
return _.extend(modelJson, App.user()); return _.extend(modelJson, app.user());
}, },
render : function() { render : function() {

View file

@ -1,4 +1,4 @@
App.Views.Comment = App.Views.StreamObject.extend({ app.views.Comment = app.views.StreamObject.extend({
template_name: "#comment-template", template_name: "#comment-template",

View file

@ -1,4 +1,4 @@
App.Views.CommentStream = App.Views.Base.extend({ app.views.CommentStream = app.views.Base.extend({
template_name: "#comment-stream-template", template_name: "#comment-stream-template",
@ -32,7 +32,7 @@ App.Views.CommentStream = App.Views.Base.extend({
}, },
appendComment: function(comment) { appendComment: function(comment) {
this.$("ul.comments").append(new App.Views.Comment({ this.$("ul.comments").append(new app.views.Comment({
model: comment model: comment
}).render().el); }).render().el);
}, },

View file

@ -1,4 +1,4 @@
App.Views.Feedback = App.Views.StreamObject.extend({ app.views.Feedback = app.views.StreamObject.extend({
template_name: "#feedback-template", template_name: "#feedback-template",
events: { events: {

View file

@ -1,4 +1,4 @@
App.Views.Header = Backbone.View.extend({ app.views.Header = Backbone.View.extend({
events : { events : {
"click ul.dropdown li:first-child" : "toggleDropdown" "click ul.dropdown li:first-child" : "toggleDropdown"
@ -16,7 +16,7 @@ App.Views.Header = Backbone.View.extend({
render : function(){ render : function(){
this.template = _.template($("#header-template").html()); this.template = _.template($("#header-template").html());
$(this.el).html(this.template(App.user())); $(this.el).html(this.template(app.user()));
return this; return this;
}, },

View file

@ -1,11 +1,11 @@
App.Views.StatusMessage = App.Views.StreamObject.extend({ app.views.StatusMessage = app.views.StreamObject.extend({
template_name : "#status-message-template" template_name : "#status-message-template"
}); });
App.Views.Reshare = App.Views.StreamObject.extend({ app.views.Reshare = app.views.StreamObject.extend({
template_name : "#reshare-template" 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" template_name : "#activity-streams-photo-template"
}); });

View file

@ -1,4 +1,4 @@
App.Views.Post = App.Views.StreamObject.extend({ app.views.Post = app.views.StreamObject.extend({
template_name: "#stream-element-template", template_name: "#stream-element-template",
@ -16,8 +16,8 @@ App.Views.Post = App.Views.StreamObject.extend({
}, },
initialize : function() { initialize : function() {
this.feedbackView = new App.Views.Feedback({model : this.model}); this.feedbackView = new app.views.Feedback({model : this.model});
this.commentStreamView = new App.Views.CommentStream({ model : this.model}); this.commentStreamView = new app.views.CommentStream({ model : this.model});
return this; return this;
}, },
@ -33,7 +33,7 @@ App.Views.Post = App.Views.StreamObject.extend({
renderPostContent: function(){ renderPostContent: function(){
var normalizedClass = this.model.get("post_type").replace(/::/, "__"); 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 }); var postView = new postClass({ model : this.model });
this.$(".post-content").html(postView.render().el); this.$(".post-content").html(postView.render().el);

View file

@ -1,4 +1,4 @@
App.Views.StreamObject = App.Views.Base.extend({ app.views.StreamObject = app.views.Base.extend({
className : "loaded", className : "loaded",
initialize: function(options) { initialize: function(options) {

View file

@ -1,17 +1,17 @@
App.Views.Stream = Backbone.View.extend({ app.views.Stream = Backbone.View.extend({
events: { events: {
"click #paginate": "render" "click #paginate": "render"
}, },
initialize: function() { 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); this.collection.bind("add", this.appendPost, this);
return this; return this;
}, },
appendPost: function(post) { 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); $(this.el).append(postView.render().el);
}, },

View file

@ -85,7 +85,7 @@
// temp hack to check if backbone is enabled for the page // temp hack to check if backbone is enabled for the page
Diaspora.backboneEnabled = function(){ Diaspora.backboneEnabled = function(){
return window.App.router.routes[window.location.pathname.replace("/","")]; return window.app.router.routes[window.location.pathname.replace("/","")];
} }
window.Diaspora = Diaspora; window.Diaspora = Diaspora;

View file

@ -1,11 +1,11 @@
describe("App", function() { describe("app", function() {
describe("user", function() { describe("user", function() {
it("sets the user if given one and returns the current 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"});
}); });
}); });
}); });

View file

@ -1,13 +1,13 @@
describe("App.Models.Stream", function() { describe("app.collections.Stream", function() {
describe("url", function() { describe("url", function() {
var stream = new App.Collections.Stream(), var stream = new app.collections.Stream(),
expectedPath = document.location.pathname + ".json"; expectedPath = document.location.pathname + ".json";
it("returns the json path", function() { it("returns the json path", function() {
expect(stream.url()).toEqual(expectedPath); expect(stream.url()).toEqual(expectedPath);
}); });
it("returns the json path with max_time if the collection has models", function() { 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); spyOn(post, "createdAt").andReturn(1234);
stream.add(post); stream.add(post);

View file

@ -1,6 +1,6 @@
describe("App.Models.Post", function() { describe("app.models.Post", function() {
describe("createdAt", 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() { it("returns the post's created_at as an integer", function() {
var date = new Date; var date = new Date;
post.set({ created_at: +date * 1000 }); post.set({ created_at: +date * 1000 });

View file

@ -1,11 +1,11 @@
describe("App.views.Feedback", function(){ describe("app.views.Feedback", function(){
beforeEach(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"]; var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"];
this.post = new App.Models.Post(posts[2]); this.post = new app.models.Post(posts[2]);
this.view = new App.Views.Feedback({model: this.post}); this.view = new app.views.Feedback({model: this.post});
}); });
it("has a like from the post", function(){ it("has a like from the post", function(){

View file

@ -1,10 +1,10 @@
describe("App.Views.Header", function() { describe("app.views.Header", function() {
beforeEach(function() { beforeEach(function() {
// should be jasmine helper // 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"); spec.loadFixture("aspects_index");
this.view = new App.Views.Header().render(); this.view = new app.views.Header().render();
}); });
describe("#toggleDropdown", function() { describe("#toggleDropdown", function() {

View file

@ -1,18 +1,18 @@
describe("App.views.Post", function(){ describe("app.views.Post", function(){
describe("#render", function(){ describe("#render", function(){
beforeEach(function(){ beforeEach(function(){
// should be jasmine helper // 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]; 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]; this.statusMessage = this.collection.models[0];
}) })
it("contains a '.like_action' link", function(){ 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); var statusElement = $(view.el);
expect(statusElement.find(".like_action").html()).not.toBeNull(); expect(statusElement.find(".like_action").html()).not.toBeNull();
@ -22,7 +22,7 @@ describe("App.views.Post", function(){
it("contains a shield element", function(){ it("contains a shield element", function(){
this.statusMessage.set({text : "this is safe for work. #sfw"}); 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) var statusElement = $(view.el)
expect(statusElement.find(".shield").html()).toBeNull(); expect(statusElement.find(".shield").html()).toBeNull();
@ -31,7 +31,7 @@ describe("App.views.Post", function(){
it("does not contain a shield element", function(){ it("does not contain a shield element", function(){
this.statusMessage.set({text : "nudie magazine day! #nsfw"}); 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) var statusElement = $(view.el)
expect(statusElement.find(".shield").html()).toNotBe(null); expect(statusElement.find(".shield").html()).toNotBe(null);
@ -40,7 +40,7 @@ describe("App.views.Post", function(){
context("Reshare link", function(){ context("Reshare link", function(){
it("is present if the post is public", 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}); this.statusMessage.set({"public" : true});
var statusElement = $(view.el) var statusElement = $(view.el)
@ -51,7 +51,7 @@ describe("App.views.Post", function(){
it("is not present if the post is not public", function(){ it("is not present if the post is not public", function(){
this.statusMessage.set({"public" : false}); 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) var statusElement = $(view.el)
expect(statusElement.find(".reshare_action").html()).toBeNull(); expect(statusElement.find(".reshare_action").html()).toBeNull();

View file

@ -1,17 +1,17 @@
describe("App.views.Stream", function(){ describe("app.views.Stream", function(){
describe("#render", function(){ describe("#render", function(){
beforeEach(function(){ beforeEach(function(){
// should be jasmine helper // 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"]; 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.statusMessage = this.collection.models[0];
this.reshare = this.collection.models[1]; 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.view.render();
this.statusElement = $(this.view.$("#" + this.statusMessage.get("guid"))); this.statusElement = $(this.view.$("#" + this.statusMessage.get("guid")));
this.reshareElement = $(this.view.$("#" + this.reshare.get("guid"))); this.reshareElement = $(this.view.$("#" + this.reshare.get("guid")));

View file

@ -1,4 +1,4 @@
describe("App.Views.Base", function(){ describe("app.views.Base", function(){
function stubView(text){ function stubView(text){
var stubClass = Backbone.View.extend({ var stubClass = Backbone.View.extend({
render : function(){ render : function(){
@ -12,7 +12,7 @@ describe("App.Views.Base", function(){
describe("#render", function(){ describe("#render", function(){
beforeEach(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.model = new Backbone.Model({text : "model attributes are in the default presenter"})
this.view = new staticTemplateClass({model: this.model}) this.view = new staticTemplateClass({model: this.model})
@ -31,7 +31,7 @@ describe("App.Views.Base", function(){
context("subViewRendering", function(){ context("subViewRendering", function(){
beforeEach(function(){ beforeEach(function(){
var viewClass = App.Views.Base.extend({ var viewClass = app.views.Base.extend({
template_name : "#static-text-template", template_name : "#static-text-template",
subviews : { subviews : {
".subview1": "subview1", ".subview1": "subview1",