MS DC posts/new page init
This commit is contained in:
parent
f5fdb8ade1
commit
ab35f2bf3d
14 changed files with 83 additions and 4 deletions
|
|
@ -8,11 +8,17 @@ class PostsController < ApplicationController
|
||||||
before_filter :authenticate_user!, :except => :show
|
before_filter :authenticate_user!, :except => :show
|
||||||
before_filter :set_format_if_malformed_from_status_net, :only => :show
|
before_filter :set_format_if_malformed_from_status_net, :only => :show
|
||||||
|
|
||||||
|
layout 'post'
|
||||||
|
|
||||||
respond_to :html,
|
respond_to :html,
|
||||||
:mobile,
|
:mobile,
|
||||||
:json,
|
:json,
|
||||||
:xml
|
:xml
|
||||||
|
|
||||||
|
def new
|
||||||
|
render :text => "", :layout => true
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
key = params[:id].to_s.length <= 8 ? :id : :guid
|
key = params[:id].to_s.length <= 8 ? :id : :guid
|
||||||
|
|
||||||
|
|
@ -34,7 +40,7 @@ class PostsController < ApplicationController
|
||||||
format.xml{ render :xml => @post.to_diaspora_xml }
|
format.xml{ render :xml => @post.to_diaspora_xml }
|
||||||
format.mobile{render 'posts/show.mobile.haml'}
|
format.mobile{render 'posts/show.mobile.haml'}
|
||||||
format.json{ render :json => PostPresenter.new(@post, current_user).to_json }
|
format.json{ render :json => PostPresenter.new(@post, current_user).to_json }
|
||||||
format.any{render 'posts/show.html.haml', :layout => 'layouts/post'}
|
format.any{render 'posts/show.html.haml'}
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,6 @@
|
||||||
|
|
||||||
%body
|
%body
|
||||||
= flash_messages
|
= flash_messages
|
||||||
|
#container
|
||||||
|
|
||||||
= yield
|
= yield
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,3 @@
|
||||||
|
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= post_page_title @post
|
= post_page_title @post
|
||||||
|
|
||||||
#container
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ Diaspora::Application.routes.draw do
|
||||||
|
|
||||||
resources :status_messages, :only => [:new, :create]
|
resources :status_messages, :only => [:new, :create]
|
||||||
|
|
||||||
resources :posts, :only => [:show, :destroy] do
|
resources :posts, :only => [:show, :new, :destroy] do
|
||||||
resources :likes, :only => [:create, :destroy, :index]
|
resources :likes, :only => [:create, :destroy, :index]
|
||||||
resources :participations, :only => [:create, :destroy, :index]
|
resources :participations, :only => [:create, :destroy, :index]
|
||||||
resources :comments, :only => [:new, :create, :destroy, :index]
|
resources :comments, :only => [:new, :create, :destroy, :index]
|
||||||
|
|
|
||||||
7
features/step_definitions/trumpeter_steps.rb
Normal file
7
features/step_definitions/trumpeter_steps.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
When /^I trumpet$/ do
|
||||||
|
visit new_post_path
|
||||||
|
end
|
||||||
|
|
||||||
|
When /^I write "([^"]*)"$/ do |text|
|
||||||
|
fill_in :text, :with => text
|
||||||
|
end
|
||||||
12
features/trumpeter.feature
Normal file
12
features/trumpeter.feature
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
@javascript
|
||||||
|
Feature: Creating a new post
|
||||||
|
Background:
|
||||||
|
Given a user with username "bob"
|
||||||
|
And I sign in as "bob@bob.bob"
|
||||||
|
|
||||||
|
Scenario: Posting a public message
|
||||||
|
When I trumpet
|
||||||
|
And I write "Rectangles are awesome"
|
||||||
|
And I press "Share"
|
||||||
|
# When I go to the stream page
|
||||||
|
# Then I should see "Rectangles are awesome" as the first post in my stream
|
||||||
12
public/javascripts/app/pages/post-new.js
Normal file
12
public/javascripts/app/pages/post-new.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
app.pages.PostNew = app.views.Base.extend({
|
||||||
|
templateName : "post-new",
|
||||||
|
|
||||||
|
subviews : { "#new-post" : "postForm"},
|
||||||
|
|
||||||
|
initialize : function(){
|
||||||
|
console.log("In the page")
|
||||||
|
|
||||||
|
this.model = new app.models.Post()
|
||||||
|
this.postForm = new app.views.PostForm({model : this.model})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -16,6 +16,7 @@ app.Router = Backbone.Router.extend({
|
||||||
"followed_tags": "stream",
|
"followed_tags": "stream",
|
||||||
"tags/:name": "stream",
|
"tags/:name": "stream",
|
||||||
|
|
||||||
|
"posts/new" : "newPost",
|
||||||
"posts/:id": "singlePost",
|
"posts/:id": "singlePost",
|
||||||
"p/:id": "singlePost"
|
"p/:id": "singlePost"
|
||||||
},
|
},
|
||||||
|
|
@ -38,6 +39,11 @@ app.Router = Backbone.Router.extend({
|
||||||
$("#main_stream").html(app.page.el);
|
$("#main_stream").html(app.page.el);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
newPost : function(){
|
||||||
|
var page = new app.pages.PostNew();
|
||||||
|
$("#container").html(page.render().el)
|
||||||
|
},
|
||||||
|
|
||||||
singlePost : function(id) {
|
singlePost : function(id) {
|
||||||
var page = new app.pages.PostViewer({ id: id });
|
var page = new app.pages.PostViewer({ id: id });
|
||||||
$("#container").html(page.el);
|
$("#container").html(page.el);
|
||||||
|
|
|
||||||
4
public/javascripts/app/templates/post-form.handlebars
Normal file
4
public/javascripts/app/templates/post-form.handlebars
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<form class="new-post">
|
||||||
|
<label>text<textarea class="text"/></label>
|
||||||
|
<input type="submit" value="Share" class="btn-primary"></input>
|
||||||
|
</form>
|
||||||
1
public/javascripts/app/templates/post-new.handlebars
Normal file
1
public/javascripts/app/templates/post-new.handlebars
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<div id="new-post"></div>
|
||||||
12
public/javascripts/app/views/post_form_view.js
Normal file
12
public/javascripts/app/views/post_form_view.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
app.views.PostForm = app.views.Base.extend({
|
||||||
|
templateName : "post-form",
|
||||||
|
|
||||||
|
initialize : function(){
|
||||||
|
console.log("In the form")
|
||||||
|
},
|
||||||
|
|
||||||
|
postRenderTemplate: function(){
|
||||||
|
console.log("I'm getting rendered")
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
9
spec/javascripts/app/pages/post_new_spec.js
Normal file
9
spec/javascripts/app/pages/post_new_spec.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
describe("app.pages.PostNew", function(){
|
||||||
|
beforeEach(function(){
|
||||||
|
this.page = new app.pages.PostNew()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("renders", function(){
|
||||||
|
this.page.render();
|
||||||
|
})
|
||||||
|
});
|
||||||
10
spec/javascripts/app/views/post_form_spec.js
Normal file
10
spec/javascripts/app/views/post_form_spec.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
describe("app.views.PostForm", function(){
|
||||||
|
beforeEach(function(){
|
||||||
|
this.post = new app.models.Post();
|
||||||
|
this.view = new app.views.PostForm({model : this.post})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("renders", function(){
|
||||||
|
this.view.render()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -53,6 +53,7 @@ src_files:
|
||||||
- public/javascripts/app/views/content_view.js
|
- public/javascripts/app/views/content_view.js
|
||||||
- public/javascripts/app/views/*.js
|
- public/javascripts/app/views/*.js
|
||||||
- public/javascripts/app/views/**/*.js
|
- public/javascripts/app/views/**/*.js
|
||||||
|
- public/javascripts/app/pages/**/*.js
|
||||||
|
|
||||||
- public/javascripts/mobile.js
|
- public/javascripts/mobile.js
|
||||||
- public/javascripts/contact-list.js
|
- public/javascripts/contact-list.js
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue