diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 0cfa14815..720027b9c 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -19,29 +19,7 @@ %i.icon-time = time_ago_in_words(@post.created_at) + ' ago' - -#post-content - -- if current_user - #user-controls - = link_to "#", :class => "label", do - %i.icon-user.icon-white - - = link_to "#", :class => "label" do - %i.icon-heart.icon-white - - = link_to "#", :class => "label" do - %i.icon-plus.icon-white - - = link_to "#", :class => "label" do - %i.icon-retweet.icon-white - - = link_to "#", :class => "label", do - %i.icon-comment.icon-white - - -= link_to image_tag('arrow-left.png'), '#', :class => 'nav-arrow left', :id => 'forward' -= link_to image_tag('arrow-right.png'), '#', :class => 'nav-arrow right', :id => 'back' +#container #comment.modal.fade .modal-header diff --git a/config/assets.yml b/config/assets.yml index e33fd732f..337a5fd98 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -24,6 +24,7 @@ javascripts: - public/javascripts/app/views.js - public/javascripts/app/models/post.js - public/javascripts/app/models/* + - public/javascripts/app/pages/* - public/javascripts/app/collections/* - public/javascripts/app/views/stream_object_view.js - public/javascripts/app/views/content_view.js diff --git a/public/images/arrow.psd b/public/images/arrow.psd new file mode 100644 index 000000000..877750426 Binary files /dev/null and b/public/images/arrow.psd differ diff --git a/public/javascripts/app/app.js b/public/javascripts/app/app.js index 2ec6f7055..e92942473 100644 --- a/public/javascripts/app/app.js +++ b/public/javascripts/app/app.js @@ -3,6 +3,7 @@ var app = { models: {}, helpers: {}, views: {}, + pages: {}, user: function(userAttrs) { if(userAttrs) { return this._user = new app.models.User(userAttrs) } diff --git a/public/javascripts/app/pages/post-viewer.js b/public/javascripts/app/pages/post-viewer.js new file mode 100644 index 000000000..25284f120 --- /dev/null +++ b/public/javascripts/app/pages/post-viewer.js @@ -0,0 +1,55 @@ +app.pages.PostViewer = app.views.Base.extend({ + + templateName: "post-viewer", + + subviews : { + "#post-content" : "postView", + "#post-nav" : "navView", + "#post-feedback" : "feedbackView" + // "#post-author" : "authorView" + }, + + postView : function(){ + return new app.views.Post({ + model : this.model, + className : "loaded", + templateName : this.options.postTemplateName + }) + }, + + navView : function() { + return new app.views.PostViewerNav({ model : this.model }) + }, + + feedbackView : function() { + if(!window.app.user()) { return null } + return new app.views.PostViewerFeedback({ model : this.model }) + }, + + postRenderTemplate : function() { + this.setKeyMappings(); + }, + + setKeyMappings : function() { + var nextPostLocation = this.model.get("next_post"); + var previousPostLocation = this.model.get("previous_post"); + var doc = $(document); + + /* focus modal */ + doc.keypress(function(){ + $('#text').focus(); + $('#comment').modal(); + }); + + /* navagation hooks */ + doc.keydown(function(e){ + if (e.keyCode == 37 && nextPostLocation) { + window.location = nextPostLocation + + }else if(e.keyCode == 39 && previousPostLocation) { + window.location = previousPostLocation + } + }) + } + +}) diff --git a/public/javascripts/app/router.js b/public/javascripts/app/router.js index 6110eb869..ed4c1cd54 100644 --- a/public/javascripts/app/router.js +++ b/public/javascripts/app/router.js @@ -41,14 +41,13 @@ app.Router = Backbone.Router.extend({ singlePost : function(id) { new app.models.Post({id : id}).fetch({success : function(resp){ var postAttrs = resp.get("post"); - var templateName = resp.get("templateName"); - var view = new app.views.SinglePost({ + var page = new app.pages.PostViewer({ model : new app.models.Post(postAttrs), - templateName : templateName + postTemplateName : resp.get("templateName") }).render(); - $("#post-content").html(view.el); + $("#container").html(page.el); }}) } }); diff --git a/public/javascripts/app/templates/post-viewer-feedback.handlebars b/public/javascripts/app/templates/post-viewer-feedback.handlebars new file mode 100644 index 000000000..929defc37 --- /dev/null +++ b/public/javascripts/app/templates/post-viewer-feedback.handlebars @@ -0,0 +1,17 @@ +
+ + + + + + + + + + + + + + + +
diff --git a/public/javascripts/app/templates/post-viewer-nav.handlebars b/public/javascripts/app/templates/post-viewer-nav.handlebars new file mode 100644 index 000000000..2f823bd0f --- /dev/null +++ b/public/javascripts/app/templates/post-viewer-nav.handlebars @@ -0,0 +1,7 @@ + + + + + + + diff --git a/public/javascripts/app/templates/post-viewer.handlebars b/public/javascripts/app/templates/post-viewer.handlebars new file mode 100644 index 000000000..daa33ab8d --- /dev/null +++ b/public/javascripts/app/templates/post-viewer.handlebars @@ -0,0 +1,3 @@ +
+
+
diff --git a/public/javascripts/app/views/post_feedback_view.js b/public/javascripts/app/views/post_feedback_view.js new file mode 100644 index 000000000..a4bce1a6d --- /dev/null +++ b/public/javascripts/app/views/post_feedback_view.js @@ -0,0 +1,6 @@ +app.views.PostViewerFeedback = app.views.Base.extend({ + + templateName: "post-viewer-feedback" + +}) + diff --git a/public/javascripts/app/views/post_nav_view.js b/public/javascripts/app/views/post_nav_view.js new file mode 100644 index 000000000..14a66c835 --- /dev/null +++ b/public/javascripts/app/views/post_nav_view.js @@ -0,0 +1,19 @@ +app.views.PostViewerNav = app.views.Base.extend({ + + templateName: "post-viewer-nav", + + postRenderTemplate : function() { + var mappings = {"#forward" : "next_post", + "#back" : "previous_post"}; + + _.each(mappings, function(attribute, selector){ + this.setArrow(this.$(selector), this.model.get(attribute)) + }, this); + }, + + setArrow : function(arrow, loc) { + loc ? arrow.attr('href', loc) : arrow.remove() + } + +}) + diff --git a/public/javascripts/app/views/single_post_view.js b/public/javascripts/app/views/single_post_view.js deleted file mode 100644 index 055fbae81..000000000 --- a/public/javascripts/app/views/single_post_view.js +++ /dev/null @@ -1,69 +0,0 @@ -app.views.SinglePost = app.views.Post.extend({ - - /* SINGLE POST SHOULD BE BROKEN OUT INTO A PAGE VIEW!!!! */ - - className : "loaded", - - postRenderTemplate : function() { - /* nav should be a subview! and tested! (this is some prototyping stuff right here... */ - this.setNav(); - - /* post author info should be a subview! and tested! */ - this.setAuthor(); - - /* post author info should be a subview! and tested! */ - this.setFeedback(); - }, - - setNav : function() { - var mappings = {"#forward" : "next_post", - "#back" : "previous_post"}; - - _.each(mappings, function(attribute, selector){ - this.setArrow($(selector), this.model.get(attribute)) - }, this); - - this.setMappings(); - }, - - setArrow : function(arrow, loc) { - loc ? arrow.attr('href', loc) : arrow.remove() - }, - - setMappings : function() { - var nextPostLocation = this.model.get("next_post"); - var previousPostLocation = this.model.get("previous_post"); - var doc = $(document); - - /* focus modal */ - doc.keypress(function(event){ - $('#text').focus(); - $('#comment').modal(); - }); - - /* navagation hooks */ - doc.keydown(function(e){ - if (e.keyCode == 37 && nextPostLocation) { - window.location = nextPostLocation - - }else if(e.keyCode == 39 && previousPostLocation) { - window.location = previousPostLocation - } - }) - }, - - setAuthor : function() { - // author avatar - // time of post - // reshared via... (if appliciable) - }, - - setFeedback : function() { - // go back to profile (app.user()) - // liking - // following - // resharing - // commenting - } - -});