SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
Hacking Movable Type
Italian Perl Workshop 2006


Stefano Rodighiero - stefano.rodighiero@dada.net
“Movable Type 3.2 is the
premier weblog publishing
  platform for businesses,
 organizations, developers,
    and web designers”
Le funzioni di MT

                MT



                             ________
                             ________
 Articoli,
                             ________
template
Le funzioni di MT
<MTEntries>
<$MTEntryTrackbackData$>
...
<a id=quot;a<$MTEntryID pad=quot;1quot;$>quot;></a>
<div class=quot;entryquot; id=quot;entry-<$MTEntryID$>quot;>
 <h3 class=quot;entry-headerquot;><$MTEntryTitle$></h3>
 <div class=quot;entry-contentquot;>
    <div class=quot;entry-bodyquot;>
    <$MTEntryBody$>
    <MTEntryIfExtended>
       ...
    </div>
 </div>
</div>
</MTEntries>
Le caratteristiche di MT

‱ Interfaccia web completa ma afïŹdabile
‱ Sistema di gestione degli autori (con
  abbozzo di gestione di ruoli e permessi)
‱ Sistema potente per la gestione dei template
Inoltre...
MT dal punto di vista
  del programmatore

‱ Espone una API soïŹsticata e documentata
‱ Incoraggia lo sviluppo di plug-in per
  estenderne le funzionalitĂ 
‱ È scritto in Perl :-)
Estendere MT
                   MT



                            ________
                            ________
 Articoli,
                            ________
template

                  Plugin
Esempi di realizzazioni
Esempi di realizzazioni
maketitle.pl
my $plugin;

require MT::Plugin;

$plugin = MT::Plugin->new( {
     name => 'Maketitle',
     description => q{Costruisce titoli grafici},
     doc_link => '',
} );

MT->add_plugin($plugin);
maketitle.pl /2

# ... continua

MT::Template::Context->add_tag(
   MakeGraphicTitle => &make_graphic_title
);
maketitle.pl /2
nel template...
...
<center>
  <$MTMakeGraphicTitle$>
</center>
...
maketitle.pl /2
sub make_graphic_title
{
    my $context = shift;
    my $params = shift;

    my $entry = $context->stash('entry');

    my $title = $entry->title();
    my $dirified_title = dirify( $title );
    ...
    return qq{<img src=quot;$imageurlquot;>};
}
maketitle.pl /2
nel ïŹle HTML risultante...
...
<center>
  <img src=”...”>
</center>
...
statwatch
statwatch
              schemas    mysql.dump



                           list.tmpl

statwatch
                        swfooter.tmpl

               tmpl
                        swheader.tmpl



                          view.tmpl
statwatch
                                 Stats.pm



                  lib            StatWatch       Visit.pm



             statvisit.cgi     StatWatch.pm



statwatch   statwatch.cgi    StatWatchConïŹg.pm



            statwatch.pl
statwatch.pl
...

MT::Template::Context->add_tag('Stats' => sub{&staturl});

sub staturl {
   my $ctx = shift;
   my $blog = $ctx->stash('blog');

     my $cfg = MT::ConfigMgr->instance;
     my $script = '<script type=quot;text/javascriptquot;>
                  '.'<!--
                  '. qq|document.write('<img src=quot;|
                   . $cfg->CGIPath
                   . quot;plugins/statwatch/statvisit.cgi?blog_id=quot; . $blog->id
                   ...
                  |.'// -->'.'
                  </script>';
     return $script;
}

1;
statwatch
                                 Stats.pm



                  lib            StatWatch       Visit.pm



             statvisit.cgi     StatWatch.pm



statwatch   statwatch.cgi    StatWatchConïŹg.pm



            statwatch.pl
Visit.pm
# StatWatch - lib/StatWatch/Visit.pm
# Nick O'Neill (http://www.raquo.net/statwatch/)

package StatWatch::Visit;
use strict;

use MT::App;
@StatWatch::Visit::ISA = qw( MT::App );

use Stats;
my $VERSION = '1.2';
my $DEBUG = 0;
MT::ErrorHandler




 MT::Plugin           MT




                    MT::App




