JeffHung.Blog

(My smile insists of having nose. :-)

升級到 wordpress 2.0.1

趁著春節假期的空檔,傍晚努力了一番,把我的 blog 給升級到 wordpress 2.0.1 了。雖然一樣是使用 Subversion 安裝,但為了保險起見,我並沒有直接使用 svn switch 的方式,而是另外 checkout 一份,照著 Wordpress 官方網站的這篇《Upgrading Wordpress》一步一步慢慢升級。我的步驟如下:

備份資料庫:使用前陣子寫的 mysql-dump.sh 備份資料庫。
下載:使用 svn checkout 下載 trunk 版 Wordpress 至 wordpress-trunk 目錄,把 blog 目錄改鍊結到此目錄。
執行升級程式。
將原本的 theme 複製至新目錄。
測試,一切正常。
將原本用的 plug-in,除了 HTMLArea 外,皆複製至新目錄。
測試,一切正常。
為了使用 rich editor 的 dialog 功能,將 tab mix plus 設成 allow all popups[1]。
安裝 editormonkey,發現會找不到 toolbar 設定,經查發現是該 plug-in 的 editormonkey/include.php 檔用了 <? 而非 [...]

use grep(1) accompany with my wcfind via xargs(1)

本系列目前有四篇文章,建議依照以下順序閱讀:

wcfind - avoid find(1) into subversion meta directories
use grep(1) accompany with my wcfind via xargs(1)
Setting svn:keywords in many files simultaneously
再探 wcfind — 用 find2perl 實作

Sorry, the comment system do not allow me to use rich-format styles. So I reply Laurent's comment of "wcfind - avoid find(1) into subversion meta directories" here.

Hi, Laurent, There are [...]

wcfind - avoid find(1) into subversion meta directories

本系列目前有四篇文章,建議依照以下順序閱讀:

wcfind - avoid find(1) into subversion meta directories
use grep(1) accompany with my wcfind via xargs(1)
Setting svn:keywords in many files simultaneously
再探 wcfind — 用 find2perl 實作

Ben Reser contributed a bash script called wcgrep that is useful for greping in a Subversion working copy by ignoring the Subversion meta directories .svn/ and vi(m) backup files. We may [...]

Hollywood - This is what I'm waiting for

早上一進辦公室,就看到《Treo 700p, Hollywood, Lowrider Treos Coming Next Year》這則好消息:
“Hollywood” will be a fancier 3G/GSM smartphone which will represent PALM first attempt at the European GSM market. We know the phone will have no external antenna and will probably he launched by Cingular in the US.
很好,Palm OS、Treo form factor、European 3G/GSM network (應該就是 WCDMA 了),完美的組合。唉呀呀~真糟糕,新的敗家目標浮現了嗎? [...]

Crazy buying domains recently

最近狂買 domain names。
因為 .tw 第二層網域名稱的推出,不得不跟著把 jeffhung.tw、lady.tw 與 gentleman.tw 拿下來。jeffhung.tw 可能沒什麼人要,但 lady.tw 就熱門了。前幾個月還有個人要來跟我買 lady.idv.tw,想來應該是為了 lady.tw 排頭香的緣故。不過因為這三個 idv.tw 我都有在用,所以當然不能讓人了。至於第二層要拿來幹什麼?我現在也不曉得,先囤著指向對應的 idv.tw。
喔,為什麼要用到 jeffhung、lady、gentleman 三個 domain 那麼多?jeffhung 不用說了,就是代表我自己,而 lady 跟 gentleman 我在《雜談 2005》裡有提到,分別代表 server 端跟 teminal 端。Terminal 端因為個人用,所以不被外界所知,而 lady 我用來架 bbs,同時也是我的個人工作站的名稱。
然後,看到 Yahoo! Small Business 的 $2.95/yr domain promotion,五年才不到台幣五百塊,實在是太便宜了,且到年底就截止了,就忍不住又跳下去買了幾個一直想買的 domains:jeffhung.net、amarganth.net 與 amarganth.org。jeffhung.net 看起來比 jeffhung.idv.tw 與 [...]

Sharing chinese file names between samba and Windows

因為我的 FreeBSD server 上的 Samba,無法正確處理從 Windows 建立的中文檔名,從 FreeBSD 上看是亂碼,因此,只好乖乖地上 FreeBSD Chinese HOWTO[1] 找到這節《Samba - 網路芳鄰,資源分享程式》,照著上面所述,在 /usr/local/etc/smb.conf 的 [global] 區段加上下面這些設定:
[global]...mangling method = hashunicode = ondos charset = UCS-2LEunix charset = CP950display charset = CP950
其中,mangling method 的意思不太懂,所以上 Google 找到這頁《The Unofficial Samba HOWTO》的說明:

