SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
Hintergrund und Projekte
           Routes, Filter und Hooks
                             Plugins
                        Deployment
                            Ausblick




                                 Tanz!

                  Stefan Hornburg (Racke)
                   racke@linuxia.de


13. Deutscher Perl-Workshop, Frankfurt, 21. Oktober 2011




                              racke    Tanz!
Hintergrund und Projekte
                                              Tanzflur
                  Routes, Filter und Hooks
                                              Dropbox
                                    Plugins
                                              LDAP Benutzerverwaltung
                               Deployment
                                              Procurement für American Spaces
                                   Ausblick




Tanzflur




      einfach
      ausdrucksstark
      effektiv
      minimale Abhängigkeiten




                                     racke    Tanz!
Hintergrund und Projekte
                                               Tanzflur
                   Routes, Filter und Hooks
                                               Dropbox
                                     Plugins
                                               LDAP Benutzerverwaltung
                                Deployment
                                               Procurement für American Spaces
                                    Ausblick




Projekte




       Dropbox-Klon
       LDAP Benutzerverwaltung
       Procurement für American Corners




                                      racke    Tanz!
Hintergrund und Projekte
                                              Tanzflur
                  Routes, Filter und Hooks
                                              Dropbox
                                    Plugins
                                              LDAP Benutzerverwaltung
                               Deployment
                                              Procurement für American Spaces
                                   Ausblick




Dropbox




      Autoindex
      Upload/Download
      Benutzerverwaltung




                                     racke    Tanz!
Hintergrund und Projekte
                                              Tanzflur
                  Routes, Filter und Hooks
                                              Dropbox
                                    Plugins
                                              LDAP Benutzerverwaltung
                               Deployment
                                              Procurement für American Spaces
                                   Ausblick




LDAP Benutzerverwaltung




      LDAP-Verzeichnis
      Benutzerverwaltung
          Adminstrator
          Referrer
          Patron




                                     racke    Tanz!
Hintergrund und Projekte
                                                 Tanzflur
                     Routes, Filter und Hooks
                                                 Dropbox
                                       Plugins
                                                 LDAP Benutzerverwaltung
                                  Deployment
                                                 Procurement für American Spaces
                                      Ausblick




Procurement für American Spaces




      Warenkorb/Wunschliste
      Genehmigungsprozesse
      LibraryThing
      ISBNDB
   https://vsc.state.gov/




                                        racke    Tanz!
Hintergrund und Projekte
                              Routes, Filter und Hooks    Routes
                                                Plugins   Filters
                                           Deployment     Hooks
                                               Ausblick




Rezept für Routes



   # ! / u s r / b i n / env p e r l

   use Dancer ;

   g e t ’ / ’ => sub {
         template ’ index ’ ;
   };

   dance ;




                                                 racke    Tanz!
Hintergrund und Projekte
                      Routes, Filter und Hooks    Routes
                                        Plugins   Filters
                                   Deployment     Hooks
                                       Ausblick




Routes



         String
         String mit benannten Parametern
         String mit Wildcards
              Splat
              Megasplat
         Regulärer Ausdruck
         Regulärer Ausdruck mit Captures




                                         racke    Tanz!
Hintergrund und Projekte
                            Routes, Filter und Hooks    Routes
                                              Plugins   Filters
                                         Deployment     Hooks
                                             Ausblick




Splat


   g e t ’ / images / covers / ∗ . j p g ’ => sub {
         my ( $ i s b n ) = s p l a t ;

        i f (− f " p u b l i c / images / covers / $ i s b n . j p g " ) {
             r e t u r n s e n d _ f i l e " images / covers / $ i s b n . j p g " ;
        }

        s t a t u s ’ not_found ’ ;
        f o r w a r d 404;
   }




                                               racke    Tanz!
Hintergrund und Projekte
                             Routes, Filter und Hooks    Routes
                                               Plugins   Filters
                                          Deployment     Hooks
                                              Ausblick




Megasplat


   h t t p s : / / vsc . s t a t e . gov / l o s t p w d / b i z @ l i n u x i a . de / e642bd543b9907bd2c06aa4

   g e t ’ / l o s t p w d / ∗∗ ’ => sub {
         my ( $email , $hash ) = s p l a t ;

         form −> f i l l ( e m a i l => $email ,
                           hash => $hash ) ;

         t e m p l a t e ( ’ l o s t p w d _ c o n f i r m ’ , form => $form ) ;
   }




                                                racke    Tanz!
Hintergrund und Projekte
                              Routes, Filter und Hooks    Routes
                                                Plugins   Filters
                                           Deployment     Hooks
                                               Ausblick




Captures


   h t t p s : / / dropbox . n i t e . s i / ~ racke / t a l k s / dancer−beamer . p d f

   any q r { ^ / ~ ( ? < user > [ ^ / ] + ) / ( ? < f i l e > . ∗ ? ) / ? $ } => sub {
       my ( $capts , $user , $ f i l e ) ;

         $capts = c a p t u r e s ;
         $ f i l e = $capts −>{ f i l e } ;
         $user = $capts −>{user } ;

          ...
   };




                                                 racke    Tanz!
Hintergrund und Projekte
                             Routes, Filter und Hooks    Routes
                                               Plugins   Filters
                                          Deployment     Hooks
                                              Ausblick




Präfix



   prefix     ’ / wiki ’ ;

   g e t q r { / ? ( ? < page > . ∗ ) } => sub {
         my $capts = c a p t u r e s ;

         t e m p l a t e ’ w i k i ’ , { c o n t e n t => w i k i ( $capts −>{page } ) ,
                                         page => $capts −>{page } } ;
   };




                                                racke    Tanz!
Hintergrund und Projekte
                        Routes, Filter und Hooks    Routes
                                          Plugins   Filters
                                     Deployment     Hooks
                                         Ausblick




Filters




    b e f o r e sub {
    };

    a f t e r sub {
    };




                                           racke    Tanz!
Hintergrund und Projekte
                        Routes, Filter und Hooks    Routes
                                          Plugins   Filters
                                     Deployment     Hooks
                                         Ausblick




before



   b e f o r e sub {
           unless ( s e s s i o n ( ’ user ’ )
                | | request −>path eq ’ / l o g i n ’
                | | request −>path =~ m%^/ l o s t p w d%
                ) {
                redirect ’ / login ’ ;
           }
   };




                                           racke    Tanz!
Hintergrund und Projekte
                            Routes, Filter und Hooks    Routes
                                              Plugins   Filters
                                         Deployment     Hooks
                                             Ausblick




Hooks

  hook b e f o r e _ t e m p l a t e _ r e n d e r => sub {
      my $tokens = s h i f t ;
      my $menu ;

        i f ( s e s s i o n ( ’ user ’ ) ) {
              $menu = [ { name => ’ Logout ’ , u r l => ’ / l o g o u t ’ } ] ;
        }
        else {
              $menu = [ { name => ’ Login ’ , u r l => ’ / l o g i n ’ } ] ;
        }

        $tokens −>{menu } = $menu ;
  };



                                               racke    Tanz!
Hintergrund und Projekte
                     Routes, Filter und Hooks    Plugins auf CPAN
                                       Plugins   Writing Plugins
                                  Deployment     Plugins und Hooks
                                      Ausblick




Plugins




      Funktionalität
      Schlüsselwort
      Route
      Konfiguration




                                        racke    Tanz!
Hintergrund und Projekte
                   Routes, Filter und Hooks    Plugins auf CPAN
                                     Plugins   Writing Plugins
                                Deployment     Plugins und Hooks
                                    Ausblick




Plugins auf CPAN



      Dancer::Plugin::Database
      database
      Dancer::Plugin::Email
      email
      Dancer::Plugin::Ajax
      ajax




                                      racke    Tanz!
Hintergrund und Projekte
                      Routes, Filter und Hooks    Plugins auf CPAN
                                        Plugins   Writing Plugins
                                   Deployment     Plugins und Hooks
                                       Ausblick




