makeSearchCommand({
  name: "google-news",
  homepage: "http://www.radiantweb.net/ubiquity/",
  author: { name: "Ian Cabell", email: "ian@radiantweb.net"},
  contributors: ["Ian Cabell"],
  license: "CC SA 3.0",
  description: "Search Google News for your terms.",
  takes: {"search word(s)": noun_arb_text},
  baseurl: "http://ajax.googleapis.com/ajax/services/search/news",
  url: "http://news.google.com/news?q={QUERY}",
  icon: "http://news.google.com/favicon.ico",
  preview: function(pblock, directObject) {
    var searchTerm = directObject.text;
    pblock.innerHTML = CmdUtils.renderTemplate("Searches Google News for <b>${query}</b>", {query: searchTerm});
    var params = { v: "1.0", q: searchTerm };
    var tpl = "<style>.gnewsitem{width: 100%; background-color: #E5E5F5; padding: 5px;}.gnewsttl{font-size:1.2em; margin:-0.1em 0 0 0;padding:0px; font-family: times; display: block; color: #4D8DBE;} .gnewssubhead{font-size:.75em; font-weight:normal; display: block; color: #000000;} .gnewscontent{ font-size: .9em; font-family: arial; margin-bottom: 10px; color: #000000;}</style>" +
"{for result in results}" +
"<div class='gnewsitem'><div class='gnewsttl'><a href='${result.unescapedUrl}'>${result.title}</a></div>" +
"<div class='gnewssubhead'><span style='float: left;'>${result.publisher}</span><span style='float: right;'>${result.publishedDate}</span></div><br style='clear: both;'>" +
"<div class='gnewscontent'>${result.content}</div></div>" +
"{/for}";

    jQuery.get( this.baseurl, params, function(data) {
      var numToDisplay = 3;
      var results = data.responseData.results.splice( 0, numToDisplay );

      pblock.innerHTML = CmdUtils.renderTemplate( tpl,
						  {results:results}
						);
      }, "json");
  },
  execute: function(directObject) {
    Utils.openUrlInBrowser( this.url.replace( /{QUERY}/g, directObject.text) );
  }
});
