<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1758489972701323316</id><updated>2024-10-25T05:36:50.315+08:00</updated><category term="Blog"/><category term="Feature"/><category term="Google"/><category term="Tag"/><category term="Cross Domain"/><category term="Javascript"/><category term="Search"/><category term="Tool"/><category term="HTML"/><category term="Template"/><title type='text'>國王的新衣</title><subtitle type='html'>邊做邊學‧學習整理</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-5179876272881419569</id><published>2008-04-17T19:57:00.000+08:00</published><updated>2008-04-17T19:58:53.988+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Blog"/><category scheme="http://www.blogger.com/atom/ns#" term="Feature"/><category scheme="http://www.blogger.com/atom/ns#" term="Google"/><category scheme="http://www.blogger.com/atom/ns#" term="Search"/><category scheme="http://www.blogger.com/atom/ns#" term="Tag"/><title type='text'>Linked CSE (Custom Search Engine)</title><content type='html'>&lt;p&gt;Google的&lt;a href=&quot;http://www.google.com/coop/docs/cse/&quot; target=&quot;_blank&quot;&gt;自訂搜尋引擎&lt;/a&gt;，讓使用者利用Google的資源打造自己的搜尋，設定檔可以放在Google上用代號連結，或是放在其他地方用url連結 (&lt;a href=&quot;http://googlecustomsearch.blogspot.com/2007/06/custom-search-engine-apis.html&quot; target=&quot;_blank&quot;&gt;Linked CSE&lt;/a&gt;)，使用Linked CSE可以在使用者端動態的改變設定檔及其連結，增加了很大的彈性。另外Google有提供一些工具，可以動態產生設定檔，例如&lt;a href=&quot;http://www.google.com/coop/docs/cse/tools.html&quot; target=&quot;_blank&quot;&gt;makecse&lt;/a&gt;可以讀取HTML、RSS、ATOM、OPML格式的檔案，掃描其中的連結，作為設定檔中的網域限制，來限制CSE的查詢範圍，Blogger in draft中的&lt;a href=&quot;http://bloggerindraft.blogspot.com/search/label/searchbox&quot; target=&quot;_blank&quot;&gt;search box&lt;/a&gt;的其中一部分，就是使用這個功能，提供範圍為blog中所有連結的查詢。&lt;/p&gt;
&lt;p&gt;可以用這個線上&lt;a href=&quot;http://www.google.com/coop/cse/onthefly&quot; target=&quot;_blank&quot;&gt;Demo&lt;/a&gt;來測試，試試在URL欄輸入feed的位置，會有什麼效果。&lt;/p&gt;
&lt;p&gt;Blogger Data API能產生符合多個標籤的文章的feed (使用summary post，而不是full post，以減少不必要的連結，max-results參數設成很大的數以取得所有符合的文章)，加上Linked CSE、makecse (參數設定pattern=exact)，雖然還有些缺陷，但是可以做出多標籤文章中的關鍵字查詢 (Multiple labels or tags keyword search)，當文章越來越多，若是標籤有分類好，這個功能將來也許會有用處。&lt;/p&gt;
&lt;div class=&quot;fullpost&quot;&gt;
&lt;p&gt;這個方法的缺陷在於：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;因為makecse本身的功能，會多出一些網站 (feed中多餘的資訊，或是文章摘要中的連結)，目前一般只會多一個，例如傳入http://happytemplate.blogspot.com/feeds/posts/summary/-/Javascript/Cross%20Domain這個feed，&lt;a href=&quot;http://www.google.com/cse/tools/makecse?pattern=exact&amp;amp;url=happytemplate.blogspot.com%2Ffeeds%2Fposts%2Fsummary%2F-%2FJavascript%2FCross%20Domain&quot; target=&quot;_blank&quot;&gt;產生的設定檔&lt;/a&gt;會多出happytemplate.blogspot.com/search/label/Javascript。&lt;br /&gt;
(非本網誌的連結可以用搜尋運算子site:來排除，使用Google AJAX Search API的話，可以用&lt;a href=&quot;http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GSearch&quot; target=&quot;_blank&quot;&gt;setQueryAddition()&lt;/a&gt;在幕後加入。若要完全解決多出來的一個網站，需要用其他方法動態產生設定檔。)&lt;/li&gt;
&lt;li&gt;目前只有&lt;a href=&quot;http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GwebSearch&quot; target=&quot;_blank&quot;&gt;web search&lt;/a&gt;有此功能，&lt;a href=&quot;http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GblogSearch&quot; target=&quot;_blank&quot;&gt;blog search&lt;/a&gt;還沒有，差別在於文章本身之外的內容也可能會被搜尋到，例如在側邊欄中的東西。&lt;/li&gt;
&lt;li&gt;因為設定檔是動態產生，所以會要多等一下，若是使用Google AJAX search control，通常第一次搜尋，會有提示訊息要你過幾秒再按一次。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;使用&lt;a href=&quot;http://code.google.com/apis/ajaxsearch/documentation/&quot; target=&quot;_blank&quot;&gt;Google AJAX Search API&lt;/a&gt;做了以上的功能放在側邊欄，介面使用其中的&lt;a href=&quot;http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GSearchControl&quot; target=&quot;_blank&quot;&gt;google.search.searchControl&lt;/a&gt;，沒有多作修改。&lt;/p&gt;
&lt;/div&gt;&lt;!-- end of fullpost --&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/5179876272881419569/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2008/04/linked-cse-custom-search-engine.html#comment-form' title='3 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/5179876272881419569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/5179876272881419569'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2008/04/linked-cse-custom-search-engine.html' title='Linked CSE (Custom Search Engine)'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-666014143482745421</id><published>2008-04-14T05:23:00.002+08:00</published><updated>2008-11-21T17:41:40.453+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Feature"/><category scheme="http://www.blogger.com/atom/ns#" term="Tag"/><title type='text'>Label Cloud Online Test</title><content type='html'>標籤雲的基本原理很簡單，就是改變一下CSS而已。
&lt;div class=&quot;fullpost&quot;&gt;
Blogger中的標籤格式大致如下：
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;&amp;lt;div&amp;gt;
  &amp;lt;ul&amp;gt;
    &amp;lt;li&amp;gt;&amp;lt;a&amp;gt;AAA&amp;lt;/a&amp;gt;&amp;lt;span&amp;gt;(2)&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;
    &amp;lt;li&amp;gt;&amp;lt;a&amp;gt;BBB&amp;lt;/a&amp;gt;&amp;lt;span&amp;gt;(1)&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;/ul&amp;gt;
