Torsten Raudssus

NAME

Yeb - A simple structure for Web::Simple applications

VERSION

version 0.103

SYNOPSIS

  package MyApp::Web;
  use Yeb qw( Session JSON );

  r "/" => sub {
    session test => pa('test');
    text "root";
  };

  r "/blub" => sub {
    text "blub";
  };

  r "/test/..." => sub {
    st stash_var => 1;
    chain 'Test';
  };

  r "/blog/..." => sub {
    chain '+SomeOther::YebApp';
  };

  1;

  package MyApp::Web::Test;
  use MyApp::Web;

  r "/json" => sub {
    json {
      test => session('test'),
      stash_var => st('stash_var'),
    }
  };

  r "/" => sub {
    text " test = ".session('test')." and blub is ".st('stash_var');
  };

  1;

Can then be started like (see Web::Simple):

  plackup -Ilib -MMyApp::Web -e'MyApp::Web->run_if_script'

or use the yeb CLI tool which automatically also loads up ./lib as path for easy handling:

  yeb MyApp::Web

You can also add additional parameter after the class name:

  yeb MyApp::Web -Imore/lib

Additional parameters get dispatched towards plackup

Bigger Text::Xslate example:

  package MyApp::WebXslate;

  use Yeb Session => JSON => 'Xslate';

  # because of the root() usage we need to use plugin function call
  plugin Static => { default_root => root('htdocs') };

  xslate_path root('templates');

  static qr{^/};
  static_404 qr{^/images/}, root('htdocs_images');

  r "/" => sub {
    st page => 'root';
    xslate 'index';
  };

  r "/test" => sub {
    st page => 'test';
    xslate 'index/test', { extra_var => 'extra' };
  };

  1;

DESCRIPTION

You need to install Task::Yeb to get all the plugin functionalities. Yeb itself is bare.

WARNING / ALPHA

WARNING: I don't advice using it without staying in contact with me (Getty) at #sycontent on irc.perl.org. While the core API will stay stable, the way how to extend the system will change with the time.

PLUGINS

For an example on how to make a simple plugin, which adds a new function and uses a Plack::Middleware, please see the source of Yeb::Plugin::Session.

FRAMEWORK FUNCTIONS

yeb

Gives back the Yeb::Application of the web application

chain

Return another class dispatcher chain, will be prepend with your main class name, this can be deactivated by using a + in front of the class name.

cfg

Access to the configuration hash

cc

Getting the current Yeb::Context of the request

env

Getting the Plack environment

req

Getting the current Plack::Request

root

Current directory or YEB_ROOT environment variable

cur

Current directory in the moment of start

plugin $yeb_plugin_name, { key => $value };

st

Access to the stash hash

pa

Access to the request parameters, gives back "" if is not set

pa_has

Check if some parameter is at all set

r (or route)

Adding a new dispatcher for this class (see Web::Simple)

pr (or post_route)

Adding a new dispatcher for this class who only reacts on POST.

middleware

Adding a Plack::Middleware to the flow

url

Get an url, via joining all parameters url encoded

text

Make a simple text/plain response with the text given as parameter

redirect

Make a simple redirect to the url given as parameter

SEE ALSO

Task::Yeb

Overview of all approved plugins

SUPPORT

IRC

  Join #sycontent on irc.perl.org. Highlight Getty for fast reaction :).

Repository

  http://github.com/Getty/p5-yeb
  Pull request and additional contributors are welcome

Issue Tracker

  http://github.com/Getty/p5-yeb/issues

AUTHOR

Torsten Raudssus <torsten@raudss.us>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.




Hosting generously
sponsored by Bytemark