Skip to main content

開始貢獻開源專案有多簡單?三件暑假都過了你可能還不知道的事

· 4 min read

暑假都快結束了,你的暑假夠充實嗎?參與開源專案,其實離身為學生的你沒那麼遠:(以下拿 Mozilla 跟 g0v 相關專案做範例,當然不止這兩家的開源專案,可以在 github, googlecode 等開源專案聚集地上找到有很多有趣的開源專案,選這兩家的原因是在台灣你一定找得到人問)

一。你不見得要懂英文 Fluent English is not essential criteria

剛打出這點,我自己都覺得很扯,跟軟體扯上邊的事情不懂英文怎麼搞?但我發現這點還真的成立,因為現在身在台灣就有不少參與開源的機會,這是幾年前難以想像的:

二。你不見得要會寫程式 Coding skill is not essential criteria

如果你的英文還行,大型的開源專案需要各種人才的貢獻,諸如協助新使用者(Helping Users)、多使用並協助找錯誤(Quality Assurance)、協助推廣(Spread the word)、將軟體翻譯成中文(Localization)、改善文件(Documentation)等等,抽點時間出來,選擇自己能做的,就可以為其他人帶來幫助,也幫自己累積經驗。這不只是社會服務,你可以自行選擇參與自己愛用的、相信的開源專案。

三。你不見得需要先有想法 Idea is not essential criteria

對於會寫程式的人來說,大型專案會有非常多的現有問題需解決,並會為新人提供一些指引。如 Mozilla 提供了「what can i do」網頁,讓具備各種不同技能的開發者可以更快地參與能貢獻的專案。

  • what can i do http://www.whatcanidoformozilla.org/ (右上角可以切換語言) 例如熟悉 JavaScript 的開發者,可以參與 Firefox OS 使用者界面
  • Gaia 專案、Mozilla 網站開發、Firefox 界面等。

熟悉 Java/Android,可以參與 Firefox for Android 版的開發等等。

有自己的想法想實做當然很好,但在還沒找到之前,不妨先參與看看中大型的專案,查看文件、瞭解文化、學習程式風格、開發流程、與其它開發者互動等學校裡沒教的事,絕對會是很難忘的暑期經驗。

貢獻開源專案?從怪獸(Mozilla)與超人蓋亞(Gaia)開始吧

· One min read

上週在 Coscup 2013 演講的投影片,介紹為何要參與 Open Source 專案,基本 Firefox OS 架構,和 web 技術人如何運用自己的能力來參與 Gaia 專案開發。

** Steps to contribute to firefox os (gaia) **

為這次演講花一個晚上做了一個簡單的 hack demo,在撥打電話時,馬總統會報出正在播的數字。

感謝馬總統跨刀演出。

聲音來自 Open Source 的 Bumbler to speech 專案。

How to build your own 'repo' to Manage project with multiple git repositories

· 4 min read

'repo' is a good tool to manage project with multiple git repositories. Its developed to serve the need to manage Android Open Source Project (AOSP), which counts on bunch of open source projects. Then the 'repo' tool is used for chromium and chromium OS (known as open source version of Chrome browser and Chrome OS). Now Mozilla Boot-to-Gecko (B2G, known as Firefox OS) also adpot the 'repo' tool to manage multiple git repositories.

For a short time of experiment, I find its pretty simple to setup your own 'repo' that can help you manage multiple git repositories. Here is my findings.

To install 'repo' command, you can refer to Installing repo.

Make your own repo

All you have to do is:

1. setup an accessible git repository 2. Put a 'default.xml' file in it 3. Use 'repo init' command to access this  git repository.

Done!

Here is the default.xml sample, there are three main tags:

<div class="highlight">> <span class="cp">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
> <span class="nt">&lt;manifest&gt;</span>
> <span class="c">&lt;!-- define hosts --&gt;</span>
> <span class="nt">&lt;**remote**</span> <span class="na">name=</span><span class="s">"b2g"</span> <span class="na">fetch=</span><span class="s">"https://github.com/mozilla-b2g/"</span><span class="nt">/&gt;</span>
> <span class="c">&lt;!-- default settings --&gt;</span>
> <span class="nt">&lt;**default**</span> <span class="na">sync-j=</span><span class="s">"4"</span><span class="nt">/&gt;</span> <span class="c"><!-- projects -->**project** remote="b2g" revision="refs/heads/master" name="gaia" path="."</manifest>Look at the 'project' tag. It describes that we'd like to sync the 'gaia' repository's 'master' branch from remote 'b2g' host.

Explaination

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

The 'default.xml' syntax is wrapped by 'manifest' tag. It contains three parts of definition:

Hosts

<remote name="b2g" fetch="https://github.com/mozilla-b2g/"/>

remote' tag is used to define the hosts that we'd like to use in projects. Note that it's not the actual git URL, but where the git hosted on.We can specify the actual git URL in 'project' tag.

Projects

<project 
remote="b2g"
revision="refs/heads/master"
name="gaia"
path="."/>

The file describes that we'll like to sync the 'gaia' repository's 'master' branch from remote 'b2g' host.

The 'revision' path is defined within the original .git folder. To switch to branch like "v1.0.1", we could change  "refs/heads/master" to "refs/heads/v1.0.1".

It's almost the same as we have to do with git command.

By the way, default.xml itself is in a git repository, so you can specify versions by branch or whatever you like.

Defaults <default sync-j="4" />

In default tag we can specify the default values in project tag. ex: revisions, default repositories..., etc. 'sync-j' means with this setting, 'repo' command will download 4 resources at the same time.

The usage

Create a folder, switch in it, and run the following command:

> $ repo init -u https://&lt;your own git URL&gt;.gitThen, fetch the resources with command

> $ repo syncTo fetch a branch, run command
> $ repo init -u https://&lt;your own git URL&gt;.git **-b** &lt;branch&gt;

Read Git and repo cheatsheet for more details about how git and repo tool work together.  

Sample

Here is a working sample that able you to sync Mozilla Gaia repositorie, and automatically put vendor customization folder into its 'distribution/' sub-folder to ease the customization work.

Update at 7/29:

A workable process elaboration in slide format http://gasolin.github.io/gaia-repo/

幫 Bugzilla 換個新佈景

· 3 min read

新的 Bugzilla 樣式

在來 Mozilla 之前我用得比較多的是 RedmineTrac 等問題追蹤系統,到了 Mozilla 之後才比較常接觸 Bugzilla

目前大部份 Mozilla 的開源軟體都使用 Bugzilla 來追蹤 issues。所有開發者間針對 issues 的討論、審查、版本間的同步,各種開發相關的資訊都圍繞著這個系統進行,所以要貢獻 Mozilla 相關軟體開發專案,Bugzilla 是必定造訪的中轉站。

Bugzilla 是貨真價實源自上個世紀的古董網站。Wikipedia 的資料寫著,第一版 Bugzilla 發表於 1998 年,使用 Tcl 語言撰寫。Bugzilla 2.0 則改使用 Perl 語言撰寫。原因是比起 Tcl,當時 Perl 語言更普遍,改成使用 Perl 語言可以吸引更多自願協助改進的開發者。

這麼老牌的開源軟體當然有很多歷史遺留問題,我們先來看目前版本的模樣

一般預設的 Bugzilla 樣式

咳咳... 只能說,過去的審美觀跟現在已經不太一樣了。

還好,Bugzilla 的開發者有意識到這個問題,登入帳號後,點選畫面右上角的 preference(設定) ,把 Bugzilla's general appearance (skin) 改成 'Mozilla',選擇 Submit Changes(儲存)後,就可以看到新版界面。

調整設定

新的界面與 Mozilla 官方網站 風格一致,界面新潮許多。

新版界面

對於每天使用的工具,做得更好看一點,真的可以增加使用的樂趣哩。

註:RedmineTrac 剛好都發表於 2006 年,就像 git 與 mercurial 都剛好發表於 2005 年一樣巧。

(Firefox) WebApp自動偵測與安裝腳本

· 2 min read

這陣子在了解如何開發 webapp,其實基本流程很簡單。 要把網頁變成 webapp,最基本的動作就是照著說明寫個 manifest.webapp 檔案,放到網站的根目錄,然後在 web server 的設定加入對應的 MIME type 即可。用 Github Page 放網站的話,最後的 MIME 設定他們都幫我們弄好了。

使用者在電腦上透過 Firefox 安裝 webapp 後,就會多出一個對應的應用程式圖示,開啓這個 WebApp 時不會出現瀏覽器框,感覺就像真的應用程式。在 Android 上透過 Firefox for Android (測試版) 安裝 webapp 後,在桌面上則會多出一個 bookmark 捷徑。

圖:在 Mac 桌面上打開 2 個 webapp,不特別講也分不出來是 Web 還是 App 吧

我在測試的時候,發現寫好了 webapp 之後,使用者連到網頁時並不會自動詢問使用者是否要安裝 webapp。於是寫了以下腳本。

在 Body 標簽中引用以下腳本,即可自動偵測使用者是否可安裝 webapp (現在只有 Firefox Aurora 和 Firefox OS 支援 webapp API)

<script type="text/javascript"> //check if app is installed if ( navigator.mozApps != undefined ){var app_stat = navigator.mozApps.getSelf (); app_stat.onsuccess = function () {   if (app_stat.result) {         //instsalled   } else {         //not installed         var manifestUrl = location.href.substring (0, location.href.lastIndexOf ('/'))+'/manifest.webapp';         var app_install = navigator.mozApps.install (manifestUrl);   }}; app_stat.onerror = function () {   alert ('Error checking installation status: '+ this.error.message); }; } </script> 原始碼包含在 webapplate 專案中。

透過

location.href.substring (0, location.href.lastIndexOf ('/'))+'/manifest.webapp'; 可以自動取得目前的 IP 或網址。