Dancer::Plugin::LibraryThing Konfiguration




   plugins :
       LibraryThing :
             api_key : d231aa37c9b4f5d304a60a3d0ad1dad4
             d i r e c t o r y : p u b l i c / images / covers
             size : large




                                         racke    Tanz!
Hintergrund und Projekte
                               Routes, Filter und Hooks       Plugins auf CPAN
                                                 Plugins      Writing Plugins
                                            Deployment        Plugins und Hooks
                                                Ausblick




Dancer::Plugin::LibraryThing Code
   use Dancer : : P l u g i n : : L i b r a r y T h i n g ;

   g e t ’ / images / covers / ∗ . j p g ’ => sub {
         my ( $isbn , @ret ) ;
         $isbn = s p l a t ;

         unless (− f " p u b l i c / images / covers / $ i s b n . j p g " ) {
             @ret = l i b r a r y t h i n g _ c o v e r ( $ i s b n ) ;
             i f ( @ret < 3 ) {
                   s t a t u s ’ not_found ’ ;
                   f o r w a r d 404;
             }
         }

          r e t u r n s e n d _ f i l e " images / covers / $ i s b n . j p g " ;
   }
                                                  racke       Tanz!
Hintergrund und Projekte
                    Routes, Filter und Hooks    Plugins auf CPAN
                                      Plugins   Writing Plugins
                                 Deployment     Plugins und Hooks
                                     Ausblick




Writing Plugins




       register
       register_plugin
       plugin_setting




                                       racke    Tanz!
Hintergrund und Projekte
                                Routes, Filter und Hooks       Plugins auf CPAN
                                                  Plugins      Writing Plugins
                                             Deployment        Plugins und Hooks
                                                 Ausblick




Plugins und Hooks




   Dancer : : F a c t o r y : : Hook
             −>i n s t a n c e
             −>i n s t a l l _ h o o k s ( ’ b e f o r e _ c a r t _ a d d ’ ) ;




                                                   racke       Tanz!
Sessions
                    Hintergrund und Projekte
                                                Logs
                    Routes, Filter und Hooks
                                                Szenarien
                                      Plugins
                                                Starman
                                 Deployment
                                                Perlbal
                                     Ausblick
                                                Skripts



Sessions



      Engine
      session: Storable
      Verzeichnis
      session_dir: /var/run/dancer-sessions
      Ablauffrist
      session_expires: 8 hours




                                       racke    Tanz!
Sessions
                     Hintergrund und Projekte
                                                 Logs
                     Routes, Filter und Hooks
                                                 Szenarien
                                       Plugins
                                                 Starman
                                  Deployment
                                                 Perlbal
                                      Ausblick
                                                 Skripts



Logs



       Engine
       logger: file
       Verzeichnis
       log_path: log
       Format
       logger_format: "%t [%P] %L @%D> %m in %f l. %l"




                                        racke    Tanz!
Sessions
                      Hintergrund und Projekte
                                                  Logs
                      Routes, Filter und Hooks
                                                  Szenarien
                                        Plugins
                                                  Starman
                                   Deployment
                                                  Perlbal
                                       Ausblick
                                                  Skripts



Szenarien



      Standalone
      ./bin/app.pl
      CGI, FastCGI
      plackup
            Starman
            Twiggy
            Corona
      Reverse Proxy




                                         racke    Tanz!
Sessions
                Hintergrund und Projekte
                                            Logs
                Routes, Filter und Hooks
                                            Szenarien
                                  Plugins
                                            Starman
                             Deployment
                                            Perlbal
                                 Ausblick
                                            Skripts



Szenarien: Reverse Proxy




      Apache
      nginx
      Perlbal




                                   racke    Tanz!
Sessions
                       Hintergrund und Projekte
                                                   Logs
                       Routes, Filter und Hooks
                                                   Szenarien
                                         Plugins
                                                   Starman
                                    Deployment
                                                   Perlbal
                                        Ausblick
                                                   Skripts



