Skip to content

Instantly share code, notes, and snippets.

@psychobunny
Created February 21, 2014 08:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save psychobunny/9130467 to your computer and use it in GitHub Desktop.
Save psychobunny/9130467 to your computer and use it in GitHub Desktop.
[nodebb-script-rss] Embed an RSS feed from your blog as a NodeBB widget
<table id="feed" class="table table-striped"></table>
<script type="text/javascript">
var feed_url = 'http://blog.nodebb.org/rss';
jQuery.ajax({
type: "GET",
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeURIComponent(feed_url),
dataType: 'json',
success: function(data){
values = data.responseData.feed.entries;
var list = '', count = 0;
jQuery.each(values, function(index, item) {
var date = item.publishedDate.split(' ');
date.pop();
date = date.join(' ');
if (count >= 5) return;
list += "<tr><td><a href='" + item.link + "'>" + item.title + "</a> <br/><span class=''>" + date + "</span> </td></tr>";
count ++;
});
jQuery('#feed').html(list);
}
});
</script>
@psychobunny
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment