Dancer Academy - from Zero to Hero

Dancer Academy - from Zero to Hero

Dance floor Templates, Routes and Keywords Customizing your application Download/Upload Security and Error Handling Deployment Conclusion and Future Dancer Academy - From Zero to Hero Stefan Hornburg (Racke) [email protected] eCommerce Innovation 2013, Hancock, 8th October 2013 racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future American Spaces Applications I Dashboard https://americanspaces.state.gov I eLibraryUSA http://elibraryusa.state.gov I eShop https://eshop.state.gov I LDAP administration racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Easy to start with I Application ready to go I Syntax easy to understand I Routes and Keywords racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Easy to expand I Plugins I Hooks I Engines racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Quickstart I I cpanm Dancer I cpanm YAML I dancer -a Dropbox racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Program ./bin/app.pl #!/usr/bin/env perl use Dancer ; use Dropbox ; dance ; racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Module lib/Dropbox.pm package Dropbox ; use Dancer ’:syntax ’; our $VERSION = ’ 0.1 ’ ; get ’ / ’ => sub { template ’index’; }; t r u e ; racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Configuration Files c o n f i g . yml environments /development.yml environments/ production .yml racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Static Files css/style.css css/error.css images/ perldancer−bg . jpg images/perldancer.jpg javascripts/jquery.js 500. html 404. html favicon.ico dispatch.cgi racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Template views / index . t t views/layouts/main. tt racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application American Spaces Applications Download/Upload Why Dancer? Security and Error Handling Quickstart Deployment Conclusion and Future Quickstart II I cd Dropbox I ./bin/app.pl I x-www-browser http://localhost:3000/ racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Templates Layout views/layouts/main.tt Content views/index.tt racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Templates I Normal Layout template ’index’, {name => ’Test’} I Specific Layout template ’index’, {name => ’Test’}, {layout => ’test’} I No Layout template ’index’, {name => ’Test’}, {layout => undef } racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Template for Filebrowser <h1><% directory %></h1> <table > <tr ><th>Name</th><th>Type</th><th>Modified </th ></ tr > <% FOREACH f i l e IN f i l e s %> <tr ><td><% file .name %></td> <td><% file .type %></td> <td><% file .modified %></td></ tr > <% END %> </ table > racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Route for Filebrowser get ’/home’ => sub { my $files = autoindex(’/ ’); template ’filebrowser ’, {directory => ’Home’, files => $files , }; }; racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Configuration Standard config.yml: # template engine # simple: default and very basic template engine template: "simple" Dropbox config.yml: template: "template_toolkit" racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Routes and Keywords I HTTP method I get I post I ... I any I Path I Subroutine racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Routes I String I Named parameters I Wildcards I Splat I Megasplat I Regular expression I Regular expression with captures racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future String get ’/home’ => sub { my $files = autoindex(’/ ’); template ’filebrowser ’, {directory => ’Home’, files => $files , }; }; racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Named parameters get ’/home/: file ’ => sub { my $files = autoindex(param( ’file ’)); template ’filebrowser ’, {directory => param(’file ’), files => $files , }; }; racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Splat get ’/images/covers/ ∗ . jpg ’ => sub { my ($isbn) = splat; i f (− f "public/images/covers/$isbn.jpg") { return send_file "images/covers/$isbn.jpg"; } status ’not_found’; forward 404; } racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Megasplat https :// eshop. state .gov/ lostpwd / biz@linuxia .de/e642bd543b9907bd2c06aa485261cb1a849a9f23fc7324bff45ebd35f4efe2cb get ’/lostpwd/∗∗ ’ => sub { my ($email, $hash) = splat; form−>fill (email => $email, hash => $hash); template( ’lostpwd_confirm ’ , form => $form); } racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Regular Expression Catch-All (last route!) any qr { . ∗ } => sub { ... }; racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Regular Expression with Captures https ://dropbox.nite.si/~racke/talks/dancer−beamer . pdf any qr{^/~(?<user>[^/]+)/(?<file >. ∗ ? ) / ? $ } => sub { my ($capts, $user, $file); $capts = captures; $file = $capts −>{ f i l e } ; $user = $capts −>{user } ; ... }; racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future Keywords I get, post, any, put, del, ... I request, params, param I redirect, forward, status, header I config, var, session I from_json, to_json, from_xml, to_xml racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Customizing your application Templates Download/Upload Routes Security and Error Handling Keywords Deployment Conclusion and Future var(s) and session Storing and retrieving data for the current request: var bar => ’pivo’; $bar = var ’bar’; $bar = vars −>{bar } ; Storing and retrieving data from the session: session username => ’[email protected]’; i f (! session( ’username’)) { redirect uri_for(’/login’); } racke Dancer Academy - From Zero to Hero Dance floor Templates, Routes and Keywords Engines Customizing your application Hooks Download/Upload

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    79 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us