在點部落Blog裡加入Google AJAX Search API,整合多個不同Blog文章的Search

最近在逛別人的Blog時,發現google有這一個功能....
利用google ajax search api可以search多個不同的網域的內容...
這個功能對我來說實在是太好用了...因為小弟有兩個主要的blog
透過這個功能可以將兩個blog的文章整合起來,在其中一個blog就可以search到兩個blog的文章...太好用了..而且是ajax

最近在逛別人的Blog時,發現google有這一個功能....

利用google ajax search api可以search多個不同的網域的內容...

這個功能對我來說實在是太好用了...因為小弟有兩個主要的blog

透過這個功能可以將兩個blog的文章整合起來,在其中一個blog就可以search到兩個blog的文章...太好用了..而且是ajax

小弟介紹如何在dotblogs加入此功能...

首先到,選項→組態設定→Custom HTML/Script→加入下列程式碼

<!-- google ajax search start -->
<link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet">
<link href="http://www.google.com/uds/css/gsearch_green.css" type="text/css" rel="stylesheet">
<style type="text/css">

    /*
     * Highlight -siteSearch in results area
     */


    /* 這行可以調整寬度 */    
    .gsc-control {
    width: 190px;
  overflow: hidden
    }

    .gs-result .gs-title,
    .gs-result .gs-title * {
  font-size: em;
    color: #;
    }

    .gsc-results .gsc-trailing-more-results,
    .gsc-results .gsc-trailing-more-results * {
    color: #;
    }

    .gs-result a.gs-visibleUrl,
    .gs-result .gs-visibleUrl {
    color: #;
    }

    .gs-result a.gs-clusterUrl,
    .gs-result .gs-clusterUrl {
    color: #;
    }

    .gsc-resultsbox-visible {
  display: table;
  width: 100%;
  overflow: hidden
    }



    /* bold the section header */
    .gsc-resultsRoot-siteSearch .gsc-title {
      font-weight : bold;
    }


    .gsc-resultsRoot-siteSearch .gsc-keeper {
      background-image : url(http://www.google.com/uds/css/orange_check.gif');
      font-weight : bold;
    }



    </style>

<script src="http://www.google.com/uds/api?file=uds.js&v=1.0" type="text/javascript"></script>

<script type="text/javascript">
    //<![CDATA[

    function OnLoad() {
      // Create a search control
      var searchControl = new GSearchControl();

      //點部落-F6 Team
      var siteSearch = new GwebSearch();
      siteSearch.setUserDefinedLabel("點部落F6 Team");
      siteSearch.setUserDefinedClassSuffix("siteSearch");
      siteSearch.setSiteRestriction("http://www.dotblogs.com.tw/puma/");
      searchControl.addSearcher(siteSearch);

      //藍色小舖-F6 Team
      var siteSearch = new GwebSearch();
      siteSearch.setUserDefinedLabel("藍色小舖F6 Team");
      siteSearch.setUserDefinedClassSuffix("siteSearch");
      siteSearch.setSiteRestriction("http://blog.blueshop.com.tw/hent");
      searchControl.addSearcher(siteSearch);

      // Establish a keep callback
      searchControl.setOnKeepCallback(null, DummyClipSearchResult);

      // tell the searcher to draw itself and tell it where to attach
      searchControl.draw(document.getElementById("searchcontrol"));

      // execute an inital search
      searchControl.execute("evonne");

    }


    function DummyClipSearchResult(result) {}

    GSearch.setOnLoadCallback(OnLoad);
    //]]>
</script>

<div id="searchcontrol">
</div>
<!-- google ajax search end -->

執行結果:

參考網址:

http://www.google.com/uds/samples/apidocs/helloworld.html

http://code.google.com/apis/ajaxsearch/web.html