&amp;lt;/div&amp;gt;&lt;/pre&gt;
只要將&amp;lt;li&amp;gt;設成display:inline，就會變成橫向表示，IE上要使標籤換行，還要在外面的區塊加上word-wrap:break-word (不知道是否有其他方法)。文章數的部分可依需要改變，例如是否顯示及顏色大小等。接下來就是依照標籤的文章數將標籤的顏色大小加以改變，顏色加在&amp;lt;a&amp;gt;上，文字大小加在&amp;lt;li&amp;gt;上 (好像這樣line-height才會有用)。&lt;br /&gt;
依照文章數改變style一般使用以下的方法，以log(文章數)/log(最大文章數)來做加權：&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;weightStyle( min, max, count, maxCount ) {
  if (maxCount &amp;lt;= 1 || min === max ) {
    return max;
  } else if (min &amp;lt; max) {
    return min + Math.floor(Math.log(count) * (max-min) / Math.log(maxCount));
  } else {
    return min - Math.floor(Math.log(count) * (min-max) / Math.log(maxCount));
  }
}
&lt;/pre&gt;
加權的方式可以自己做合理的改變，例如想要靠近代表最小值的顏色多一點，可以依照比例縮小加權用的文章數：&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;if (count &amp;lt; maxCount*0.66) {
  count = (count-1)*0.3 + 1;
}
&lt;/pre&gt;
&lt;a href=&quot;http://happy-blog.googlecode.com/svn/trunk/demo/LabelCloudColorDemo.html&quot; target=&quot;_blank&quot;&gt;標籤雲的線上測試&lt;/a&gt;：用來選擇自己喜歡的顏色及大小範圍、加權方式，可以設定標籤數、最大文章數，按下Refresh按鈕重繪。繪圖使用jquery plugin：&lt;a href=&quot;http://code.google.com/p/flot/&quot; target=&quot;_blank&quot;&gt;flot&lt;/a&gt;，顏色選擇器使用yui color picker，flot使用&lt;a href=&quot;http://developer.mozilla.org/en/docs/Canvas_tutorial&quot; target=&quot;_blank&quot;&gt;canvas&lt;/a&gt;繪圖，因為IE不支援，所以需要&lt;a href=&quot;http://excanvas.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;ExploreCanvas&lt;/a&gt; (動態載入ExploreCanvas的話，flot繪圖會有問題，目前原因不明)，祝大家找到自己喜歡的標籤雲。
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/666014143482745421/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2008/04/label-cloud-online-test.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/666014143482745421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/666014143482745421'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2008/04/label-cloud-online-test.html' title='Label Cloud Online Test'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-763078464272384044</id><published>2008-01-15T18:00:00.004+08:00</published><updated>2008-04-18T15:32:26.664+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cross Domain"/><category scheme="http://www.blogger.com/atom/ns#" term="Google"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>Google AJAX Feed API</title><content type='html'>&lt;p&gt;Google.com serves as a proxy to the outside feeds。&lt;/p&gt;
&lt;div class=&quot;fullpost&quot;&gt;
&lt;p&gt;&lt;a href=&quot;http://code.google.com/apis/ajaxfeeds/&quot; target=&quot;_blank&quot;&gt;Google AJAX Feed API&lt;/a&gt;是&lt;a href=&quot;http://code.google.com/apis/ajax/&quot; target=&quot;_blank&quot;&gt;Google AJAX API&lt;/a&gt;的一個分支，簡單來說就是連到Google來取得feed，本質上仍是使用script tag的方式突破same-origin policy取得資料。&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;說明上說要先申請一個&lt;a href=&quot;http://code.google.com/apis/ajaxfeeds/signup.html&quot; target=&quot;_blank&quot;&gt;Google API key&lt;/a&gt;，雖然要輸入使用的URL（&lt;a href=&quot;http://code.google.com/support/bin/answer.py?answer=56505&amp;topic=10021&quot; target=&quot;_blank&quot;&gt;說明&lt;/a&gt;上說在此URL下所有的子目錄都可以使用，且可以用不同的URL申請），但是我用部落格申請的key，在個人電腦上也可以用，好像並沒有限制，甚至沒有key也可以用。 &lt;/li&gt;
  &lt;li&gt;依照&lt;a href=&quot;http://code.google.com/apis/ajaxfeeds/documentation/&quot; target=&quot;_blank&quot;&gt;Developer&#39;s Guide&lt;/a&gt;的說明，使用起來非常直覺簡單。 &lt;/li&gt;
  &lt;li&gt;有提供JSON、XML、Conbined JSON/XML三種資料格式，&lt;a href=&quot;http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON&quot; target=&quot;_blank&quot;&gt;JSON格式&lt;/a&gt;將RSS或Atom的部分常用元素轉成對應的欄位，並統一名稱，並沒有全部轉換，XML格式可以使用google.feeds.getElementsByTagNameNS來取得擴充的資料。 &lt;/li&gt;
  &lt;li&gt;feed資料由crawler（Feedfetcher）取得，所以不一定是最新的。 &lt;/li&gt;
  &lt;li&gt;可以設定取得資料的數量，預設是4個。&lt;/li&gt;
  &lt;li&gt;對於一般的資料顯示，有&lt;a href=&quot;http://code.google.com/apis/ajaxfeeds/documentation/reference.html#FeedControl&quot; target=&quot;_blank&quot;&gt;FeedControl&lt;/a&gt;可以直接用，另外還有提供一些成品可以套用（請參考&lt;a href=&quot;http://code.google.com/apis/ajaxfeeds/examples.html&quot; target=&quot;_blank&quot;&gt;Example&lt;/a&gt;、&lt;a href=&quot;http://googleajaxsearchapi.blogspot.com/&quot; target=&quot;_blank&quot;&gt;Blog&lt;/a&gt;）。 &lt;/li&gt;
  &lt;li&gt;甚至可以做feed的&lt;a href=&quot;http://code.google.com/apis/ajaxfeeds/documentation/reference.html#findFeeds&quot; target=&quot;_blank&quot;&gt;查詢及探知&lt;/a&gt;。 &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;範例&lt;/h3&gt;
&lt;pre name=&quot;code&quot; class=&quot;javascript&quot;&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://www.google.com/jsapi&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
google.load(&amp;quot;feeds&amp;quot;, &amp;quot;1&amp;quot;);

