顯示具有 blogger 標籤的文章。 顯示所有文章
顯示具有 blogger 標籤的文章。 顯示所有文章

2011/03/17

如何在Blogger新增隨機文章

For English Reader: How to Add a Random Post Gadget in Blogger

有時候想讓舊文章出來透透氣,以免永遠不見天日。找了網路上許多工具,但都有2個很大的缺點:1. 速度慢,使部落格效能低落。 2. 只抓得到部份文章(部落格文章總數超過500篇以上就抓不到)。

因此,為了改進這2個缺點,我抓取Google官方提供部落格文章清單功能,在配合最新的非同步傳輸技術,使得文章在載入的時候,不會讓整個部落格卡住,讓你載入速度超快,避免因為一個小工具降低整體效能。而且,經過一些程式技巧,就算您的文章總數超過500篇,一樣可以抓得到。並且,可讓使用者點擊https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWZfz-IshwTWNPcPj8SCUvK0LGjo-WQXXqRuYXEZdoDhzsbjatd88vewdqZg7k8YaBMiNLILumtzK46fcJS6jgJM1UHrZbncgjppCQUa2fRU4XPTz3T0xw1foWaAe1QsoFfFloRg/的時候,更新隨機文章,增加互動性。

效果如下:

 image

 

使用方法:

1. 先到後台管理頁面。版面配置->網驗元素。

csie-tw.blogspot.com

2. 新增小工具

csie-tw.blogspot.com (1)

3. 新增一個HTML/JavaScript Gadget

csie-tw.blogspot.com (2)

4. 填上標題,和程式碼

  csie-tw.blogspot.com (3)

程式碼如下:

<script type="text/javascript" src="http://sites.google.com/site/csietw123/randomPost.js"></script>
<script type="text/javascript">
numofpost=3;
borderSize=0;
buttomLineSize=1;
refresh_period=-1;
RandomPost();
</script>

numofpost為一次顯示文章篇數,這裡是設定為3篇。

borderSize為邊框寬度,如果設為0的話,那就是沒有邊框。

buttomLineSize為每個標題下方的底線寬度,如果設為0的話,那就是沒有底線。

refresh_period為自動重新整理的週期,單位為秒數;如果不想自動重新整理,則設為-1。

各參數設定效果如下:

 image

 image

numofpost=3;
borderSize=0;
buttomLineSize=0;

numofpost=3;
borderSize=2;
buttomLineSize=0;

image 

image

numofpost=3;
borderSize=0;
buttomLineSize=1;

numofpost=3;
borderSize=2;
buttomLineSize=1;

此程式已在Firefox 3.6、Firefox 4.0、Firefox 5.0、IE 6、IE 7、IE 8、Chrome 5、Opera 10測試過相容性,皆沒有問題,歡迎使用。

技術層面(無興趣可跳過)

我原本是使用stuffablog提供的服務,可是發現它不夠隨機,總是出現部分的隨機文章,不是把整個部落格文章都隨機輸出。這是因為它使用搜尋引擎的引索資料擷取下來的資訊,但是如果沒有被引索的頁面就無法顯示在隨機文章中。

網路上提供的第二個辦法是使用blogger本身提供的feeds來作為隨機清單,由bloggodown的作者實做出來,程式碼可以在這裡下載。使用這個方法時,一開始都很順利,但是使用一段時卻發現,早期的文章沒有被加入隨機清單裡,後來查詢到google的說明是:feeds的max-results參數最大只可以列出500篇。所以bloggodown提供的程式碼只能使用最新的500文章當作隨機清單。

以上2個方法是網路上提供的,但都有一些問題,因此我就自己寫,方法如同bloggodown,但是我會使用index參數設定起始位置,再用max-results當做要顯示的篇數,再透過分析JSON物件擷取之間的文章當作隨機清單,這樣就沒有500篇限制的問題了。

2010/11/21

[Blog] 隨機格言/佳言/諺語

佳言錦句, 佳言錄, 佳言名句 ,名人佳言 ,佳言佳句 ,教育佳言 ,聖經佳言 ,勵志佳言 ,佳言,語中心 ,佳言例句 ,格言佳句 ,名人格言 ,勵志格言 ,朱子治家格言 ,人生格言 ,英文格言 ,伊格言 ,朱子治家格言翻譯 ,治家格言 ,程式設計師的格言,

English version of this page.

如果你想在你的部落格或網站顯示隨機的格言/佳言/諺語,可以使用下面方法達成。

隨機格言效果如下(可按F5更新畫面):

 

 

使用方法:

1. 先到後台管理頁面。版面配置->網驗元素。

csie-tw.blogspot.com

2. 新增小工具

csie-tw.blogspot.com (1)

3. 新增一個HTML/JavaScript Gadget

csie-tw.blogspot.com (2)

4. 填上標題,和程式碼

image

程式碼如下:

<script type="text/javascript" src="http://sites.google.com/site/csietw123/WisdomWords.js"></script><script type="text/javascript">WisdomWords();</script>

2010/11/16

[Blog] Random Words of Wisdom

English proverb, Proverb Quotes, Adage, proverbial saying; Byword; saw

本文中文版

If you want to add a widget showing random words of wisdom in your blogs to websites, you should try this easy mothod.

The outcome of the program looks like (Press F5 to reflesh the screen):

 

 

How to use it?

1. Go to Dashboard->Design->Page Elements.

csie-tw.blogspot.com

2. Add a Gadget.

csie-tw.blogspot.com (1)

3. Add a HTML/JavaScript Gadget.

csie-tw.blogspot.com (2)

4. Type the title and the program.

image

The program is shown below.

<script type="text/javascript" src="http://sites.google.com/site/csietw123/WisdomWords.js"></script><script type="text/javascript">WisdomWords();</script>

2010/09/18

The SEO of Blogger Title tag

The importance of <title> tag

The default setting of blogger for <title> HTML tag would be something like

Blogger name: Article name

However, with this kind of setting, it have lower probability for search engines to show your page at the top of the result list because what really matters is the article name instead of blogger name.

Therefore, I would like to show my page with <title> HTML tag in the following format:

Article name - Blogger name

In this case, the search engines would know the Article name is superior to Blogger name in the <title>, resulting in the PageRank of this page may have a higher value.

How to do?

1. Go to the page Design -> Edit HTML. Find the code like:

<title><data:blog.pageTitle/></title>

csie-tw.blogspot.com

2. Replace the code found in the step 1 by

<b:if cond='data:blog.pageType == "index"'>
<title><data:blog.title/></title>
<b:else/>
<title><data:blog.pageName/> - <data:blog.title/></title>
</b:if>

or replace code by the following, if you just want to show the Article name without Blogger name.

<b:if cond='data:blog.pageType == "index"'>
<title><data:blog.title/></title>
<b:else/>
<title><data:blog.pageName/></title>
</b:if>

Buddhism and Software Developer

In today's fast-paced society, we are often surrounded by work, goals, and external pressures. However, the wisdom found in Buddhism off...