MT::App::CMS   MT::App::Comments   MT::App::Search
Visit.pm /2
sub init {
    my $app = shift;
    $app->SUPER::init(@_) or return;
    $app->add_methods(
        visit => &visit,
    );
    $app->{default_mode} = 'visit';
    $app->{user_class} = 'MT::Author';

    $app->{charset} = $app->{cfg}->PublishCharset;
    my $q = $app->{query};

    $app;
}
Visit.pm /2
sub visit {
   my $app = shift;
   my $q = $app->{query};
   my $blog_id;

  if ($blog_id = $q->param('blog_id')) {
     require MT::Blog;
     my $blog = MT::Blog->load({ id => $blog_id })
       or die quot;Error loading blog from blog_id $blog_idquot;;

     my $stats = Stats->new;

     # ...
statwatch
                                 Stats.pm



                  lib            StatWatch       Visit.pm



             statvisit.cgi     StatWatch.pm



statwatch   statwatch.cgi    StatWatchConïŹg.pm



            statwatch.pl
Visit.pm /2
package Stats;
use strict;

use MT::Object;
@Stats::ISA = qw( MT::Object );
__PACKAGE__->install_properties({
    columns => [
         'id', 'blog_id', 'url', 'referrer', 'ip',
    ],
    indexes => {
       ip => 1,
       blog_id => 1,
       created_on => 1,
    },
    audit => 1,
    datasource => 'stats',
    primary_key => 'id',
});

1;
MT::ErrorHandler




              MT::Object                      MT::ObjectDriver




                                            MT::ObjectDriver::DBI   MT::ObjectDriver::DBM




MT::Entry     MT::Author       MT::Config
Visit.pm /2
       # ...

       $stats->ip($app->remote_ip);
       $stats->referrer($referrer);
       $stats->blog_id($blog_id);
       $stats->url($url);

       &compileStats($blog_id,$app->remote_ip);

       $stats->save
         or die quot;Saving stats failed: quot;, $stats->errstr;
    } else {
       die quot;No blog idquot;;
    }
}
statwatch
                                 Stats.pm



                  lib            StatWatch       Visit.pm



             statvisit.cgi     StatWatch.pm



statwatch   statwatch.cgi    StatWatchConïŹg.pm



            statwatch.pl
Visit.pm /2
sub init {
    my $app = shift;
    $app->SUPER::init(@_) or return;
    $app->add_methods(
        list => &list,
        view => &view,
    );
    $app->{default_mode} = 'list';
    $app->{user_class} = 'MT::Author';

    $app->{requires_login} = 1;
    $app->{charset} = $app->{cfg}->PublishCharset;
    my $q = $app->{query};

    $app;
}
Visit.pm /2
sub list {
   my $app = shift;
   my %param;
   my $q = $app->{query};
   $param{debug} = ($DEBUG || $q->param('debug'));
   $param{setup} = $q->param('setup');

  ( $param{script_url} ,
    $param{statwatch_base_url} ,
    $param{statwatch_url} ,
    my $static_uri) = parse_cfg();

  require MT::PluginData;
  unless (MT::PluginData->load({ plugin => 'statwatch',
                                 key => 'setup_'.$VERSION })) {
     &setup;
     $app->redirect($param{statwatch_url}.quot;?setup=1quot;);
  }

  require MT::Blog;
  my @blogs = MT::Blog->load;
  my $data = [];
  ...
Visit.pm /2
    ...
    ### Listing the blogs on the main page ###
    for my $blog (@blogs) {
       if (Stats->count({ blog_id => $blog->id })) {

          # [... colleziona i dati da mostrare ...]

          # Row it
          my $row = { ... };
          push @$data, $row;
      }
    }
    $param{blog_loop} = $data;

    $param{gen_time} = quot; | quot;.$now.quot; secondsquot;;

    $param{version} = $VERSION;
    $app->build_page('tmpl/list.tmpl', %param);
}
Riepilogo?

‱ Inserire nuovi tag speciale all’interno dei
  template
‱ Aggiungere pannelli (applicazioni)
‱ ...
BigPAPI

‱ Big Plugin API
‱ Permette di agganciarsi all’interfaccia
  esistente di MT, estendendo le funzionalitĂ 
  dei pannelli esistenti