Starman



  plackup −E p r o d u c t i o n
          −s Starman 
          −−workers =5 
          −−p i d / home / racke / Dropbox / run / Dropbox . p i d 
          −p 5000 
          −a b i n / app . p l 
          −D




                                          racke    Tanz!
Sessions
                   Hintergrund und Projekte
                                               Logs
                   Routes, Filter und Hooks
                                               Szenarien
                                     Plugins
                                               Starman
                                Deployment
                                               Perlbal
                                    Ausblick
                                               Skripts



Perlbal




   LOAD vpaths
   XS enable headers




                                      racke    Tanz!
Sessions
                        Hintergrund und Projekte
                                                    Logs
                        Routes, Filter und Hooks
                                                    Szenarien
                                          Plugins
                                                    Starman
                                     Deployment
                                                    Perlbal
                                         Ausblick
                                                    Skripts



Perlbal: Pools




   CREATE POOL prod_starman_dosqua
    POOL prod_starman_dosqua ADD 1 2 7 . 0 . 0 . 1 : 5 0 0 0

   CREATE POOL prod_starman_vsc
    POOL prod_starman_vsc ADD 1 2 7 . 0 . 0 . 1 : 5 0 0 1




                                           racke    Tanz!
Sessions
                          Hintergrund und Projekte
                                                      Logs
                          Routes, Filter und Hooks
                                                      Szenarien
                                            Plugins
                                                      Starman
                                       Deployment
                                                      Perlbal
                                           Ausblick
                                                      Skripts



Perlbal: Reverse Proxy




   CREATE SERVICE vsc_prod
    SET r o l e                            = reverse_proxy
    SET p o o l                            = prod_starman_vsc
    SET b u f f e r _ u p l o a d s        = on
   ENABLE vsc_prod




                                             racke    Tanz!
Sessions
                       Hintergrund und Projekte
                                                   Logs
                       Routes, Filter und Hooks
                                                   Szenarien
                                         Plugins
                                                   Starman
                                    Deployment
                                                   Perlbal
                                        Ausblick
                                                   Skripts



Perlbal: Selector




   CREATE SERVICE v s c _ s e l e c t o r
    SET l i s t e n                   = 86.59.13.238:80
    SET r o l e                       = selector
    SET p l u g i n s                 = vpaths
    VPATH . ∗                         = vsc_prod
   ENABLE v s c _ s e l e c t o r




                                          racke    Tanz!
Sessions
                               Hintergrund und Projekte
                                                           Logs
                               Routes, Filter und Hooks
                                                           Szenarien
                                                 Plugins
                                                           Starman
                                            Deployment
                                                           Perlbal
                                                Ausblick
                                                           Skripts



Perlbal: SSL Selector


   CREATE SERVICE v s c _ s s l _ s e l e c t o r
    SET l i s t e n                        = 86.59.13.238:443
    SET r o l e                            = selector
    SET p l u g i n s                      = vpaths
    SET e n a b l e _ s s l                = on
    SET s s l _ k e y _ f i l e            = / e t c / s s l / p r i v a t e / vsc . s t a t e . gov . key
    SET s s l _ c e r t _ f i l e          = / e t c / s s l / c e r t s / vsc . s t a t e . gov . pem
    VPATH . ∗                              = vsc_prod
   ENABLE v s c _ s s l _ s e l e c t o r
   HEADER v s c _ s s l _ s e l e c t o r INSERT X−Forwarded−P r o t o : HTTPS




                                                  racke    Tanz!
Sessions
                             Hintergrund und Projekte
                                                         Logs
                             Routes, Filter und Hooks
                                                         Szenarien
                                               Plugins
                                                         Starman
                                          Deployment
                                                         Perlbal
                                              Ausblick
                                                         Skripts



Skripts




   use Dancer ’ : s c r i p t ’ ;

   s e t l o g g e r => ’ console ’ ;
   s e t l o g g e r _ f o r m a t => ’% ’ ;
                                        m




                                                racke    Tanz!
Hintergrund und Projekte
                  Routes, Filter und Hooks
                                              Dancer 2
                                    Plugins
                                              Community
                               Deployment
                                   Ausblick




