finish beta striping

A lot of cleanup is still needed, refactoring the CSS to be consistent, removing all sorts of unused stuff etc
This commit is contained in:
Jonne Haß 2012-09-12 07:51:19 +02:00
parent ab0ad630df
commit 7ec2f8f419
12 changed files with 14 additions and 416 deletions

View file

@ -1,59 +0,0 @@
app.pages.Composer = app.views.Base.extend({
templateName : "flow",
subviews : {
".flow-content" : "postForm",
".flow-controls .controls" : "composerControls"
},
events : {
"click .next" : "navigateNext"
},
formAttrs : {
"textarea#text_with_markup" : "text"
},
initialize : function(){
app.frame = this.model = this.model || new app.models.StatusMessage();
/* add class to make this smaller than the default framer */
this.postForm = new app.forms.Post({model : this.model, className : "span4 offset1"});
this.composerControls = new app.views.ComposerControls({model : this.model});
},
unbind : function(){
this.model.off()
if(this.model.photos) {
this.model.photos.off()
}
},
navigateNext : function(){
var self = this,
textArea = this.$("form textarea.text")
textArea.mentionsInput('val', function(markup){
textArea.mentionsInput('getMentions', function(mentions){
var overrides = {
text : markup,
mentioned_people : mentions
}
self.setModelAttributes(overrides);
app.router.navigate("framer", true);
})
});
},
setModelAttributes : function(overrides){
this.setFormAttrs()
this.model.photos = this.postForm.pictureForm.photos
this.model.set({"photos": this.model.photos.toJSON() })
this.model.set(overrides)
}
});
app.views.ComposerControls = app.views.Base.extend({
templateName : 'composer-controls'
})

View file

@ -1,15 +1,11 @@
app.Router = Backbone.Router.extend({ app.Router = Backbone.Router.extend({
routes: { routes: {
//new hotness //new hotness
"stream?ex=true:params": 'newStream',
"stream?ex=true": 'newStream',
"people/:id?ex=true": "newProfile",
"posts/new" : "composer", "posts/new" : "composer",
"posts/:id": "singlePost", "posts/:id": "singlePost",
"posts/:id/next": "siblingPost", "posts/:id/next": "siblingPost",
"posts/:id/previous": "siblingPost", "posts/:id/previous": "siblingPost",
"p/:id": "singlePost", "p/:id": "singlePost",
"framer": "framer",
//oldness //oldness
"activity": "stream", "activity": "stream",
@ -25,26 +21,14 @@ app.Router = Backbone.Router.extend({
"tags/:name": "stream", "tags/:name": "stream",
"people/:id/photos": "photos", "people/:id/photos": "photos",
"people/:id": "profile", "people/:id": "stream",
"u/:name": "profile" "u/:name": "stream"
},
newStream : function() {
this.renderPage(function(){ return new app.pages.Stream()});
},
newProfile : function(personId) {
this.renderPage(function(){ return new app.pages.Profile({ personId : personId })});
}, },
composer : function(){ composer : function(){
this.renderPage(function(){ return new app.pages.Composer()}); this.renderPage(function(){ return new app.pages.Composer()});
}, },
framer : function(){
this.renderPage(function(){ return new app.pages.Framer()});
},
singlePost : function(id) { singlePost : function(id) {
this.renderPage(function(){ return new app.pages.PostViewer({ id: id })}); this.renderPage(function(){ return new app.pages.PostViewer({ id: id })});
}, },
@ -80,10 +64,6 @@ app.Router = Backbone.Router.extend({
$('#selected_aspect_contacts .content').html(streamFacesView.render().el); $('#selected_aspect_contacts .content').html(streamFacesView.render().el);
}, },
profile : function(page) {
this.stream()
},
photos : function() { photos : function() {
app.photos = new app.models.Stream([], {collection: app.collections.Photos}); app.photos = new app.models.Stream([], {collection: app.collections.Photos});
app.page = new app.views.Photos({model : app.photos}); app.page = new app.views.Photos({model : app.photos});

View file

@ -1,6 +1,5 @@
/* Mixin file for sass. Here is where we define our variables and /* Mixin file for sass. Here is where we define our variables and
browser compatability functions used in all scss/sass files */ browser compatability functions used in all scss/sass files */
@import 'new_styles/new_mixins';
/* Diapora's default color palate */ /* Diapora's default color palate */
$blue: #3f8fba; $blue: #3f8fba;

View file

@ -115,16 +115,8 @@ class PeopleController < ApplicationController
respond_to do |format| respond_to do |format|
format.all do format.all do
if params[:ex]
@page = :experimental
gon.person = PersonPresenter.new(@person, current_user)
gon.stream = PostPresenter.collection_json(@stream.stream_posts, current_user)
render :nothing => true, :layout => 'post'
else
respond_with @person, :locals => {:post_type => :all} respond_with @person, :locals => {:post_type => :all}
end end
end
format.json { render :json => @stream.stream_posts.map { |p| LastThreeCommentsDecorator.new(PostPresenter.new(p, current_user)) }} format.json { render :json => @stream.stream_posts.map { |p| LastThreeCommentsDecorator.new(PostPresenter.new(p, current_user)) }}
end end

View file

@ -1,7 +1,9 @@
class RemoveWallpaperFromProfile < ActiveRecord::Migration class RemoveWallpaperFromProfile < ActiveRecord::Migration
def up def up
remove_column :profiles, :wallpaper
end
def down
add_column :profiles, :wallpaper, :string add_column :profiles, :wallpaper, :string
end end
def down
remove_column: profiles, :wallpaper
end end

View file

@ -55,5 +55,6 @@ Scenario: Resharing an nsfw post
And I wait for the ajax to finish And I wait for the ajax to finish
And I go to the home page And I go to the home page
#if this is failing on travis throw a random wait in here :/ #if this is failing on travis throw a random wait in here :/
And I wait for the ajax to finish
Then I should not see "Sexy Senators Gone Wild!" Then I should not see "Sexy Senators Gone Wild!"
And I should have 2 nsfw posts And I should have 2 nsfw posts

View file

@ -60,3 +60,7 @@ end
When /^I post an extremely long status message$/ do When /^I post an extremely long status message$/ do
click_and_post("I am a very interesting message " * 64) click_and_post("I am a very interesting message " * 64)
end end
When /^I open the show page of the "([^"]*)" post$/ do |post_text|
visit post_path_by_content(post_text)
end

View file

@ -1,41 +0,0 @@
describe("app.pages.Composer", function(){
beforeEach(function(){
this.page = new app.pages.Composer()
})
describe("rendering", function(){
beforeEach(function(){
this.page.render();
})
describe("clicking next", function(){
beforeEach(function(){
this.navigateSpy = spyOn(app.router, "navigate")
})
it("navigates to the framer", function(){
this.page.$("input.next").click()
expect(this.navigateSpy).toHaveBeenCalledWith("framer", true)
});
describe(" setting the model's attributes from the various form fields", function(){
beforeEach(function(){
this.page.$("form .text").val("Oh My")
})
it("instantiates a post on form submit", function(){
this.page.$("input.next").click()
waitsFor(function(){ return this.navigateSpy.wasCalled })
runs(function(){
expect(this.page.model.get("text")).toBe("Oh My")
})
})
});
})
})
it("stores a reference to the form as app.composer" , function(){
expect(this.page.model).toBeDefined()
expect(app.frame).toBe(this.page.model)
});
});

View file

@ -1,68 +0,0 @@
describe("app.pages.Framer", function(){
beforeEach(function(){
loginAs(factory.user())
app.frame = new factory.statusMessage({frame_name: undefined});
this.page = new app.pages.Framer();
this.model = this.page.model
expect(this.model).toBe(app.frame) //uses global state of app.frame :/
});
describe("navigation on save", function(){
it("navigates to the current user's profile page", function(){
spyOn(app.router, "navigate")
this.page.model.trigger("sync")
expect(app.router.navigate).toHaveBeenCalled()
})
// want a spec here for the bookmarklet case
})
describe("initialization", function(){
it("calls setFrameName on the model when there is no frame_name", function(){
spyOn(this.model, 'setFrameName')
this.model.unset("frame_name")
new app.pages.Framer()
expect(this.model.setFrameName).toHaveBeenCalled()
})
it("sets the frame_name of the model to 'Vanilla' by default", function(){ //jasmine integration test, arguably unnecessary
expect(this.model.get("frame_name")).toBe("Vanilla")
})
})
describe("rendering", function(){
beforeEach(function(){
this.page.render();
});
it("saves the model when you click done", function(){
spyOn(app.frame, "save");
this.page.$("input.done").click();
expect(app.frame.save).toHaveBeenCalled();
});
describe("setting the model's attributes from the various form fields", function(){
beforeEach(function(){
this.page.$("input.mood").attr("checked", false) //radio button hax
expect(app.frame.get("frame_name")).not.toBe("Typist")
this.page.$("input.aspect_ids").val("public")
this.page.$("input[value='Typist']").attr("checked", "checked")
this.page.$("input.services[value=facebook]").attr("checked", "checked")
this.page.$("input.services[value=twitter]").attr("checked", "checked")
})
it("instantiates a post on form submit", function(){
this.page.$("input").trigger("change") //runs setFormAttrs
waitsFor(function(){
return this.page.model.get("frame_name") == "Typist"
})
runs(function(){
expect(this.page.model.get("aspect_ids")).toEqual(["public"])
expect(this.page.model.get("services")).toEqual(["facebook", "twitter"])
expect(this.page.model.get("frame_name")).toBe("Typist")
})
})
});
});
});

View file

@ -1,167 +0,0 @@
describe("app.pages.Profile", function(){
beforeEach(function(){
this.guid = 'abcdefg123'
this.profile = factory.profile({personId: this.guid})
this.profile.deferred = new $.Deferred()
spyOn(app.collections.Posts.prototype, "fetch").andReturn(new $.Deferred)
app.page = this.page = new app.pages.Profile({model : this.profile });
this.stream = this.page.stream
this.profile.deferred.resolve()
});
it("fetches the profile of the user with the params from the router and assigns it as the model", function(){
var profile = new factory.profile()
profile.deferred = $.Deferred()
spyOn(app.models.Profile, 'findByGuid').andReturn(profile)
var page = new app.pages.Profile({personId : 'jarjabinkisthebest' })
expect(app.models.Profile.findByGuid).toHaveBeenCalledWith('jarjabinkisthebest')
expect(page.model).toBe(profile)
})
it("passes the stream down to the canvas view", function(){
expect(this.page.canvasView.model).toBeDefined()
expect(this.page.canvasView.model).toBe(this.stream)
});
it("preloads the stream for the user", function(){
spyOn(this.stream, "preload")
window.preloads = {stream : JSON.stringify(["unicorns"]) }
new app.pages.Profile({stream : this.stream})
expect(this.stream.preload).toHaveBeenCalled()
delete window.preloads //cleanup
})
describe("rendering", function(){
context("with no posts", function(){
beforeEach(function(){
this.profile.set({"name" : "Alice Waters", person_id : "889"})
this.stream.deferred.resolve()
})
it("has a message that there are no posts", function(){
this.page.render()
expect(this.page.$("#canvas").text()).toBe("Alice Waters hasn't posted anything yet.")
})
it("tells you to post something if it's your profile", function(){
this.profile.set({is_own_profile : true})
this.page.render()
expect(this.page.$("#canvas").text()).toBe("Make something to start the magic.")
})
})
context("with a post", function(){
beforeEach(function(){
this.post = factory.post()
this.stream.add(this.post)
this.stream.deferred.resolve()
this.page.toggleEdit()
expect(this.page.editMode).toBeTruthy()
this.page.render()
});
context("profile control pane", function(){
it("shows the edit and create buttons if it's your profile", function() {
this.page.model.set({is_own_profile : true})
this.page.render()
expect(this.page.$("#profile-controls .control").length).toBe(2)
})
})
context("clicking fav", function(){
beforeEach(function(){
spyOn(this.post, 'toggleFavorite')
spyOn($.fn, "isotope")
this.page.$(".content").click()
})
it("relayouts the page", function(){
expect($.fn.isotope).toHaveBeenCalledWith("reLayout")
})
it("toggles the favorite status on the model", function(){
expect(this.post.toggleFavorite).toHaveBeenCalled()
})
})
context("clicking delete", function(){
beforeEach(function () {
spyOn(window, "confirm").andReturn(true);
this.page.render()
})
it("kills the model", function(){
spyOn(this.post, "destroy")
this.page.$(".canvas-frame:first a.delete").click()
expect(this.post.destroy).toHaveBeenCalled()
})
it("removes the frame", function(){
spyOn($.fn, "remove").andCallThrough()
expect(this.page.$(".canvas-frame").length).toBe(1)
this.page.$(".canvas-frame:first a.delete").click()
waitsFor(function(){ return $.fn.remove.wasCalled })
runs(function(){ expect(this.page.$(".canvas-frame").length).toBe(0) })
})
})
})
});
describe("edit mode", function(){
describe("toggle edit", function(){
it("changes the page's global edit state", function(){
expect(this.page.editMode).toBeFalsy()
this.page.toggleEdit()
expect(this.page.editMode).toBeTruthy()
})
it("changes the page's class to 'edit-mode'", function(){
expect(this.page.$el).not.toHaveClass('edit-mode')
this.page.toggleEdit()
expect(this.page.$el).toHaveClass('edit-mode')
})
})
})
describe("composing", function(){
beforeEach(function(){
this.page.model.set({is_own_profile : true})
this.page.render()
/* stub navigation changes */
spyOn(app.router, "navigate")
})
describe("invoking the interaction", function(){
it("shows the publisher and disables the body from scrolling", function(){
expect(this.page.$("#composer")).toHaveClass('hidden')
this.page.$("#composer-button").click()
expect(this.page.$("#composer")).not.toHaveClass('hidden')
expect($("body")).toHaveClass('lock')
})
it("changes the URL", function(){
this.page.$("#composer-button").click()
expect(app.router.navigate).toHaveBeenCalled()
})
})
describe("revoking the interaction", function(){
beforeEach(function(){
/* invoke the composer */
this.page.$("#composer-button").click()
this.evt = Event
this.evt.keyCode = 28
})
it("changes the URL", function(){
$(window).trigger("keydown", this.evt)
expect(app.router.navigate).toHaveBeenCalled()
})
})
});
});

View file

@ -6,13 +6,6 @@ describe("app.Pages.Stream", function(){
expect(this.post).toBeTruthy() expect(this.post).toBeTruthy()
}) })
describe('postRenderTemplate', function(){
it("sets the background-image of #header", function(){
this.page.render()
expect(this.page.$('#header').css('background-image')).toBeTruthy()
})
})
describe("rendering", function(){ describe("rendering", function(){
beforeEach(function(){ beforeEach(function(){
this.page.render() this.page.render()
@ -30,7 +23,7 @@ describe("app.Pages.Stream", function(){
context("when more posts are loaded", function(){ context("when more posts are loaded", function(){
it("navigates to the last post in the stream's max_time", function(){ it("navigates to the last post in the stream's max_time", function(){
spyOn(app.router, 'navigate') spyOn(app.router, 'navigate')
var url = location.pathname + "?ex=true&max_time=" + this.post.createdAt() var url = location.pathname + "?max_time=" + this.post.createdAt()
, options = {replace: true} , options = {replace: true}
this.page.streamView.trigger('loadMore') this.page.streamView.trigger('loadMore')

View file

@ -1,38 +0,0 @@
describe("app.views.framerControls", function(){
beforeEach(function(){
loginAs(factory.user())
this.post = new factory.statusMessage({frame_name: undefined});
this.view = new app.views.framerControls({model : this.post})
})
describe("rendering", function(){
beforeEach(function(){
this.view.render();
});
it("disables the buttons when you click the X", function(){
this.view.$("input.done").click();
expect(this.view.$('input').prop('disabled')).toBeTruthy();
});
it("does not disable the frame if it is invaild", function(){
spyOn(this.view, 'inValidFrame').andReturn(true)
this.view.$("input.done").click();
expect(this.view.$('input').prop('disabled')).toBeFalsy();
});
it("does not disable the frame if it is invaild", function(){
spyOn(this.view.model, 'save')
spyOn(this.view, 'inValidFrame').andReturn(true)
this.view.$("input.done").click();
expect(this.view.model.save).not.toHaveBeenCalled()
});
})
describe("inValidFrame", function(){
it("is invalid if the frame has no text or photos", function(){
this.view.model = new factory.statusMessage({text: '', photos : []})
expect(this.view.inValidFrame).toBeTruthy();
})
});
});