Commit d504bf45 authored by Daniel Grippi's avatar Daniel Grippi Committed by Dennis Collinson

add current user to body tag data field (hackity hack). add comment links to posts

parent 176963fd
......@@ -23,6 +23,7 @@ class Comment < ActiveRecord::Base
t.add :guid
t.add :text
t.add :author
t.add :created_at
end
......
......@@ -15,6 +15,7 @@ class Post < ActiveRecord::Base
t.add :id
t.add :guid
t.add :text
t.add :public
t.add :created_at
t.add :comments_count
t.add :last_three_comments
......
......@@ -42,6 +42,7 @@ class Services::Facebook < Service
end
def save_friends
return
url = "https://graph.facebook.com/me/friends?fields[]=name&fields[]=picture&access_token=#{URI.escape(self.access_token)}"
response = Faraday.get(url)
data = JSON.parse(response.body)['data']
......
......@@ -60,7 +60,8 @@
- if @person
%link{:rel => "alternate", :href => "#{@person.public_url}.atom", :type => "application/atom+xml", :title => "#{t('.public_feed', :name => @person.name)}"}
%body{:class => "#{yield(:body_class)}", 'data-current-user-metadata' => CGI::escape(current_user.person.as_api_response(:backbone).to_json) }
- metadata = user_signed_in? ? CGI::escape({:current_user => current_user.person.as_api_response(:backbone)}.to_json) : ""
%body{:class => "#{yield(:body_class)}", 'data-current-user-metadata' => metadata }
- unless @page == :logged_out
- flash.each do |name, msg|
......
<div id="<%= guid %>" class="stream_element">
<div class="right controls">
<a href="#" class="block_user control_icon">
<img src="/images/icons/ignoreuser.png">
</a>
<% if(author.id != current_user.id) { %>
<a href="#" class="block_user control_icon">
<img src="/images/icons/ignoreuser.png">
</a>
<% } %>
<a href="#" class="delete control_icon remove_post">
<img src="/images/deletelabel.png"/>
......@@ -37,14 +40,33 @@
</p>
<div class="info">
<span class="via">
via <%= provider_display_name %>
<% if(provider_display_name != null) { %>
<span class="via">
via <%= provider_display_name %>
-
</span>
<% } %>
<span class="post_scope">
<%= public === true ? "Public" : "Limited" %>
-
</span>
<a href="#" class="focus_comment_textarea">
Comment
</a>
</div>
<div class="comments">
<div class="comment_stream">
<ul class="comments" >
<ul class="show_comments <%= comments_count <= 3 ? 'hidden' : '' %>">
<li>
<a href="/posts/<%= id %>/comments" class="toggle_post_comments">
Show <%= comments_count - 3 %> more comments
</a>
</li>
</ul>
<ul class="comments">
<% _.each(last_three_comments, function(comment) { %>
<li id="<%= comment.guid %>" class="comment">
......@@ -74,9 +96,11 @@
</ul>
<div class="new_comment_form_wrapper">
<div class="new_comment_form_wrapper <%= comments_count > 0 ? '' : 'hidden' %>">
<form accept-charset="UTF-8" action="/posts/<%= id %>/comments" class="new_comment" data-remote="true" id="new_comment_on_<%= id %>" method="post">
<!-- <img alt="Bob Grimm" class="avatar" data-person_id="2" src="http://localhost:3000/images/user/wolf.jpg" title="Bob Grimm"> -->
<a href="/people/<%= current_user.id %>">
<img src="<%= current_user.avatar.small %>" class="avatar" data-person-id="<%= current_user.id %>"/>
</a>
<p>
<label for="comment_text_on_<%= id %>">Comment</label>
......
......@@ -15,6 +15,7 @@ javascripts:
- public/javascripts/vendor/underscore.js
- public/javascripts/vendor/backbone.js
- public/javascripts/app.js
- public/javascripts/models/*
- public/javascripts/collections/*
- public/javascripts/views/*
......
var App = {
Collections: {},
Models: {},
Views: {},
currentUser: function() {
return $.parseJSON(unescape($("body").data("current-user-metadata")));
}
};
......@@ -2,10 +2,5 @@ var Post = Backbone.Model.extend({
url: "/posts/:id",
intTime: function(){
return +new Date(this.get("created_at")) / 1000;
},
// should be moved into the view or something?
currentUserJSON: function(){
return $.parseJSON(unescape($("body").data("current-user-metadata")));
}
});
......@@ -18,13 +18,17 @@ $(function() {
},
appendPost: function(model) {
var post = $(this.template(model.toJSON()));
var post = $(this.template($.extend(
model.toJSON(),
App.currentUser()
)));
$(this.el).append(post);
Diaspora.BaseWidget.instantiate("StreamElement", post);
},
collectionFetched: function() {
this.$(".details time").timeago();
this.$("label").inFieldLabels();
this.$("#paginate").remove();
$(this.el).append($("<a>", {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment