[nodebb-script-rss] Embed an RSS feed from your blog as a widget
-
Copy the following code into an HTML widget. Modify
feed_url
to the RSS/XML feed of your blog/site.https://gist.github.com/psychobunny/9130467
(p.s. if you haven't yet, have a look at our new NodeBB Blog!)
-
trying to think of more things we can do with widgets
-
(At that point it kind of dawned on me that I've already built this before)
-
First off, I want to say how amazing NodeBB is. I've used every forum software you can think of and nothing compares to the foundation NodeBB, simply because of the 'no refresh required' when reading topics such as a live game thread where hundreds of users are posting while watching the game.
Anyways, my question is simple for you I hope!
I tried using this URL: http://www.nfl.com/liveupdate/scorestrip/ss.xml
as an HTML widget and nothing displays. I tried your example RSS feed and it worked fine. How would I get the other URL to work? My goal is to have it update and display the current NFL scores. -
Thanks!
Your XML doesn't seem to have that much data in it, from what I see. What is it supposed to look like?
-
Thanks for the reply! The NFL season hasn't actually started yet so those scores are from last year. It's supposed to just display the teams and scores such as BAL 14 - DEN 24. When I put the link in the XML, it displays nothing. I think I'm going to try to find another RSS feed to test with since that one does look funky.
My goal:
-
Automatically start a new topic for each game from an RSS feed.
-
When the score changes on the RSS feed, automatically post a new reply with the updated score OR automatically edit topic when score is updated.
I saw NodeBB and how it loads new replies in real-time. I knew that would be perfect for game threads like that. Seriously though, since I saw NodeBB for the first time this week, it has inspired me to start learning Javascript so I can help develop plugins because I think all forums should update in real-time. Kudos to everyone that has worked on this!
-
-
Here is my version of it. Check out the result on UEX start page. Feel free to use Google translate
<style> #nyheter .date { float: right; } #nyheter img { display: block; height: auto; margin: 10px 0px; max-width: 100%; } #nyheter iframe { max-width: 100%; } </style> <table id="nyheter" class="table table-striped"></table> <script type="text/javascript"> var rss_urls = [ 'http://www.fz.se/core/rss/fznews_rss20.xml', 'http://loading.se/rss.php?type=news', 'http://www.eurogamer.se/?format=rss&type=news', 'http://www.gamereactor.se/rss/rss.php?texttype=4' ]; var news_items = []; var protocol = document.location.protocol === "file:" ? "http:" : document.location.protocol; for (var i = 0; i < rss_urls.length; i++) { var rss_url = rss_urls[i]; jQuery.ajax({ type: "GET", url: protocol+'//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeURIComponent(rss_url), dataType: 'json', success: function(data) { values = data.responseData.feed.entries; var list = '', count = 0; jQuery.each(values, function(index, item) { if (count >= 5) { return; } var news_item = {}; var pubDate = item.publishedDate; var date = new Date(pubDate); var month = date.getMonth < 10 ? date.getMonth() : "0" + date.getMonth(); news_item.date = date.getFullYear() + "-" + month + "-" + date.getDate() + " " + date.getHours() + ":" + date.getHours(); news_item.datetime = date.getTime(); news_item.link = item.link; news_item.title = item.title; news_item.content = item.content; news_items.push(news_item); count++; }); update_table(); } }); } function update_table() { news_items.sort(function(a, b) { var keyA = new Date(a.datetime), keyB = new Date(b.datetime); // Compare the 2 dates if (keyA < keyB) return 1; if (keyA > keyB) return -1; return 0; }); var list = ""; for (var i = 0; i < news_items.length; i++) { var item = news_items[i]; list += "<tr><td><a href='" + item.link + "' target='_blank'>" + item.title + "</a><span class='date'''>" + item.date + "</span> <br/> <span>" + item.content + "</span><br/></td></tr>"; } jQuery('#nyheter').html(list); } </script>
Sharing is caring ....