Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
cb2c972cee
13 changed files with 158 additions and 264 deletions
|
|
@ -2,6 +2,14 @@ app.models.Profile = Backbone.Model.extend({
|
|||
urlRoot : "/profiles"
|
||||
}, {
|
||||
|
||||
preloadOrFetch : function(id){
|
||||
if(app.hasPreload("person")) {
|
||||
return new app.models.Profile(app.parsePreload("person"))
|
||||
} else {
|
||||
return this.findByGuid(id)
|
||||
}
|
||||
},
|
||||
|
||||
findByGuid : function(personId){
|
||||
var person = new app.models.Profile({ id : personId})
|
||||
person.fetch()
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
//= require ../views/profile_info_view
|
||||
|
||||
app.pages.Profile = app.views.Base.extend({
|
||||
|
||||
id : "profile",
|
||||
|
||||
templateName : "profile",
|
||||
id : "profile",
|
||||
|
||||
subviews : {
|
||||
"#profile-info" : "profileInfo",
|
||||
|
|
@ -23,20 +21,10 @@ app.pages.Profile = app.views.Base.extend({
|
|||
personGUID : null,
|
||||
editMode : false,
|
||||
|
||||
presenter : function(){
|
||||
var bio = this.model.get("bio") || ''
|
||||
|
||||
return _.extend(this.defaultPresenter(),
|
||||
{text : this.model && app.helpers.textFormatter(bio, this.model),
|
||||
isOwnProfile : this.isOwnProfile(),
|
||||
showFollowButton : this.showFollowButton()
|
||||
})
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
this.personGUID = options.personId
|
||||
|
||||
this.model = new app.models.Profile.findByGuid(options.personId)
|
||||
this.model = this.model || app.models.Profile.preloadOrFetch(this.personGUID)
|
||||
this.stream = options && options.stream || new app.models.Stream()
|
||||
|
||||
this.model.bind("change", this.setPageTitleAndBackground, this)
|
||||
|
|
@ -54,6 +42,16 @@ app.pages.Profile = app.views.Base.extend({
|
|||
this.profileInfo = new app.views.ProfileInfo({ model : this.model.set({isOwnProfile : this.isOwnProfile()}) })
|
||||
},
|
||||
|
||||
presenter : function(){
|
||||
var bio = this.model.get("bio") || ''
|
||||
|
||||
return _.extend(this.defaultPresenter(),
|
||||
{text : this.model && app.helpers.textFormatter(bio, this.model),
|
||||
isOwnProfile : this.isOwnProfile(),
|
||||
showFollowButton : this.showFollowButton()
|
||||
})
|
||||
},
|
||||
|
||||
pulsateNewPostControl : function() {
|
||||
this.$("#composer-button")[
|
||||
this.stream.items.length == 0
|
||||
|
|
|
|||
|
|
@ -10,9 +10,23 @@ app.views.Canvas = app.views.Base.extend(_.extend({}, app.views.infiniteScrollMi
|
|||
|
||||
renderTemplate : function() {
|
||||
this.$el.empty()
|
||||
|
||||
if(this.stream.items.isEmpty()){
|
||||
var message
|
||||
, person = app.page.model
|
||||
if(person.get("is_own_profile")){
|
||||
message = "Make something to start the magic."
|
||||
} else {
|
||||
var name = person.get("full_name") || ""
|
||||
message = name + " hasn't posted anything yet."
|
||||
}
|
||||
|
||||
this.$el.html("<p class='no-post-message'>" + message + "</p>")
|
||||
} else {
|
||||
this.stream.items.each(_.bind(function(post){
|
||||
this.$el.append(this.createPostView(post).render().el);
|
||||
}, this))
|
||||
}
|
||||
|
||||
//needs to be deferred so it happens after html rendering finishes
|
||||
_.defer(_.bind(this.mason, this))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@
|
|||
min-width : $two-column-width + px;
|
||||
max-width : $two-column-width + px;
|
||||
}
|
||||
.no-post-message {
|
||||
text-align: center;
|
||||
margin-top: 50px;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.canvas-frame {
|
||||
float : left;
|
||||
|
|
|
|||
|
|
@ -1,173 +0,0 @@
|
|||
<div class="canvas-frame">
|
||||
<div class="content">
|
||||
<img src="https://joindiaspora.s3.amazonaws.com/uploads/images/scaled_full_bb076dd0d45f0caa4478.gif"/>
|
||||
</div>
|
||||
<div class="info">
|
||||
Daniel Grippi
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame width x2">
|
||||
<div class="content">
|
||||
<p>
|
||||
Here, he discusses how globalisation has exacerbated income inequalities and the control over politics exerted by the rich, citing the Occupy movement which he describes as a 'public relations hazard not a health hazard'
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Echo park wolf kale chips sunt, dolor scenester deserunt ad cray leggings 3 wolf moon thundercats direct trade. Banksy placeat odd future et, ex gastropub elit whatever. Messenger bag eu fanny pack, pitchfork locavore four loko yr marfa forage. Mcsweeney's hoodie terry richardson exercitation, consectetur commodo banh mi ullamco laboris cliche raw denim salvia selvage in nulla. Lo-fi chambray culpa, dreamcatcher fugiat squid portland nihil high life. Quis VHS blog sunt sint, salvia wes anderson fingerstache portland eiusmod ex consectetur synth enim. Tattooed aliquip proident id, lomo aliqua qui pitchfork hella cosby sweater pariatur vero. </p>
|
||||
|
||||
</div>
|
||||
<div class="info">
|
||||
Dennis Collinson
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame">
|
||||
<div class="content">
|
||||
<img src="https://joindiaspora.s3.amazonaws.com/uploads/images/scaled_full_7dbfea26846d99848aac.jpg"/>
|
||||
</div>
|
||||
<div class="info">
|
||||
Sarah Mei
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="canvas-frame">
|
||||
<div class="content">
|
||||
<h1>
|
||||
sometimes, i say things loud.
|
||||
</h1>
|
||||
</div>
|
||||
<div class="info">
|
||||
Sean Tilley
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame height x2">
|
||||
<div class="content">
|
||||
<h1>
|
||||
this is a longish status but i don't have that much to say. i guess i can keep on typing or something like that or make this a run-on sentance.
|
||||
</h1>
|
||||
</div>
|
||||
<div class="info">
|
||||
Daniel Grippi
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame width x2">
|
||||
<div class="content">
|
||||
<p>
|
||||
Echo park wolf kale chips sunt, dolor scenester deserunt ad cray leggings 3 wolf moon thundercats direct trade. Banksy placeat odd future et, ex gastropub elit whatever. Messenger bag eu fanny pack, pitchfork locavore four loko yr marfa forage. Mcsweeney's hoodie terry richardson exercitation, consectetur commodo banh mi ullamco laboris cliche raw denim salvia selvage in nulla. Lo-fi chambray culpa, dreamcatcher fugiat squid portland nihil high life. Quis VHS blog sunt sint, salvia wes anderson fingerstache portland eiusmod ex consectetur synth enim. Tattooed aliquip proident id, lomo aliqua qui pitchfork hella cosby sweater pariatur vero.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="info">
|
||||
Dennis Collinson
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame height width x2">
|
||||
<div class="content">
|
||||
<img src="http://24.media.tumblr.com/tumblr_lzwkez5ew31qzxz2so1_500.jpg"/>
|
||||
</div>
|
||||
<div class="info">
|
||||
Sarah Mei
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="canvas-frame">
|
||||
<div class="content">
|
||||
<h1>
|
||||
#weinerjuice
|
||||
</h1>
|
||||
</div>
|
||||
<div class="info">
|
||||
Sean Tilley
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame width x2">
|
||||
<div class="content">
|
||||
<img src="http://hipsteripsum.wpengine.netdna-cdn.com/wp-content/uploads/2011/08/cropped-asian_hipster.jpg"/>
|
||||
</div>
|
||||
<div class="info">
|
||||
Rosanna Yau
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame height x2">
|
||||
<div class="content">
|
||||
<h3>
|
||||
Banksy placeat odd future et, ex gastropub elit whatever. Messenger bag eu fanny pack, pitchfork locavore four loko yr marfa forage. Mcsweeney's hoodie terry richardson exercitation, consectetur commodo banh mi ullamco laboris cliche raw denim salvia selvage
|
||||
Banksy placeat odd future et, ex gastropub elit whatever. Messenger bag eu fanny pack, pitchfork.
|
||||
</h3>
|
||||
</div>
|
||||
<div class="info">
|
||||
Sarah Mei
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame width height x2">
|
||||
<div class="content">
|
||||
<img src="http://28.media.tumblr.com/tumblr_m02dfqdQT31qfzxa7o1_500.jpg"/>
|
||||
</div>
|
||||
<div class="info">
|
||||
Daniel Grippi
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="canvas-frame">
|
||||
<div class="content">
|
||||
<p>
|
||||
Banksy placeat odd future et, ex gastropub elit whatever. Messenger bag eu fanny pack, pitchfork locavore four loko yr marfa forage. Mcsweeney's hoodie terry richardson exercitation, consectetur commodo banh mi ullamco laboris cliche raw denim salvia selvage
|
||||
</p>
|
||||
</div>
|
||||
<div class="info">
|
||||
Daniel Grippi
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="canvas-frame">
|
||||
<div class="content">
|
||||
<h1>
|
||||
skribblex.
|
||||
</h1>
|
||||
</div>
|
||||
<div class="info">
|
||||
Rosanna Yau
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame height x2">
|
||||
<div class="content">
|
||||
<img src="http://28.media.tumblr.com/tumblr_ln5654hJrs1qd33kzo1_1280.jpg"/>
|
||||
</div>
|
||||
<div class="info">
|
||||
Sarah Mei
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="canvas-frame">
|
||||
<div class="content">
|
||||
hey there kids!
|
||||
</div>
|
||||
<div class="info">
|
||||
Daniel Grippi
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="canvas-frame width x2">
|
||||
<div class="content">
|
||||
<iframe width="100%" height="450" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F1821180&show_artwork=true"></iframe>
|
||||
</div>
|
||||
<div class="info">
|
||||
Rosanna Yau
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -119,7 +119,9 @@ class PeopleController < ApplicationController
|
|||
format.all do
|
||||
if params[:ex]
|
||||
@page = :experimental
|
||||
gon.stream = @stream.stream_posts.as_api_response(:backbone).as_json
|
||||
gon.person = PersonPresenter.new(@person, current_user)
|
||||
gon.stream = @stream.stream_posts.as_api_response(:backbone)
|
||||
|
||||
render :nothing => true, :layout => 'post'
|
||||
else
|
||||
respond_with @person, :locals => {:post_type => :all}
|
||||
|
|
|
|||
|
|
@ -14,20 +14,7 @@ class ProfilesController < ApplicationController
|
|||
@person = Person.find_by_guid!(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
public_json = @person.as_api_response(:backbone)
|
||||
extra_json = {:wallpaper => @person.profile.wallpaper.url}
|
||||
|
||||
if(current_user && (current_user.person == @person || current_user.contacts.receiving.where(:person_id => @person.id).first))
|
||||
extra_json = extra_json.merge({
|
||||
:location => @person.profile.location,
|
||||
:birthday => @person.profile.formatted_birthday,
|
||||
:bio => @person.profile.bio
|
||||
})
|
||||
end
|
||||
|
||||
render :json => public_json.merge(extra_json)
|
||||
}
|
||||
format.json { render :json => PersonPresenter.new(@person, current_user) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
34
app/presenters/person_presenter.rb
Normal file
34
app/presenters/person_presenter.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class PersonPresenter
|
||||
def initialize(person, current_user = nil)
|
||||
@person = person
|
||||
@current_user = current_user
|
||||
end
|
||||
|
||||
def as_json(options={})
|
||||
attrs = @person.as_api_response(:backbone).merge(
|
||||
{
|
||||
:wallpaper => @person.profile.wallpaper.url,
|
||||
:is_own_profile => is_own_profile
|
||||
})
|
||||
|
||||
if is_own_profile || person_is_following_current_user
|
||||
attrs.merge!({
|
||||
:location => @person.profile.location,
|
||||
:birthday => @person.profile.formatted_birthday,
|
||||
:bio => @person.profile.bio
|
||||
})
|
||||
end
|
||||
|
||||
attrs
|
||||
end
|
||||
|
||||
def is_own_profile
|
||||
@current_user.try(:person) == @person
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def person_is_following_current_user
|
||||
@current_user.contacts.receiving.where(:person_id => @person.id).first
|
||||
end
|
||||
end
|
||||
|
|
@ -3,8 +3,8 @@ Feature: Invitations
|
|||
|
||||
Scenario: Accepting an invitation
|
||||
When I visit alice's invitation code url
|
||||
Then I should see the "alice is excited" message
|
||||
# Then I should see the "alice is excited" message
|
||||
When I fill in the new user form
|
||||
And I press "Create my account!"
|
||||
And I press "Continue"
|
||||
Then I should see the "welcome to diaspora" message
|
||||
And I should be able to friend Alice
|
||||
|
|
|
|||
|
|
@ -183,7 +183,6 @@ When /^I fill in the new user form$/ do
|
|||
step 'I fill in "user_username" with "ohai"'
|
||||
step 'I fill in "user_email" with "ohai@example.com"'
|
||||
step 'I fill in "user_password" with "secret"'
|
||||
step 'I fill in "user_password_confirmation" with "secret"'
|
||||
end
|
||||
|
||||
And /^I should be able to friend Alice$/ do
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ describe HomeController do
|
|||
end
|
||||
|
||||
it "points to a user's profile page if a user is an admin without contacts" do
|
||||
alice.contacts.delete_all
|
||||
alice.contacts.destroy_all
|
||||
Role.add_admin(alice.person)
|
||||
get :show, :home => true
|
||||
response.should redirect_to(person_path(alice.person))
|
||||
end
|
||||
|
||||
it "points to the root_path if a user is an admin without contacts" do
|
||||
alice.contacts.delete_all
|
||||
alice.contacts.destroy_all
|
||||
Role.add_beta(alice.person)
|
||||
get :show, :home => true
|
||||
response.should redirect_to(person_path(alice.person))
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ describe PostsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe "next" do
|
||||
describe "#next" do
|
||||
before do
|
||||
sign_in alice
|
||||
#lets make a class and unit test it, because this is still not working
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
describe("app.pages.Profile", function(){
|
||||
beforeEach(function(){
|
||||
this.guid = 'abcdefg123'
|
||||
app.page = this.page = new app.pages.Profile({personId :this.guid });
|
||||
this.profile = factory.profile({personId: this.guid})
|
||||
app.page = this.page = new app.pages.Profile({model : this.profile });
|
||||
this.stream = this.page.stream
|
||||
});
|
||||
|
||||
it("fetches the profile of the user with the params from the router and assigns it as the model", function(){
|
||||
profile = new factory.profile()
|
||||
var profile = new factory.profile()
|
||||
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 model down to the post view", function(){
|
||||
it("passes the stream down to the canvas view", function(){
|
||||
expect(this.page.canvasView.model).toBeDefined()
|
||||
expect(this.page.canvasView.model).toBe(this.stream)
|
||||
});
|
||||
|
|
@ -30,6 +31,24 @@ describe("app.pages.Profile", function(){
|
|||
})
|
||||
|
||||
describe("rendering", function(){
|
||||
context("with no posts", function(){
|
||||
beforeEach(function(){
|
||||
this.profile.set({"full_name" : "Alice Waters", person_id : "889"})
|
||||
})
|
||||
|
||||
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)
|
||||
|
|
@ -94,6 +113,7 @@ describe("app.pages.Profile", function(){
|
|||
runs(function(){ expect(this.page.$(".canvas-frame").length).toBe(0) })
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
describe("edit mode", function(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue