diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 667eb51a49125d20f789e59612ce22f90b13955b..7fff7c82edc5c1eef2a1b5918206acd8249dd7ae 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 bc10e192a3b9cdcf2a425fb59708ec961c87d768..b2a2e4d0a043c769cbd1aad4df53784fe43de078 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 ad90ddc2ee1a49522bf9caa4dacd7c899506b433..5720b3364cf69a6165f2e541f0698630f39c4a2f 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 59fe1a02733216baa503055287eba984509852de..f6e8771eb3484c2a72a0641da873a62a2df9e122 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 0000000000000000000000000000000000000000..a3b32a59f7bd52999f38fccd7ac242630e435d77 --- /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 0000000000000000000000000000000000000000..28a8b0288044e25a1cfb32c609150157b39aedc0 --- /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 0000000000000000000000000000000000000000..339f1942439f5ff8427929613f532e78fedc2988 --- /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 30d12cc7db8d181a5c6c2eb61b6a14674f9d19df..d56ece7c7b6f8f4abec8156ccf8a045304371c1d 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 0000000000000000000000000000000000000000..4d5253c6ace9e64c5fcdc11e9f99c91777782ba2 --- /dev/null +++ b/public/javascripts/app/templates/post-form.handlebars @@ -0,0 +1,4 @@ +<form class="new-post"> + <label>text<textarea class="text"/></label> + <input type="submit" value="Share" class="btn-primary"></input> +</form> diff --git a/public/javascripts/app/templates/post-new.handlebars b/public/javascripts/app/templates/post-new.handlebars new file mode 100644 index 0000000000000000000000000000000000000000..444b344222e8783d3c5acc97ecbaed3478597203 --- /dev/null +++ b/public/javascripts/app/templates/post-new.handlebars @@ -0,0 +1 @@ +<div id="new-post"></div> \ No newline at end of file diff --git a/public/javascripts/app/views/post_form_view.js b/public/javascripts/app/views/post_form_view.js new file mode 100644 index 0000000000000000000000000000000000000000..b451ae48b0271efffaf2f80ce61b987c0570763b --- /dev/null +++ b/public/javascripts/app/views/post_form_view.js @@ -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") + } + +}); \ No newline at end of file diff --git a/spec/javascripts/app/pages/post_new_spec.js b/spec/javascripts/app/pages/post_new_spec.js new file mode 100644 index 0000000000000000000000000000000000000000..e0e13b39aa0bfb0372df6aca8fc4341780dfc2db --- /dev/null +++ b/spec/javascripts/app/pages/post_new_spec.js @@ -0,0 +1,9 @@ +describe("app.pages.PostNew", function(){ + beforeEach(function(){ + this.page = new app.pages.PostNew() + }) + + it("renders", function(){ + this.page.render(); + }) +}); \ No newline at end of file diff --git a/spec/javascripts/app/views/post_form_spec.js b/spec/javascripts/app/views/post_form_spec.js new file mode 100644 index 0000000000000000000000000000000000000000..03bcbe233750a17ebfd96699171a0f23e07c33e7 --- /dev/null +++ b/spec/javascripts/app/views/post_form_spec.js @@ -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() + }) +}) \ No newline at end of file diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml index 83fbd18746b400064e1c23f26198310d2948de28..9c29ffafdcb75669d609fdf66a40e7924053a54a 100644 --- a/spec/javascripts/support/jasmine.yml +++ b/spec/javascripts/support/jasmine.yml @@ -53,6 +53,7 @@ src_files: - public/javascripts/app/views/content_view.js - public/javascripts/app/views/*.js - public/javascripts/app/views/**/*.js + - public/javascripts/app/pages/**/*.js - public/javascripts/mobile.js - public/javascripts/contact-list.js