本文描述包裝 Firefox 及 Thunderbird 之佈景主題的方法。
需求
製作 Firefox 或 Thunderbird 的佈景主題需要懂層疊樣式表(CSS)、會一點 XBL、還要有美術繪圖設計等能力(不過也不見得一定要)。本文只說明包裝佈景主題以便顯示於 Firefox 佈景主題視窗的方法。
佈景主題檔案架構
Firefox 及 Thunderbird 的佈景主題是一個將資料以下列結構包裝的 JAR 檔案:
theme.jar: install.rdf contents.rdf preview.png icon.png browser/一堆檔案 global/一堆檔案 mozapps/一堆檔案 communicator/一堆檔案 ...
- 最頂層必須有個 chrome.manifest 檔(適用於 Firefox 或 Thunderbird 1.5 以上)或 contents.rdf 來將佈景主題註冊到 chrome 中,另外還需要一個 install.rdf 清單記載佈景主題視窗中需要用到的資訊。
- preview.png 是佈景主題視窗中會出現的預覽圖,尺寸大小不限。
- icon.png 是 32x32 的 PNG 檔(可以有 alpha 半透明資訊),會出現於佈景主題視窗的佈景列表中。
install.rdf
install.rdf 清單長得像這樣:
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:type>4</em:type>
''其他特性''
</Description>
</RDF>
必備特性
install.rdf 檔中必須含有下列特性:
- em:id
- em:version
- em:type
- em:targetApplication
- em:name
- em:internalName
詳細資訊請見 install.rdf 參考。
選用特性
- em:description
- em:creator
- em:contributor
- em:homepageURL
- em:updateURL
如果你想將佈景主題送上 addons.mozilla.org,則 updateURL 就是必備的特性。
範例
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>{18b64b56-d42f-428d-a88c-baa413bc413f}</em:id>
<em:version>1.0</em:version>
<em:type>4</em:type>
<!-- 擴充套件的適用軟體,含最低需求及上限版本資訊。 -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.8</em:minVersion>
<em:maxVersion>0.9</em:maxVersion>
</Description>
</em:targetApplication>
<!-- 使用者會看到的資訊 -->
<em:name>New Theme 1</em:name>
<em:description>A test theme for Firefox</em:description>
<em:creator>Ben Goodger</em:creator>
<em:contributor>John Doe</em:contributor>
<em:homepageURL>http://www.bengoodger.com/</em:homepageURL>
<!-- 佈景主題管理員內部所用的識別名稱 -->
<em:internalName>newtheme1</em:internalName>
</Description>
</RDF>
以下是幾個 targetApplication 特性常用的應用程式 GUID:
Firefox {ec8030f7-c20a-464f-9b0e-13a3a9e97384} Thunderbird {3550f703-e582-4d05-9a08-453d09bdfdc6} Sunbird {718e30fb-e89b-41dd-9da7-e25a45638b28}
Toolkit API 官方參考文件
Official References. Do not add to this list without contacting Benjamin Smedberg. Note that this page is included from the pages listed below. So: Don't Add Breadcrumbs!
- Structure of an Installable Bundle: describes the common structure of installable bundles, including extensions, themes, and XULRunner applications
- Extension Packaging: specific information about how to package extensions
- Theme Packaging: specific information about how to package themes
- Multiple-item Extension Packaging: specific information about multiple-item extension XPIs
- XUL Application Packaging: specific information about how to package XULRunner applications
- Chrome Registration