Mangling Method Name mangling is a method where Windows allows long filenames to retain a [...]

修復 recent comments 把中文字切一半的問題

我在這篇《Fixing wordpress plugin - recent comments》介紹了怎麼樣修正以便安裝 recent comments 在某些比較新版本的 wordpress 裡。然後網友 1614 留訊息問可不可以解決中文字切一半的問題,所以我就研究了一下,然後就不小心解決了。
首先,先把 PHP 的 multibyte string extension 裝起來,對於 FreeBSD 來說,就是把 converters/php5-mbstring 裝起來即可。如下:

SHELL> cd /usr/ports/converters/php5-mbstring
SHELL> make install
...
基本上,我們將使用 mb_strimwidth() 幫我們切文字,這個函式知道一段字串在 terminal 上會有多「寬」,好比說兩個全形字加三個半形字,會被認知為寬度為 (2*2+3*1)=7,然後依據給定的寬數「切」字串。所以,只要改用 mb_strimwidth() 來作真正的切字串的動作即可。
請修改 recent comments 的 kjgrc_excerpt() 這個函式如下:

function kjgrc_excerpt ($text,$chars_per_comment,$chars_per_word,$tag,$output)
{
$length = strlen(str_replace($tag,"",strip_tags($output)));
[...]

List non utf-8 encoded files

Arlo 問我有沒有辦法讓 Editplus 2 預設使用 UTF-8 encoding?很可惜地,雖然 Editplus 2 可以預設檔案的行尾要用 PC (CR-LF)、UNIX (LF) 還是 Mac (CR) 格式,但卻沒有辦法預設新檔案要使用的 encoding,一律使用 ANSI codepage。
Arlo 問這個問題,想必是因為常常忘了把原始碼檔案的 encoding 設成 UTF-8,導致程式執行時出錯。我以前也有碰過這樣的困擾,於是從某 trac 資料庫裡把下面這段挖出來:

Here's a command to check which file has incorrect utf8 encoding:

SHELL> find . -type f -name '*.php' -or -name '*.html' -or -name '*.htm' \
 | [...]

Fixing wordpress plugin - recent comments

總算是找到 recent comments 這個 wordpress 的 plugin 的修法了。原本照著安裝步驟,把檔案 copy 進 plugin 目錄啟動之,但是進入 recent comments 的 options 選單,卻會出現如下的錯誤訊息而無法使用:

Fatal error: Cannot redeclare kjgrc_subpage_gravatar()
還好,最後終於是讓我找到了解法。簡單講應該就是 recent comments 沒有按照 wordpress 新的 add_action() 的方式,讓 wordpress 知道有 recent comments 的 action 可以用。而且用了一個很奇怪的手法,避免 double inclusion 如下:

if ( function_exists("is_plugin_page") && is_plugin_page() ) { kjgrc_options_page(); return;} 
而 kjgrc_options_page() 卻是在之後才 define,也因此造成了 [...]

換成 beeblebrox 布景

Arlo 跟我說,我的 trackback 爛掉了,想了一想,原本用的 theme 版本,因為不是英文版,檔案又東缺西缺,其實根本不完整,因此決定乾脆再換個 theme 好了。這次不去《alexking.org: WordPress Theme Browser》找了,改到 Codex 找,官方列的東西,應該會比較乾淨完整些。
最後,選到 beeblebrox 這個 theme,符合我的幾個需求:

2-columns,sidebar 在左邊:因為我的文章裡會列程式碼,一航太長是會往右邊伸展,若 sidebar 在右邊的話,就會互相蓋到。不過我正在考慮把內頁的 sidebar 拿掉,一來 sidebar 在左邊,每次載入都要花時間,拖慢內容呈現的速度;二來因為這個 theme 已經有 navigation bar 的設計了,可以很方便地回到首頁或其他地方;三來這樣子就更寬了,我喜歡。

要寬:一樣是因為文章裡會列程式碼的緣故。有些 theme 有用 HTML/CSS 限制寬度,但我希望是能夠 browser 有多寬,就用多寬,這樣才夠用。

清爽乾淨,鍊結清晰,標題明白,屬性不喧賓奪主:這個條件蠻主觀的,但我覺得這個 theme 蠻符合我的要求的。

不過,還是不能夠直接套用,beeblebrox 這個 theme 與我的 blog 還是有些屬性不太相同:

Creative Commons 授權預設使用 Attribution-ShareAlike,我只需要 Attribution 即可。這個把相關的 code 拿掉,改用之前的 WP-CC plugin 即可。
留 comment 的地方,如同 wordpress 預設的 [...]

 Prev 1 2 3 4 5 6 7 8 9 Next