-
Notifications
You must be signed in to change notification settings - Fork 11
1.x configuration env key
conf/[env]/[key].json
[key] の中に更に、圧縮版、非圧縮版、issue版といった、キー別に設定を分けて管理するための キー です。
[env]/[key].jsonは、develop.json, release.json, debug.json, といったふうに複数作る事で、キー別の差異を設定ファイルで分離します。
{
"develop": {
"entrypoint": "index/index",
"extend": {
"condition": {
"ua": ["android","ios"]
},
"content": {
"config": {
"beez.core": {
"url": {
//"app":"http://192.168.2.1:1109/m/example",
"api":"http://192.168.2.1:1109/p",
"base":"http://192.168.2.1:1109/m/example/s",
//"stat":"http://192.168.2.1:1109/m/example/s",
"vendor":"http://192.168.2.1:1109/m/example/vendor"
}
}
}
}
},
"requirejs": {
"baseUrl": "/m/example/s",
"paths": {
"underscore": "/m/example/vendor/underscore",
"zepto" : "/m/example/vendor/zepto",
"backbone" : "/m/example/vendor/backbone",
"handlebars": "/m/example/vendor/handlebars.runtime",
"beez" : "/m/example/vendor/beez",
"backbone.localStorage": "/m/example/vendor/backbone.localStorage"
},
"shim": {
"backbone": {
"deps": ["underscore", "zepto"],
"exports": "Backbone"
},
"zepto": {
"exports": "$"
},
"underscore": {
"exports": "_"
},
"handlebars": {
"exports": "Handlebars"
}
},
"config": {
// configuration information used by beez
"beez.core": {
"url": {
//"app":"http://0.0.0.0:1109/m/example",
"api":"http://0.0.0.0:1109/p",
"base":"http://0.0.0.0:1109/m/example/s",
//"stat":"http://0.0.0.0:1109/m/example/s",
"vendor":"http://0.0.0.0:1109/m/example/vendor"
},
"defines": {
"globals": {
"DEBUG": true
}
},
"logging": {
"level": "DEBUG",
"separator": " "
},
"router": {
"*default": {
"route": "*default",
"name": "todos",
"require": "todos/index",
"xpath": "/@/todos"
},
"todos/:state": {
"route": "todos(/:state)",
"name": "todos",
"require": "todos/index",
"xpath": "/@/todos"
}
}
}
}
}
}
}
[env]/[key].json 設定ファイルは、大きく4つのセクションに分かれます。
entrypointextendrequirejsrequirejs.config["beez.core"]
requirejsで最初にロードされる script の path を指定します。
ベースディレクトリパスは設定の requirejs.baseUrl です。
require.beez.js.hbs を合わせて参照ください。
アクセス端末 UserAgent 単位で都度 requirejs section を上書きする設定です。
Macのインターネット共有を使用した場合などに有効な設定です。
起動時にこの設定がそのままrequirejs.config()に渡されます。
詳細は requirejsのドキュメント を参照
requirejs.config['beez.core']の内容が beez のプロジェクトに関する設定となっています。
このときキーが
beez.coreとなっているのはbeezの決め事です。
プログラム内で利用するコード
var config = beez.config;
このファイルの[key] と同じ文字を設定してください。
conf/local/develop.jsonであれば、developになります。
前述参照
前述参照
UserAgentにマッチした場合に extend.content を requirejs に上書きします。
requirejs sectionで上書きしたいデータ
Mac OSX
インターネット共有環境のIPアドレス OSX 10.7:10.0.2.1OSX 10.8:192.168.2.1
前述参照
@see http://requirejs.org/docs/api.html#config
@see: http://requirejs.org/docs/api.html#config-moduleconfig
プログラムから
module.config()で取得出来ます
beez.config でconfig["beez.core"]のデータがプログラムから取得出来ます。
beez内部で利用しているURL情報をまとめています。 プログラム中でURLを設定ファイルに外出しする際はこちらに記述すると良いでしょう。
beez.Modelインスタンスで urlRoot の定義が明示的にされていない場合は、urlRootに自動でconfig.url.apiが設定されます。
beez.configから取得できますので、プログラム内で利用可能です 。
beez.Controller.css やbeez.manager.css のCSSロードのURL Prefixで使用されます。
beez.configから取得できますので、プログラム内で利用可能です。
beezでは直接使用しません。
beez.configから取得できますので、プログラム内で利用可能です。 使用しない場合は消してしまって構いません。
組み込み logcafe.js の設定
@see: https://github.com/CyberAgent/logcafe.js#configure
デバッグ、トレースログが多くなった場合は、
excludesで、categoryを設定して出力しないようにできます。
"logging": {
"level": "INFO",
"separator": " "
"excludes": ["beez"] // beezのログを出力しない
},
beez.Routerの設定
@see: Router
@see: Backbone.js#Router-extend
"router": {
"*default": { // beez.Routerで一意な文字列
"route": "*default", // ハッシュフラグメントのマッチ条件式
"name": "todos", // routeにヒットした時に呼ばれるメソッド名 keyと同じにしておくのが望ましい
"require": "todos/index", // メソッドが存在するcontrollerのファイルパス
"xpath": "/@/todos" // beez.bmanager.controllerの管理Path
}
},
beez.managerの設定
beez.manager.css がロード済みかcheckするインターバル(ms)。default) 1000 / 20
beez.manager.css がロードする時の timeout(ms)。 default) 1000 * 10
beez.manager.image がプールするHTMLImageElementの上限数
beez.manager.image が生成するHTMLImageElement の属性にデフォルトで設定するcrossOrigin
画像個別に設定することも可能です。