Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Perl DancerPerl Dancer
Мариян HackMan Маринов
<mm@1h.com>
Who am I?Who am I?
➢ Chief system architect of
➢ Sysadmin since the stone age
➢ Linux Sysadmin & Network security
courses ...
What is DancerWhat is Dancer
What is DancerWhat is Dancer
➢Dancer is a simple but powerful web application
framework for Perl.
➢http://www.perldancer.o...
InstallationInstallation
RHEL/CentOs/Fedora:
# yum install cpan
# cpan Dancer2
Debian/Ubuntu:
# apt-get install perl
# cpa...
InstallationInstallation
Worst case you also need to do this:
# cpan -fi YAML File::ShareDir::Install Time::HiRes
MIME::Ba...
How to create a projectHow to create a project
# dancer2 -a MyProject::Site
# cd MyProject-Site
# plackup bin/app.psgi
dancer2 ­a MyProject::Site      dancer2 ­a MyProject::Site      
-rw-rw-r-- 1 dance dance 442 Jul 3 20:01 MANIFEST
-rw-rw-...
StructureStructure
➢bin
➢environments - configurations
➢lib - the actual logic of your site
➢public - static files
➢t - te...
What can we do now?What can we do now?
➢Routing
➢ What the hell is routing :)
http://example.com/path/path
/path/path - is...
What can we do now?What can we do now?
➢Routing
➢ What the hell is routing :)
➢ GET, POST, PUT, DELETE
➢ ANY
➢ Combination...
Using paramsUsing params
get '/hello/:name' => sub {
"Hey " . param('name') . "... You are an idiot :)";
};
get '/hello/:n...
Params in templatesParams in templates
[% IF session.logged_in %]
<form action="[% add_entry_url %]" method=post
class=add...
Params in templatesParams in templates
<ul class=entries>
[% IF entries.size %]
[% FOREACH id IN entries.keys.nsort %]
<li...
DocumentationDocumentation
$ perldoc Dancer2
$ perldoc Dancer2::Tutorial
$ perldoc Dancer2::Manual
$ perldoc Dancer2::Conf...
Въпроси?Въпроси?
Мариян HackMan MarinovМариян HackMan Marinov
E-Mail:E-Mail: mm@1h.commm@1h.com
IRC: irc.freenode.net Hack...
Upcoming SlideShare
Loading in …5
×

Perl dancer

1,026 views

Published on

A nice easy to use framework for creating small and nimble web sites

Published in: Software
  • Be the first to comment

  • Be the first to like this

Perl dancer

  1. 1. Perl DancerPerl Dancer Мариян HackMan Маринов <mm@1h.com>
  2. 2. Who am I?Who am I? ➢ Chief system architect of ➢ Sysadmin since the stone age ➢ Linux Sysadmin & Network security courses in FMI Sofia and SoftUni
  3. 3. What is DancerWhat is Dancer
  4. 4. What is DancerWhat is Dancer ➢Dancer is a simple but powerful web application framework for Perl. ➢http://www.perldancer.org
  5. 5. InstallationInstallation RHEL/CentOs/Fedora: # yum install cpan # cpan Dancer2 Debian/Ubuntu: # apt-get install perl # cpan Dancer2
  6. 6. InstallationInstallation Worst case you also need to do this: # cpan -fi YAML File::ShareDir::Install Time::HiRes MIME::Base64
  7. 7. How to create a projectHow to create a project # dancer2 -a MyProject::Site # cd MyProject-Site # plackup bin/app.psgi
  8. 8. dancer2 ­a MyProject::Site      dancer2 ­a MyProject::Site       -rw-rw-r-- 1 dance dance 442 Jul 3 20:01 MANIFEST -rw-rw-r-- 1 dance dance 173 Jul 3 20:01 MANIFEST.SKIP -rw-rw-r-- 1 dance dance 817 Jul 3 20:01 Makefile.PL drwxrwxr-x 2 dance dance 4096 Jul 3 20:01 bin -rw-rw-r-- 1 dance dance 797 Jul 3 20:01 config.yml -rw-rw-r-- 1 dance dance 300 Jul 3 20:01 cpanfile drwxrwxr-x 2 dance dance 4096 Jul 3 20:45 environments drwxrwxr-x 3 dance dance 4096 Jul 3 20:01 lib drwxrwxr-x 5 dance dance 4096 Jul 3 20:01 public drwxrwxr-x 2 dance dance 4096 Jul 3 20:01 t drwxrwxr-x 3 dance dance 4096 Jul 3 20:36 views
  9. 9. StructureStructure ➢bin ➢environments - configurations ➢lib - the actual logic of your site ➢public - static files ➢t - tests (if you write any) ➢views - templates for your site
  10. 10. What can we do now?What can we do now? ➢Routing ➢ What the hell is routing :) http://example.com/path/path /path/path - is route- is route we need to connect this route towe need to connect this route to CODECODE get 'get '/path/path' => sub {' => sub { return "Hello mammy :)";return "Hello mammy :)"; };};
  11. 11. What can we do now?What can we do now? ➢Routing ➢ What the hell is routing :) ➢ GET, POST, PUT, DELETE ➢ ANY ➢ Combinations ➢Redirects ➢ once in a route you simply need to write: redirect('/newpath');
  12. 12. Using paramsUsing params get '/hello/:name' => sub { "Hey " . param('name') . "... You are an idiot :)"; }; get '/hello/:name' => sub { "Hey " . ( param('name') || “Idiot” ); };
  13. 13. Params in templatesParams in templates [% IF session.logged_in %] <form action="[% add_entry_url %]" method=post class=add-entry> Title:<input type=text size=30 name=title> Text:<textarea name=text rows=5 cols=40></textarea> <input type=submit value=Share> </form> [% END %]
  14. 14. Params in templatesParams in templates <ul class=entries> [% IF entries.size %] [% FOREACH id IN entries.keys.nsort %] <li><h2>[% entries.$id.title %]</h2>[% entries.$id.text %] [% END %] [% ELSE %] <li><em>Unbelievable. No entries here so far</em> [% END %] </ul>
  15. 15. DocumentationDocumentation $ perldoc Dancer2 $ perldoc Dancer2::Tutorial $ perldoc Dancer2::Manual $ perldoc Dancer2::Config $ perldoc Dancer2::Plugins
  16. 16. Въпроси?Въпроси? Мариян HackMan MarinovМариян HackMan Marinov E-Mail:E-Mail: mm@1h.commm@1h.com IRC: irc.freenode.net HackManIRC: irc.freenode.net HackMan ICQ: 7556201ICQ: 7556201 Jabber/Gtalk:Jabber/Gtalk: hackman@jabber.orghackman@jabber.org http://github.com/hackman/http://github.com/hackman/

×