From ab35f2bf3d83d245fa2833e5654afaeb1a33d293 Mon Sep 17 00:00:00 2001 From: Dennis Collinson Date: Tue, 6 Mar 2012 13:55:24 -0800 Subject: [PATCH] MS DC posts/new page init --- app/controllers/posts_controller.rb | 8 +++++++- app/views/layouts/post.html.haml | 1 + app/views/posts/show.html.haml | 2 -- config/routes.rb | 2 +- features/step_definitions/trumpeter_steps.rb | 7 +++++++ features/trumpeter.feature | 12 ++++++++++++ public/javascripts/app/pages/post-new.js | 12 ++++++++++++ public/javascripts/app/router.js | 6 ++++++ .../javascripts/app/templates/post-form.handlebars | 4 ++++ public/javascripts/app/templates/post-new.handlebars | 1 + public/javascripts/app/views/post_form_view.js | 12 ++++++++++++ spec/javascripts/app/pages/post_new_spec.js | 9 +++++++++ spec/javascripts/app/views/post_form_spec.js | 10 ++++++++++ spec/javascripts/support/jasmine.yml | 1 + 14 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 features/step_definitions/trumpeter_steps.rb create mode 100644 features/trumpeter.feature create mode 100644 public/javascripts/app/pages/post-new.js create mode 100644 public/javascripts/app/templates/post-form.handlebars create mode 100644 public/javascripts/app/templates/post-new.handlebars create mode 100644 public/javascripts/app/views/post_form_view.js create mode 100644 spec/javascripts/app/pages/post_new_spec.js create mode 100644 spec/javascripts/app/views/post_form_spec.js diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 667eb51a4..7fff7c82e 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -8,11 +8,17 @@ class PostsController < ApplicationController before_filter :authenticate_user!, :except => :show before_filter :set_format_if_malformed_from_status_net, :only => :show + layout 'post' + respond_to :html, :mobile, :json, :xml + def new + render :text => "", :layout => true + end + def show 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.mobile{render 'posts/show.mobile.haml'} 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 else diff --git a/app/views/layouts/post.html.haml b/app/views/layouts/post.html.haml index bc10e192a..b2a2e4d0a 100644 --- a/app/views/layouts/post.html.haml +++ b/app/views/layouts/post.html.haml @@ -50,5 +50,6 @@ %body = flash_messages + #container = yield diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index ad90ddc2e..5720b3364 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -4,5 +4,3 @@ - content_for :page_title do = post_page_title @post - -#container diff --git a/config/routes.rb b/config/routes.rb index 59fe1a027..f6e8771eb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,7 @@ Diaspora::Application.routes.draw do 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 :participations, :only => [:create, :destroy, :index] resources :comments, :only => [:new, :create, :destroy, :index] diff --git a/features/step_definitions/trumpeter_steps.rb b/features/step_definitions/trumpeter_steps.rb new file mode 100644 index 000000000..a3b32a59f --- /dev/null +++ b/features/step_definitions/trumpeter_steps.rb @@ -0,0 +1,7 @@ +When /^I trumpet$/ do + visit new_post_path +end + +When /^I write "([^"]*)"$/ do |text| + fill_in :text, :with => text +end diff --git a/features/trumpeter.feature b/features/trumpeter.feature new file mode 100644 index 000000000..28a8b0288 --- /dev/null +++ b/features/trumpeter.feature @@ -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 diff --git a/public/javascripts/app/pages/post-new.js b/public/javascripts/app/pages/post-new.js new file mode 100644 index 000000000..339f19424 --- /dev/null +++ b/public/javascripts/app/pages/post-new.js @@ -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}) + } +}) diff --git a/public/javascripts/app/router.js b/public/javascripts/app/router.js index 30d12cc7d..d56ece7c7 100644 --- a/public/javascripts/app/router.js +++ b/public/javascripts/app/router.js @@ -16,6 +16,7 @@ app.Router = Backbone.Router.extend({ "followed_tags": "stream", "tags/:name": "stream", + "posts/new" : "newPost", "posts/:id": "singlePost", "p/:id": "singlePost" }, @@ -38,6 +39,11 @@ app.Router = Backbone.Router.extend({ $("#main_stream").html(app.page.el); }, + newPost : function(){ + var page = new app.pages.PostNew(); + $("#container").html(page.render().el) + }, + singlePost : function(id) { var page = new app.pages.PostViewer({ id: id }); $("#container").html(page.el); diff --git a/public/javascripts/app/templates/post-form.handlebars b/public/javascripts/app/templates/post-form.handlebars new file mode 100644 index 000000000..4d5253c6a --- /dev/null +++ b/public/javascripts/app/templates/post-form.handlebars @@ -0,0 +1,4 @@ +
+