add current user to body tag data field (hackity hack). add comment links to posts
This commit is contained in:
parent
176963fdad
commit
d504bf4591
9 changed files with 52 additions and 15 deletions
|
|
@ -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|
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
<div id="<%= guid %>" class="stream_element">
|
||||
<div class="right controls">
|
||||
|
||||
<% 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,13 +40,32 @@
|
|||
</p>
|
||||
|
||||
<div class="info">
|
||||
<% 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="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) { %>
|
||||
|
|
@ -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/*
|
||||
|
|
|
|||
9
public/javascripts/app.js
Normal file
9
public/javascripts/app.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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>", {
|
||||
|
|
|
|||
Loading…
Reference in a new issue