function initialize() {
  var feed = new google.feeds.Feed(&amp;quot;http://api.flickr.com/services/feeds/photos_public.gne?tags=羅平,油菜花,sunset&amp;amp;tagmode=all&amp;quot;);
  feed.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
  feed.load(function(result) {
    if (!result.error) {
      var div = document.getElementById(&amp;quot;flickr photos&amp;quot;);
      for (var i = 0; i &amp;lt; result.feed.entries.length; i++) {
        var entry = result.feed.entries[i];
        var img = document.createElement(&amp;quot;img&amp;quot;);
        var imgLink = google.feeds.getElementsByTagNameNS(entry.xmlNode, &amp;quot;http://www.w3.org/2005/Atom&amp;quot;, &amp;quot;link&amp;quot;)[2];
        img.setAttribute(&amp;quot;src&amp;quot;, imgLink.getAttribute(&amp;quot;href&amp;quot;));
        img.setAttribute(&amp;quot;title&amp;quot;, entry.title);
        img.setAttribute(&amp;quot;width&amp;quot;, &amp;quot;200&amp;quot;);
        img.setAttribute(&amp;quot;height&amp;quot;, &amp;quot;116&amp;quot;);
        var a = document.createElement(&amp;quot;a&amp;quot;);
        a.setAttribute(&amp;quot;href&amp;quot;, entry.link);
        a.setAttribute(&amp;quot;target&amp;quot;,&amp;quot;_blank&amp;quot;);
        a.appendChild(img);
        div.appendChild(a);
      }
    }
  });
}

google.setOnLoadCallback(initialize);
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;div id=&quot;flickr photos 2&quot;&gt;&lt;/div&gt;
&lt;h3&gt;動態載入&lt;sup&gt;&lt;span style=&quot;color:red&quot;&gt;updated on 2008-04-18&lt;/span&gt;&lt;/sup&gt;&lt;/h3&gt;
&lt;p&gt;基本上使用Google AJAX API loader載入所需的模組分為兩個階段：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span class=&quot;javascript&quot;&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://www.google.com/jsapi&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;  建立google、google.loader模組及相關函式&lt;/span&gt;。&lt;/li&gt;
&lt;li&gt;使用google.load(moduleName, moduleVersion, optionalSettings)載入所需要的AJAX API模組，例如google.load(&amp;quot;feeds&amp;quot;,&amp;quot;1&amp;quot;)載入google.feeds模組&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Google對這兩個階段都提供了動態載入的支援 (參考：&lt;a href=&quot;http://google-code-updates.blogspot.com/2008/03/how-we-improved-performance-on-google.html&quot; target=&quot;_blank&quot;&gt;blog&lt;/a&gt;、&lt;a href=&quot;http://code.google.com/apis/ajax/documentation/#Dynamic&quot; target=&quot;_blank&quot;&gt;doc&lt;/a&gt;)：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;加上callback參數，動態插入&lt;span class=&quot;javascript&quot;&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://www.google.com/jsapi&amp;amp;callback=&lt;em&gt;YOUR_CALLBACK&lt;/em&gt;&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;，載入完成後會執行所指定的回呼函式。&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;傳入callback參數，google.load(..., ..., {&amp;quot;callback&amp;quot;: &lt;em&gt;YOUR_CALLBACK&lt;/em&gt;})會使用動態插入script tag的方式載入模組，完成後會執行所指定的回呼函式。&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;&lt;!-- end of fullpost --&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
if (Happy.Blog.pageType &amp;&amp; Happy.Blog.pageType() == &quot;item&quot;) {
  Happy.Example = Happy.Example || {};
  
  Happy.Example.doFeedLoad = function() {
    var feed = new google.feeds.Feed(&quot;http://api.flickr.com/services/feeds/photos_public.gne?tags=羅平,油菜花,sunset&amp;tagmode=all&quot;);
    feed.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
    feed.load(function(result) {
      if (!result.error) {
        var div = document.getElementById(&quot;flickr photos 2&quot;);
        for (var i = 0; i &lt; result.feed.entries.length; i++) {
          var entry = result.feed.entries[i];
          var img = document.createElement(&quot;img&quot;);
          var imgLink = google.feeds.getElementsByTagNameNS(entry.xmlNode, &quot;http://www.w3.org/2005/Atom&quot;, &quot;link&quot;)[2];
          img.setAttribute(&quot;src&quot;, imgLink.getAttribute(&quot;href&quot;));
          img.setAttribute(&quot;title&quot;, entry.title);
          img.setAttribute(&quot;width&quot;, &quot;200&quot;);
          img.setAttribute(&quot;height&quot;, &quot;116&quot;);
          var a = document.createElement(&quot;a&quot;);
          a.setAttribute(&quot;href&quot;, entry.link);
          a.setAttribute(&quot;target&quot;,&quot;_blank&quot;);
          a.appendChild(img);
          div.appendChild(a);
        }//end of for
      }//end of if
    });//end of feed.load
  };
  
  Happy.Example.doGoogleLoad = function() {
    google.load(&quot;feeds&quot;, &quot;1&quot;, { callback: Happy.Example.doFeedLoad, nocss: true });
  };
  
  Happy.Example.doExample = function(){ 
    var scriptUrls = [&quot;http://www.google.com/jsapi?callback=Happy.Example.doGoogleLoad&quot;];
    var scriptOptions = {};
    var ScriptTransaction = YAHOO.util.Get.script(scriptUrls,scriptOptions);
  };
  
  $(document).ready(Happy.Example.doExample);
}//end of if
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/763078464272384044/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2008/01/google-ajax-feed-api.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/763078464272384044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/763078464272384044'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2008/01/google-ajax-feed-api.html' title='Google AJAX Feed API'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-6439129364136506499</id><published>2008-01-13T11:21:00.002+08:00</published><updated>2008-04-14T05:06:40.112+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Blog"/><category scheme="http://www.blogger.com/atom/ns#" term="Feature"/><category scheme="http://www.blogger.com/atom/ns#" term="Google"/><category scheme="http://www.blogger.com/atom/ns#" term="Search"/><category scheme="http://www.blogger.com/atom/ns#" term="Tag"/><title type='text'>Multiple labels or tags search</title><content type='html'>&lt;p&gt;目前很多網站及部落格都有提供使用標籤來分類文章的功能，對於以網頁提供服務的方式，這是傳統目錄分類方式的合理替代品。在瀏覽部落格時，常會想要找出符合多個標籤的文章，但網站上通常都沒有明確的說明如何做到，只把標籤當作類似單層的目錄來使用。&lt;/p&gt;  &lt;div class=&quot;fullpost&quot;&gt;   &lt;p&gt;以下是我目前知道的多標籤查詢方法：&lt;/p&gt;    &lt;h3&gt;1. &lt;a title=&quot;Technorati&quot; href=&quot;http://technorati.com/&quot; target=&quot;_blank&quot;&gt;Technorati&lt;/a&gt;&lt;/h3&gt;    &lt;p&gt;在 Advanced Serch 中，Tag Search 好像可以做多個標籤邏輯組合的搜尋（使用AND、OR、NOT，空白似乎代表AND，標籤中有空白的話可用雙引號「&amp;quot;」將標籤包起來），但是介面上缺少只搜尋某個網站文章的功能，但是上面的 Keyword Search 卻有這項功能，使用的參數名稱是from，於是試著自己加看看，結果竟然成功了。&lt;/p&gt;    &lt;p&gt;例如要搜尋 &lt;a title=&quot;Ajaxian.com&quot; href=&quot;http://ajaxian.com/&quot; target=&quot;_blank&quot;&gt;Ajaxian.com&lt;/a&gt; 上包含 jQuery 和 Prototype 標籤的文章（標籤的大小寫好像無關，這點跟一些部落格上的查詢好像有差），可以在網址列上輸入 &lt;a href=&quot;http://technorati.com/tag/jQuery+AND+prototype?authority=n&amp;amp;language=n&amp;amp;from=http://ajaxian.com/&quot;&gt;http://technorati.com/tag/jQuery+AND+prototype?authority=n&amp;amp;language=n&amp;amp;from=http://ajaxian.com/&lt;/a&gt; （中間用 jQuery+prototype 也可以）。&lt;/p&gt;    &lt;p&gt;&lt;a href=&quot;http://picasaweb.google.com/siyeh0407/Blog/photo#5185678312689625442&quot;&gt;&lt;img src=&quot;http://lh6.google.com/siyeh0407/R_c681NP6WI/AAAAAAAAAJs/GIUFVZXvwfE/s800/Technorati%20multi%20tags%20search.jpg&quot;/&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;可惜的是查詢結果的 feed 及網站所提供的 &lt;a href=&quot;http://technorati.com/developers/api/tag.html&quot; target=&quot;_blank&quot;&gt;Tag Query API&lt;/a&gt; 無法用上面的參數得到限制網站的結果，不過或許還有隱藏秘技沒被發現，有了這些資訊，要自己做一個多標籤限制網站的Technorati搜尋介面應該不難。&lt;/p&gt;    &lt;p&gt;另外有的部落格較舊的文章在 Technorati 上找不到。（ps. 關於 Technorati 有一些問題，例如如何與部落格同步增減標籤及文章，或著如何以人工方式做到，如果有人知道希望能分享一下）&lt;/p&gt;    &lt;h3&gt;2. &lt;a href=&quot;http://code.google.com/apis/blogger/developers_guide_protocol.html#retrieving_with_query&quot; target=&quot;_blank&quot;&gt;Blogger Data API&lt;/a&gt;（for &lt;a href=&quot;http://www.blogger.com/&quot; target=&quot;_blank&quot;&gt;Blogger.com&lt;/a&gt; 的 blog ）&lt;/h3&gt;    &lt;p&gt;Blogger Data API 是 &lt;a href=&quot;http://code.google.com/apis/gdata/&quot; target=&quot;_blank&quot;&gt;Google Data API&lt;/a&gt; 的一個分支，提供以 feed 的格式存取 blog 資料的功能，其中包括查詢多個標籤文章的功能，例如要查詢本站包含 Javascript 和 Cross Domain 標籤的文章，可以輸入 &lt;a href=&quot;http://happytemplate.blogspot.com/feeds/posts/summary/-/Javascript/Cross%20Domain&quot;&gt;http://happytemplate.blogspot.com/feeds/posts/summary/-/Javascript/Cross%20Domain&lt;/a&gt;。&lt;/p&gt;    &lt;p&gt;要注意的是標籤的大小寫要一致，並且要經過 UTF-8 編碼，目前只支援 AND 的功能，用「/」表示。另外網頁上所列的查詢參數有一些錯誤，orderby 的值可以是 published（發佈）或 updated（更新），updated-min 和 updated-max 要與 orderby=updated 一起用才會有效，日期時間的值似乎不能加後面的時區（與 &lt;a href=&quot;http://code.google.com/apis/gdata/reference.html#Queries&quot; target=&quot;_blank&quot;&gt;Google Data API&lt;/a&gt; 上說的不一樣），以上這些可在討論群組中找到。&lt;/p&gt;    &lt;p&gt;利用這些資訊，練習寫了一個 Multiple labels search，放在側邊欄：&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;多個標籤的 AND 以「/」表示，標籤與/之間不能有空白，例如：Javascript/Cross Domain &lt;/li&gt;      &lt;li&gt;本站查詢可以從下方標籤雲以拖拉的方式輸入 &lt;/li&gt;      &lt;li&gt;可以查詢其他 Blogger.com 的 blog &lt;/li&gt;      &lt;li&gt;日期格式為YYYY-MM-DD，會跳出月曆方便選擇，不接受時間 &lt;/li&gt;      &lt;li&gt;為了方便，日期範圍統一依照排序方式為發佈日期或更新日期 &lt;/li&gt;      &lt;li&gt;顯示的日期時間以查詢目標網站的時區為主，不做轉換 &lt;/li&gt;   &lt;/ul&gt;    &lt;p&gt;程式方面的感想：&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;使用 dynamic script sag 及 JSONP 方式取得資料，若是查詢失敗或產生的網址有錯，script tag 的 onload 事件好像不會觸發，所以使用 timer 來刪除失敗時的 script tag，不知道是否有更好的方法，另外不知是否有辦法取得 script tag 所載入的內容。 &lt;/li&gt;      &lt;li&gt;IE 真的很難搞，連簡單的產生並設定 DOM 物件的屬性的都會有問題，根據網路上的討論，似乎短時間內還不會改變。 &lt;/li&gt;      &lt;li&gt;放在 Google project hosting 的 download 中的 css 檔似乎無法在網頁中直接連結，還不知道原因。 &lt;/li&gt;      &lt;li&gt;會再用 &lt;a href=&quot;http://code.google.com/apis/ajaxfeeds/&quot; target=&quot;_blank&quot;&gt;Google AJAX Feed API&lt;/a&gt; 試試看。 &lt;/li&gt;      &lt;li&gt;&lt;a href=&quot;http://pipes.yahoo.com/pipes/&quot; target=&quot;_blank&quot;&gt;Yahoo Pipes&lt;/a&gt; 的 &lt;a href=&quot;http://pipes.yahoo.com/pipes/docs?doc=operators#Filter&quot; target=&quot;_blank&quot;&gt;Filter operator&lt;/a&gt; 也可以用來過濾標籤，但是對於 Atom 格式的 feed 會有問題，未深入研究，不知怎樣將參數導入 Filter operator。 &lt;/li&gt;   &lt;/ul&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/6439129364136506499/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2008/01/multiple-labels-or-tags-search.html#comment-form' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/6439129364136506499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/6439129364136506499'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2008/01/multiple-labels-or-tags-search.html' title='Multiple labels or tags search'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-4444222663082522722</id><published>2007-11-14T14:24:00.005+08:00</published><updated>2008-04-14T04:49:13.950+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cross Domain"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>JSONP</title><content type='html'>&lt;p&gt;The script tag method for cross-domain data fetching: JSON with Padding, or simply &lt;b&gt;JSONP&lt;/b&gt;. - &lt;a href=&quot;http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/&quot; target=&quot;_blank&quot;&gt;Bob Ippolito&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;fullpost&quot;&gt;
&lt;h3&gt;緣由&lt;/h3&gt;
&lt;p&gt;為了安全，瀏覽器中的javascript不能存取位在不同domain的資料，這稱做&lt;a href=&quot;http://en.wikipedia.org/wiki/Same_origin_policy&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;same-origin policy&lt;/b&gt;&lt;/a&gt;。&lt;a href=&quot;http://taossa.com/index.php/2007/02/08/same-origin-policy/&quot; target=&quot;_blank&quot;&gt;Same-Origin Policy Part 1: Why we’re stuck with things like XSS and XSRF/CSRF&lt;/a&gt;中說的很清楚：&lt;/p&gt;
&lt;blockquote&gt;Put simply, same-origin prevents a document or script loaded from one site of origin from manipulating properties of or communicating with a document loaded from another site of origin. In this case the term origin refers to the domain name, port, and protocol of the site hosting the document. The following list covers the major actions that cause the browser to check access against the same-origin policy:
&lt;ul&gt; 
&lt;li&gt;manipulating browser windows&lt;/li&gt;
&lt;li&gt;URLs requested via the &lt;a href=&quot;http://www.w3.org/TR/XMLHttpRequest/&quot; target=&quot;_blank&quot;&gt;XmlHttpRequest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;manipulating frames (including inline frames)&lt;/li&gt;
&lt;li&gt;manipulating documents (included using the object tag)&lt;/li&gt;
&lt;li&gt;manipulating cookie&lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt;
&lt;p&gt;但是HTML本身仍可以加入很多其他domain的資源。&lt;/p&gt;
&lt;blockquote&gt;
The above restrictions don’t limit all interaction, however. There is no limitation on including documents from other sources in HTML tag elements. It’s fairly common for images, style sheets, and scripts to be included from other domains. In fact, the only time same-origin explicitly restricts document retrieval is when the XmlHttpRequest method is used.&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;若是需要cross domain取得資料時，例如使用其他網站提供的web service，就需要一些額外的輔助，例如&lt;a href=&quot;http://developer.yahoo.com/javascript/howto-proxy.html&quot; target=&quot;_blank&quot;&gt;local proxy&lt;/a&gt;，但是一般的使用者，無法在server上放proxy。
於是Bob Ippolito提出了以下的建議：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;使用script tag載入javascript檔的方式，可以cross domain取得資料。&lt;/li&gt;
&lt;li&gt;server端傳回的資料採&lt;a href=&quot;http://www.json.org/&quot; target=&quot;_blank&quot;&gt;JSON&lt;/a&gt;(Javascript object notation)格式。&lt;/li&gt;
&lt;li&gt;server端提供一項服務，接受回呼函式(callback function)名稱為參數，將傳回的資料當成回呼函式的參數，傳回對此回呼函式的呼叫(padding 所指的就是此加上回呼函式的填充動作)。當此javascript傳輸完成，client端會自動執行，呼叫此回呼函式，因此在資料傳輸完畢時可以得知。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;這裡需要的是server端的幫助，目前&lt;a href=&quot;http://code.google.com/apis/gdata/json.html&quot; target=&quot;_blank&quot;&gt;Google&lt;/a&gt;、&lt;a href=&quot;http://developer.yahoo.com/common/json.html&quot; target=&quot;_blank&quot;&gt;Yahoo&lt;/a&gt;等的服務都有提供JSONP格式的回傳。&lt;/p&gt;
&lt;h3&gt;範例&lt;/h3&gt;
&lt;p&gt;以&lt;a href=&quot;http://www.flickr.com/services/feeds/&quot; target=&quot;_blank&quot;&gt;Flickr&lt;/a&gt;提供的服務查詢標籤包含羅平、油菜花、sunset的公開照片，並加入參數format=json、jsoncallback=doPhoto，表示傳回資料為JSON格式，並將其填入回呼函式doPhoto的呼叫中作為參數：&lt;/p&gt;
&lt;pre name=&quot;code&quot; class=&quot;html&quot;&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://api.flickr.com/services/feeds/photos_public.gne?tags=羅平,油菜花,sunset&amp;amp;tagmode=all&amp;amp;format=json&amp;amp;jsoncallback=doPhoto&amp;quot;&amp;gt;
&lt;/pre&gt;
&lt;p&gt;會得到「回呼函式名稱(JSON格式資料)」這種格式的回傳：&lt;/p&gt;
&lt;pre name=&quot;code&quot; class=&quot;javascript&quot;&gt;
doPhoto({&lt;br /&gt; &amp;quot;title&amp;quot;: &amp;quot;每個人的相片 已標籤 羅平, 油菜花 和 sunset&amp;quot;,&lt;br /&gt; &amp;quot;link&amp;quot;: &amp;quot;http://www.flickr.com/photos/&amp;quot;,&lt;br /&gt; &amp;quot;description&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt; &amp;quot;modified&amp;quot;: &amp;quot;2007-04-22T14:19:09Z&amp;quot;,&lt;br /&gt; &amp;quot;generator&amp;quot;: &amp;quot;http://www.flickr.com/&amp;quot;,&lt;br /&gt; &amp;quot;items&amp;quot;: [&lt;br /&gt; {&lt;br /&gt; &amp;quot;title&amp;quot;: &amp;quot;羅平金雞嶺夕陽&amp;quot;,&lt;br /&gt; &amp;quot;link&amp;quot;: &amp;quot;http://www.flickr.com/photos/38362352@N00/468370409/&amp;quot;,&lt;br /&gt; &amp;quot;media&amp;quot;: {&amp;quot;m&amp;quot;:&amp;quot;http://farm1.static.flickr.com/211/468370409_319f383a24_m.jpg&amp;quot;},&lt;br /&gt; &amp;quot;date_taken&amp;quot;: &amp;quot;2007-04-22T22:19:09-08:00&amp;quot;,&lt;br /&gt; &amp;quot;description&amp;quot;: &amp;quot;...&amp;quot;,&lt;br /&gt; &amp;quot;published&amp;quot;: &amp;quot;2007-04-22T14:19:09Z&amp;quot;,&lt;br /&gt; &amp;quot;author&amp;quot;: &amp;quot;nobody@flickr.com (Nature RGB)&amp;quot;,&lt;br /&gt; &amp;quot;author_id&amp;quot;: &amp;quot;38362352@N00&amp;quot;,&lt;br /&gt; &amp;quot;tags&amp;quot;: &amp;quot;sunset yunnan 油菜花 羅平&amp;quot;&lt;br /&gt; }&lt;br /&gt; ]&lt;br /&gt;})
&lt;/pre&gt;
&lt;p&gt;當回傳載入完畢後，client端執行上面這段javascript，便會呼叫之前定義好的doPhoto，這裡做的是秀出查詢的圖片(請原諒我憋腳的javascript)：&lt;/p&gt;
&lt;pre name=&quot;code&quot; class=&quot;javascript&quot;&gt;
function doPhoto(result) {&lt;br /&gt;  var div = document.getElementById(&amp;quot;flickr photos&amp;quot;);&lt;br /&gt;  for(var i=0; i &amp;lt; result.items.length; i++) {&lt;br /&gt;    var img = document.createElement(&amp;quot;img&amp;quot;);&lt;br /&gt;    img.setAttribute(&amp;quot;src&amp;quot;,result.items[i].media.m);&lt;br /&gt;    img.setAttribute(&amp;quot;alt&amp;quot;,result.items[i].title);&lt;br /&gt;    var a = document.createElement(&amp;quot;a&amp;quot;);&lt;br /&gt;    a.setAttribute(&amp;quot;href&amp;quot;,result.items[i].link);&lt;br /&gt;    a.setAttribute(&amp;quot;target&amp;quot;,&amp;quot;_blank&amp;quot;);&lt;br /&gt;    a.appendChild(img);&lt;br /&gt;    div.appendChild(a);&lt;br /&gt;  }&lt;br /&gt;}
&lt;/pre&gt;
&lt;div id=&quot;flickr photos&quot;&gt;&lt;/div&gt;
&lt;/div&gt;&lt;!-- end of fullpost --&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
if (pageType() == &quot;item&quot;) {

  function doPhoto(result) {
    var div = document.getElementById(&quot;flickr photos&quot;);
    for(var i=0; i &lt; result.items.length; i++) {
      var img = document.createElement(&quot;img&quot;);
      img.setAttribute(&quot;src&quot;,result.items[i].media.m);
      img.setAttribute(&quot;alt&quot;,result.items[i].title);
      var a = document.createElement(&quot;a&quot;);
      a.setAttribute(&quot;href&quot;,result.items[i].link);
      a.setAttribute(&quot;target&quot;,&quot;_blank&quot;);
      a.appendChild(img);
      div.appendChild(a);
    }
  }
    
  $(document).ready(function(){    
    var failureHandler = function(o) {
      var div = document.getElementById(&quot;flickr photos&quot;);
      div.innerHTML = &quot;Loading script failed !!&quot;;
    };
    
    var scriptUrls = [&quot;http://api.flickr.com/services/feeds/photos_public.gne?tags=羅平,油菜花,sunset&amp;tagmode=all&amp;format=json&amp;jsoncallback=doPhoto&quot;];
    
    var scriptOptions = {
      onFailure: failureHandler
    };
    
    var objScriptTransaction = YAHOO.util.Get.script(scriptUrls,scriptOptions);
  });//end of $(document).ready
}//end of if
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/4444222663082522722/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2007/11/jsonp.html#comment-form' title='3 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/4444222663082522722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/4444222663082522722'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2007/11/jsonp.html' title='JSONP'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-4287483462911812711</id><published>2007-11-09T05:14:00.001+08:00</published><updated>2008-04-14T04:48:40.209+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Feature"/><category scheme="http://www.blogger.com/atom/ns#" term="Tool"/><title type='text'>Syntax Highlight</title><content type='html'>&lt;p&gt;厭倦了單調的程式碼嗎，來加點色彩吧！&lt;/p&gt;
&lt;div class=&quot;fullpost&quot;&gt;
&lt;p&gt;當你需要某種軟體功能時，要花多久時間才能找到讓你滿意的答案呢？龐大的資料量，加上不同的用語、語言、資料來源，使得需要在搜尋結果中花費很多時間來篩選，然後還要再一一測試，而且說不定還找不到想要的結果。所以搜尋引擎還有很多進步空間，suryvey、catalog類型的網站或文章還是需要的。&lt;/p&gt;
&lt;p&gt;對於將程式碼加上語法色彩，大致上分為兩類，&lt;b&gt;事先產生&lt;/b&gt;後將靜態的資料貼到網頁上，或是以javascript&lt;b&gt;線上即時&lt;/b&gt;修改網頁，以下是一些例子：&lt;/p&gt;
&lt;h3&gt;事先產生：&lt;/h3&gt;
&lt;p&gt;1. &lt;a href=&quot;http://andre-simon.de/index.html&quot; target=&quot;_blank&quot;&gt;Highlight&lt;/a&gt;(名字真直接)&lt;br /&gt;
桌上軟體，可將檔案轉換成所選的格式，語法以副檔名判斷，可選擇配色、CSS是否inline、是否顯示行數，可自行定義語法及配色，若輸出格式選擇UTF-8，中文在預覽視窗會是亂碼，不過輸出的結果是正確的。&lt;/p&gt;
&lt;a href=&quot;http://picasaweb.google.com/siyeh0407/Blog/photo#5130477798285859362&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://lh3.google.com/siyeh0407/RzMeYAbbWiI/AAAAAAAAAGs/Aoo2StuPLd4/s400/Highlight.jpg&quot; alt=&quot;Highlight Screen Capture&quot; /&gt;&lt;/a&gt;
&lt;div style=&quot;color:green;&quot;&gt;因為使用CSS檔，以下程式碼在feeds中顯示會有問題。&lt;/div&gt;
&lt;pre class=&quot;code&quot;&gt;﻿&lt;span class=&quot;hl slc&quot;&gt;//syntax highligth 測試程式碼&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;public static&lt;/span&gt; &lt;span class=&quot;hl sym&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span class=&quot;hl sym&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;&amp;lt;&lt;/span&gt;? &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt; T&lt;span class=&quot;hl sym&quot;&gt;&amp;gt;&lt;/span&gt; dst&lt;span class=&quot;hl sym&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;&amp;lt;&lt;/span&gt;? &lt;span class=&quot;hl kwa&quot;&gt;extends&lt;/span&gt; T&lt;span class=&quot;hl sym&quot;&gt;&amp;gt;&lt;/span&gt; src&lt;span class=&quot;hl sym&quot;&gt;) {&lt;/span&gt;
  logger&lt;span class=&quot;hl sym&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;copy 開始!&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwb&quot;&gt;int&lt;/span&gt; i &lt;span class=&quot;hl sym&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;hl sym&quot;&gt;&amp;lt;&lt;/span&gt; src&lt;span class=&quot;hl sym&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;();&lt;/span&gt; i&lt;span class=&quot;hl sym&quot;&gt;++) {&lt;/span&gt;
    dst&lt;span class=&quot;hl sym&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;hl sym&quot;&gt;,&lt;/span&gt; src&lt;span class=&quot;hl sym&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;hl sym&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;hl sym&quot;&gt;}&lt;/span&gt;
  logger&lt;span class=&quot;hl sym&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;copy 結束!&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl sym&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;hl sym&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;2. &lt;a href=&quot;http://www.istaysharp.net/index.php?title=SyntaxColor4Writer&quot; target=&quot;_blank&quot;&gt;SyntaxColor4Writer&lt;/a&gt; (Windows Live Writer Plugin)&lt;br /&gt;
需要.NET 2.0，使用inline CSS，神奇的是會將WLW轉換編輯模式後吃掉的空白和斷行回復。&lt;br /&gt;
&lt;span style=&quot;color:red&quot;&gt;註：0.26版在WLW 12.0.1367.1128無法執行&lt;/span&gt;&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;syntax highligth 測試程式碼&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; copy(List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; T&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; dst, List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;extends&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; T&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; src) {
  logger.info(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;copy 開始!&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
  &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;; i &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; src.size(); i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;) {
    dst.set(i, src.get(i));
  }
  logger.info(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;copy 結束!&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
}&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;3. &lt;a href=&quot;http://sourceforge.net/forum/forum.php?forum_id=742220&quot; target=&quot;_blank&quot;&gt;CodeSnippet&lt;/a&gt;(Eclipse plugin)&lt;br /&gt;
將所選程式片段依Editor中的顏色設定產生輸出，因為如此所以不需要定義語法，但是目前只支援幾種格式，使用inline CSS。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;font style=&quot;color: rgb(63,127,95);&quot;&gt;//syntax highligth &amp;#28204;&amp;#35430;&amp;#31243;&amp;#24335;&amp;#30908;
&lt;/font&gt;&lt;font style=&quot;font-weight: bold; color: rgb(127,0,85);&quot;&gt;public&lt;/font&gt; &lt;font style=&quot;font-weight: bold; color: rgb(127,0,85);&quot;&gt;static&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;&amp;lt;T&amp;gt;&lt;/font&gt; &lt;font style=&quot;font-weight: bold; color: rgb(127,0,85);&quot;&gt;void&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;copy(List&amp;lt;?&lt;/font&gt; &lt;font style=&quot;font-weight: bold; color: rgb(127,0,85);&quot;&gt;super&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;T&amp;gt;&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;dst,&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;List&amp;lt;?&lt;/font&gt; &lt;font style=&quot;font-weight: bold; color: rgb(127,0,85);&quot;&gt;extends&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;T&amp;gt;&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;src)&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;{&lt;/font&gt;
  &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;logger.info(&lt;/font&gt;&lt;font style=&quot;color: rgb(42,0,255);&quot;&gt;&amp;quot;copy &amp;#38283;&amp;#22987;!&amp;quot;&lt;/font&gt;&lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;);&lt;/font&gt;
  &lt;font style=&quot;font-weight: bold; color: rgb(127,0,85);&quot;&gt;for&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;(&lt;/font&gt;&lt;font style=&quot;font-weight: bold; color: rgb(127,0,85);&quot;&gt;int&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;i&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;=&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;0;&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;i&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;&amp;lt;&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;src.size();&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;i++)&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;{&lt;/font&gt;
    &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;dst.set(i,&lt;/font&gt; &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;src.get(i));&lt;/font&gt;
  &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;}&lt;/font&gt;
  &lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;logger.info(&lt;/font&gt;&lt;font style=&quot;color: rgb(42,0,255);&quot;&gt;&amp;quot;copy &amp;#32080;&amp;#26463;!&amp;quot;&lt;/font&gt;&lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;);&lt;/font&gt;
&lt;font style=&quot;color: rgb(0,0,0);&quot;&gt;}&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;4. &lt;a href=&quot;http://duartes.org/iris/index.aspx&quot; target=&quot;_blank&quot;&gt;Iris Syntax Highlighter&lt;/a&gt;(C# Open Source)&lt;br /&gt;
提供網頁版syntax highlight介面，下載版需要.NET 2.0，利用&lt;a href=&quot;http://www.vim.org/&quot; target=&quot;_blank&quot;&gt;Vim&lt;/a&gt;(一種文字編輯器)已有的語法定義檔，支援超過460種語法，可選擇配色、是否顯示行數，可自行定義語法及配色。&lt;/p&gt;
&lt;table callpadding=&#39;0&#39; cellspacing=&#39;0&#39; class=&#39;irisContainer&#39; style=&#39;border-collapse: collapse; border-spacing:0&#39;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&#39;margin: 0; padding:0&#39;&gt;&lt;/td&gt;
&lt;td rowspan=&#39;2&#39; class=&#39;highlighted output&#39;&gt;&lt;pre class=&quot;java highlighted&quot;&gt;&lt;span class=&quot;normal&quot;&gt;&lt;span class=&quot;comment&quot;&gt;//syntax highligth 測試程式碼&lt;/span&gt;
&lt;span class=&quot;storageClass&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;storageClass&quot;&gt;static&lt;/span&gt; &amp;lt;T&amp;gt; &lt;span class=&quot;type&quot;&gt;void&lt;/span&gt; copy(List&amp;lt;? &lt;span class=&quot;typedef&quot;&gt;super&lt;/span&gt; T&amp;gt; dst, List&amp;lt;? &lt;span class=&quot;storageClass&quot;&gt;extends&lt;/span&gt; T&amp;gt; src) {
  logger.info(&lt;span class=&quot;string&quot;&gt;&amp;quot;copy 開始!&amp;quot;&lt;/span&gt;);
  &lt;span class=&quot;repeat&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;type&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;; i &amp;lt; src.size(); i++) {
    dst.set(i, src.get(i));
  }
  logger.info(&lt;span class=&quot;string&quot;&gt;&amp;quot;copy 結束!&amp;quot;&lt;/span&gt;);
}
&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&#39;output lineNumbers&#39;&gt;
&lt;pre class=&#39;lineNumbers&#39;&gt;&lt;span class=&#39;lineNumbers&#39;&gt;1
2
3
4
5
6
7
8
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;線上即時：&lt;/h3&gt;
&lt;p&gt;1. &lt;a href=&quot;http://code.google.com/p/syntaxhighlighter/&quot; target=&quot;_blank&quot;&gt;SyntaxHighlighter&lt;/a&gt; (&lt;a href=&quot;http://developer.yahoo.com/yui/examples/tabview/frommarkup.html&quot; target=&quot;_blank&quot;&gt;Yahoo Developer Network&lt;/a&gt;上有在用)&lt;br /&gt;
可以處理&amp;lt;textarea&amp;gt;(ps. 為了在feed中有較好的顯示結果，最好還是使用&amp;lt;pre&amp;gt;)，使用CSS檔做樣式，適合用在少量程式碼的情況(因為用regular expression來做parse)，在Blogger上因為轉換換行符號的問題，需要特別設定(只是多呼叫一個函示)。&lt;/p&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;
//syntax highligth 測試程式碼&lt;br /&gt;public static &amp;lt;T&amp;gt; void copy(List&amp;lt;? super T&amp;gt; dst, List&amp;lt;? extends T&amp;gt; src) {&lt;br /&gt;  logger.info(&amp;quot;copy 開始!&amp;quot;);&lt;br /&gt;  for (int i = 0; i &amp;lt; src.size(); i++) {&lt;br /&gt;    dst.set(i, src.get(i));&lt;br /&gt;  }&lt;br /&gt;  logger.info(&amp;quot;copy 結束!&amp;quot;);&lt;br /&gt;}
&lt;/pre&gt;
&lt;/div&gt;&lt;!-- end of fullpost --&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
if (pageType() == &quot;item&quot;) {
  $(document).ready(function(){
    var cssUrls = [&quot;http://happyjavascript.googlepages.com/highlight.css&quot;,&quot;http://happyjavascript.googlepages.com/iris.css&quot;];
    var objTransaction = YAHOO.util.Get.css(cssUrls);
  });
}
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/4287483462911812711/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2007/11/syntax-highlight.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/4287483462911812711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/4287483462911812711'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2007/11/syntax-highlight.html' title='Syntax Highlight'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-1042147813109611295</id><published>2007-11-07T06:39:00.002+08:00</published><updated>2008-04-14T05:05:14.647+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Blog"/><category scheme="http://www.blogger.com/atom/ns#" term="Tool"/><title type='text'>Blog Editor</title><content type='html'>&lt;p&gt;編輯blog文章，這麼常做的事反而這麼不方便。&lt;/p&gt;
&lt;div class=&quot;fullpost&quot;&gt;
&lt;p&gt;Weblog的出現以及網路環境的成熟，讓個人發表網頁變的簡單了，blog的數量一下子增加，這麼多人每天進行的活動，照理說應該存在適當的輔助工具，但是卻沒有。(或是有但我沒找到)&lt;/p&gt;
&lt;p&gt;目前我是先在客戶端以自己喜歡的網頁編輯器編輯好文章，用瀏覽器測試自己想要的效果，然後登錄到Blogger的線上介面，貼上文章的HTML。&lt;/p&gt;
&lt;div class=&quot;note&quot;&gt;
使用Blogger線上編輯器有些需要注意的事：
&lt;ul&gt;
&lt;li&gt;要在「設定」&amp;gt;「格式」頁面中將選項「轉換分行符號」設定為&lt;span style=&quot;color:red&quot;&gt;否&lt;/span&gt;，否則在線上編輯器中的換行會被換成&amp;lt;br /&amp;gt;。&lt;br /&gt;
(通常在編輯HTML時都不會把所有內容排成一行，如果不改設定就會出現一大堆換行)&lt;/li&gt;
&lt;li&gt;不要按到網頁編輯器中的撰寫(其實就是所視即所得的編輯方式)，不然一些自動轉換會改變你的文章格式。&lt;br /&gt;
(例如&amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt;中的空白和換行會被壓縮成一個空白)&lt;/li&gt;
&lt;li&gt;預覽看到的是將轉換分行符號設定為是的結果。&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;這種土法煉鋼的方式其實是很不方便的，這時如果有一個好用的離線部落格編輯器就好了，最好要是免錢的！(少男的祈禱～～)&lt;br /&gt;
但是…現實總是殘酷的！&lt;br /&gt;
參考了&lt;a href=&quot;http://mashable.com/2007/10/22/10-desktop-blog-editors/&quot; target=&quot;_blank&quot;&gt;Top 10 Free Desktop Blog Editors for Windows&lt;/a&gt;、&lt;a href=&quot;http://eucaly61.blogspot.com/2007/11/top-10-free-blog-editors.html&quot; target=&quot;_blank&quot;&gt;十大免費部落格寫作軟體之旅&lt;/a&gt;中的幾個比較可以行的軟體，只考慮編輯、上下載文章這兩種最基本的功能：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://get.live.com/betas/writer_betas&quot; target=&quot;_blank&quot;&gt;Windows Live Writer beta 3&lt;/a&gt;&lt;br /&gt;
編輯：切換編輯模式會修改網頁(空白和換行會被壓縮成一個空白、HTML保留符號會被自動轉換，對於有貼程式碼的會造成困擾)&lt;br /&gt;
上下載：會修改網頁(空白和換行會被壓縮成一個空白、HTML保留符號會被自動轉換)、&lt;span style=&quot;color:red;&quot;&gt;下載文章會失敗&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.zoundry.com/&quot; target=&quot;_blank&quot;&gt;Zoundry Blog Writer 1.0.40&lt;/a&gt;&lt;br /&gt;
編輯：切換編輯模式會修改網頁(HTML保留符號會被自動轉換)&lt;br /&gt;
上下載：會修改網頁格式(HTML保留符號會被自動轉換、&lt;span style=&quot;color:red;&quot;&gt;為了只顯示文章摘要所加的&amp;lt;div id=&amp;quot;fullpost&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;不見了&lt;/span&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://devblog.zoundry.com/&quot; target=&quot;_blank&quot;&gt;Zoundry Raven alpha 0.8.134&lt;/a&gt;&lt;br /&gt;
編輯：下載文章失敗就不太想測了，不過看起來好像還ok&lt;br /&gt;
上下載：&lt;span style=&quot;color:red;&quot;&gt;下載文章會失敗&lt;/span&gt;(好像是XML not well-formated)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.flock.com/&quot; target=&quot;_blank&quot;&gt;Flock 1.0&lt;/a&gt;&lt;br /&gt;
編輯：切換編輯模式會修改網頁(空白和換行會被壓縮成一個空白、HTML保留符號會被自動轉換)&lt;br /&gt;
上下載：&lt;span style=&quot;color:red;&quot;&gt;沒有下載功能&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.scribefire.com/&quot; target=&quot;_blank&quot;&gt;ScribeFire 1.4.2&lt;/a&gt; (Mozilla Firefox 附加元件)&lt;br /&gt;
編輯：切換編輯模式會修改網頁(空白和換行會被壓縮成一個空白、HTML保留符號會被自動轉換)&lt;br /&gt;
上下載：&lt;span style=&quot;color:red;&quot;&gt;顯示上載成功，但實際上卻沒有上載&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;當然光批評比實際上去做要容易的多，而且這些是免費的軟體，很多都還在測試階段，有很多問題感覺好像都是自動轉換格式造成的，而且似乎只會對想貼程式碼，或不想網頁元素變成一坨的人有影響，難怪還是有人覺得好用。&lt;br /&gt;
所以…向流星許願吧！希望好用的blog editor早日出現。&lt;/p&gt;
&lt;/div&gt;&lt;!-- end of fullpost --&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/1042147813109611295/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2007/11/blog-editor.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/1042147813109611295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/1042147813109611295'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2007/11/blog-editor.html' title='Blog Editor'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-3878603325590482010</id><published>2007-11-04T06:19:00.001+08:00</published><updated>2008-04-14T04:48:02.131+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="HTML"/><title type='text'>Code Snippet</title><content type='html'>&lt;p&gt;想要在blog貼一段程式碼，這是個很基本的需求，但是真麻煩。&lt;/p&gt;
&lt;div class=&quot;fullpost&quot; class=&quot;yui-skin-sam&quot;&gt;
&lt;p&gt;假設想要貼上以下這段java程式碼：&lt;/p&gt;
&lt;pre&gt;
public static &amp;lt;T&amp;gt; void copy(List&amp;lt;? super T&amp;gt; dst, List&amp;lt;? extends T&amp;gt; src) {
  for (int i = 0; i &amp;lt; src.size(); i++) {
    dst.set(i, src.get(i));
  }
}
&lt;/pre&gt;
&lt;p&gt;首先會遇到兩個問題，「&amp;lt;」、「&amp;gt;」在HTML用來表示標籤，必須要用「&amp;amp;lt;」取代「&amp;lt;」，「&amp;amp;gt;」取代「&amp;gt;」，否則無法正常顯示，還有一些&lt;a href=&quot;http://www.w3.org/TR/html4/charset.html#h-5.3.2&quot; target=&quot;_blank&quot;&gt;特殊用途的符號&lt;/a&gt;也需要避開：「&amp;amp;amp;」取代「&amp;amp;」，「&amp;amp;quot;」取代「&amp;quot;」，另外就是空白和斷行的問題，必須要用「&amp;amp;nbsp;」(non-breaking space)和「&amp;lt;br /&amp;gt;」表示(r和/之間的空格好像是為了相容於較舊的瀏覽器)，不過若是使用網頁編輯器，通常都會自動置換這些符號。&lt;br /&gt;
程式碼片段可以放在&lt;a href=&quot;http://www.w3.org/TR/html4/struct/text.html#edef-CODE&quot; target=&quot;_blank&quot;&gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&lt;/a&gt;之間，但是這個標籤只是用來增加文字片段的結構資訊，對於頁面的顯示沒有影響。&lt;br /&gt;
接著通常會以CSS來修改顯示方式，這時就看個人的創意了，例如：&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;
/* for code */
code, .code {
  display: block;
  background: #E3F5D2;
  padding: 10px 10px 10px 21px;
  margin: 10px;
  border: 1px solid #CCCCCC;
  max-height: 300px;
  overflow: auto;
  font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;
  font-size: 95%;
  line-height: 120%;
}
&lt;/pre&gt;
&lt;div id=&quot;example-code-tag&quot; class=&quot;yui-navset&quot;&gt;
&lt;p&gt;&amp;lt;code&amp;gt; example：&lt;/p&gt;
&lt;ul class=&quot;yui-nav&quot;&gt;
&lt;li class=&quot;selected&quot;&gt;&lt;a href=&quot;#demo-code-tag&quot;&gt;&lt;em&gt;demo&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#source-code-tag&quot;&gt;&lt;em&gt;source&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yui-content&quot;&gt;
&lt;div id=&quot;demo-code-tag&quot;&gt;
&lt;code&gt;
&lt;span style=&quot;color:#FF0000&quot;&gt;//This is a code tag test&lt;/span&gt;&lt;br /&gt;
public static &amp;lt;T&amp;gt; void copy(List&amp;lt;? super T&amp;gt; dst, List&amp;lt;? extends T&amp;gt; src) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;for (int i = 0; i &amp;lt; src.size(); i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dst.set(i, src.get(i));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}
&lt;/code&gt;
&lt;/div&gt;
&lt;div id=&quot;source-code-tag&quot;&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;code&amp;gt;&lt;br /&gt;&amp;lt;span style=&amp;quot;color:#FF0000&amp;quot;&amp;gt;//This is a code tag test&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;public static &amp;amp;lt;T&amp;amp;gt; void copy(List&amp;amp;lt;? super T&amp;amp;gt; dst, List&amp;amp;lt;? extends T&amp;amp;gt; src) {&amp;lt;br /&amp;gt;&lt;br /&gt;&amp;amp;nbsp;&amp;amp;nbsp;for (int i = 0; i &amp;amp;lt; src.size(); i++) {&amp;lt;br /&amp;gt;&lt;br /&gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;dst.set(i, src.get(i));&amp;lt;br /&amp;gt;&lt;br /&gt;&amp;amp;nbsp;&amp;amp;nbsp;}&amp;lt;br /&amp;gt;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/code&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;!-- end of yui content --&gt;
&lt;/div&gt;&lt;!-- end of code tage example --&gt;
&lt;p&gt;但以這種方法來處理空白和斷行，還是太麻煩了，這時可以試試看「&amp;lt;pre&amp;gt;」或「&amp;lt;textarea&amp;gt;」。&lt;br /&gt;
&lt;a href=&quot;http://www.w3.org/TR/html4/struct/text.html#edef-PRE&quot; target=&quot;_blank&quot;&gt;&amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt;&lt;/a&gt;(preformatted text)會將標籤所包圍的空白和斷行顯示在網頁上，但仍舊會處理其中的HTML標籤，所以仍需要置換特殊符號，這也表示可以用CSS修飾程式碼。&lt;br /&gt;
&lt;a href=&quot;http://www.w3.org/TR/html4/interact/forms.html#edef-TEXTAREA&quot; target=&quot;_blank&quot;&gt;&amp;lt;textarea&amp;gt;&amp;lt;/textarea&amp;gt;&lt;/a&gt;會將標籤所包圍的文字全部顯示，但這也表示無法用CSS修飾程式碼，而且比較麻煩的是必須自己設定寬高和唯讀等屬性。(這是目前所知的情況，也許有其他的好方法可以辦到。)&lt;/p&gt;
&lt;div id=&quot;example-pre-tag&quot; class=&quot;yui-navset&quot;&gt;
&lt;p&gt;&amp;lt;pre&amp;gt; example：&lt;/p&gt;
&lt;ul class=&quot;yui-nav&quot;&gt;
&lt;li class=&quot;selected&quot;&gt;&lt;a href=&quot;#demo-pre-tag&quot;&gt;&lt;em&gt;demo&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#source-pre-tag&quot;&gt;&lt;em&gt;source&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yui-content&quot;&gt;
&lt;div id=&quot;demo-pre-tag&quot;&gt;
&lt;pre class=&quot;code&quot;&gt;
&lt;span style=&quot;color:#FF0000&quot;&gt;//This is a pre tag test&lt;/span&gt;
public static &amp;lt;T&amp;gt; void copy(List&amp;lt;? super T&amp;gt; dst, List&amp;lt;? extends T&amp;gt; src) {
  for (int i = 0; i &amp;lt; src.size(); i++) {
    dst.set(i, src.get(i));
  }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&quot;source-pre-tag&quot;&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;pre class=&amp;quot;code&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;span style=&amp;quot;color:#FF0000&amp;quot;&amp;gt;//This is a pre tag test&amp;lt;/span&amp;gt;&lt;br /&gt;public static &amp;amp;lt;T&amp;amp;gt; void copy(List&amp;amp;lt;? super T&amp;amp;gt; dst, List&amp;amp;lt;? extends T&amp;amp;gt; src) {&lt;br /&gt;  for (int i = 0; i &amp;amp;lt; src.size(); i++) {&lt;br /&gt;    dst.set(i, src.get(i));&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&amp;lt;/pre&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;!-- end of yui content --&gt;
&lt;/div&gt;&lt;!-- end of pre tage example --&gt;
&lt;div id=&quot;example-textarea-tag&quot; class=&quot;yui-navset&quot;&gt;
&lt;p&gt;&amp;lt;textarea&amp;gt; example：&lt;/p&gt;
&lt;ul class=&quot;yui-nav&quot;&gt;
&lt;li class=&quot;selected&quot;&gt;&lt;a href=&quot;#demo-textarea-tag&quot;&gt;&lt;em&gt;demo&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#source-textarea-tag&quot;&gt;&lt;em&gt;source&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yui-content&quot;&gt;
&lt;div id=&quot;demo-textarea-tag&quot;&gt;
&lt;textarea name=&quot;textarea&quot; rows=&quot;6&quot; readonly=&quot;readonly&quot; class=&quot;code&quot; style=&quot;width:90%&quot;&gt;
//This is a textarea tag test
public static &lt;T&gt; void copy(List&lt;? super T&gt; dst, List&lt;? extends T&gt; src) {
  for (int i = 0; i &lt; src.size(); i++) {
    dst.set(i, src.get(i));
  }
}
&lt;/textarea&gt;
&lt;/div&gt;
&lt;div id=&quot;source-textarea-tag&quot;&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;textarea name=&amp;quot;textarea&amp;quot; rows=&amp;quot;6&amp;quot; readonly=&amp;quot;readonly&amp;quot; class=&amp;quot;code&amp;quot; style=&amp;quot;width:90%&amp;quot;&amp;gt;&lt;br /&gt;//This is a textarea tag test&lt;br /&gt;public static &amp;lt;T&amp;gt; void copy(List&amp;lt;? super T&amp;gt; dst, List&amp;lt;? extends T&amp;gt; src) {&lt;br /&gt;  for (int i = 0; i &amp;lt; src.size(); i++) {&lt;br /&gt;    dst.set(i, src.get(i));&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&amp;lt;/textarea&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;!-- end of yui content --&gt;
&lt;/div&gt;&lt;!-- end of textarea tage example --&gt;
&lt;p&gt;所以結論是，用&amp;lt;pre&amp;gt;似乎是比較方便的方法，不用自己設定寬高，也可以用CSS修飾達成syntax highlight的效果。&lt;/p&gt;
&lt;/div&gt;&lt;!-- end of fullpost --&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
if (pageType() == &quot;item&quot;) {
  $(document).ready(function(){
    var successHandler = function(o) {
      var tabView1 = new YAHOO.widget.TabView(&#39;example-code-tag&#39;); 
      var tabView2 = new YAHOO.widget.TabView(&#39;example-pre-tag&#39;);
      var tabView3 = new YAHOO.widget.TabView(&#39;example-textarea-tag&#39;);
    };
  
    var scriptUrls = [&quot;http://yui.yahooapis.com/2.4.1/build/yahoo-dom-event/yahoo-dom-event.js&quot;,&quot;http://yui.yahooapis.com/2.4.1/build/element/element-beta-min.js&quot;,&quot;http://yui.yahooapis.com/2.4.1/build/tabview/tabview-min.js&quot;];
    
    var scriptOptions = {
      onSuccess: successHandler
    };
    
    var objScriptTransaction = YAHOO.util.Get.script(scriptUrls,scriptOptions);
    
    var cssUrls = [&quot;http://yui.yahooapis.com/2.4.1/build/tabview/assets/skins/sam/tabview.css&quot;];
    var objCSSTransaction = YAHOO.util.Get.css(cssUrls);
  });//end of $(document).ready
}//end of if
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/3878603325590482010/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2007/11/code-snippet.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/3878603325590482010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/3878603325590482010'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2007/11/code-snippet.html' title='Code Snippet'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1758489972701323316.post-3912315771154381879</id><published>2007-10-18T23:34:00.002+08:00</published><updated>2008-04-14T05:05:14.647+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Blog"/><category scheme="http://www.blogger.com/atom/ns#" term="Template"/><title type='text'>Blog Template I Want</title><content type='html'>&lt;p&gt;列出目前 blog 想要有的功能，原則：在符合需求下，越簡單越好。&lt;/p&gt;  &lt;div class=&quot;fullpost&quot;&gt;   &lt;p&gt;版面規劃：      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; 目前沒有很多 widgets，主要內容是文章，所以 2 columns 就OK，左邊文章欄，右邊佈告欄。&lt;/p&gt;    &lt;p&gt;功能：&lt;/p&gt;    &lt;ol&gt;     &lt;li&gt;Peek-a-boo（躲貓貓）：只顯示標題，或者摘要，詳細內容隱藏起來，需要時可打開。        &lt;br /&gt;需要此功能的部分：佈告欄&lt;sup style=&quot;color: red&quot;&gt;done&lt;/sup&gt;、文章&lt;sup style=&quot;color: red&quot;&gt;done&lt;/sup&gt;         &lt;br /&gt;&lt;span style=&quot;color: green&quot;&gt;（blogger-ext2 與 jQuery 1.2+ 相容性請參考&lt;a href=&quot;http://groups.google.com/group/blogger-ext2/t/e30488fc8e937d94&quot; target=&quot;_blank&quot;&gt;討論群組&lt;/a&gt;，另外裡面的 jQuery.noConflict(); 好像不是這樣用的，似乎應該去掉，否則若有其他使用 jQuery 的程式會有問題）&lt;/span&gt; &lt;/li&gt;      &lt;li&gt;標籤雲&lt;sup style=&quot;color: red&quot;&gt;done&lt;/sup&gt; &lt;/li&gt;      &lt;li&gt;站內搜尋&lt;sup style=&quot;color: red&quot;&gt;done&lt;/sup&gt;        &lt;br /&gt;（有仍在 &lt;a href=&quot;http://draft.blogger.com/&quot; target=&quot;_blank&quot;&gt;Draft&lt;/a&gt; 中的 &lt;a href=&quot;http://bloggerindraft.blogspot.com/2007/07/new-feature-search-box.html&quot; target=&quot;_blank&quot;&gt;Search Box&lt;/a&gt;，不過本站搜尋結果中搜尋條件的 highlight 好像有問題，會直接顯示成&amp;lt;font color=CC0033&amp;gt;...&amp;lt;/font&amp;gt;，有向 Google 反應，但似乎沒有回應。另外自己寫了一個 &lt;a href=&quot;http://happytemplate.blogspot.com/2008/01/multiple-labels-or-tags-search.html&quot; target=&quot;_blank&quot;&gt;Multiple labels search&lt;/a&gt;） &lt;/li&gt;      &lt;li&gt;程式碼片段顯示&lt;sup style=&quot;color: red&quot;&gt;done&lt;/sup&gt;、syntax highlight&lt;sup style=&quot;color: red&quot;&gt;done&lt;/sup&gt; &lt;/li&gt;   &lt;/ol&gt;    &lt;p&gt;儲存空間：&lt;/p&gt;    &lt;ol&gt;     &lt;li&gt;javascript、CSS files        &lt;br /&gt;Google Page（no gzip, no foler support）、Google Code Project Hosting（gzip support） &lt;/li&gt;      &lt;li&gt;images        &lt;br /&gt;&lt;span&gt;Flikr、Picasa&lt;/span&gt; &lt;/li&gt;      &lt;li&gt;videos        &lt;br /&gt;YouTube &lt;/li&gt;   &lt;/ol&gt;    &lt;p&gt;目前網路上增加 Blogger 功能的方法大致上可以分為兩類，&lt;b&gt;侵入式&lt;/b&gt;的直接修改 template 中的 widgets，主要好處是不用等頁面載入後再去進行修改，且可以利用 template 中專用的一些標籤來輔助，使用 ajax 方式載入 widget 時不用再重新修改頁面元素（例如較新的文章、較舊的文章這類聯結會以 ajax 方式載入文章），但是所修改的程式會散落在 template 的各個角落，變更 template 時需要比較多修改；&lt;b&gt;非侵入式&lt;/b&gt;的是以 javascript 依設定在頁面元素載入後來作修改，優缺點跟侵入式的相反。&lt;/p&gt;    &lt;p&gt;非侵入式的有找到&lt;a href=&quot;http://racklin.blogspot.com/&quot;&gt;阿土伯程式大觀園&lt;/a&gt;作者寫的 &lt;a href=&quot;http://code.google.com/p/blogger-ext2/&quot;&gt;blogger-ext2&lt;/a&gt;（底層使用 jQuery javascript library ），目前想要的功能好像都有，再加上可以直接到 Google Code Project Hosting 上去連結 js 檔案，似乎已經解決的一大半問題，不過還是想學會自己改。&lt;/p&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happytemplate.blogspot.com/feeds/3912315771154381879/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://happytemplate.blogspot.com/2007/10/blog-template-i-want.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/3912315771154381879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1758489972701323316/posts/default/3912315771154381879'/><link rel='alternate' type='text/html' href='http://happytemplate.blogspot.com/2007/10/blog-template-i-want.html' title='Blog Template I Want'/><author><name>HappyMonster</name><uri>http://www.blogger.com/profile/09835638685125578295</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://lh4.google.com/siyeh0407/Ry4SevRzNiI/AAAAAAAAAGI/K_2gqspU9xg/s144/045_%E9%A0%AD%E6%9A%88%E7%9B%AE%E7%9C%A9.gif'/></author><thr:total>0</thr:total></entry></feed>