Skip to content

Commit 77d101d

Browse files
committed
Merge branch 'master' into gh-pages
2 parents 6ea6080 + e8f3c88 commit 77d101d

File tree

4 files changed

+46
-13
lines changed

4 files changed

+46
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
## 0.4.4
2+
* Displayed comments on facebok posts
3+
14
## 0.4.3
2-
* Enforced posts option on facebook feed
5+
* Enforced posts option on facebook feed to limit the number of posts
36

47
## 0.4.2
58
* Added facebook support

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.3
1+
0.4.4

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363

6464
.facebook .created-at { display: block; }
6565

66+
67+
.comment { background: #f0f0f0; margin-bottom: 2px; clear: both; overflow: auto; }
68+
.comment .picture { float: left; }
69+
.comment .picture img { border: none; }
70+
.comment .comment-content { display: table-cell; padding-top: 8px; }
71+
6672

6773
</style>
6874
</head>

src/jquery.soliloquy.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,33 +202,27 @@ http://github.com/devth/soliloquy
202202
// DATE
203203
var raw_date = post.created_time;
204204

205-
var year = raw_date.substr(0,4);
206-
var month = raw_date.substr(5,2) - 1;
207-
var day = raw_date.substr(8,2);
208-
var hour = raw_date.substr(11,2);
209-
var minute = raw_date.substr(14,2);
210-
var second = raw_date.substr(17,2);
205+
parsed_date = parse_facebook_date( raw_date );
211206

212207
// console.log( new Date(year, month, day, hour, minute, second) );
213208
// console.log(year, month, day, hour, minute, second );
214209

215-
var date_string = build_date_string( new Date(year, month, day, hour, minute, second), settings.relative_dates );
210+
var date_string = build_date_string( parsed_date, settings.relative_dates );
216211

217212
var thumbnail = "http://graph.facebook.com/" + post.from.id + "/picture";
218213

219-
console.log( post.type );
220214
var html = '<div class="facebook post">';
221215
html += '<span class="thumbnail"><img src="' + thumbnail + '" alt="' + post.from.name + '" /></span>';
222216
html += '<div class="post_content">';
223217
html += '<span class="screen-name">' + post.from.name + '</span> ';
224218
if ( post.type == "status" ){
225219
html += processPost( post.message );
226220
} else if ( post.type == "link" ){
227-
if ( post.message ) html += '<span class="message">' + processPost(post.message) + '</span>';
221+
if ( post.message ) html += '<span class="message">' + processPost(parse_facebook_newlines(post.message)) + '</span>';
228222
if ( post.picture ){
229223
html += '<div class="link-picture"><a href="' + post.link + '"><img src="' + post.picture + '"></a></div>';
230224
}
231-
html += '<div class="link-content"><a href="' + post.link + '">' + post.name + '</a><span class="description">' + post.description + '</span></div>';
225+
if ( post.link && post.name ) html += '<div class="link-content"><a href="' + post.link + '">' + post.name + '</a><span class="description">' + post.description + '</span></div>';
232226
} else if ( post.type == "photo" ){
233227
html += '<span class="photo">';
234228
html += post.message;
@@ -244,8 +238,26 @@ http://github.com/devth/soliloquy
244238
html += date_string + "</span>";
245239

246240

247-
if ( post.comments ){
241+
if ( post.comments && $.isArray( post.comments.data ) ){
248242
html += '<div class="comments">';
243+
$.each( post.comments.data, function(index, comment){
244+
console.log( comment);
245+
246+
var commenter_thumb = "http://graph.facebook.com/" + comment.from.id + "/picture";
247+
248+
html += '<div class="comment">';
249+
html += '<span class="picture">';
250+
html += '<img src="' + commenter_thumb + '" />';
251+
html += '</span>';
252+
html += '<span class="comment-content">';
253+
html += '<span class="screen-name">' + comment.from.name + '</span> ';
254+
html += processPost( parse_facebook_newlines(comment.message) );
255+
html += '</span>';
256+
html += ' <span class="created-at">' + date_string + "</span>";
257+
258+
259+
html += '</div>';
260+
});
249261
html += '</div>';
250262
}
251263

@@ -255,6 +267,18 @@ http://github.com/devth/soliloquy
255267
return html;
256268
}
257269

270+
function parse_facebook_newlines( message ){
271+
return message.replace(/\n/g, '<br>');
272+
}
273+
function parse_facebook_date( raw_date ){
274+
var year = raw_date.substr(0,4);
275+
var month = raw_date.substr(5,2) - 1;
276+
var day = raw_date.substr(8,2);
277+
var hour = raw_date.substr(11,2);
278+
var minute = raw_date.substr(14,2);
279+
var second = raw_date.substr(17,2);
280+
return new Date(year, month, day, hour, minute, second);
281+
}
258282

259283

260284

0 commit comments

Comments
 (0)