Title: Welcome to
1- Welcome to
- San Francisco Perl Mongers
Sponsored by
Wireless Network Info SSID melody No WEP, no
keys, nada.
2Building on the
- Byrne Reese
- Manager, Platform Technology
- Six Apart, Ltd.
- October 20, 2005
3overview
Introductions About Six Apart Why Movable
Type? Your First Plugin
4me
Product Manager Open Source Hacker CPAN
Contributor (SOAPLite) Movable Type Plugin
Developer
5six apart
10 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
6our modules
XMLFeed XMLFOAF WWWBlogMetadata XMLAtom
XMLAtomFilter SOAPLite NetOpenID LWPPara
noidAgent Perlbal SWFChart CryptOpenSSLDSA T
extTextile EmailFind MacMacBinary
plus over a hundred more
7movabletype
highly extensible plugin architecture large
community of developers free! not a product
a platform
8a platform
Plugins can range from the very simple to the
very complex.
9a platform
Template Tags Text Filters
Examples IfEmpty ModifiedOn Textile Markdown Ajax
ify
10a platform
- StatWatch
- Add one template tag and
- Get hit stats for your blog.
- One template tag
- A one-page user interface
11a platform
- StyleCatcher
- MT Template Plugin Action
- Complex Javascript UI
- Support for multiple template libraries
12a platform
- SpamLookup
- Complex set of plugin actions for filtering
incoming comments - Expert use of MTs plugin configuration framework
13a platform
- Media Manager
- Third party integration
- Dedicated User Interface
- Alternative templates
- Overloaded modes
14a platform
- Not to mention plugins for
- Feedburner plugin
- PayPal Firewalls
- Editorial Workflow
- Podcasting
- you name it.
15pronet
you are not alone hundreds of members
strong articles, docs and mailing lists plugin
directory a community of developers
16pronet
and professionals gig leads promote
yourself deals on conferences free technical
support
17your first plugin
18creating your plugin
package MTPluginMyPlugin use MT use base
qw(MTPlugin) use vars qw(VERSION) sub BEGIN
VERSION '1.0' my plugin plugin
new MTPluginMyPlugin( name gt 'Photo
Gallery', version gt VERSION,
description gt A description.', doc_link gt
'', author_name gt 'Byrne Reese',
author_link gt 'http//www.majordojo.com/',
) MT-gtadd_plugin(plugin)
19registering your plugin
place your plugin .pl file in the plugins
directory your plugin will appear among the
other plugins in MTs Plugins Control Panel
20template tags
21a simple tag
MTTemplateContext-gtadd_tag(HelloWorld gt
\helloworld) sub helloworld my (context,
args) _at__ my who args-gtwho
World if (who eq Byrne) return
context-gterror(Please dont feed the
animals) return Hello who
ltMTHelloWorld whoByrnegt
22a container tag
MTTemplateContext-gtadd_container_tag(HelloWorl
d gt \helloworld) sub helloworld my
(context, args) _at__ my who args-gtwho
World my res my builder
ctx-gtstash('builder') my tokens
ctx-gtstash('tokens') foreach my p
(split(,,who) ctx-gtstash(who', p)
defined(my out builder-gtbuild(context,
tokens)) or return ctx-gterror(context-gter
rstr) res . out res
23a container tag (continued)
MTTemplateContext-gtadd_tag(Who gt
\who) sub who my (context, args) _at__
my who context-gtstash(who) return
who ltMTHelloWorld whobyrne,ben,markgt
ltMTWhogt lt/MTHelloWorld
24a conditional tag
MTTemplateContext-gtadd_conditional_tag(IfByrne
gt \ifbyrne) sub ifbyrne my
(context, args) _at__ my who
context-gtstash(who) return who
/Byrne/i ltMTHelloWorld whobyrne,ben,markgt
ltMTIfByrnegt Please dont feed the
animals. ltMTElsegt ltMTWhogt
lt/MTIfByrnegt lt/MTHelloWorld
25text filters
26a simple text filter
MT-gtadd_text_filter(bfil, label gt
"Byrnes Filter",
on_format gt filter,
docs gt url) sub filter my (str,
context) _at__ str sByrnelta
hrefhttp//majordojo.com/gt\1lt/agtgi return
str
27building a UI of your own
28MTApp
your plugin a tiny MT contains all of your
application logic
package MyPluginApp use strict use
MTApp _at_MyPluginAppISA qw( MTApp ) sub
init my app shift my param _at__
app-gtSUPERinit(param) or return
app-gtadd_methods(hello gt hello) return
app
sub hello my app shift
app-gtl10n_filter( hello world )
29creating a cgi script
dispatches requests to your MTApp MTBootstrap
!/usr/bin/perl My Movable Type Plugin use
strict use lib "lib", (ENVMT_HOME ?
"ENVMT_HOME/lib" "../../lib") use
MTBootstrap App gt MyPluginApp' __END__
30MTObject
abstracts developer away from SQL and database
package MediaManagerEntry use strict use
MTObject _at_MediaManagerEntryISA qw(
MTObject ) __PACKAGE__-gtinstall_properties(
column_defs gt 'id'
gt 'integer not null auto_increment',
'blog_id' gt 'integer not null',
'title' gt 'string(150) not null',
'catalog' gt 'string(50) not
null', 'isbn' gt
'string(50) not null', 'entry_id'
gt 'integer' , indexes gt
blog_id gt 1, , audit gt 1,
datasource gt 'mediamanager', primary_key gt
'id', )
31MTObject methods
count exists
load and load_iter save remove
my constraints constraintsblog_id
blog_id constraintsstatus show if show
ne 'all' constraintscatalog catalog if
catalog ne 'all' my options optionssort
sort optionsdirection direction gt
acs ? 'ascend' 'descend' optionslimit
limit if limit ne 'none' optionsoffset
offset my iter MediaManagerEntry-gtload_i
ter( \constraints, \options )
32etcetera
alt-templates junk filters callbacks advanced
plugin actions integrated plugin settings
interface BigPAPI
33oh yeah
34were hiring )
35discussion