Wednesday, December 09, 2009

Gadget

哈哈哈哈哈你地覺得我會有弄清事情來龍去脈的一天嗎?





What is a gadget?


Google gadgets are HTML and JavaScript mini-webpages, mostly served in iFrames that can be embedded in web pages and other apps. Gadgets may be embedded in iGoogle, Google Desktop and any page on the web. Gadgets that can work on iGoogle, Google Desktop, and other pages across the Web are created using the Universal Gadgets API, and they are as easy to develop as a webpage.


While simple gadgets can be created in a few minutes, in order to develop a useful gadget with interesting functionality and an appealing look and feel we suggest learning about HTML, JavaScript and Google's Gadget API.


A gadget is described in an XML file. This XML file defines the gadget look and feel as well as its functionality.


Here is an example "Hello World" gadget:



<?xml version="1.0" encoding="UTF-8" ?>

<Module>

<ModulePrefs title=“Hello World" />

<Content type="html”><![CDATA[

<b>Hello World!</b>

]]></Content>

</Module>


A gadget is defined in an XML document containing a module root element. In this example the module contains a ModulePrefs element and a Content element. The ModulePrefs element describes general gadget preferences, such as its title ("Hello World" in this example) and may also contain other gadget preferences, such as Description, Author and more. The Content element is the heart of the gadget and it describes the actual HTML displayed by the gadget (the >Hello World!</b> string in this example). The Hello World gadget in this example is very simple - it has very limited functionality and will just display a "Hello World!" text - but more advanced gadgets will use the Content element to put their JavaScript and HTML code. The <![CDATA[..]]> markers are XML standard way of embedding data strings within XML elements. Learn more about CDATA here.


Developing gadgets does not require special development tools. You may either use the online Google Gadgets Editor tool (GGE), or use your favorite text editor to edit the gadget and upload it using GGE.




Some gadget examples


Gadget functionality runs from simple static HTML pages to very sophisticated HTML, JavaScript, AJAX with Server Side functionality gadgets, such as a virtual keyboard that lets you type in your own locale even if you are are using a kiosk computer that does not have that locale installed, and lets you also email the text you type using an email server.


To get a good sense of what gadgets can do let us review some gadgets examples.
In this section we will introduce some gadgets and in the next section we will review more gadgets, view their source code and learn how they operate.





Some Code Examples


To learn how gadgets work, let's go through some gadget code examples:


A Hello World


As a reminder let's look at the Hello World gadget presented before.



<?xml version="1.0" encoding="UTF-8" ?>

<Module>

<ModulePrefs title=“Hello World" />

<Content type="html”><![CDATA[

<b>Hello World!</b>

]]></Content>

</Module>


A Better Hello World


The following example also displays a Hello World message, but also introduces the ModulePrefs and the UserPref sections.


A better Hello World gadget


In this example we see a module named "My First Gadget".


The first section (green) describes the gadget preferences in the ModulePrefs XML element. The ModulePrefs section describes the gadget name, description, height, author's name and a category. All these attributes are used by Google when the gadget is published to the gadgets directory.


The second section (blue) describes user preferences. The set of user preferences used by the gadget is really up to the gadget developer. In this example we chose Color, Toggle and Locations. The developer of the gadget chooses the set of user preferences that make sense to the gadget. After publishing the gadget the user of the gadget selects the preferred values for the gadget preferences and saves them as her own preferences. An example would be color. A gadget developer creates a Color UserPref XML element and the user of the gadget may chose her favorite color, such as "blue". The Color is saved by iGoogle and next time she logs in to iGoogle the value "blue" is restored.


The third section (red) is the content of the gadget. In this case, it's the same HTML string seen before containing the "Hello World" text. This time the "Hello World" text is colored in red. Note that, in this example, even though user preferences were introduced they were not actually used by the gadget content (e.g. in this example, the color of the "Hello World" text is always red). In the next example, however, we demonstrate how they can be used.


