Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new RSS feed #224

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions js/jquery.socialfeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ if (typeof Object.create !== 'function') {
utility: {

getPosts: function(json) {
console.log(json);
if (json.query.count > 0 ){
$.each(json.query.results.feed, function(index, element) {
var post = new SocialFeedPost('rss', Feed.rss.utility.unifyPostData(index, element));
Expand All @@ -759,15 +758,41 @@ if (typeof Object.create !== 'function') {
if( item.creator !== undefined ){
post.author_name = item.creator;
}
post.message = item.title;
if ( item.title.content !== undefined ){
post.message = item.title.content;
} else if( item.title !== undefined ) {
post.message = item.title;
}
post.description = '';
if( item.summary !== undefined ){
HTMLcontent = '';
if ( item.content !== undefined ){
post.description = Utility.stripHTML(item.content.content);
HTMLcontent = item.content.content;
} else if( item.summary !== undefined && HTMLcontent == ""){
post.description = Utility.stripHTML(item.summary.content);
HTMLcontent = item.summary.content;
}
post.social_network = 'rss';
post.link = item.link.href;
if (options.show_media && item.thumbnail !== undefined ) {
post.attachment = '<img class="attachment" src="' + item.thumbnail.url + '" />';

if ( item.link.href !== undefined ){
post.link = item.link.href;
} else if ( item.link[0].href !== undefined ){
post.link = item.link[0].href;
}

if (options.show_media) {
if(item.thumbnail !== undefined && item.thumbnail.height !== "72") {
post.attachment = '<img class="attachment" src="' + item.thumbnail.url + '" />';
} else if (item.content[2] !== undefined) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey HartLarsson, thanks for your commit, helped me a lot, but on this line it can produce an "Uncaught TypeError: Cannot read property '2' of undefined".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i need time to review the code with latest wordpress feed, sorry

// wordpress place for Image
post.attachment = '<img class="attachment" src="' + item.content[2].url + '" />';
} else if (HTMLcontent) {
var imgurl = '';
var regexp = /<img[^>]+src\s*=\s*['"]([^'"]+)['"][^>]*>/g;
var match = regexp.exec(HTMLcontent);
if (match !== null) imgurl = match[1];
if (imgurl !== '' && imgurl !== undefined) post.attachment = '<img class="attachment" src="' + imgurl + '" />';
}
}
return post;
}
Expand Down