
function yql_lookup(query, cb_function) {
    var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + '&format=json&diagnostics=true';

    //alert(url);

    $.getJSON(url, cb_function);
}

function look_up_news() {

    var feed_url = 'http://mediacloud.org/blog/feed/';

    //alert(google_url);
    yql_lookup("select * from rss where url = '" + feed_url + "'", function (response) {

        var results = response.query.results;

	var news_items = $('#news_items');

        //console.log(results);
        news_items.children().remove();
        news_items.html('');

        $.each(results.item, function (index, element) {
            var title = element.title;
            var link = element.link;

            news_items.append($('<a/>', {
                'href': link
            }).text(title)).append('<br/>');
        });

    });
}


function yql_lookup(query, cb_function) {
    var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + '&format=json&diagnostics=true';

    //alert(url);

    $.getJSON(url, cb_function);
}

function look_up_news() {

    // TEMPORARY HACK
    //mediacloud.org is password protected so we can't pull from it directly
    // instead we pull from 'https://blogs.law.harvard.edu/mediacloud2/feed/' and dynamically rewrite the URLs to point to mediacloud.org/blog;
    var feed_url = 'https://blogs.law.harvard.edu/mediacloud2/feed/';

    //alert(google_url);
    yql_lookup("select * from rss where url = '" + feed_url + "'", function (response) {

        var results = response.query.results;

	var news_items = $('#news_items');

        //console.log(results);
        news_items.children().remove();
        news_items.html('');

        $.each(results.item, function (index, element) {
            var title = element.title;
            var link = element.link;

	    link = link.replace('https://blogs.law.harvard.edu/mediacloud2/', 'http://www.mediacloud.org/blog/');
            news_items.append($('<a/>', {
                'href': link
            }).text(title)).append('<br/>');
        });

    });
}

Add work around for the mediacloud.org/blog page being password protected so we can still display the news dynamically on the front page.
Add work around for the mediacloud.org/blog page being password protected so we can still display the news dynamically on the front page.