Notes example - Storing State


The notes example allows a user to create a note and save it.

The next time the user visits iGoogle the note will be restored.

It also lets the user set a different background color for the gadget.


Storing State in a gadget


The color is selected by a user and stored into the "color" user preference. Note the <UserPref name="color" element. In this example a user may choose 3 different colors: Yellow, Blue and Green.
In the content section you may notice there is a <style> block. This block determines the look and feel of the gadget using CSS. CSS is a widely used standard for controlling HTML look and feel. Inside the style block you'll find the text
background-color: __UP_color__;
This means that the value of the background-color CSS property is replaced for each user of the gadget with the value of the user preference color selected by the user from the UserPref section. This is done automatically by iGoogle.


Another example of user preferences usage would be the text UserPref highlighted in red.
In this example we use a hidden text UserPref. Since user preferences are stored by Google, the text UserPref lets us save the content of the note. We use JavaScript to populate the test UserPref with the value of the note textarea.
The <Require feature="setprefs"/> element provides us with programmatic access to the user preferences object using JavaScript. Programmatic access to user preferences is an optional feature, this is why we include the Require section. To learn more about optional features see http://code.google.com/apis/gadgets/docs/reference.html#Feature_Libs


The <UserPref name="text" default_value="Type text here.” datatype="hidden"/> element defines a hidden user preference. The hidden user preference is used to store the content of the note. However, this is not done automatically. We do it by calling the JavaScript save() function.
The JavaScript save() function is called whenever a user clicks the "Save Note" button. The method uses the __IG_Prefs() object to set the value of the user preference keyed "text" with the content of the "note" textarea element. _gel() is just a simple replacement for JavaScript's document.getElementById(), which gets a reference to an HTML element using its ID.


This example is simple, yet demonstrates the power of gadgets using Google Gadgets API.




Before You Start


The Google Gadgets API uses a few simple building blocks: XML, HTML, and JavaScript. Here are some resources that could help you get familiarized with building your own gadget. As a starting point, all you need is a basic understanding of HTML. Later, as you write more sophisticated gadgets, you will probably want to learn some JavaScript if you're not familiar with it already.



  • HTML is the markup language used to format pages on the Internet. The static content of a gadget is typically written in HTML. HTML looks similar to XML, but it's used to format Web documents rather than to describe structured data.

  • JavaScript is a scripting language you can use to add dynamic behavior to your gadgets.

  • Google Gadgets API is the JavaScript library developed by Google used for implementing the more sophisticated gadgets features, such as controlling user preferences programatically, tabs, remote server communication and more.

  • In addition, it would be useful to understand some basic XML concepts and syntax. XML is a general purpose markup language. It describes structured data in a way that both humans and computers can read and write. XML is the language you use to write gadget specifications. A gadget is simply an XML file, placed somewhere on the internet where Google can find it. It may be hosted by Google as well as on your own server. As demonstrated before, the XML file that specifies a gadget contains instructions on how to process and render the gadget. The XML file can contain all of the data and code for the gadget, or it can have references (URLs) for where to find the rest of the elements. References (URLs) were not discussed on this page. To learn more about them read http://code.google.com/apis/gadgets/docs/fundamentals.html#URL

  • Gadgets are open-source by design. A immediate consequence is that if you see a gadget with interesting functionality, you may simply open the the gadget module definition file with your browser and examine its source code. For example, the source code for the Date & Time gadget is here: http://www.google.com/ig/modules/datetime.xml. This is the best way to learn about gadgets development.




Gadget Hosting and Placement


As a gadget developer you have two options for hosting your gadget - you may host the gadget on Google's servers or you may host the gadget on your own server. Hosting the gadget on Google's servers is very convenient since you don't need to have administrative access to a web server. If, however, you do have access to a web server, you can use it to host your gadget as well.


