View on
MetaCPAN
Simone Faré > Strehler > Strehler::Dancer2::Plugin::EX

Download:
Strehler-1.6.8.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: v1.6.8   Source  

NAME ^

Strehler::Dancer2::Plugin::EX - Plugin for easy and fast site building!

DESCRIPTION ^

Using Strehler object to build a frontend may be a little messy because someone could need many instructions also to do simple things. EX plugin gives to the developer easy shortcuts, useful for standard scenarios, to write just elegant frontend code.

SYNOPSIS ^

Here is the route definition for Strehler Demo site, using EX plugin.

    get '/' => sub {template 'home';};

    slug '/ex/slug/:slug', 'element';
    list '/ex/list/dummy', 'dummy_list', 'dummy';
    latest_page '/ex/mypage', 'mypage', 
        { upper => 'upper', 
          lower => 'lower' };

FUNCTIONS ^

All the functions available to generate routes are in the form:

keyword 'pattern/to/match', 'template', { options }, { extra_data }

When you have to configure just the category where contenst are, you can pass it just as its name instead of options hash. All the others values will be the default ones. If you want to use as default an item_type different from article default_entity Strehler parameter will come useful to you.

extra_data is just an hash reference to any variable you want in the template.

SLUG

Slug keyword allows you to retrieve data from a slugged entity and pass it to a template as element.

Slug must be passed as a param named slug, in any way Dancer2 accept it.

Slug keyword passes to the template also the data about the previous and the next element in category (by order or publish date) as prev and next.

PARAMETERS

item-type

The entity. It must be configured in Strehler configuration.

language

The language to use. If no language is configured plugin will try for a language entry in params. If also this solution will fail it will use the default language.

category

To restrict slugged entity retrieving just to a certain category.

LIST

List keyword gives you a list of entities' data in the template variable named elements. A route designed using list keyword accepts as params page and order to navigate the list. All the configuration parameter are passed to the template in template variables with the same name.

PARAMETERS

item-type

The entity. It must be configured in Strehler configuration.

language

The language to use. If no language is configured plugin will try for a language entry in params. If also this solution will fail it will use the default language.

category

To restrict list retrieving just to a certain category.

entries-per-page

To change the length of a page.

order-by

To decide what database field to use to order elements.

Pay attention: an ordered entity will use display_order by default, a dated (but not ordered) entity publish_date. Otherwise, id will be used.

order

'asc' or 'desc'

extra_data

Hash reference. Any other variable you want for the template.

LATEST_PAGE

Consider a scenario where you need to update a content once in a while and you don't really need to keep an archive for it. You could always updating the same content, but why don't exploit Strehler power to have a little of version control?

Latest_page retrieve data from latest content (by publish_date or by orded) in a category and can be used to manage multiple contents. This way you can build a customized page with all the area freely editable.

PARAMETERS

Latest_page parameters are organized as a hash of hashes where every key of the primary hash is the name of the template variable where content data will be stored. Each key points to an hash of parameters for retrieving the content.

For each elements parameters are quite the same of the previous keywords.

item-type

The entity. It must be configured in Strehler configuration.

language

The language to use. If no language is configured plugin will try for a language entry in params. If also this solution will fail it will use the default language.

category

To restrict list retrieving just to a certain category.

by

It can assume values "date" or "order", it's the criteria to calculate latest article.

LATEST

As latest_page, but returns an hash and not a route, so you can use it when calling the template in a more complex situation.

    template 'the_page', { parameter => 'yadda', 
                           parameter2 => 'badda', 
                           latest { a_page => { category => 'cat1' }, 
                                    another => { category => 'cat2' }}
                         };
syntax highlighting: