View
215
Download
2
Category
Tags:
Preview:
Citation preview
Welcome to
San Francisco Perl Mongers
Wireless Network Info:SSID: melodyNo WEP, no keys, nada.
Sponsored by
Byrne ReeseManager, Platform Technology
Six Apart, Ltd.
October 20, 2005
Building on the
Page 3
overviewIntroductions
About Six Apart
Why Movable Type?
Your First Plugin
Page 4
me Product Manager
Open Source Hacker
CPAN Contributor (SOAP::Lite)
Movable Type Plugin Developer
Page 5
six apart10+ million bloggers using our software to share their lives, experiences and opinions with their friends, their families and the world.
plus, a company of perl experts, hackers and enthusiasts
Page 6
our modulesXML::FeedXML::FOAFWWW::Blog::MetadataXML::AtomXML::Atom::FilterSOAP::LiteNet::OpenIDLWP::ParanoidAgentPerlbalSWF::ChartCrypt::OpenSSL::DSAText::TextileEmail::FindMac::MacBinary
plus over a hundred more…
Page 7
movabletype
a platform
highly extensible plugin architecture
large community of developers
free!
not a product…
Page 8
a platform
Plugins can range from the very simple to the very complex.
Simple Complex
Page 9
a platform
Template Tags
Text Filters
Simple Complex
Examples:IfEmptyModifiedOnTextileMarkdownAjaxify
Page 10
a platformStatWatch
• Add one template tag
and…
• Get hit stats for your
blog.
• One template tag
• A one-page user
interface
Simple Complex
Page 11
a platformStyleCatcher
• MT Template Plugin
Action
• Complex Javascript UI
• Support for multiple
template libraries
Simple Complex
Page 12
a platformSpamLookup
• Complex set of plugin
actions for filtering
incoming comments
• Expert use of MT’s plugin
configuration framework
Simple Complex
Page 13
a platformMedia Manager
• Third party integration
• Dedicated User
Interface
• Alternative templates
• Overloaded modes
Simple Complex
Page 14
a platformNot to mention plugins
for:
• Feedburner plugin
• PayPal Firewalls
• Editorial Workflow
• Podcasting
…you name it.
Simple Complex
Page 15
pronetyou are not alone…
hundreds of members strong
articles, docs and mailing lists
plugin directory
a community of developers…
Page 16
pronet…and professionals
gig leads
promote yourself
deals on conferences
free technical support
Page 17
your first plugin
Page 18
creating your pluginpackage MT::Plugin::MyPlugin;use MT;use base qw(MT::Plugin);use vars qw($VERSION);sub BEGIN { $VERSION = '1.0'; my $plugin; $plugin = new MT::Plugin::MyPlugin({ name => 'Photo Gallery', version => $VERSION, description => ‘A description.', doc_link => '', author_name => 'Byrne Reese', author_link => 'http://www.majordojo.com/', }); MT->add_plugin($plugin);}
Page 19
registering your pluginplace your plugin .pl file in the plugins directory
your plugin will appear among the other plugins in MT’s Plugins Control Panel
Page 20
template tags
Page 21
a simple tagMT::Template::Context->add_tag(HelloWorld => \&helloworld);
sub helloworld { my ($context, $args) = @_; my $who = $args->{who} || “World”; if ($who eq “Byrne”) { return $context->error(“Please don’t feed the animals”); } return “Hello $who”;}
# <MTHelloWorld who=“Byrne”>
Page 22
a container tagMT::Template::Context->add_container_tag(HelloWorld => \&helloworld);
sub helloworld { my ($context, $args) = @_; my $who = $args->{who} || “World”; my $res; my $builder = $ctx->stash('builder'); my $tokens = $ctx->stash('tokens'); foreach my $p (split(“,”,$who) { $ctx->stash(‘who', $p); defined(my $out = $builder->build($context, $tokens)) or return $ctx->error($context->errstr); $res .= $out; } $res;}
Page 23
a container tag (continued)
MT::Template::Context->add_tag(Who => \&who);
sub who { my ($context, $args) = @_; my $who = $context->stash(‘who’); return $who;}
# <MTHelloWorld who=“byrne,ben,mark”># <$MTWho$># </MTHelloWorld
Page 24
a conditional tagMT::Template::Context->add_conditional_tag(IfByrne => \&ifbyrne);
sub ifbyrne { my ($context, $args) = @_; my $who = $context->stash(‘who’); return $who =~ /Byrne/i;}
# <MTHelloWorld who=“byrne,ben,mark”># <MTIfByrne># Please don’t feed the animals.# <MTElse># <$MTWho$># </MTIfByrne># </MTHelloWorld
Page 25
text filters
Page 26
a simple text filterMT->add_text_filter(‘bfil’, { label => "Byrne’s Filter", on_format => &filter, docs => ‘url’});
sub filter { my ($str, $context) = @_; $str =~ s#Byrne#<a href=“http://majordojo.com/”>\1</a>#gi return $str;}
Page 27
building a UI of your own
Page 28
MT::Appyour plugin == a tiny MT
contains all of your application logic
package MyPlugin::App;use strict;use MT::App;@MyPlugin::App::ISA = qw( MT::App );sub init { my $app = shift; my %param = @_; $app->SUPER::init(%param) or return; $app->add_methods(‘hello’ => &hello); return $app; }
sub hello { my $app = shift; $app->l10n_filter( “hello world” );}
Page 29
creating a cgi scriptdispatches requests to your MT::App
MT::Bootstrap
#!/usr/bin/perl## My Movable Type Plugin
use strict;use lib "lib", ($ENV{MT_HOME} ? "$ENV{MT_HOME}/lib" : "../../lib");use MT::Bootstrap App => ‘MyPlugin::App';
__END__
Page 30
MT::Object
package MediaManager::Entry;use strict;
use MT::Object;@MediaManager::Entry::ISA = qw( MT::Object );__PACKAGE__->install_properties({ column_defs => { 'id' => 'integer not null auto_increment', 'blog_id' => 'integer not null', 'title' => 'string(150) not null', 'catalog' => 'string(50) not null', 'isbn' => 'string(50) not null', 'entry_id' => 'integer' }, indexes => { blog_id => 1, }, audit => 1, datasource => 'mediamanager', primary_key => 'id',});
abstracts developer away from SQL and database
Page 31
MT::Object methodsload and load_iter
save
remove
count
exists
my %constraints;$constraints{blog_id} = $blog_id;$constraints{status} = $show if $show ne 'all';$constraints{catalog} = $catalog if $catalog ne 'all';my %options;$options{sort} = $sort;$options{direction} = direction => $acs ? 'ascend' : 'descend';$options{limit} = $limit if $limit ne 'none';$options{offset} = $offset;
my $iter = MediaManager::Entry->load_iter( \%constraints, \%options );
Page 32
etceteraalt-templates
junk filters
callbacks
advanced plugin actions
integrated plugin settings interface
BigPAPI
Page 33
oh yeah…
Page 34
we’re hiring ;)
Page 35
discussion
Recommended