Follow these steps to publish a gadget using Google hosting service:



  1. Use the Google Gadgets Editor (GGE) or any text editor to write your gadget specification, and host it on a public Web server. The easiest way to do this is through GGE. When you save a gadget in GGE, it is automatically hosted in the GGE environment.

  2. In GGE, choose File > Publish. This step will put your gadget on Google's servers, available on the internet.

  3. You may grab the URL to your published gadget. In the Publish dialog use the link that reads "Your gadget is located here".


Gadgets may be placed on iGoogle, as well as on any other blog or Web site such as http://blogger.com, http://orkut.com or your own website.


To add your gadget to your iGoogle page use the following procedure:



  1. Use the Google Gadgets Editor (GGE) or any text editor to write your gadget specification, and host it on a public Web server. The easiest way to do this is through GGE. When you save a gadget in GGE, it is automatically hosted in the GGE environment.

  2. In GGE, choose File > Publish.

  3. In the Publish Your Gadget dialog, choose Add to my iGoogle page. If you don't already have an iGoogle page, you must create one as described in Getting Started.

  4. Go to http://www.google.com/ig, and make sure you are logged in. You will see the gadget you just published to iGoogle.


For more details visit http://code.google.com/apis/gadgets/docs/basic.html


To place gadget on your website use the following procedure:



  1. Create a gadget using GGE or your favorite text editor

  2. Publish the gadget, by choosing File > Publish in GGE

  3. In the publish dialog select the Add to a web page option. This action is also referred to as Syndication.

  4. Select your preferred color, width etc, click the Get the Code button and copy the code in the text box. This is a short JavaScript code that will display your gadget on any Web site.

  5. Paste the copied code on your blog or Web site.


Gadgets you create may be used by other users (if you choose to publish them), and any gadgets that you see and like can be added to your personalized iGoogle page, blog or Web site.
To add gadgets created by others to your iGoogle page go to http://www.google.com/ig and click Add Stuff. Browse the gadgets directory and add which ever gadget you like.
To add gadgets created by others to your website go to http://www.google.com/ig/directory?synd=open, select your gadget and click Add to your webpage.




Internationalizing a Gadget


After implementing a useful gadget you may extend its reach by making it available to users speaking different languages by internationalizing the gadget.


Localizing a gadget is simple. Let us start with an example:


Internationalizing a gadget


In this example we see the Hello World example from previous sections, in different languages: The title and the "Hello, World!" messages are externalized and translated into two languages, English and Japanese.
In the gadget module definition the "Hello, World!" string was replaced with __MSG_hello__ and the title was replaced with __MSG_title__. In addition to this change, there are now two message bundles that go along with the gadget: the en.xml message bundle, which translates __MSG_hello__ to "Hello, World!" and ja.xml which translates __MSG_hello__ to the "こんにちは、世界" Japanese string.
When a user uses your gadget, Google will make sure that the gadget automatically uses the user's own language, where available, as indicated by the user's domain and language preferences.


We recommend that you to prepare the gadget for internationalization and start with English. This requires from you to externalize all strings in your HTML by using __MSG_ variables and creating an English message bundle.
If you speak another language, you can also translate the English message bundle to this other language and include it with the gadget.


If your gadget becomes popular enough, you may want to consider translating it into even more languages. But the important thing is that you make your gadget ready for internationalization in the first place by using __MSG_ strings rather than the actual English strings in the module definition.


To learn more about internationalization visit here.




Where to Go Next


You're ready to start writing your first gadget. Here are some resources to help you:



For additional information consult the resources below:



Third party gadgets and links are listed for your convenience. Google does not make any representation, endorsement or warranty regarding their content.





Labels:

Monday, November 16, 2009

爆房

上星期四清晨我趕不上公司車,很有點this is not my day的感慨。

輾轉抵達辦公室,在洗手間攬鏡自照,覺得自己消瘦了太多,亦無心打扮,便想起「長門盡日無梳洗,何必珍珠慰寂寥」兩句詩。復又想起我既不是江采蘋,也未有皇上寵幸,心裡便更添悵然。

