複数のデバイス向けのバージョンをパブリッシュできる、 Pickles 2 用のパブリッシュプラグイン。, (*1)
導入手順 - Setup
require の項目に、"tomk79/px2-publish-for-multi-device" を追加します。, (*2)
{
"repositories": [
{
"type": "git",
"url": "https://github.com/tomk79/px2-publish-for-multi-device.git"
}
],
"require": {
"tomk79/px2-publish-for-multi-device": "dev-master"
},
}
追加したら、composer update を実行して変更を反映することを忘れずに。, (*3)
$ composer update
2. config.php に、プラグインを設定
設定ファイル config.php (通常は ./px-files/config.php) を編集します。
before_content にある、PX=publish の設定を、次の例を参考に書き換えます。, (*4)
<?php
/* 中略 */
/**
* funcs: Before content
*
* サイトマップ読み込みの後、コンテンツ実行の前に実行するプラグインを設定します。
*/
$conf->funcs->before_content = array(
// PX=api
'picklesFramework2\commands\api::register' ,
// PX=publish
'tomk79\pickles2\publishForMultiDevice\publish::register('.json_encode(array(
'devices'=>array(
array(
'user_agent'=>'iPhone',
'path_publish_dir'=>'./px-files/dist_smt/',
),
array(
'user_agent'=>'iPad',
'path_publish_dir'=>'./px-files/dist_tab/',
),
)
)).')' ,
);
Pickles 2 の設定をJSON形式で編集している方は、config.json の該当箇所に追加してください。, (*5)
3. パブリッシュを実行
標準的な Pickles 2 のパブリッシュと同じ手順で、パブリッシュコマンドを実行します。, (*6)
$ php .px_execute.php /?PX=publish.run
オプション - Options
<?php
$conf->funcs->before_content = array(
// PX=api
'picklesFramework2\commands\api::register' ,
// PX=publish
'tomk79\pickles2\publishForMultiDevice\publish::register('.json_encode(array(
// ↓パブリッシュするデバイスの情報を設定する。
'devices'=>array(
array(
'user_agent'=>'iPhone', // USER_AGENT 文字列
'path_publish_dir'=>'./px-files/dist_smt/', // このデバイス向けのパブリッシュ先ディレクトリ
'path_rewrite_rule'=>'functionNameOf::rewrite_smt', // パスの書き換えロジック
),
array(
'user_agent'=>'iPad',
'path_publish_dir'=>'./px-files/dist_tab/',
'path_rewrite_rule'=>'functionNameOf::rewriter_tab',
),
/* ...以下同様... */
)
)).')' ,
);
更新履歴 - Change log
ライセンス - License
MIT License, (*7)
作者 - Author