TinyMCEComments 0.4.2

昨夜沒有玩遊戲消磨時間以外,反而繼續嘗試如何讓 TinyMCEComments 支援 K2 以及其他會用 AJAX 傳送留言的主題。

因為用家終於按捺不住,向我發出追魂電郵。

其實我對將留言轉成 AJAX 這種設計不以為然,反正大部份人也是「一擊脫離」,寫好留言就離開。AJAX 純粹只是美觀,並沒有為瀏覽者帶來更好的 experiences。我是這樣想的。

所以最初(九個月前)也沒有很用心研究這問題,尤其是我 JavaScript 編寫能力只是半桶水,對任何新潮 framework,好像 JQuery,prototype.js 等等一竅不通。最後只是草草地在自己的電腦上設定好一套 WordPress,裝好 K2,抄了幾句 JQuery,三四試不行便放棄,將注意力放在其他事情上。

一直將事情擱到昨夜。

不得已,迫得近在眼前,唯有硬著頭皮重新來過。本來我是將那段處理傳送留言的程式碼放在wp_footer 那裏,誰不知原來 K2 原來根本就沒有使用過 wp_footer()。後來,把那函式拆掉,試了還是不行。這次又是 JQuery 那段爆出問題,掛事件怎樣還是掛不了上去。一氣之下轉用原始的 document.getElementById(‘submit’).onclick 重寫,居然就可以了。

氣得我… 我從來沒想過照著 guideline 寫會出問題。見鬼。

在這裏下載最新版本:Download

Update: 有 0.4.2-1 版,因為不小心把早前的程式碼留了在裏面,所以有這個再修正版本。唉,真不小心 :-(

Adsense for Search

其實我不是想賺多一點廣告費,只不過 WordPress 本身的搜尋功能實在太… 總而言之效果不能接受。既不會搜尋頁面,關鍵字太短也會找不到(看過有很多人嘗試找 “Trackping Seperator” 失敗而回)。最後如果用 Google 搜尋的用戶比較多,我想還是從頁面直接移除內置的搜尋連結好了。

外判支援

難怪現在大公司都喜歡外判公司內部的系統支援服務了,因為支援自己開發的 WordPress 插件還真是意外的累人。首先你要回應問題,不管在網誌留言還是直接送信,最好要快別讓人家等著,不然有些性子急的人的通知會排山倒海的壓過來,而且良心不停譴責自己真有夠難受。

好了,支援問題千奇百怪,有些是要求加進新功能,有些則是 bugfix – 但問題是大家 WordPress 用的主題,版本也不盡相同,要支援各種不同搭配難度真高。再加上瀏覽器的問題,天呀,這明明是 TinyMCE 的問題呢,竟然要我想辦法解決。不同瀏覽器,要分別支援 IE 跟 Firefox 就有夠頭痛了(證明 Opera/Safari 市場還小,或者他們對 TinyMCE 的支援很棒),而且還有對不同版本的支援,由 IE5 到 FF 1.0 的支援請求也有。

加上自己有一份正職,這些東西已經成為了一種… 夢魘了。不不,千萬別誤會我討厭大家傳來支援請求,更不要以為我會將服務外判,只是我會慢一點而且可能不會再搞新插件而已(畢竟 WP 功能越來越完美,插件量也越來越多),況且爛攤子是自己搞出來的,收拾的當然也是自己啊!:-)

TinyMCEComments, 繼續

這個只有 36 行程式碼,邏輯上只有一句 if 來控制流程的插件居然沒有人弄過,真不敢相信。今天收到幾個留言,以為有人會來提我一下「這個插件早有人弄過了」,怎料到現在還是沒有 :P。倒是支援問題有一大堆,主要還是跟其他留言插件的相容性。希望這堆問題會在 0.2 版得以解決。

對了對了,今天早上收到另一封電郵,主要是關於 TPS 跟 threaded comments 的相容性問題。想了個解決辦法,如果沒問題我會更新 wiki 貼出來。其實這封信還問我可不可以捐錢的(有點受寵若驚了),想想這裏連 Google 廣告也擺了出來,不如直接向人家伸手拿錢吧(笑)。

I’m a bit surprised that no one ever made this 36-lines-only WordPress plugin. I expected someone would point me out there’s already another plugin that does the same thing, but till now I don’t receive a single complaint. OTOH, there are reports that this plugin doesn’t work peacefully with other comment-based plugin. I’m still studying and hopefully they could be solved in version 0.2.

Todo List:

  1. Linebreaks are automatically turn into <br />s
  2. Work with various plugins that make use of the old <textarea>
  3. Populate thge toolbar with useful functions

TinyMCEComments

好像暫時還沒有人做過這款插件。

我對訪客留言要自己輸入 html 語法這種方式實在不太滿意,偏偏有一套好好的所見即所得編輯器卻只給網誌作者自己用,實在太浪費了。不知道 WordPress 開發團隊是怎麼想的,不過搬過來用方法也不太難,在 header.php 加幾句便成。這個 plugin 剛剛花了不到三十分鐘時間將我以前寫在那個地方的 JavaScript抽出來放到 plugin 裏,留給懶人跟 HTML 恐懼症患者使用。

英文說明和下載連結都放在這裏,如果出現了甚麼問題請回報。

MCEComments

Why the need of a preview box if you have the What You See Is What You Get Editor in the same place as your visitors type in the comments?