中午找梁小姐想她陪陪我,但不巧梁小姐公私兩忙。我不忍太過纏擾她,便坐在她身旁畫了一幅畫,然後開會去。

六時半下班,悲傷竟如舊患襲來,我一邊走下電梯,一邊流淚。出了辦公大樓,竟下起一場瀟瀟雨,我沒有傘,便一邊啜泣一邊找計程車,我需要醫生的耳朵。

七時半,不停哭了一小時後,弄濕了一整包tempo後,我終於坐在醫生身邊。但我只能夠哭泣,我說不出任何說話。我失去了我的組織能力。醫生於是命令我立即回家休息,並且要好好進食。我哭著往配藥處,藥劑師有點擔心,但還是放我走了。

哭哭哭哭哭,我在計程車上一直哭回我的低密度新家。我忍不住打電話 ,向你求救。

其後。

其後,當我睜開眼,我看見了你的笑臉。你陪我走出客廳,白色實木大門已經被爆開,而高大威猛的男子,站滿一屋。他們是:消房員,救護員,警察及屋苑護衛。

我只是哭得累極,睡得深了。抱歉令你這樣擔心,抱歉驚動了這麼多人。

我失去了一道門,但也因此,看見了另外一條路。

Labels:

閒話家常

在街上給人輕薄,向身邊人申訴:

妹妹評說:「d 人真係賤格...你又係既,著衫咪咁低啦!」
梁小姐說:「下次小心d...你又係既,行路咪咁扭啦!」
我問妹妹:「乜我好扭咩?有幾扭呀?!」
妹妹不屑:「七十樓啦你!」

還是 wai lim 疼我,他一收到消息,便辦妥公務,立即到警署接我,然後好好安慰我。

Labels:

Monday, November 09, 2009

SOFINA Beaute 高滲透保濕精華霜

扮存在主義的我常常掛在口邊的一句說話是年歲長了可不要是甚麼大不了的事,只要對人生的閱歷同步增長,年紀都不是活到狗身上去,便無悔過去的每一天。

再次拾我崇拜的錢鍾書先生的牙慧:人生據說是一部大書。而世上有一種人。他們覺得看書的目的,並不是為了寫書評或介紹。他們有一種業餘消遣者的隨便和從容,他們不慌不忙地瀏覽。每到有什麼意見,他們隨手在書邊的空白上注幾個字,寫一個問號或感嘆號,像中國舊書上的眉批,外國書裡的Marginalia。

寫在人生的邊上。

見諸日常,我很願意生活的痕跡在我人生的書眉上留下深深淺淺的腳印;但說到容貌身材,我卻瀟灑不起,因為做了三十年女人,我非常明白眉眉目目一顰一笑, 可以令人一念之天堂,一念之地獄。

張愛玲說出名要趁早,我說保養都要趁早。早些開始尋找適合的保養方法,就不用書到用時方恨少,末了只有無奈依靠天價產品。

用了SOFINA Beaute 高滲透保濕精華霜三星期,我認為這可以成為我的super cream之一。睡前把一茶匙的面霜用掌心搓暖,然後在面部及頸項打圈按摩,眼圈週邊則用點推手勢,而唇部則塗上薄薄一層。翌日一覺醒來,肌膚極為柔潤。

如果你像我一樣愛保養卻沒有耐性時間每天出門前花一小時塗塗抹抹,建議你在早上潔面後淋浴前再把一茶匙的SOFINA Beaute 高滲透保濕精華霜塗在面上,包括眼圈及嘴唇。淋浴後你會發然蒸氣已經幫助你的皮膚把面上的精華霜完全吸收,此時你只要塗上防曬便可出門。這個方法既簡便而且有助你整天維持水潤。