PerchĂš?
RightFields
MT->add_callback( 'bigpapi::template::edit_entry::top',
                  9,
                  $rightfields,
                  &edit_entry_template );

MT->add_callback( 'bigpapi::param::edit_entry',
                  9,
                  $rightfields,
                  &edit_entry_param );

MT->add_callback( 'bigpapi::param::preview_entry',
                  9,
                  $rightfields,
                  &preview_entry_param);
RightFields
Approfondimenti

‱ Six Apart Developer Wiki
  http://www.lifewiki.net/sixapart/

‱ Seedmagazine.com — Lookin’ Good
  http://o2b.net/archives/seedmagazine

‱ Beyond the blog
  http://a.wholelottanothing.org/features/2003/07/beyond_the_blog

‱ http://del.icio.us/slr/movabletype :-)
Grazie :)

Stefano Rodighiero
stefano.rodighiero@dada.net

Weitere Àhnliche Inhalte

Was ist angesagt?

TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
Peter Baylies
 
ĐĐœĐ°Ń‚ĐŸĐ»ĐžĐč ĐŸĐŸĐ»ŃĐșĐŸĐČ - Drupal.ajax framework from a to z
ĐĐœĐ°Ń‚ĐŸĐ»ĐžĐč ĐŸĐŸĐ»ŃĐșĐŸĐČ - Drupal.ajax framework from a to zĐĐœĐ°Ń‚ĐŸĐ»ĐžĐč ĐŸĐŸĐ»ŃĐșĐŸĐČ - Drupal.ajax framework from a to z
ĐĐœĐ°Ń‚ĐŸĐ»ĐžĐč ĐŸĐŸĐ»ŃĐșĐŸĐČ - Drupal.ajax framework from a to z
LEDC 2016
 

Was ist angesagt? (20)

Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
Perl5i
Perl5iPerl5i
Perl5i
 
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js Fundamentals
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Intro to advanced caching in WordPress
Intro to advanced caching in WordPressIntro to advanced caching in WordPress
Intro to advanced caching in WordPress
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com Backbone
 
Daily notes
Daily notesDaily notes
Daily notes
 
ĐĐœĐ°Ń‚ĐŸĐ»ĐžĐč ĐŸĐŸĐ»ŃĐșĐŸĐČ - Drupal.ajax framework from a to z
ĐĐœĐ°Ń‚ĐŸĐ»ĐžĐč ĐŸĐŸĐ»ŃĐșĐŸĐČ - Drupal.ajax framework from a to zĐĐœĐ°Ń‚ĐŸĐ»ĐžĐč ĐŸĐŸĐ»ŃĐșĐŸĐČ - Drupal.ajax framework from a to z
ĐĐœĐ°Ń‚ĐŸĐ»ĐžĐč ĐŸĐŸĐ»ŃĐșĐŸĐČ - Drupal.ajax framework from a to z
 
Hidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeysHidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeys
 
Angular js routing options
Angular js routing optionsAngular js routing options
Angular js routing options
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
 
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
 
Optimizing Angular Performance in Enterprise Single Page Apps
Optimizing Angular Performance in Enterprise Single Page AppsOptimizing Angular Performance in Enterprise Single Page Apps
Optimizing Angular Performance in Enterprise Single Page Apps
 
Upgrade your javascript to drupal 8
Upgrade your javascript to drupal 8Upgrade your javascript to drupal 8
Upgrade your javascript to drupal 8
 
Keeping It Simple
Keeping It SimpleKeeping It Simple
Keeping It Simple
 

Andere mochten auch

Evaporation New Template
Evaporation New TemplateEvaporation New Template
Evaporation New Template
dloschiavo
 
Science - Evaporation
Science - EvaporationScience - Evaporation
Science - Evaporation
Rutvij Vagadia
 
CFD-based Evaporation Estimation Approach
CFD-based Evaporation Estimation ApproachCFD-based Evaporation Estimation Approach
CFD-based Evaporation Estimation Approach
Ali Abbasi
 

Andere mochten auch (20)

Basic Introduction to hacking
Basic Introduction to hackingBasic Introduction to hacking
Basic Introduction to hacking
 
Internet and personal privacy
Internet and personal privacyInternet and personal privacy
Internet and personal privacy
 
Evaporation New Template
Evaporation New TemplateEvaporation New Template
Evaporation New Template
 
Evaporation
EvaporationEvaporation
Evaporation
 
Hacking 1
Hacking 1Hacking 1
Hacking 1
 
Hacking
HackingHacking
Hacking
 
Cybercrime (Computer Hacking)
Cybercrime (Computer Hacking)Cybercrime (Computer Hacking)
Cybercrime (Computer Hacking)
 
Is hacking good or bad
Is hacking good or badIs hacking good or bad
Is hacking good or bad
 
my new HACKING
my new HACKINGmy new HACKING
my new HACKING
 
What is hacking | Types of Hacking
What is hacking | Types of HackingWhat is hacking | Types of Hacking
What is hacking | Types of Hacking
 
Group 4 (evaporation)
Group 4 (evaporation)Group 4 (evaporation)
Group 4 (evaporation)
 
Science - Evaporation
Science - EvaporationScience - Evaporation
Science - Evaporation
 
Soil Steady-State Evaporation
Soil Steady-State EvaporationSoil Steady-State Evaporation
Soil Steady-State Evaporation
 
AMAZING COMPUTER TRICKS
AMAZING COMPUTER TRICKSAMAZING COMPUTER TRICKS
AMAZING COMPUTER TRICKS
 
Water evaporation reduction from lakes
Water evaporation reduction from lakesWater evaporation reduction from lakes
Water evaporation reduction from lakes
 
CFD-based Evaporation Estimation Approach
CFD-based Evaporation Estimation ApproachCFD-based Evaporation Estimation Approach
CFD-based Evaporation Estimation Approach
 
Hacking And EthicalHacking By Satish
Hacking And EthicalHacking By SatishHacking And EthicalHacking By Satish
Hacking And EthicalHacking By Satish
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
 
Evaporation 4 slides
Evaporation 4 slidesEvaporation 4 slides
Evaporation 4 slides
 
hacking and its types
hacking and its typeshacking and its types
hacking and its types
 

Ähnlich wie Hacking Movable Type

Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
Kar Juan
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
diego_k
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new API
Six Apart KK
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
svilen.ivanov
 

Ähnlich wie Hacking Movable Type (20)

Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Api Design
Api DesignApi Design
Api Design
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new API
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016
 
Perl web app 테슀튞전랔
Perl web app 테슀튞전랔Perl web app 테슀튞전랔
Perl web app 테슀튞전랔
 
Magento Indexes
Magento IndexesMagento Indexes
Magento Indexes
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
 
Smarty
SmartySmarty
Smarty
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
 
Workshop quality assurance for php projects - ZendCon 2013
Workshop quality assurance for php projects - ZendCon 2013Workshop quality assurance for php projects - ZendCon 2013
Workshop quality assurance for php projects - ZendCon 2013
 

Mehr von Stefano Rodighiero (8)

Perl101 - Italian Perl Workshop 2011
Perl101 - Italian Perl Workshop 2011Perl101 - Italian Perl Workshop 2011
Perl101 - Italian Perl Workshop 2011
 
On the most excellent theory of time travel, poetic revolutions, and dynamic ...
On the most excellent theory of time travel, poetic revolutions, and dynamic ...On the most excellent theory of time travel, poetic revolutions, and dynamic ...
On the most excellent theory of time travel, poetic revolutions, and dynamic ...
 
Perl101
Perl101Perl101
Perl101
 
Perl Template Toolkit
Perl Template ToolkitPerl Template Toolkit
Perl Template Toolkit
 
Test Automatici^2 per applicazioni Web
Test Automatici^2 per applicazioni WebTest Automatici^2 per applicazioni Web
Test Automatici^2 per applicazioni Web
 
Perl, musica automagica
Perl, musica automagicaPerl, musica automagica
Perl, musica automagica
 
POE
POEPOE
POE
 
Scatole Nere
Scatole NereScatole Nere
Scatole Nere
 

KĂŒrzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

KĂŒrzlich hochgeladen (20)

Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navi Mumbai Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Hacking Movable Type

  • 1. Hacking Movable Type Italian Perl Workshop 2006 Stefano Rodighiero - stefano.rodighiero@dada.net
  • 2. “Movable Type 3.2 is the premier weblog publishing platform for businesses, organizations, developers, and web designers”
  • 3. Le funzioni di MT MT ________ ________ Articoli, ________ template
  • 4. Le funzioni di MT <MTEntries> <$MTEntryTrackbackData$> ... <a id=quot;a<$MTEntryID pad=quot;1quot;$>quot;></a> <div class=quot;entryquot; id=quot;entry-<$MTEntryID$>quot;> <h3 class=quot;entry-headerquot;><$MTEntryTitle$></h3> <div class=quot;entry-contentquot;> <div class=quot;entry-bodyquot;> <$MTEntryBody$> <MTEntryIfExtended> ... </div> </div> </div> </MTEntries>
  • 5. Le caratteristiche di MT ‱ Interfaccia web completa ma afïŹdabile ‱ Sistema di gestione degli autori (con abbozzo di gestione di ruoli e permessi) ‱ Sistema potente per la gestione dei template
  • 7. MT dal punto di vista del programmatore ‱ Espone una API soïŹsticata e documentata ‱ Incoraggia lo sviluppo di plug-in per estenderne le funzionalitĂ  ‱ È scritto in Perl :-)
  • 8. Estendere MT MT ________ ________ Articoli, ________ template Plugin
  • 11. maketitle.pl my $plugin; require MT::Plugin; $plugin = MT::Plugin->new( { name => 'Maketitle', description => q{Costruisce titoli grafici}, doc_link => '', } ); MT->add_plugin($plugin);
  • 12.
  • 13. maketitle.pl /2 # ... continua MT::Template::Context->add_tag( MakeGraphicTitle => &make_graphic_title );
  • 14. maketitle.pl /2 nel template... ... <center> <$MTMakeGraphicTitle$> </center> ...
  • 15. maketitle.pl /2 sub make_graphic_title { my $context = shift; my $params = shift; my $entry = $context->stash('entry'); my $title = $entry->title(); my $dirified_title = dirify( $title ); ... return qq{<img src=quot;$imageurlquot;>}; }
  • 16. maketitle.pl /2 nel ïŹle HTML risultante... ... <center> <img src=”...”> </center> ...
  • 18. statwatch schemas mysql.dump list.tmpl statwatch swfooter.tmpl tmpl swheader.tmpl view.tmpl
  • 19. statwatch Stats.pm lib StatWatch Visit.pm statvisit.cgi StatWatch.pm statwatch statwatch.cgi StatWatchConïŹg.pm statwatch.pl
  • 20. statwatch.pl ... MT::Template::Context->add_tag('Stats' => sub{&staturl}); sub staturl { my $ctx = shift; my $blog = $ctx->stash('blog'); my $cfg = MT::ConfigMgr->instance; my $script = '<script type=quot;text/javascriptquot;> '.'<!-- '. qq|document.write('<img src=quot;| . $cfg->CGIPath . quot;plugins/statwatch/statvisit.cgi?blog_id=quot; . $blog->id ... |.'// -->'.' </script>'; return $script; } 1;
  • 21. statwatch Stats.pm lib StatWatch Visit.pm statvisit.cgi StatWatch.pm statwatch statwatch.cgi StatWatchConïŹg.pm statwatch.pl
  • 22. Visit.pm # StatWatch - lib/StatWatch/Visit.pm # Nick O'Neill (http://www.raquo.net/statwatch/) package StatWatch::Visit; use strict; use MT::App; @StatWatch::Visit::ISA = qw( MT::App ); use Stats; my $VERSION = '1.2'; my $DEBUG = 0;
  • 23. MT::ErrorHandler MT::Plugin MT MT::App MT::App::CMS MT::App::Comments MT::App::Search
  • 24. Visit.pm /2 sub init { my $app = shift; $app->SUPER::init(@_) or return; $app->add_methods( visit => &visit, ); $app->{default_mode} = 'visit'; $app->{user_class} = 'MT::Author'; $app->{charset} = $app->{cfg}->PublishCharset; my $q = $app->{query}; $app; }
  • 25. Visit.pm /2 sub visit { my $app = shift; my $q = $app->{query}; my $blog_id; if ($blog_id = $q->param('blog_id')) { require MT::Blog; my $blog = MT::Blog->load({ id => $blog_id }) or die quot;Error loading blog from blog_id $blog_idquot;; my $stats = Stats->new; # ...
  • 26. statwatch Stats.pm lib StatWatch Visit.pm statvisit.cgi StatWatch.pm statwatch statwatch.cgi StatWatchConïŹg.pm statwatch.pl
  • 27. Visit.pm /2 package Stats; use strict; use MT::Object; @Stats::ISA = qw( MT::Object ); __PACKAGE__->install_properties({ columns => [ 'id', 'blog_id', 'url', 'referrer', 'ip', ], indexes => { ip => 1, blog_id => 1, created_on => 1, }, audit => 1, datasource => 'stats', primary_key => 'id', }); 1;
  • 28. MT::ErrorHandler MT::Object MT::ObjectDriver MT::ObjectDriver::DBI MT::ObjectDriver::DBM MT::Entry MT::Author MT::Config
  • 29. Visit.pm /2 # ... $stats->ip($app->remote_ip); $stats->referrer($referrer); $stats->blog_id($blog_id); $stats->url($url); &compileStats($blog_id,$app->remote_ip); $stats->save or die quot;Saving stats failed: quot;, $stats->errstr; } else { die quot;No blog idquot;; } }
  • 30. statwatch Stats.pm lib StatWatch Visit.pm statvisit.cgi StatWatch.pm statwatch statwatch.cgi StatWatchConïŹg.pm statwatch.pl
  • 31. Visit.pm /2 sub init { my $app = shift; $app->SUPER::init(@_) or return; $app->add_methods( list => &list, view => &view, ); $app->{default_mode} = 'list'; $app->{user_class} = 'MT::Author'; $app->{requires_login} = 1; $app->{charset} = $app->{cfg}->PublishCharset; my $q = $app->{query}; $app; }
  • 32. Visit.pm /2 sub list { my $app = shift; my %param; my $q = $app->{query}; $param{debug} = ($DEBUG || $q->param('debug')); $param{setup} = $q->param('setup'); ( $param{script_url} , $param{statwatch_base_url} , $param{statwatch_url} , my $static_uri) = parse_cfg(); require MT::PluginData; unless (MT::PluginData->load({ plugin => 'statwatch', key => 'setup_'.$VERSION })) { &setup; $app->redirect($param{statwatch_url}.quot;?setup=1quot;); } require MT::Blog; my @blogs = MT::Blog->load; my $data = []; ...
  • 33. Visit.pm /2 ... ### Listing the blogs on the main page ### for my $blog (@blogs) { if (Stats->count({ blog_id => $blog->id })) { # [... colleziona i dati da mostrare ...] # Row it my $row = { ... }; push @$data, $row; } } $param{blog_loop} = $data; $param{gen_time} = quot; | quot;.$now.quot; secondsquot;; $param{version} = $VERSION; $app->build_page('tmpl/list.tmpl', %param); }
  • 34. Riepilogo? ‱ Inserire nuovi tag speciale all’interno dei template ‱ Aggiungere pannelli (applicazioni) ‱ ...
  • 35. BigPAPI ‱ Big Plugin API ‱ Permette di agganciarsi all’interfaccia esistente di MT, estendendo le funzionalitĂ  dei pannelli esistenti
  • 37. RightFields MT->add_callback( 'bigpapi::template::edit_entry::top', 9, $rightfields, &edit_entry_template ); MT->add_callback( 'bigpapi::param::edit_entry', 9, $rightfields, &edit_entry_param ); MT->add_callback( 'bigpapi::param::preview_entry', 9, $rightfields, &preview_entry_param);
  • 39. Approfondimenti ‱ Six Apart Developer Wiki http://www.lifewiki.net/sixapart/ ‱ Seedmagazine.com — Lookin’ Good http://o2b.net/archives/seedmagazine ‱ Beyond the blog http://a.wholelottanothing.org/features/2003/07/beyond_the_blog ‱ http://del.icio.us/slr/movabletype :-)