MTDDC 2010.2.5 Tokyo - Brand new API
Upcoming SlideShare
Loading in...5
×
 

MTDDC 2010.2.5 Tokyo - Brand new API

on

  • 4,944 views

 

Statistics

Views

Total Views
4,944
Views on SlideShare
4,471
Embed Views
473

Actions

Likes
1
Downloads
22
Comments
0

10 Embeds 473

http://www.movabletype.jp 256
http://creazy.net 124
http://smallworld.west-tokyo.com 35
http://www.komacchi.com 20
http://www.concorde.gr.jp 17
http://www.slideshare.net 10
http://www.mt-j.info 4
http://tatzuro.com 3
http://webcache.googleusercontent.com 3
http://cache.yahoofs.jp 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • ウェブサイト関係だけでこれだけのタグが追加されていますが、サイトを見ていただいた方が早いかと思います
  • 割愛します

MTDDC 2010.2.5 Tokyo - Brand new API MTDDC 2010.2.5 Tokyo - Brand new API Presentation Transcript

  • Brand New API Movable Type Developers & Designers Conference 2010.2.5 in Tokyo Yuji Takayama,Six Apart
  • r y! u ng H
  • Whatʼs brand new?
  • • Website • Theme Framework • Revision History Framework • User Dashboard
  • • Everything is UTF-8 • Permission API • Menu Structure • Dynamic Publishing • User Interface • Custom Fields
  • What is “Website”?
  • Website is ...
  • The root object of the Movable Type 5
  • How can I use the website object
  • use MT::Website; my $website_id = 1; my $website = MT::Website- >load($website_id) or die; $website->name(‘New Website’); $website->save or die;
  • itʼs easy
  • use MT::Blog; use MT::Website; my $website_id = 1; my $website = MT::Website->load($website_id) or die; my $blog = new MT::Blog; $website->add_blog($blog); my $blogs = $website->blogs;
  • All blogs belongs to the website
  • $website->site_url; $website->site_path; $website->name; $website->description;
  • like a blog? Right.
  • • The website uses same table as the blog. • The class of the website is “website”, also the class of the blog is “blog”. • The blog has parent_id that means the belonging website.
  • mysql> select blog_id, blog_class, blog_parent_id from mt_blog; +---------+------------+----------------+ | blog_id | blog_class | blog_parent_id | +---------+------------+----------------+ | 1 | website | NULL | | 2 | blog | 1 | | 3 | blog | 1 | | 4 | blog | 1 | | 5 | website | NULL | +---------+------------+----------------+ 5 rows in set (0.01 sec)
  • new template tags • MTWebsites • MTWebsitePath • MTIfWebsite? • MTWebsiteTimezone • MTWebsiteIfCCLicense • MTWebsiteCCLicenseURL • MTWebsiteHasBlog • MTWebsiteCCLicenseImage • MTBlogParentWebsite • MTWebsiteFileExtension • MTWebsiteIfCommentsOpen • MTWebsiteHost • MTWebsiteID • MTWebsiteRelativeURL • MTWebsiteName • MTWebsiteThemeID • MTWebsiteDescription • MTWebsiteCommentCount • MTWebsiteLanguage • MTWebsitePingCount • MTWebsiteURL • MTWebsitePageCount
  • new template tags • MTWebsites • MTWebsitePath • MTIfWebsite? • MTWebsiteTimezone • MTWebsiteIfCCLicense • MTWebsiteCCLicenseURL • MTWebsiteHasBlog • MTWebsiteCCLicenseImage • MTBlogParentWebsite • MTWebsiteFileExtension • MTWebsiteIfCommentsOpen • MTWebsiteHost • MTWebsiteID • MTWebsiteRelativeURL • MTWebsiteName • MTWebsiteThemeID • MTWebsiteDescription • MTWebsiteCommentCount • MTWebsiteLanguage • MTWebsitePingCount • MTWebsiteURL • MTWebsitePageCount
  • Now, Movable Type has a revision history management.
  • By default, only the entry and the template use it.
  • But....
  • You can use it in your plug-in.
  • package MT::Object::MyModel use base qw ( MT::Object MT::Revisable ); __PACKAGE__->install_properties({ ‘id’ => ‘integer not null auto_increment’, ‘text’ => ‘string(255) revisioned’ # ... }); 1;
  • package MT::Object::MyModel use base qw ( MT::Object MT::Revisable ); __PACKAGE__->install_properties({ ‘id’ => ‘integer not null auto_increment’, ‘text’ => ‘string(255) revisioned’ # ... }); 1;
  • package MT::Object::MyModel use base qw ( MT::Object MT::Revisable ); __PACKAGE__->install_properties({ ‘id’ => ‘integer not null auto_increment’, ‘text’ => ‘string(255) revisioned’ # ... }); 1;
  • itʼs easy
  • Movable Type does save a revision automatically.
  • If your object related to other object
  • You must override ʻpack_revisionʼ and ʻunpack_revisionʼ method on your object.
  • sub pack_revision { my $obj = shift; my $values = MT::Revisable::pack_revision( $obj ); # add category placements and tag associations my ( @tags, @cats ); if ( my $tags = $obj->get_tag_objects ) { @tags = map { $_->id } @$tags if @$tags; } # a revision may remove all the tags $values->{__rev_tags} = @tags; my $primary = $obj->category; if ( my $cats = $obj->categories ) { @cats = map { [ $_->id, $_->id == $primary->id ? 1 : 0 ] } @$cats if @$cats; } # a revision may remove all the categories $values->{__rev_cats} = @cats; $values; }
  • } sub unpack_revision { if ( my $rev_cats = delete $packed_obj- my $obj = shift; >{__rev_cats} ) { my ($packed_obj) = @_; $obj->clear_cache('category'); MT::Revisable::unpack_revision( $obj, $obj->clear_cache('categories'); @_ ); my ( $cat, @cats ); # restore category placements and tag if ( @$rev_cats ) { associations my ($primary) = grep { $_->[1] } if ( my $rev_tags = delete $packed_obj- @$rev_cats; >{__rev_tags} ) { $cat = MT::Category- delete $obj->{__tags}; >lookup( $primary->[0] ); delete $obj->{__tag_objects}; my $cats = MT::Category- MT::Tag->clear_cache(datasource => >lookup_multi([ map { $_->[0] } @ $obj->datasource, $rev_cats ]); ($obj->blog_id ? (blog_id => my @cats = sort { $a->label cmp $obj->blog_id) : ())); $b->label } grep { defined } @$cats; $obj->{__missing_cats_rev} = 1 require MT::Memcached; if scalar( @cats ) != MT::Memcached->instance- scalar( @$cats ); >delete( $obj->tag_cache_key ); } $obj->cache_property( 'category', if ( @$rev_tags ) { undef, $cat ); my $lookups = MT::Tag- $obj->cache_property( 'categories', >lookup_multi($rev_tags); undef, @cats ); my @tags = grep { defined } @ } $lookups; } $obj->{__tags} = [ map { $_- >name } @tags ]; $obj->{__tag_objects} = @tags; $obj->{__missing_tags_rev} = 1 if scalar( @tags ) != scalar( @$lookups ); } else { $obj->{__tags} = []; $obj->{__tag_objects} = []; }
  • See MT::Entry
  • perldoc MT::Revisable
  • Itʼs your Home to start all actions.
  • Also, you can add your own widget here
  • widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • Everything is UTF-8
  • Now, all strings in the Movable Type 5 is utf-8 flagged.
  • before Movable Type 5
  • You must encode object by yourself if PublishCharset is not UTF-8.
  • sub _hdlr_my_tag { my ( $ctx, $args ) = @_; my $obj = MT::Entry->load( $args->{id}); my $data = $obj->text; # do something... return MT::I18N::encode_text( $data, ‘utf-8’ ); }
  • sub _hdlr_my_tag { my ( $ctx, $args ) = @_; my $obj = MT::Entry->load( $args->{id}); my $data = $obj->text; # do something... return MT::I18N::encode_text( $data, ‘utf-8’ ); }
  • from now,
  • You are freed from obligation of Encode.
  • sub _hdlr_my_tag { my ( $ctx, $args ) = @_; my $obj = MT::Entry->load( $args->{id}); my $data = $obj->text; # do something... return $data; }
  • You must encode/decode your own data when...
  • • Communicating with an external network. • File input/output without MT::FileMgr. • Saving valuesto columns declared in MT::Object blob format.
  • sub _hdlr_my_tag { my ( $ctx, $args ) = @_; my $data; # received from web service. return Encode::decode_utf8( $data ); }
  • sub _hdlr_my_tag { my ( $ctx, $args ) = @_; my $data; # received from web service. return Encode::decode_utf8( $data ); }
  • Weʼve aimed to... • easy to understanding
  • An user who has ‘manage_pages’ permission. Which actions this user can do?
  • Movable Type 4... $app->can_manage_pages(); Movable Type 5... $app->can_do( ‘remove_all_trackbacks_on_webpages’ ); manage_pages: permitted_action: remove_all_trackbacks_on_webpages: 1
  • See MT::Core load_core_permissions
  • Weʼve aimed to... • easy to understanding • Can be extensible
  • permissions: blog.your_permission: group: blog_admin label: Your New Permission order: 350 permitted_action: your_action: 1 your_other_action: 1
  • Specify the role group. • blog_admin • auth_pub • sys_admin • blog_upload (only system level) • blog_comment • blog_design
  • label The display name of the permission.
  • order Ordering the permission in its role group
  • permitted_action Hash to define a list of actions permitted for hte use who has this permission.
  • inherit_from A list of inheritance origins for this permission. Defined by references to the list.
  • Of course, you can add your menu by plugin.
  • applications: cms: menus: tools:my_menu: label: Your Menu Label mode: your_mode order: 150 view: blog
  • You can display your menu on any dashboard
  • applications: cms: menus: tools:my_menu: label: Your Menu Label mode: your_mode order: 150 view: blog
  • applications: cms: menus: tools:my_menu: label: Your Menu Label mode: your_mode order: 150 view: blog
  • You can restrict your menu by permission.
  • permissions: blog.your_permission: permitted_action: your_action: 1 applications: cms: menus: tools:my_menu: label: Your Menu Label mode: your_mode order: 150 view: blog permit_action: your_action
  • If your plugin still supports MT4 and MT5
  • menus: create:my_object:   condition: >   sub { MT->product_version < 5; }  entries:create:   condition: >   sub { MT->product_version >= 5; }
  • jquery
  • and... jquery-ui Ready.
  • CSS
  • More detail... http://www.slideshare.net/ swordbreaker/plugin
  • Thank you for listening.