Movable Type/第9回MTプラグイン勉強会 - registryのリファレンスを精読する(2) http://www.ark-web.jp/sandbox/wiki/908.html

Movable Type/第9回MTプラグイン勉強会 - registryのリファレンスを精読する(2)

第9回は第8回に続いてMovable Type Registry Referenceの精読の続きを行います。元のドキュメントが未完状態が多いため、各機能の具体的な指定方法といったことより、だいたいにどういったことができるのかといったことを確認することに主眼をおきます。

[edit]

動画(Ustream)

勉強会の模様をアップしました。
今回は確信をもっていえる内容に乏しいです(汗
勉強会の中でも言っていますが、使い方がよくわからないものは、ちょっとづつ実際につかって試してみていこうと思います(ドキュメントに書かれていないものを使っていいのかという疑問は常にありますが^^;)

Ustreamのチャンネルはこちら。
http://www.ustream.tv/channel/mt%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E5%8B%89%E5%BC%B7%E4%BC%9A

[edit]

ご感想・ご質問など

ご感想、ご質問などあればお気軽にどうぞ。頂けるととても励みになります。


[edit]

ネタ

[edit]

日時

[edit]

Registry Keys

registryで指定できるkeyとその解説。

[edit]

permissions

label
ユーザに見せるラベル名(パーミッション名)
group
当該パーミッションが表示されるパーミッショングループ。指定できる値は、sys_admin、blog_admin、auth_pub、blog_design、blog_upload、blog_comment。
パーミッショングループ項目名
ユーザプロフィールのシステム権限sys_admin
ロール編集の「管理」blog_admin
ロール編集の「作成と公開」auth_pub
ロール編集の「デザインする」blog_design
ロール編集の「アイテム」blog_upload
ロール編集の「コメント投稿」blog_comment
order
表示順

※ 追加したカスタムパーミッションは自動的に管理画面のUIで指定できるようにはならない。当分の間、指定できるようにするためにはTransformerコールバックを用意する必要がある。

例)

$registry = {
    permissions => {
        'system.create_blog' => {
            label => trans("Create Blogs"),
            group => 'sys_admin',
            order => 100,
        },
    },
};
[edit]

text_filters

例)

text_filters => {
    'my_filter' => {   # key
        label => 'Transform this Text',
        handler => 'MT::Foo::text_transform',
    },
}
label
フィルターの表示名
handler
ハンドラー(フィルター処理の実体が記述された関数のリファレンス)
[edit]

In Progress*1

[edit]

applications

Application Properties

handler
web interfaceに紐付けられてコールされるパッケージ名?(The package name that will process calls dispatched via the web interface.)
cgi-base
.cgiの拡張子なしのCGIファイル名。現在は使われていない。URL構築のために利用される。
list_actions
一時に実行されるアクションのリスト。何らかのアクション(Do Something)を指定できるのはentry, page, asset, commenter, author, role, groupに対して。
page_actions
A page action is a simple link that is surfaced in association with a given object.
menus
アプリケーションに追加するメニューのリスト
methods
アプリケーションに追加するモード(またはコマンド*2)とこれらのリクエストを処理するハンドラのリスト

例)

applications => {
    'ack' => {
        handler => 'MyApp::Ack',
        cgi_base => 'ack',
        list_actions => {
            'entry' => {
                'do_something' => {
                    label      => "Batch Do Something",
                    order      => 100,
                    code       => \&do_something,
                    permission => 'edit_all_posts,publish_post',
                },
            },
            menus => {
                'foo' => {
                label => "Create",
                order => 100,
            },
            'foo:bar' => {
                label         => "Do Something",
                order         => 100,
                mode          => 'hdlr_bar',
                args          => { _type => 'entry' },
                permission    => 'create_post',
                requires_blog => 1,
            },
        },
        methods => sub { MT->app->core_methods() },
    },
};

How to Add a Mode to the CMS Component

$registry = {
    applications => {
        'cms' => {
            methods => {
                myapp_new-mode => sub { // my handler // },
            },
        },
    },
};,

※ コアや他のプラグイン等と重複を避けるために独自モード名の頭には固有の接頭辞をつけるようにすべき。

CMS Application Specific Stuff

例)

import_formats => {
    'import_mt_format' => { # key
            label => 'Another system (Movable Type format)',
            code => \&MT::ImportExport::import,
            options => [ 'title_start', 'title_end', 'default_status' ],
            options_template => 'import_others.tmpl',
        },
    },
},
label
ユーザに表示するラベル
code
importする際に実行するコードのリファレンス
options
The input keys for import type specific configuration options.
options_template
The file that contains the HTML and template code for rendering the custom configuration options for the import type.
[edit]

callbacks

ドキュメントなし

[edit]

tasks

[edit]

junk_filters

ドキュメントなし

[edit]

list_filters

ドキュメントなし

一覧の絞込み(フィルタ)の定義か可能ということだと思います。

例)

entry => {
    published => {
        label   => 'Published entries',
        order   => 100,
        handler => sub {
            my ( $terms, $args ) = @_;
            $terms->{status} = 2;
        },
    },
    received_comments_in_last_7_days => {
        label   => 'Entries with comments in the last 7 days',
        order   => 500,
        handler => sub {
            my ( $terms, $args ) = @_;
            my $ts = time - 10 * 24 * 60 * 60;
            $ts = MT::Util::epoch2ts( MT->app->blog, $ts );
            $args->{join} = MT::Comment->join_on(
                'entry_id',
                { created_on => [ $ts,       undef ], },
                { range_incl => { created_on => 1 }, }
            );
            $args->{sort}      = \'comment_created_on';
            $args->{direction} = 'descend';
        },
    },
},
[edit]

upgrade_functions

ドキュメントなし

独自のアップグレード処理を定義できる??

upgrade_functions => {
    'core_create_placements' => {
        version_limit => 2.0,
        priority => 9.1,
        updater => {
            type => 'entry',
            label => 'Creating entry category placements...',
            condition => sub { $_[0]->category_id },
            code => sub {
                require MT::Placement;
                my $entry = shift;
                my $existing = MT::Placement->load({ entry_id => $entry->id,
                    category_id => $entry->category_id });
                if (!$existing) {
                    my $place = MT::Placement->new;
                    $place->entry_id($entry->id);
                    $place->blog_id($entry->blog_id);
                    $place->category_id($entry->category_id);
                    $place->is_primary(1);
                    $place->save;
                }
                $entry->category_id(0);
            },
        },
    },    
}
[edit]

tags

ドキュメントなし

独自テンプレートタグ、モディファイア(=global filter)の定義

tags => {
    block => {
        TagNameFoo => &foo_handler,
    },
    function => {
        TagNameFoo => &foo_handler,
    },
    modifier => { # attribute only, not a tag name - this is for global filters
        TagNameFoo => &foo_handler,
    },  
}
[edit]

archive_types

Archive Type Properties

name
アーカイブ名(key)
archive_label
アーカイブの表示名
archive_file
TODO
archive_title
TODO
date_range
TODO
archive_group_iter
TODO
archive_group_entries
TODO
dynamic_template
ダイナミックパブリッシング用のfile path/pattern
default_archive_templates
このアーカイブのdefault file/path structure
dynamic_support
ダイナミックパブリッシングをサポートするかどうか。1 or 0で指定。
date_based
アーカイブがエントリーのdateをつかってページわけ(paginated)されるかどうか。1 or 0で指定。

例)

archive_types => {
    'Weekly' =>
        ArchiveType( name => 'Weekly',
            archive_label => \&weekly_archive_label,
            archive_file => \&weekly_archive_file,
            archive_title => \&weekly_archive_title,
            date_range => \&weekly_date_range,
            archive_group_iter => \&weekly_group_iter,
            archive_group_entries => \&weekly_group_entries,
            dynamic_template => 'archives/week/<$MTArchiveDate format="%Y%m%d"$>',
            default_archive_templates => [
                ArchiveFileTemplate( label => MT->translate('yyyy/mm/day-week/index.html'),
                    template => '%y/%m/%d-week/%i', default => 1 ),
                ],
            dynamic_support => 1,
            date_based => 1,
        ),
}
[edit]

commenter_authenticators

ドキュメントなし

コメントの独自の認証を定義できる??

例)

commenter_authenticators => {
    'OpenID' => {
        class => 'MT::Auth::OpenID',
        label => 'OpenID',
        login_form => <<OpenID,
<form method="post" action="<mt:var name="script_url">">
<input type="hidden" name="__mode" value="login_external" />
<input type="hidden" name="blog_id" value="<mt:var name="blog_id">" />
<input type="hidden" name="entry_id" value="<mt:var name="entry_id">" />
<input type="hidden" name="static" value="<mt:var name="static" escape="html">" />
<fieldset>
<mtapp:setting
    id="openid_display"
    label="<__trans phrase="OpenID URL">">
<input type="hidden" name="key" value="OpenID" />
<input name="openid_url" />
</mtapp:setting>
<input type="submit" name="submit" value="<__trans phrase="Sign In">" />
</fieldset>
</form>
OpenID
        login_form_params => \&_commenter_auth_params,
    },
}
[edit]

captcha_providers

ドキュメントなし

キャプチャを定義できる?

例)

captcha_providers => {
    'mt_default' => {
        label => 'Movable Type default',
        class => 'MT::Util::Captcha',
    }
}
[edit]

default_templates

ドキュメントなし*3

[edit]

次回予定

次回はMT::App、MT::App::CMSのリファレンスの精読を予定します。

投稿者進地 | パーマリンク | コメント(0)

| append.gif

tag: Movable TypeMTMTMTPlugin勉強会A-Form


*1 まだドキュメントが未完、書いてる途中という意味だと思います
*2 というものがあるらしい
*3 予測すらできず^^;

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2008-07-18 (金) 11:18:54 (5762d)

アークウェブのサービスやソリューションはこちら