Your SlideShare is downloading. ×
  • Like
MTDDC 2010.2.5 Tokyo - Brand new API
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

MTDDC 2010.2.5 Tokyo - Brand new API

  • 3,664 views
Published

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,664
On SlideShare
0
From Embeds
0
Number of Embeds
6

Actions

Shares
Downloads
23
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • ウェブサイト関係だけでこれだけのタグが追加されていますが、サイトを見ていただいた方が早いかと思います
  • 割愛します

Transcript

  • 1. Brand New API Movable Type Developers & Designers Conference 2010.2.5 in Tokyo Yuji Takayama,Six Apart
  • 2. r y! u ng H
  • 3. Whatʼs brand new?
  • 4. • Website • Theme Framework • Revision History Framework • User Dashboard
  • 5. • Everything is UTF-8 • Permission API • Menu Structure • Dynamic Publishing • User Interface • Custom Fields
  • 6. What is “Website”?
  • 7. Website is ...
  • 8. The root object of the Movable Type 5
  • 9. How can I use the website object
  • 10. use MT::Website; my $website_id = 1; my $website = MT::Website- >load($website_id) or die; $website->name(‘New Website’); $website->save or die;
  • 11. itʼs easy
  • 12. 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;
  • 13. All blogs belongs to the website
  • 14. $website->site_url; $website->site_path; $website->name; $website->description;
  • 15. like a blog? Right.
  • 16. • 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.
  • 17. 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)
  • 18. 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
  • 19. 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
  • 20. Now, Movable Type has a revision history management.
  • 21. By default, only the entry and the template use it.
  • 22. But....
  • 23. You can use it in your plug-in.
  • 24. 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;
  • 25. 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;
  • 26. 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;
  • 27. itʼs easy
  • 28. Movable Type does save a revision automatically.
  • 29. If your object related to other object
  • 30. You must override ʻpack_revisionʼ and ʻunpack_revisionʼ method on your object.
  • 31. 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; }
  • 32. } 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} = []; }
  • 33. See MT::Entry
  • 34. perldoc MT::Revisable
  • 35. Itʼs your Home to start all actions.
  • 36. Also, you can add your own widget here
  • 37. widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • 38. widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • 39. widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • 40. widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • 41. widgets: FeedsWidget: label: Feed Aggregate template: tmpl/widget.tmpl handler: $FeedWidget::Widget::hdlr_widget set: main singular: 1 view: blog
  • 42. Everything is UTF-8
  • 43. Now, all strings in the Movable Type 5 is utf-8 flagged.
  • 44. before Movable Type 5
  • 45. You must encode object by yourself if PublishCharset is not UTF-8.
  • 46. 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’ ); }
  • 47. 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’ ); }
  • 48. from now,
  • 49. You are freed from obligation of Encode.
  • 50. sub _hdlr_my_tag { my ( $ctx, $args ) = @_; my $obj = MT::Entry->load( $args->{id}); my $data = $obj->text; # do something... return $data; }
  • 51. You must encode/decode your own data when...
  • 52. • Communicating with an external network. • File input/output without MT::FileMgr. • Saving valuesto columns declared in MT::Object blob format.
  • 53. sub _hdlr_my_tag { my ( $ctx, $args ) = @_; my $data; # received from web service. return Encode::decode_utf8( $data ); }
  • 54. sub _hdlr_my_tag { my ( $ctx, $args ) = @_; my $data; # received from web service. return Encode::decode_utf8( $data ); }
  • 55. Weʼve aimed to... • easy to understanding
  • 56. An user who has ‘manage_pages’ permission. Which actions this user can do?
  • 57. 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
  • 58. See MT::Core load_core_permissions
  • 59. Weʼve aimed to... • easy to understanding • Can be extensible
  • 60. permissions: blog.your_permission: group: blog_admin label: Your New Permission order: 350 permitted_action: your_action: 1 your_other_action: 1
  • 61. Specify the role group. • blog_admin • auth_pub • sys_admin • blog_upload (only system level) • blog_comment • blog_design
  • 62. label The display name of the permission.
  • 63. order Ordering the permission in its role group
  • 64. permitted_action Hash to define a list of actions permitted for hte use who has this permission.
  • 65. inherit_from A list of inheritance origins for this permission. Defined by references to the list.
  • 66. Of course, you can add your menu by plugin.
  • 67. applications: cms: menus: tools:my_menu: label: Your Menu Label mode: your_mode order: 150 view: blog
  • 68. You can display your menu on any dashboard
  • 69. applications: cms: menus: tools:my_menu: label: Your Menu Label mode: your_mode order: 150 view: blog
  • 70. applications: cms: menus: tools:my_menu: label: Your Menu Label mode: your_mode order: 150 view: blog
  • 71. You can restrict your menu by permission.
  • 72. 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
  • 73. If your plugin still supports MT4 and MT5
  • 74. menus: create:my_object:   condition: >   sub { MT->product_version < 5; }  entries:create:   condition: >   sub { MT->product_version >= 5; }
  • 75. jquery
  • 76. and... jquery-ui Ready.
  • 77. CSS
  • 78. More detail... http://www.slideshare.net/ swordbreaker/plugin
  • 79. Thank you for listening.