Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elipousson/ecc117177c30862bb146 to your computer and use it in GitHub Desktop.
Save elipousson/ecc117177c30862bb146 to your computer and use it in GitHub Desktop.
Script to embed RSS feed on Omeka Simple Page via @ebellempire
<div id="feed-container"></div>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("feeds", "1");</script>
<script>
function stripHTML(dirtyString) {
var container = document.createElement('div');
container.innerHTML = dirtyString;
return container.textContent || container.innerText;
}
jQuery(jQuery(window)).load(function(){
var feed = new google.feeds.Feed('http://baltimoreheritage.org/feed/');
feed.load(function (data) {
console.dir(data);
var excerpt=true;
var html='<h2 class="feed-title">Latest news</h2>';
jQuery.each( data.feed.entries, function(i, entry) {
html+='<h3 class="feed-item-title"><a target="_blank" href="'+entry.link+'">'+entry.title+'</a></h3>';
html+='<div class="feed-item-auth"> by: '+(entry.author ? entry.author : feed_title)+'</div>';
html+='<div class="feed-item-content">'+(excerpt ? stripHTML(entry.content).substring(0,500)+' <a target="_blank" href="'+entry.link+'">Read more...<a>' : entry.content)+'</div>';
});
jQuery('#feed-container').html(html);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment