SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
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 affidabile
• 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 sofisticata 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 file 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    StatWatchConfig.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    StatWatchConfig.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    StatWatchConfig.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    StatWatchConfig.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

Contenu connexe

Tendances

Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From IusethisMarcus Ramberg
 
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-2011Alessandro Nadalin
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js FundamentalsMark
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
Intro to advanced caching in WordPress
Intro to advanced caching in WordPressIntro to advanced caching in WordPress
Intro to advanced caching in WordPressMaor Chasen
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneRafael Felix da Silva
 
Анатолий Поляков - 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 zLEDC 2016
 
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 monkeysNicholas Dionysopoulos
 
Angular js routing options
Angular js routing optionsAngular js routing options
Angular js routing optionsNir Kaufman
 
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...allilevine
 
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 PerformanceIvan Chepurnyi
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordCamp Kyiv
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS OverviewEyal Vardi
 
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 AppsMorgan Stone
 
Upgrade your javascript to drupal 8
Upgrade your javascript to drupal 8Upgrade your javascript to drupal 8
Upgrade your javascript to drupal 8Théodore Biadala
 

Tendances (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
 

En vedette

Basic Introduction to hacking
Basic Introduction to hackingBasic Introduction to hacking
Basic Introduction to hackingSainath Volam
 
Evaporation New Template
Evaporation New TemplateEvaporation New Template
Evaporation New Templatedloschiavo
 
Cybercrime (Computer Hacking)
Cybercrime (Computer Hacking)Cybercrime (Computer Hacking)
Cybercrime (Computer Hacking)Michael Asres
 
What is hacking | Types of Hacking
What is hacking | Types of HackingWhat is hacking | Types of Hacking
What is hacking | Types of HackingGOPCSOFT
 
Soil Steady-State Evaporation
Soil Steady-State EvaporationSoil Steady-State Evaporation
Soil Steady-State EvaporationMorteza Sadeghi
 
AMAZING COMPUTER TRICKS
AMAZING COMPUTER TRICKSAMAZING COMPUTER TRICKS
AMAZING COMPUTER TRICKSMarc Jones
 
Water evaporation reduction from lakes
Water evaporation reduction from lakesWater evaporation reduction from lakes
Water evaporation reduction from lakesguestb311d8
 
CFD-based Evaporation Estimation Approach
CFD-based Evaporation Estimation ApproachCFD-based Evaporation Estimation Approach
CFD-based Evaporation Estimation ApproachAli Abbasi
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profitDavid Stockton
 
hacking and its types
hacking and its typeshacking and its types
hacking and its typesBharath Reddy
 

En vedette (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
 

Similaire à Hacking Movable Type

Curscatalyst
CurscatalystCurscatalyst
CurscatalystKar Juan
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Api Design
Api DesignApi Design
Api Designsartak
 
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 APISix Apart KK
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowVrann Tulika
 
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 FrameworkDirk Haun
 
Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016John Napiorkowski
 
Perl web app 테스트전략
Perl web app 테스트전략Perl web app 테스트전략
Perl web app 테스트전략Jeen Lee
 
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)Michael Wales
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalystsvilen.ivanov
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
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, GermanyBalázs Tatár
 
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 2013Michelangelo van Dam
 

Similaire à 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
 

Plus de Stefano Rodighiero

Plus de 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
 

Dernier

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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 FresherRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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 Scriptwesley chun
 
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 DevelopmentsTrustArc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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.pdfsudhanshuwaghmare1
 

Dernier (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 

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 affidabile • 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 sofisticata 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 file 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 StatWatchConfig.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 StatWatchConfig.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 StatWatchConfig.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 StatWatchConfig.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 :-)