This plugin turns the comment field from a primitive <textfield> into a WYSIWYG editor, using the internal TinyMCE library bundled with WordPress 2.0 or up, without the need of another separate installation. Functions that only available to writers like adding images were removed and will not show up in the toolbar.

Consider a donation :).


Current Version

0.4.5 – Download

Version History
0.4.5 – Compatible with WordPress 2.6.x; Fix a bug that cause JS regeneration doesn’t work

0.4.4 – Read here (Thanks ioannis!). Also the tooltips should be displaying correctly, and should support K2/AJAX Commenting.

0.4.3 – Support for WordPress 2.5. (gzip/cache for the script will be in 0.4.4)

0.4.2 – Support for K2 and other themes that uses AJAX Comment field, finally! (JQuery is time wasting, and it just doesn’t work for me) (And given that they are using onsubmit() to submit comments, not onclick() of the submit button!)

0.4.1 – Store comments in UTF-8 instead of HTML entities; Load TinyMCE only when there’s a comment form (Thanks José!)

0.4.0 – User supplied custom CSS; Modify interface a bit. Plugins of TinyMCE are now auto detected and can be added by clicking on the hyperlinks.

0.3.5 – Allow to change interface language; Subscript/superscript options; Allow user to add own plugins and buttons to the editor

0.3.0 – Increase loading speed; Fix IE7 disappearance of linebreaks

0.2.5 – Enable Firefox spell checking in the editor

0.2.0 – Newlines are correctly displayed and added a JavaScript function help adding text into TinyMCE editor

0.1.5 – RTL Text Support and allow to view HTML source

0.1.0 – Initial release

Instructions

The usual steps for installing and running a WordPress plugin:

  1. Download.
  2. Rename the extension from phps to php.
  3. Upload.
  4. Activate.

Known Issues

  1. Unwanted carriage return/newline/enter key were put into comment in older versions of Firefox. (Unconfirmed)
  2. Content inserted not within tags (for instance, WP Grins) are not removable by backspace. (Workaround: encapsulate in <span> tags, see updated instructions for WP Grins below)
  3. Message disappeared in submission using IE 6. (Unconfirmed)
  4. Compatibility with various comment-related plugins and customized themes. Please make sure the comment field is named “comment” and there are no other scripts that will interfere with it.

Working with WP Grins

Open wp-grins.php from the WordPress admin interface. Find

myField = $('comment');

Replace with

myField = document.getElementById('comment');
insertHTML('<span>'+tag+'</span>');
return;

Making TinyMCEComments works with other plugins

TinyMCEComments provides a JavaScript function insertHTML(text) which could be used by other plugins on the same page. It is used for inserting customized content generated by other plugins into the TinyMCE editor.

Compatibility with Akismet

Since there are some users receive complaints that the plugin increase the number of false positives of Akismet anti-spam, I sent a support request to Automattic recently. Here’s the conversation.

mk dot is dot here at gmail dot com wrote:
> Hello,
>
> I am the author of the plugin – TinymceComments for WordPress. My plugin
> just turns the comment area of the blog into a WYSIWYG editor, just like
> the one in the write page of the admin interface. Some users complains
> that if my plugin is turned on, many normal and healthy comments (without
> using special tags I suppose) were considered as spam by Akismet. I’m no
> anti-spam expert, so the only thing I can do is to ask for an advice. My
> plugin doesn’t have any server-side elements (except the admin interface)
> but purely rely on JavaScript. Mya you provide ideas so I could further
> investigate and solve the problem? Thanks in advance and I am looking
> forward to your reply.
>
> Yours,
> Thomas Au

Hi,
If this were all users then I think there would be a clear relationship somewhere.
As it is only some, and as it could therefore be any factor in their comment which causes this I don’t see that Akismet and your plugin are causing problems.


Mark

Though they claimed there are no clear relationships, I’ll continue test on this. And, if your blog is okay with both plugins activated, leave me a message :).

Update: Seems I’m getting less comments eaten by the Akismet filter on my test blog (Here I use SK2). Either it could be Akismet getting used to it, or some other unknown factors acting behind the scene. Tell me your case if it’s different.

P.S.: This plugin is NOT designed to work with Live Comment Preview. Stop complaining about it.

P.P.S.: Please stop using this page as your testing ground, as the intention of the thread is for support request only. Set up a WordPress yourself, install the plugin, and enjoy yourself there. If you wish to report a bug or provide insightful and valuable comments, file your request here or e-mail me directly.

wpopenid+ 錯誤修正與 Pavatar

終於找到錯誤的原因了!話說我早前遇到一篇無名氏的留言,旁邊卻有 OpenID 的圖示。起初以為這問題無解沒有理會,只期待作者會推出新版本。剛剛無聊試了一下,發現原來只要把原有 wpopenid+ 自動開設的戶口移除,出來的留言便沒有問題。

趁還沒心情溫書,準備為這裏添置新功能:Pavatar。Pavatar 大概可以想像成分散式的 Gavatar,概念跟 OpenID 差不多,留言者只要提供預先設定好的網頁的 URL,便能設定自己的圖示,很方便吧?只要你的網站有權限讓你設定在 <head> 裏的 meta 標籤,便可以享受這項服務。

Update: 設定不了 :( 還是省下一點腦汁比較好。倒是將留言變成 tinyMCE 的編輯器。