寫在人生的邊上。我但願能繼續帶著這種業餘消遣者的隨便和從容,體味人生,品味小資產階級的生活。我上網研究了一番SOFINA Beaute 高滲透保濕精華霜的主要成份,也是抱這種好奇好玩的心態。

Labels:

Monday, October 26, 2009

今年生日

多謝精心炮製的party,漂亮的鮮花及三隻可愛的熊仁先生。很愉快的一個夜晚。Life is thrilling but you light up my days.

Picture: Dance at Bougival by Renoir

生命是一個過程

除了測量師叔叔,尚有兩個人對我的物業買賣觀影响至深。一位是舊同事嬌滴滴律師,一位是遠在西岸的 Uncle CW。

嬌滴滴律師回港執業前在倫敦的大行做樓宇買賣,專門服侍那些喜說廣東話的中港台星洲同胞。因利成便,她時常購入倫敦近郊的小房子,經過一輪修葺,待房子裡裡外外煥然一新後再轉手賣出,利潤可觀。

Uncle CW 在西岸歷史名城開了一間類中國古玩傢俱店,兼賣手飾。他的店清優典雅,傢俱在柔和幽暗的燈光下古樸美實。他笑說他的顧客都投訴傢俱一買回家便失卻味道。夜來出城晚飯,他帶我們一眾來客往他即將放租的寫字樓物業參觀,復又指著街上另一棟大廈說若他買下了那頂樓,他就開一間迴轉餐廳。「七十呀,你知嗎?商業租客就會 upgrade 你間樓但家用租客就 downgrade 佢,所以你要買商業物業呀。」Uncle CW下結論。

當然我未有能力投資商用物業,但總括嬌滴滴律師及Uncle CW的經歷,投資物業咩都唔洗講,地點最要緊,因為這是升值的基礎。第二步就是你如何為物業打扮,令它看起來舒服,容易令人受落。這增值行為類似銅鑼灣那些時裝小店的經營之道--衣服明明是深水埗長沙灣荔枝角有售的貨色,經時裝小店擺擺弄弄,左披右搭,小姐們便用十倍價錢買回家。ummm 所謂名牌私竇,亦是同樣一回事。

我敢於去到盡,其實也不是 groundless 的。當然我非常幸運,時常巧遇出色前輩,但我在人生的路上卻並非未輸過。我輸過,仲輸得好狠仆街。然而生命就是如此,承受得了承受不了的你也要承受。那個夜晚我心碎了,帶著七顆 stilnox 就往水塘,打算在麻醉後溺斃自己。麗口在我出門後覺得事情有異,果斷地報了警,及時救回我一命。

事後有兩個人令我徹底地打消輕生的念頭,一個是醫生,一個是 ak 師兄。醫生說:「七十小姐,浸死好辛苦的,當你個肺入水後你會極力掙扎至慢慢氣絕。你勿以為吃了安眠葯便失去意識,當你落水呼吸不了你身體便會本能釋出腎上線素,你就會馬上清醒過來!」

ak 師兄說:「白痴婆,我們怎可以幫你堵住傳媒把口呀如過你死左,仲懶醒擇埋d咁既日子!方向報一定會大大隻字話妙齡少女為情輕生啦。低鬼能既你。」

此時此刻事情已經變得內在婉約。傷口當然仍是粉紅色,稍一觸碰就會痛,但大家這樣愛我,我不忍心辜負大家的心意。

生命中不能承受的輕是存在的,但前題是生命仍然存來,才能述說能不能承受。

Picture:我的近照,狀態ok,還幫朋友主持婚禮。

Friday, October 23, 2009

Building My Helena May

我其實蠻愛冒險(所以我喜歡永遠嚇死你的 event management 多於 office admin 所以我喜歡鑊鑊新鮮的舞台多於電影)。

