[nodebb-script-rss] Embed an RSS feed from your blog as a widget

NodeBB Plugins
  • 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

    latestposts.png

    (p.s. if you haven't yet, have a look at our new NodeBB Blog!)

  • wow, thank you so much!

  • 😉 trying to think of more things we can do with widgets 😛

  • Oh wow, I already wrote this. I was going to start writing one... rofl...

    @julian @baris we should put one of these synching our blog on our homepage as a widget 🙂

  • (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?

  • @psychobunny

    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!

  • On a side note and probably more important at this point than the actual game threads:
    Would it be possible to post the first entry in the RSS feed as a topic and then post the rest of the entries as replies?

  • 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 ....


Suggested Topics


  • 4 Votes
    21 Posts
    8k Views

    Yes, It was working before I updated it to the newest version of NodeBB.

  • 0 Votes
    8 Posts
    4k Views

    For anyone else that may find this post and is struggling, this step by step walkthrough really helped me out (at least regarding the php oauth2 server) http://bshaffer.github.io/oauth2-server-php-docs/cookbook/

  • 0 Votes
    15 Posts
    7k Views

    @RichG Embedly has a pretty decent API which you can potentially call from the NodeBB server instance - it will give you a fair bit of data from the page that you're trying to embed, in JSON format. Up to you how to use that data.

    Once I have a stable and scalable "vanilla" NodeBB, want to look at using their API on NodeBB.

  • 3 Votes
    54 Posts
    23k Views

    @efraimip I don't believe this specific plugin is supported anymore.

    Does a tool like this exist now, or is it in the works?

    There is nodebb-plugin-customize when you want to make quick modifications to templates or translations. Between that and Custom CSS in the ACP you can modify most aspects of your theme without creating a new theme or subtheme.

    99% of all posts in the "nodebb themes" forum are questions - not themes (I found actually only 1 single actual theme in searching many pages of that forum)

    Here are some themes I know of that I think are still maintained:

    nodebb-theme-persona (first party, default) nodebb-theme-lavender (first party) nodebb-theme-vanilla (first party) nodebb-theme-oxide nodebb-theme-slick

    I like allot of what nodebb offers but it seems less supported now - and less plugins available - than a few years ago.

    NodeBB has adopted many plugin features into core.

    How do we easily customize theme now? Without putting dev hours into it?

    I'm not sure what exactly you're referring to by "dev hours", but obviously you can't get something for nothing. Somebody needs to know how to use HTML and CSS, even with this defunct plugin.

  • 4 Votes
    25 Posts
    11k Views

    @GeneralLedger Not a problem, most plugins will follow the same style of just putting the URL in, however if different, it should be included in the ReadMe file of the plugin.