Dancer2




     keine globalen Variablen
     100% OO Backend (Moo)
     Scoping for Sub-Applikationen
     überarbeitete Architektur




                                     racke    Tanz!
Hintergrund und Projekte
               Routes, Filter und Hooks
                                           Dancer 2
                                 Plugins
                                           Community
                            Deployment
                                Ausblick




Community




  Web: http://perldancer.org/
  Github: git://github.com/sukria/Dancer.git
  IRC: #dancer @ irc.perl.org
  Mitarbeit: Dancer::Development




                                  racke    Tanz!
Hintergrund und Projekte
                    Routes, Filter und Hooks
                                                Dancer 2
                                      Plugins
                                                Community
                                 Deployment
                                     Ausblick




The End




  Slides, Handout, Skripte:
  http://www.linuxia.de/talks/pws2011/




                                       racke    Tanz!

Más contenido relacionado

Destacado

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destacado (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Tanz!

  • 1. Hintergrund und Projekte Routes, Filter und Hooks Plugins Deployment Ausblick Tanz! Stefan Hornburg (Racke) racke@linuxia.de 13. Deutscher Perl-Workshop, Frankfurt, 21. Oktober 2011 racke Tanz!
  • 2. Hintergrund und Projekte Tanzflur Routes, Filter und Hooks Dropbox Plugins LDAP Benutzerverwaltung Deployment Procurement für American Spaces Ausblick Tanzflur einfach ausdrucksstark effektiv minimale Abhängigkeiten racke Tanz!
  • 3. Hintergrund und Projekte Tanzflur Routes, Filter und Hooks Dropbox Plugins LDAP Benutzerverwaltung Deployment Procurement für American Spaces Ausblick Projekte Dropbox-Klon LDAP Benutzerverwaltung Procurement für American Corners racke Tanz!
  • 4. Hintergrund und Projekte Tanzflur Routes, Filter und Hooks Dropbox Plugins LDAP Benutzerverwaltung Deployment Procurement für American Spaces Ausblick Dropbox Autoindex Upload/Download Benutzerverwaltung racke Tanz!
  • 5. Hintergrund und Projekte Tanzflur Routes, Filter und Hooks Dropbox Plugins LDAP Benutzerverwaltung Deployment Procurement für American Spaces Ausblick LDAP Benutzerverwaltung LDAP-Verzeichnis Benutzerverwaltung Adminstrator Referrer Patron racke Tanz!
  • 6. Hintergrund und Projekte Tanzflur Routes, Filter und Hooks Dropbox Plugins LDAP Benutzerverwaltung Deployment Procurement für American Spaces Ausblick Procurement für American Spaces Warenkorb/Wunschliste Genehmigungsprozesse LibraryThing ISBNDB https://vsc.state.gov/ racke Tanz!
  • 7. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick Rezept für Routes # ! / u s r / b i n / env p e r l use Dancer ; g e t ’ / ’ => sub { template ’ index ’ ; }; dance ; racke Tanz!
  • 8. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick Routes String String mit benannten Parametern String mit Wildcards Splat Megasplat Regulärer Ausdruck Regulärer Ausdruck mit Captures racke Tanz!
  • 9. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick Splat g e t ’ / images / covers / ∗ . j p g ’ => sub { my ( $ i s b n ) = s p l a t ; i f (− f " p u b l i c / images / covers / $ i s b n . j p g " ) { r e t u r n s e n d _ f i l e " images / covers / $ i s b n . j p g " ; } s t a t u s ’ not_found ’ ; f o r w a r d 404; } racke Tanz!
  • 10. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick Megasplat h t t p s : / / vsc . s t a t e . gov / l o s t p w d / b i z @ l i n u x i a . de / e642bd543b9907bd2c06aa4 g e t ’ / l o s t p w d / ∗∗ ’ => sub { my ( $email , $hash ) = s p l a t ; form −> f i l l ( e m a i l => $email , hash => $hash ) ; t e m p l a t e ( ’ l o s t p w d _ c o n f i r m ’ , form => $form ) ; } racke Tanz!
  • 11. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick Captures h t t p s : / / dropbox . n i t e . s i / ~ racke / t a l k s / dancer−beamer . p d f any q r { ^ / ~ ( ? < user > [ ^ / ] + ) / ( ? < f i l e > . ∗ ? ) / ? $ } => sub { my ( $capts , $user , $ f i l e ) ; $capts = c a p t u r e s ; $ f i l e = $capts −>{ f i l e } ; $user = $capts −>{user } ; ... }; racke Tanz!
  • 12. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick Präfix prefix ’ / wiki ’ ; g e t q r { / ? ( ? < page > . ∗ ) } => sub { my $capts = c a p t u r e s ; t e m p l a t e ’ w i k i ’ , { c o n t e n t => w i k i ( $capts −>{page } ) , page => $capts −>{page } } ; }; racke Tanz!
  • 13. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick Filters b e f o r e sub { }; a f t e r sub { }; racke Tanz!
  • 14. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick before b e f o r e sub { unless ( s e s s i o n ( ’ user ’ ) | | request −>path eq ’ / l o g i n ’ | | request −>path =~ m%^/ l o s t p w d% ) { redirect ’ / login ’ ; } }; racke Tanz!
  • 15. Hintergrund und Projekte Routes, Filter und Hooks Routes Plugins Filters Deployment Hooks Ausblick Hooks hook b e f o r e _ t e m p l a t e _ r e n d e r => sub { my $tokens = s h i f t ; my $menu ; i f ( s e s s i o n ( ’ user ’ ) ) { $menu = [ { name => ’ Logout ’ , u r l => ’ / l o g o u t ’ } ] ; } else { $menu = [ { name => ’ Login ’ , u r l => ’ / l o g i n ’ } ] ; } $tokens −>{menu } = $menu ; }; racke Tanz!
  • 16. Hintergrund und Projekte Routes, Filter und Hooks Plugins auf CPAN Plugins Writing Plugins Deployment Plugins und Hooks Ausblick Plugins Funktionalität Schlüsselwort Route Konfiguration racke Tanz!
  • 17. Hintergrund und Projekte Routes, Filter und Hooks Plugins auf CPAN Plugins Writing Plugins Deployment Plugins und Hooks Ausblick Plugins auf CPAN Dancer::Plugin::Database database Dancer::Plugin::Email email Dancer::Plugin::Ajax ajax racke Tanz!
  • 18. Hintergrund und Projekte Routes, Filter und Hooks Plugins auf CPAN Plugins Writing Plugins Deployment Plugins und Hooks Ausblick Dancer::Plugin::LibraryThing Konfiguration plugins : LibraryThing : api_key : d231aa37c9b4f5d304a60a3d0ad1dad4 d i r e c t o r y : p u b l i c / images / covers size : large racke Tanz!
  • 19. Hintergrund und Projekte Routes, Filter und Hooks Plugins auf CPAN Plugins Writing Plugins Deployment Plugins und Hooks Ausblick Dancer::Plugin::LibraryThing Code use Dancer : : P l u g i n : : L i b r a r y T h i n g ; g e t ’ / images / covers / ∗ . j p g ’ => sub { my ( $isbn , @ret ) ; $isbn = s p l a t ; unless (− f " p u b l i c / images / covers / $ i s b n . j p g " ) { @ret = l i b r a r y t h i n g _ c o v e r ( $ i s b n ) ; i f ( @ret < 3 ) { s t a t u s ’ not_found ’ ; f o r w a r d 404; } } r e t u r n s e n d _ f i l e " images / covers / $ i s b n . j p g " ; } racke Tanz!
  • 20. Hintergrund und Projekte Routes, Filter und Hooks Plugins auf CPAN Plugins Writing Plugins Deployment Plugins und Hooks Ausblick Writing Plugins register register_plugin plugin_setting racke Tanz!
  • 21. Hintergrund und Projekte Routes, Filter und Hooks Plugins auf CPAN Plugins Writing Plugins Deployment Plugins und Hooks Ausblick Plugins und Hooks Dancer : : F a c t o r y : : Hook −>i n s t a n c e −>i n s t a l l _ h o o k s ( ’ b e f o r e _ c a r t _ a d d ’ ) ; racke Tanz!
  • 22. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Sessions Engine session: Storable Verzeichnis session_dir: /var/run/dancer-sessions Ablauffrist session_expires: 8 hours racke Tanz!
  • 23. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Logs Engine logger: file Verzeichnis log_path: log Format logger_format: "%t [%P] %L @%D> %m in %f l. %l" racke Tanz!
  • 24. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Szenarien Standalone ./bin/app.pl CGI, FastCGI plackup Starman Twiggy Corona Reverse Proxy racke Tanz!
  • 25. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Szenarien: Reverse Proxy Apache nginx Perlbal racke Tanz!
  • 26. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Starman plackup −E p r o d u c t i o n −s Starman −−workers =5 −−p i d / home / racke / Dropbox / run / Dropbox . p i d −p 5000 −a b i n / app . p l −D racke Tanz!
  • 27. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Perlbal LOAD vpaths XS enable headers racke Tanz!
  • 28. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Perlbal: Pools CREATE POOL prod_starman_dosqua POOL prod_starman_dosqua ADD 1 2 7 . 0 . 0 . 1 : 5 0 0 0 CREATE POOL prod_starman_vsc POOL prod_starman_vsc ADD 1 2 7 . 0 . 0 . 1 : 5 0 0 1 racke Tanz!
  • 29. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Perlbal: Reverse Proxy CREATE SERVICE vsc_prod SET r o l e = reverse_proxy SET p o o l = prod_starman_vsc SET b u f f e r _ u p l o a d s = on ENABLE vsc_prod racke Tanz!
  • 30. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Perlbal: Selector CREATE SERVICE v s c _ s e l e c t o r SET l i s t e n = 86.59.13.238:80 SET r o l e = selector SET p l u g i n s = vpaths VPATH . ∗ = vsc_prod ENABLE v s c _ s e l e c t o r racke Tanz!
  • 31. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Perlbal: SSL Selector CREATE SERVICE v s c _ s s l _ s e l e c t o r SET l i s t e n = 86.59.13.238:443 SET r o l e = selector SET p l u g i n s = vpaths SET e n a b l e _ s s l = on SET s s l _ k e y _ f i l e = / e t c / s s l / p r i v a t e / vsc . s t a t e . gov . key SET s s l _ c e r t _ f i l e = / e t c / s s l / c e r t s / vsc . s t a t e . gov . pem VPATH . ∗ = vsc_prod ENABLE v s c _ s s l _ s e l e c t o r HEADER v s c _ s s l _ s e l e c t o r INSERT X−Forwarded−P r o t o : HTTPS racke Tanz!
  • 32. Sessions Hintergrund und Projekte Logs Routes, Filter und Hooks Szenarien Plugins Starman Deployment Perlbal Ausblick Skripts Skripts use Dancer ’ : s c r i p t ’ ; s e t l o g g e r => ’ console ’ ; s e t l o g g e r _ f o r m a t => ’% ’ ; m racke Tanz!
  • 33. Hintergrund und Projekte Routes, Filter und Hooks Dancer 2 Plugins Community Deployment Ausblick Dancer2 keine globalen Variablen 100% OO Backend (Moo) Scoping for Sub-Applikationen überarbeitete Architektur racke Tanz!
  • 34. Hintergrund und Projekte Routes, Filter und Hooks Dancer 2 Plugins Community Deployment Ausblick Community Web: http://perldancer.org/ Github: git://github.com/sukria/Dancer.git IRC: #dancer @ irc.perl.org Mitarbeit: Dancer::Development racke Tanz!
  • 35. Hintergrund und Projekte Routes, Filter und Hooks Dancer 2 Plugins Community Deployment Ausblick The End Slides, Handout, Skripte: http://www.linuxia.de/talks/pws2011/ racke Tanz!