談戀愛我唯心,知道應該為將來籌謀但我縱容自己放肆。工作上如果覺得委屈,我話走就走,寧願獨自面對其後找工作的種種不安定。旅行不買地圖不訂酒店,亂行。而原來買房子我也可貫徹任性的作風,霎時衝動購入低密度住宅一間,回首還是覺得之前居住的那區好,便立即放盤。

家人朋友都覺得我冒險。但 no risk no gain, 並且常常謹記 hope for the best, prepare for the worst--既然有心理準備接受最差的情況,何不釋然去到盡,all or nothing 地 execute 自己的自由意志?

這次賣房子我必定扭盡六壬,使出我混身解數。如果我連其他人的ideas都可以market,我為什麼不能market我親手收拾,滿是我靈氣的房子呢?嘿!

Pic: Personal Values by René Magritte

Labels:

Tuesday, October 20, 2009

Soooo Sofina Beaute

中學念的是文科,但我時常想想像,如過我讀理科,如過我讀chem,如過我chem拿了A但考不進醫科,我會不會選擇主修化學?如果我主修化學,我會不會進入護膚品公司,研發護膚品,造福萬民?

The body shop尚未賣盤時,其創辦人曾經說護膚品是一門好生意,你只要生產一瓶氣味顏色清新可喜的東西,然後找個代言人,便可大賣。但好說護膚品也是一項化學發明,實則虛之者有之,真正有益用家者亦不能沒殺。誠然大家可以選擇塗凡士林,但能夠一生只塗凡士林的女子,世間幾何?

回顧Sofina 母公司花王的歷史,正正是一個科學進化里程碑。從1890年的第一塊肥皂到潤膚露,從洗髮精到洗面膏,最後到護膚品,企業在研發的旅途上一步一步向前走。而Sofina,由1982年面世,發展至今,已經是一個擁有27年資歷的品牌。

猶如其他人情物事,能不能邂逅適合你肌膚的護膚品,也講求緣份。當然Sofina Beaute稟承Sofina產品一貫潤澤透薄易推的優點,討好用家不難,但更令我驚喜的是,大學時我用 Sofina very very,深覺其甜睡面膜極窩心滋潤,現在長了一點年紀,這Sofina Beaute又能切合我肌膚在初秋時份的轉季需要。

Sofina 彷彿在陪伴我,走這條成長之路。

英雄先生:你當年chem拿了A,令我非常崇拜。又不過吸引我的其實是你的味道--這個有機會再寫。

Labels:

Friday, October 16, 2009

如果西瓜,一個旅人

~ 很喜歡sofina贈送的這一套新產品。容許我,緩慢地寫 ~



那年盛夏,在羅馬一城碎石上我與你揮著汗在遊行的人群中蠕蠕前行。你把一塊濕毛巾搭在我的後頸,為我散熱。我的身子從來沒有那麼熱,混身不舒服。你拖著我的手,引領我向前走。

那個毒太陽普照的午後,你在路邊,買了一塊西瓜給我。你不懂意大利語,但你在人頭湧湧的街頭擠來擠去,終於從小販攤子上買了一塊西瓜給我。要我吃西瓜消暑,是你的主意。菓汁滴滴,我卻不完全領情。我嫌西瓜拿在手中黏呼呼,又想回家洗澡。一貫縱容我的你為了要我吃那消暑解渴的良菓,便像逗貓一樣慢慢地安撫我。

那片西瓜,甜蜜可口,菓香怡人。

其後,你我不再走在一起。其後,我受過傷。其後,我成天跌跌撞撞,因為沒有人愛我一如當天的你。其後,我長了一點年紀,因為沒有你在旁,我不得不長大。這些其後,不知道你可知道。

是 sofina 爽膚水喚起這關於西瓜的回憶,關於初戀的回憶。

沒有你在身邊的日子,我便得自己照顧自己。幸好有 sofina 爽膚水,我塗塗抹抹,既潤澤了疲倦缺水的肌膚,並帶走了黯淡無光的老化角質,那婉約的花香亦鎮定了我起伏不安的神緒。

Labels: