Gears始めるメル
Tutorial
このチュートリアルのステップをふむ事で、どんな静的なファイルでも、オフラインでも
見る事が出来ます。このチュートリアルでは、どのようにして manifest Fileを作成するかを
ご紹介します。そして、15分後には、あなたは自分のファイルがオフライン状態でも
Gearsを用いて利用する事が出来るようになっているでしょう。
想定レベル
* 基本的なJSの知識
* HTTPサーバーにファイルをアップロード出来る事
* 静的ファイルをオフラインで見たい事
* 対象ブラウザと、OSを使用している事(詳細はこちらgears.google.com.)
まず始める前に以下のファイルをDownLoadしてください。
* tutorial_manifest.json
* go_offline.html
* go_offline.js
* gears_init.js
1. Edit the sample manifest file
Sampleのmanifestファイルを編集しよう。
Save this tutorial manifest file to your computer.
* Rename it "manifest.json".
* Open your manifest.json in an editor.
チュートリアル用のサンプルマニフェストファイルをダウンロード してください。
* ファイル名は"manifest.json"としてください。
* manifest.jsonをエディターで開いてください。どうせやるならと、http://code.google.com/intl/ja/apis/gears/tutorial.htmlこのページを訳しながらやってみようと思ってたけど途中で力尽きた。
ていうか、普通に簡単にできすぎてこのレベルは、特に訳さなくてもいいな。
やりかた
Googleから、gears_init.jsとgo_offline.jsファイルを落としてきて、適当なサーバーに上げる。
- http://code.google.com/intl/ja/apis/gears/tutorials/go_offline.js
- http://code.google.com/intl/ja/apis/gears/gears_init.js
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="../gears_init.js"></script> <script type="text/javascript" src="./go_offline.js"></script> <title>Enable Offline Usage</title> </head> <body onload="init()"> <h2>Getting offline-enabled documents with Gears </h2> <p> </p> <div> <p class="style1">Status Message: <span id="textOut" class="style3"></span></p> </div> <p><strong>Q:</strong> I want to see these documents when I'm not online! What must I do?<br /> <strong>A:</strong> <a href="http://gears.google.com/">Install Gears</a> on your computer and then click "Capture" to store the documents to your computer. You can then access the URLs without a network connection. </p> <p> <button onclick="createStore()" > Capture </button> </p> <p><strong>Q:</strong> I want to remove my offline access to these documents. What must I do?<br /> <strong>A: </strong>Click "Erase" below to removed the "captured" documents from your computer. The documents will no longer be available without a network connection. </p> <p> <button onclick="removeStore()" > Erase </button> </p> </body> </html>
こんなhtmlを同じ所において、キャプチャーってやるとマニフェストファイルに定義されているファイルがローカルのキャッシュストレージにたまる。
マニフェストファイルは以下の様なJsonファイル。
{
"betaManifestVersion": 1,
"version": "0.10.2.0",
"entries": [
{ "url": "index.html" },
{ "url": "gears_init.js"},
{ "url": "go_offline.html"},
{ "url": "go_offline.js"},
{ "url": "001.html"}
]
}自分的にGearsの難しいところは、複雑なところ簡単なところがぱっと見ただけでは、で分からないところだと思う。