diff options
| author | Franck Cuny <franckcuny@gmail.com> | 2016-08-04 11:45:44 -0700 |
|---|---|---|
| committer | Franck Cuny <franckcuny@gmail.com> | 2016-08-04 11:45:44 -0700 |
| commit | 585b48b6a605cb71ef99dd767880e1b7ee5bf24e (patch) | |
| tree | c65377350d12bd1e62e0bdd58458c1044541c27b /posts/2010-04-19-the-dancer-ecosystem.org | |
| parent | Use Bullet list for the index. (diff) | |
| parent | Mass convert all posts from markdown to org. (diff) | |
| download | lumberjaph-585b48b6a605cb71ef99dd767880e1b7ee5bf24e.tar.gz | |
Merge branch 'convert-to-org'
Diffstat (limited to 'posts/2010-04-19-the-dancer-ecosystem.org')
| -rw-r--r-- | posts/2010-04-19-the-dancer-ecosystem.org | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/posts/2010-04-19-the-dancer-ecosystem.org b/posts/2010-04-19-the-dancer-ecosystem.org new file mode 100644 index 0000000..e155573 --- /dev/null +++ b/posts/2010-04-19-the-dancer-ecosystem.org @@ -0,0 +1,160 @@ +Even though it's still a young project, an active community is starting +to emerge around Dancer. Some modules start to appear on CPAN and github +to add functionalities, or to extend existing ones. + +** Templates + +By default, Dancer comes with support for two templating systems: +Template Toolkit and Dancer::Template::Simple, a small templating engine +written by sukria. But support for other templating systems are +available: + +- Dancer::Template::Tenjin by ido +- Dancer::Template::Sandbox by Sam Graham +- Dancer::Template::Tiny by Sawyer +- Dancer::Template::MicroTemplate by me +- Dancer::Template::Mason by Yanick Champoux +- Dancer::Template::Haml by David Moreno + +** Logger + +Out of the box, Dancer only has a simple logging system to write to +file, but more logging sytems are available: + +#+BEGIN_HTML + <ul> +#+END_HTML + +#+BEGIN_HTML + <li> +#+END_HTML + +Dancer::Logger::Syslog by sukria + +#+BEGIN_HTML + </li> +#+END_HTML + +#+BEGIN_HTML + <li> +#+END_HTML + +Dancer::Logger::LogHandler by me + +#+BEGIN_HTML + </li> +#+END_HTML + +#+BEGIN_HTML + <li> +#+END_HTML + +Dancer::Logger::PSGI by me + +#+BEGIN_HTML + </li> +#+END_HTML + +#+BEGIN_HTML + </ul> +#+END_HTML + +The last one is for writing directly your log message via Plack. You can +use a middleware like P::M::LogDispatch or P::M::Log4perl to handle logs +for your application. Even better, if you use P::M::ConsoleLogger, you +can have logs from your Dancer application in your javascript console. + +** Debug + +To debug your application with Plack, you can use the awesome +Plack::Middleware::Debug. I've writen Dancer::Debug (which requires my +fork of P::M::Debug), a middleware that add panels, with specific +informations for Dancer applications. + +To activate this middleware, update your app.psgi to make it look like +this: + +#+BEGIN_SRC perl + my $handler = sub { + my $env = shift; + my $request = Dancer::Request->new($env); + Dancer->dance($request); + }; + $handler = builder { + enable "Debug", panels => [ + qw/Dancer::Settings Dancer::Logger Environment Memory + ModuleVersions Response Session Parameters Dancer::Version / + ]; + $handler; + }; +#+END_SRC + +** Plugins + +Dancer has support for plugins since a few version. There is not a lot +of plugins at the moment, but this will soon improve. Plugins support is +one of the top priorities for the 1.2 release. + +*** Dancer::Plugin::REST + +This one is really nice. This plugin, used with the serialization stuff, +allow you to write easily REST application. + +#+BEGIN_SRC perl + resource user => get => sub { # return user where id = params->{id} }, + create => sub { # create a new user with params->{user} }, + delete => sub { # delete user where id = params->{id} }, + update => sub { # update user with params->{user} }; +#+END_SRC + +And you got the following routes: + +- GET /user/:id +- GET /user/:id.:format +- POST /user/create +- POST /user/create.:format +- DELETE /user/:id +- DELETE /user/:id.:format +- PUT /user/:id +- PUT /user/:id.:format + +*** Dancer::Plugin::Database + +This plugin, by bigpresh, add the database keyword to your app. + +#+BEGIN_SRC perl + use Dancer; + use Dancer::Plugin::Database; + + # Calling the database keyword will get you a connected DBI handle: + get '/widget/view/:id' => sub { + my $sth = database->prepare('select * from widgets where id = ?', + {}, params->{id}); + $sth->execute; + template 'display_widget', {widget => $sth->fetchrow_hashref}; + }; +#+END_SRC + +*** Dancer::Plugin::SiteMap + +With this plugin, by James Ronan, a sitemap of your application is +created. + +#+BEGIN_HTML + <blockquote> +#+END_HTML + +Plugin module for the Dancer web framwork that automagically adds +sitemap routes to the webapp. Currently adds /sitemap and /sitemap.xml +where the former is a basic HTML list and the latter is an XML document +of URLS. + +#+BEGIN_HTML + </blockquote> +#+END_HTML + +** you can help! :) + +There is still a lot of stuff to do. Don't hesitate to come on +#dancer@irc.perl.org to discuss ideas or new features that you would +like. |
